From 484ff696e29fbe30cd600702756dd68e3e875329 Mon Sep 17 00:00:00 2001 From: albert Date: Wed, 27 Oct 2010 13:40:50 -0400 Subject: [PATCH] fixed jrails, fixed deprecation warnings --- Gemfile | 2 +- Gemfile.lock | 22 ++++--- app/logical/pixiv_proxy.rb | 2 +- app/views/comments/index.html.haml | 9 +-- .../comments/partials/index/_header.html.haml | 43 ++++++++++++++ .../comments/partials/index/_list.html.haml | 1 + .../partials/index/_threshold.html.haml | 3 + db/development_structure.sql | 57 +------------------ public/stylesheets/compiled/default.css | 12 ++-- public/stylesheets/src/default.scss | 16 ++++-- test/test_helper.rb | 4 -- test/unit/pixiv_proxy_test.rb | 23 ++++++++ vendor/plugins/jrails/VERSION.yml | 2 +- vendor/plugins/jrails/lib/jrails.rb | 4 +- vendor/plugins/jrails/lib/jrails/jrails.rb | 2 +- vendor/plugins/jrails/rails/init.rb | 16 ------ 16 files changed, 119 insertions(+), 99 deletions(-) create mode 100644 app/views/comments/partials/index/_header.html.haml create mode 100644 app/views/comments/partials/index/_threshold.html.haml create mode 100644 test/unit/pixiv_proxy_test.rb delete mode 100644 vendor/plugins/jrails/rails/init.rb diff --git a/Gemfile b/Gemfile index 81b57ebfe..a0b89c092 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 0884d876f..4774600bf 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/logical/pixiv_proxy.rb b/app/logical/pixiv_proxy.rb index 9496776f3..25b2fa7dd 100644 --- a/app/logical/pixiv_proxy.rb +++ b/app/logical/pixiv_proxy.rb @@ -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 diff --git a/app/views/comments/index.html.haml b/app/views/comments/index.html.haml index f83de3a65..487e49d10 100644 --- a/app/views/comments/index.html.haml +++ b/app/views/comments/index.html.haml @@ -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"} \ No newline at end of file + %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"} \ No newline at end of file diff --git a/app/views/comments/partials/index/_header.html.haml b/app/views/comments/partials/index/_header.html.haml new file mode 100644 index 000000000..f0bda3074 --- /dev/null +++ b/app/views/comments/partials/index/_header.html.haml @@ -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 + + +
+
+ Date <%= compact_time(post.created_at) %> + User <%= fast_link_to h(post.author), :controller => "user", :action => "show", :id => post.user_id %> + Rating <%= post.pretty_rating %> + + Score <%= post.score %> + <% 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 %> + +
+
+ Tags + <% post.cached_tags.split(/ /).each do |name| %> + + <%= fast_link_to h(name.tr("_", " ")), :controller => "post", :action => "index", :tags => name %> + + <% end %> +
+
+ <% if post.comments.count > 6 %> + <%= link_to_remote "#{pluralize post.comments.size - 6, 'comment'} hidden", :url => {:controller => "comment", :action => "index_hidden", :post_id => post.id} %>. + <% end %> + + <%= render :partial => "threshold_notice", :locals => {:post => post} %> \ No newline at end of file diff --git a/app/views/comments/partials/index/_list.html.haml b/app/views/comments/partials/index/_list.html.haml index 4a31b0d3e..bdba1b403 100644 --- a/app/views/comments/partials/index/_list.html.haml +++ b/app/views/comments/partials/index/_list.html.haml @@ -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} diff --git a/app/views/comments/partials/index/_threshold.html.haml b/app/views/comments/partials/index/_threshold.html.haml new file mode 100644 index 000000000..5b02e190d --- /dev/null +++ b/app/views/comments/partials/index/_threshold.html.haml @@ -0,0 +1,3 @@ +<% if post.hidden_comment_count(@current_user) > 0 %> + <%= link_to_remote "#{pluralize post.hidden_comment_count(@current_user), 'comment'} below threshold", :url => {:controller => "comment", :action => "index_all", :post_id => post.id} %>. +<% end %> diff --git a/db/development_structure.sql b/db/development_structure.sql index 2ceaeec5e..21872342e 100644 --- a/db/development_structure.sql +++ b/db/development_structure.sql @@ -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'); diff --git a/public/stylesheets/compiled/default.css b/public/stylesheets/compiled/default.css index 1cd91933f..33880c03f 100644 --- a/public/stylesheets/compiled/default.css +++ b/public/stylesheets/compiled/default.css @@ -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 { diff --git a/public/stylesheets/src/default.scss b/public/stylesheets/src/default.scss index 9ed163cf0..0813a831d 100644 --- a/public/stylesheets/src/default.scss +++ b/public/stylesheets/src/default.scss @@ -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; + } + } } } } diff --git a/test/test_helper.rb b/test/test_helper.rb index ce4b0c794..3a954b082 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -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' diff --git a/test/unit/pixiv_proxy_test.rb b/test/unit/pixiv_proxy_test.rb new file mode 100644 index 000000000..e27b291f2 --- /dev/null +++ b/test/unit/pixiv_proxy_test.rb @@ -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 diff --git a/vendor/plugins/jrails/VERSION.yml b/vendor/plugins/jrails/VERSION.yml index e90238922..468746ed4 100644 --- a/vendor/plugins/jrails/VERSION.yml +++ b/vendor/plugins/jrails/VERSION.yml @@ -2,4 +2,4 @@ :patch: 0 :build: :major: 0 -:minor: 7 +:minor: 8 diff --git a/vendor/plugins/jrails/lib/jrails.rb b/vendor/plugins/jrails/lib/jrails.rb index 8a8a4817b..9dbfebb53 100644 --- a/vendor/plugins/jrails/lib/jrails.rb +++ b/vendor/plugins/jrails/lib/jrails.rb @@ -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' \ No newline at end of file +require 'jrails/jquery_selector_assertions' if Rails.env == 'test' diff --git a/vendor/plugins/jrails/lib/jrails/jrails.rb b/vendor/plugins/jrails/lib/jrails/jrails.rb index a4e28d6ce..4ac6dee5d 100644 --- a/vendor/plugins/jrails/lib/jrails/jrails.rb +++ b/vendor/plugins/jrails/lib/jrails/jrails.rb @@ -1,4 +1,4 @@ -class JRails +module JRails @@config = { :google => false, :jquery_version => "1.4.2", diff --git a/vendor/plugins/jrails/rails/init.rb b/vendor/plugins/jrails/rails/init.rb deleted file mode 100644 index 5a1019482..000000000 --- a/vendor/plugins/jrails/rails/init.rb +++ /dev/null @@ -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?