fixed jrails, fixed deprecation warnings

This commit is contained in:
albert
2010-10-27 13:40:50 -04:00
parent a9da0f1059
commit 484ff696e2
16 changed files with 119 additions and 99 deletions

View File

@@ -4,7 +4,7 @@ group :test do
gem "shoulda"
gem "factory_girl"
gem "mocha"
gem "faker"
gem "ffaker", :git => "http://github.com/EmmanuelOga/ffaker.git"
end
gem "rails", "3.0.0"

View File

@@ -1,3 +1,9 @@
GIT
remote: http://github.com/EmmanuelOga/ffaker.git
revision: cbe849d
specs:
ffaker (0.4.0)
GIT
remote: http://github.com/mislav/will_paginate.git
revision: b1a5bee
@@ -44,17 +50,17 @@ GEM
erubis (2.6.6)
abstract (>= 1.0.0)
factory_girl (1.3.2)
faker (0.3.1)
haml (3.0.21)
i18n (0.4.1)
haml (3.0.22)
i18n (0.4.2)
imagesize (0.1.1)
mail (2.2.7)
mail (2.2.9)
activesupport (>= 2.3.6)
mime-types
treetop (>= 1.4.5)
i18n (~> 0.4.1)
mime-types (~> 1.16)
treetop (~> 1.4.8)
memcache-client (1.8.5)
mime-types (1.16)
mocha (0.9.8)
mocha (0.9.9)
rake
pg (0.9.0)
polyglot (0.3.1)
@@ -93,7 +99,7 @@ PLATFORMS
DEPENDENCIES
delayed_job
factory_girl
faker
ffaker!
haml
imagesize
memcache-client

View File

@@ -83,7 +83,7 @@ class PixivProxy
mech = WWW::Mechanize.new
mech.get("http://www.pixiv.net") do |page|
page.form_with(:action => "index.php") do |form|
page.form_with(:action => "login.php") do |form|
form.pixiv_id = "uroobnad"
form.pass = "uroobnad556"
end.click_button

View File

@@ -1,7 +1,8 @@
%div{:class => "comments"}
%div{:class => "index"}
- @posts.each do |post|
%div{:class => "preview"}
= image_tag(post.medium_file_url)
= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments}
%div{:class => "clearfix"}
%div{:class => "post"}
%div{:class => "preview"}
= image_tag(post.preview_file_url)
= render :partial => "comments/partials/index/list", :locals => {:post => post, :comments => post.comments.recent.reverse}
%div{:class => "clearfix"}

View File

@@ -0,0 +1,43 @@
%div{:class => "header"}
%div{:class => "row"}
%span{:class => "info"}
%time Date
= compact_time(post.created_at)
%span{:class => "info"}
%strong User
= link_to(post.uploader_name, user_path(post.uploader_id))
%span{:class => "info"}
%strong Rating
= post.rating
%span{:class => "info"}
%strong Score
%span{:id => "score-for-post-#{post.id}"}
= post.score
<div class="header">
<div>
<span class="info"><strong>Date</strong> <%= compact_time(post.created_at) %></span>
<span class="info"><strong>User</strong> <%= fast_link_to h(post.author), :controller => "user", :action => "show", :id => post.user_id %></span>
<span class="info"><strong>Rating</strong> <%= post.pretty_rating %></span>
<span class="info">
<strong>Score</strong> <span id="post-score-<%= post.id %>"><%= post.score %></span>
<% if @current_user.is_privileged_or_higher? %>
(vote <%= link_to_function "up", "Post.vote(1, #{post.id})" %>/<%= link_to_function "down", "Post.vote(-1, #{post.id})" %>)
<% end %>
</span>
</div>
<div class="tags">
<strong>Tags</strong>
<% post.cached_tags.split(/ /).each do |name| %>
<span class="tag-type-<%= Tag.type_name(name) %>">
<%= fast_link_to h(name.tr("_", " ")), :controller => "post", :action => "index", :tags => name %>
</span>
<% end %>
</div>
<div style="margin-top: 1em;">
<% if post.comments.count > 6 %>
<span class="info" id="hidden-comments-notice-for-<%= post.id %>"><%= link_to_remote "#{pluralize post.comments.size - 6, 'comment'} hidden", :url => {:controller => "comment", :action => "index_hidden", :post_id => post.id} %>.</span>
<% end %>
<%= render :partial => "threshold_notice", :locals => {:post => post} %>

View File

@@ -1,6 +1,7 @@
%div{:class => "comments-for-post", "data-post-id" => post.id}
%div{:class => "list-of-comments"}
= render :partial => "comments/partials/show/comment", :collection => comments
%div{:class => "clearfix"}
%div{:class => "new-comment"}
%p= link_to "Post comment", new_comment_path, :class => "expand-comment-response"
= render :partial => "comments/partials/new/form", :locals => {:post => post}

View File

@@ -0,0 +1,3 @@
<% if post.hidden_comment_count(@current_user) > 0 %>
<span class="info" id="threshold-comments-notice-for-<%= post.id %>"><%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => {:controller => "comment", :action => "index_all", :post_id => post.id} %>.</span>
<% end %>

View File

@@ -223,6 +223,7 @@ CREATE TABLE artists (
name character varying(255) NOT NULL,
creator_id integer NOT NULL,
is_active boolean DEFAULT true NOT NULL,
is_banned boolean DEFAULT false NOT NULL,
other_names text,
other_names_index tsvector,
group_name character varying(255),
@@ -864,41 +865,6 @@ CREATE SEQUENCE janitor_trials_id_seq
ALTER SEQUENCE janitor_trials_id_seq OWNED BY janitor_trials.id;
--
-- Name: jobs; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
CREATE TABLE jobs (
id integer NOT NULL,
category character varying(255) NOT NULL,
status character varying(255) NOT NULL,
message text NOT NULL,
data_as_json text NOT NULL,
repeat_count integer NOT NULL,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
--
-- Name: jobs_id_seq; Type: SEQUENCE; Schema: public; Owner: -
--
CREATE SEQUENCE jobs_id_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO MINVALUE
CACHE 1;
--
-- Name: jobs_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--
ALTER SEQUENCE jobs_id_seq OWNED BY jobs.id;
--
-- Name: note_versions; Type: TABLE; Schema: public; Owner: -; Tablespace:
--
@@ -1283,7 +1249,7 @@ CREATE TABLE tag_aliases (
antecedent_name character varying(255) NOT NULL,
consequent_name character varying(255) NOT NULL,
creator_id integer NOT NULL,
request_ids character varying(255),
forum_topic_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
@@ -1318,7 +1284,7 @@ CREATE TABLE tag_implications (
consequent_name character varying(255) NOT NULL,
descendant_names text NOT NULL,
creator_id integer NOT NULL,
request_ids character varying(255),
forum_topic_id integer,
created_at timestamp without time zone,
updated_at timestamp without time zone
);
@@ -1813,13 +1779,6 @@ ALTER TABLE ip_bans ALTER COLUMN id SET DEFAULT nextval('ip_bans_id_seq'::regcla
ALTER TABLE janitor_trials ALTER COLUMN id SET DEFAULT nextval('janitor_trials_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
ALTER TABLE jobs ALTER COLUMN id SET DEFAULT nextval('jobs_id_seq'::regclass);
--
-- Name: id; Type: DEFAULT; Schema: public; Owner: -
--
@@ -2145,14 +2104,6 @@ ALTER TABLE ONLY janitor_trials
ADD CONSTRAINT janitor_trials_pkey PRIMARY KEY (id);
--
-- Name: jobs_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
ALTER TABLE ONLY jobs
ADD CONSTRAINT jobs_pkey PRIMARY KEY (id);
--
-- Name: note_versions_pkey; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace:
--
@@ -3205,8 +3156,6 @@ INSERT INTO schema_migrations (version) VALUES ('20100221003655');
INSERT INTO schema_migrations (version) VALUES ('20100221005812');
INSERT INTO schema_migrations (version) VALUES ('20100221012656');
INSERT INTO schema_migrations (version) VALUES ('20100223001012');
INSERT INTO schema_migrations (version) VALUES ('20100224171915');

View File

@@ -225,10 +225,14 @@ div.comments-for-post div.comment-preview {
div.comments div.index div.preview {
float: left;
width: 420px; }
div.comments div.index div.list-of-comments {
float: left;
width: 55em; }
width: 180px; }
div.comments div.index div.post {
margin-bottom: 4em; }
div.comments div.index div.post div.comments-for-post {
float: left;
width: 55em; }
div.comments div.index div.post div.comments-for-post h1 {
font-size: 1.2em; }
/*** Posts ***/
div.posts h1 {

View File

@@ -324,12 +324,20 @@ div.comments {
div.index {
div.preview {
float: left;
width: 420px;
width: 180px;
}
div.list-of-comments {
float: left;
width: 55em;
div.post {
margin-bottom: 4em;
div.comments-for-post {
float: left;
width: 55em;
h1 {
font-size: 1.2em;
}
}
}
}
}

View File

@@ -1,9 +1,5 @@
ENV["RAILS_ENV"] = "test"
require 'factory_girl'
require 'shoulda'
require 'mocha'
require 'faker'
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'

View File

@@ -0,0 +1,23 @@
# encoding: UTF-8
require_relative '../test_helper'
class PixivProxyTest < ActiveSupport::TestCase
context "The proxy" do
should "get the profile" do
results = PixivProxy.get_profile("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=9646484")
assert_equal("シビレ\347\275\240", results[:artist])
assert_equal("/member_illust.php?id=9646484", results[:listing_url])
end
should "get a single post" do
results = PixivProxy.get_single("http://www.pixiv.net/member_illust.php?mode=medium&illust_id=9646484")
assert_equal("/member.php?id=4015", results[:profile_url])
assert(results[:jp_tags].size > 0)
first_tag = results[:jp_tags][0]
assert_equal(2, first_tag.size)
assert(first_tag[0] =~ /./)
assert(first_tag[1] =~ /tags\.php\?tag=/)
end
end
end

View File

@@ -2,4 +2,4 @@
:patch: 0
:build:
:major: 0
:minor: 7
:minor: 8

View File

@@ -1,3 +1,5 @@
$: << File.expand_path("..", __FILE__)
require 'jrails/jrails'
require 'jrails/asset_tag_ext'
require 'jrails/jquery_selector_assertions' if Rails.env == 'test'
require 'jrails/jquery_selector_assertions' if Rails.env == 'test'

View File

@@ -1,4 +1,4 @@
class JRails
module JRails
@@config = {
:google => false,
:jquery_version => "1.4.2",

View File

@@ -1,16 +0,0 @@
# The following options can be changed by creating an initializer in config/initializers/jrails.rb
# jRails uses jQuery.noConflict() by default
# to use the default jQuery variable, use:
# ActionView::Helpers::PrototypeHelper::JQUERY_VAR = '$'
# ActionView::Helpers::PrototypeHelper:: DISABLE_JQUERY_FORGERY_PROTECTION
# Set this to disable forgery protection in ajax calls
# This is handy if you want to use caching with ajax by injecting the forgery token via another means
# for an example, see http://henrik.nyh.se/2008/05/rails-authenticity-token-with-jquery
# ActionView::Helpers::PrototypeHelper::DISABLE_JQUERY_FORGERY_PROTECTION = true
#ActionView::Helpers::AssetTagHelper::JAVASCRIPT_DEFAULT_SOURCES = ['jquery','jquery-ui','jrails']
#ActionView::Helpers::AssetTagHelper::reset_javascript_include_default
require 'jrails'
require 'jquery_selector_assertions' if Rails.env.test?