From a16dfdf0dd69eb09c927bf0691fda1cdceccc467 Mon Sep 17 00:00:00 2001 From: albert Date: Sat, 9 Jul 2011 03:32:18 -0400 Subject: [PATCH] fixes --- app/controllers/forum_posts_controller.rb | 2 +- app/controllers/forum_topics_controller.rb | 4 +- app/controllers/note_versions_controller.rb | 2 +- app/controllers/wiki_pages_controller.rb | 2 +- app/helpers/application_helper.rb | 3 + app/logical/post_sets/pool.rb | 4 +- app/models/note.rb | 2 + app/models/pool.rb | 1 + app/presenters/post_set_presenters/pool.rb | 2 +- app/views/comments/search.html.erb | 4 +- app/views/note_versions/index.html.erb | 76 ++++++++++--------- app/views/pools/show.html.erb | 2 +- .../20100224172146_create_note_versions.rb | 2 + db/seeds.rb | 17 ++++- 14 files changed, 75 insertions(+), 48 deletions(-) diff --git a/app/controllers/forum_posts_controller.rb b/app/controllers/forum_posts_controller.rb index 582904fe2..aac3d12f3 100644 --- a/app/controllers/forum_posts_controller.rb +++ b/app/controllers/forum_posts_controller.rb @@ -16,7 +16,7 @@ class ForumPostsController < ApplicationController def index @search = ForumPost.search(params[:search]) - @forum_posts = @search.paginate(:page => params[:page], :order => "id DESC") + @forum_posts = @search.paginate(params[:page]) respond_with(@forum_posts) end diff --git a/app/controllers/forum_topics_controller.rb b/app/controllers/forum_topics_controller.rb index 4b35a72d8..5668dfdad 100644 --- a/app/controllers/forum_topics_controller.rb +++ b/app/controllers/forum_topics_controller.rb @@ -18,13 +18,13 @@ class ForumTopicsController < ApplicationController def index @search = ForumTopic.search(params[:search]) - @forum_topics = @search.paginate(:page => params[:page], :order => "is_sticky DESC, updated_at DESC") + @forum_topics = @search.paginate(params[:page]).order("is_sticky DESC, updated_at DESC") respond_with(@forum_topics) end def show @forum_topic = ForumTopic.find(params[:id]) - @forum_posts = ForumPost.search(:topic_id_eq => @forum_topic.id).paginate(:page => params[:page]) + @forum_posts = ForumPost.search(:topic_id_eq => @forum_topic.id).paginate(params[:page]) respond_with(@forum_topic) end diff --git a/app/controllers/note_versions_controller.rb b/app/controllers/note_versions_controller.rb index 05a5cb3d2..cdbdea30c 100644 --- a/app/controllers/note_versions_controller.rb +++ b/app/controllers/note_versions_controller.rb @@ -4,7 +4,7 @@ class NoteVersionsController < ApplicationController def index @search = NoteVersion.search(params[:search]) - @note_versions = @search.paginate(:page => params[:page]) + @note_versions = @search.paginate(params[:page]) respond_with(@note_versions) end end diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index dab1e768b..cfdeeef5f 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -16,7 +16,7 @@ class WikiPagesController < ApplicationController def index @search = WikiPage.search(params[:search]) - @wiki_pages = @search.paginate(:page => params[:page]) + @wiki_pages = @search.paginate(params[:page]) respond_with(@wiki_pages) do |format| format.html do if @wiki_pages.count == 1 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ace6fc1b3..e9002a45e 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -53,6 +53,9 @@ protected when "note_versions" /^\/note/ + + when "artist_versions" + /^\/artist/ else /^\/#{controller}/ diff --git a/app/logical/post_sets/pool.rb b/app/logical/post_sets/pool.rb index 754818ed3..7caf81532 100644 --- a/app/logical/post_sets/pool.rb +++ b/app/logical/post_sets/pool.rb @@ -16,7 +16,7 @@ module PostSets end def offset - ([page.to_i, 1].max - 1) * limit + (current_page - 1) * limit end def limit @@ -40,7 +40,7 @@ module PostSets end def current_page - (offset.to_f / pool.post_count).floor + [page.to_i, 1].max end end end diff --git a/app/models/note.rb b/app/models/note.rb index 85ba99c35..0eb048bcf 100644 --- a/app/models/note.rb +++ b/app/models/note.rb @@ -61,6 +61,7 @@ class Note < ActiveRecord::Base versions.create( :updater_id => updater_id, :updater_ip_addr => updater_ip_addr, + :post_id => post_id, :x => x, :y => y, :width => width, @@ -73,6 +74,7 @@ class Note < ActiveRecord::Base def revert_to(version) self.x = version.x self.y = version.y + self.post_id = version.post_id self.body = version.body self.width = version.width self.height = version.height diff --git a/app/models/pool.rb b/app/models/pool.rb index d70ffbe50..c962c61c5 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -91,6 +91,7 @@ class Pool < ActiveRecord::Base offset = options[:offset] || 0 limit = options[:limit] || Danbooru.config.posts_per_page slice = post_id_array.slice(offset, limit) + puts slice.inspect if slice && slice.any? Post.where("id in (?)", slice).order(arbitrary_sql_order_clause(slice, "posts")) else diff --git a/app/presenters/post_set_presenters/pool.rb b/app/presenters/post_set_presenters/pool.rb index 002be2862..fbb805748 100644 --- a/app/presenters/post_set_presenters/pool.rb +++ b/app/presenters/post_set_presenters/pool.rb @@ -1,6 +1,6 @@ module PostSetPresenters class Pool - attr_accessor :tag_set_presenter + attr_reader :tag_set_presenter, :pool_set def initialize(pool_set) @pool_set = pool_set diff --git a/app/views/comments/search.html.erb b/app/views/comments/search.html.erb index 818b02998..f287ed913 100644 --- a/app/views/comments/search.html.erb +++ b/app/views/comments/search.html.erb @@ -10,4 +10,6 @@ <%= f.button :submit, "Search" %> <% end %> - \ No newline at end of file + + +<%= render "comments/secondary_links" %> \ No newline at end of file diff --git a/app/views/note_versions/index.html.erb b/app/views/note_versions/index.html.erb index 7b3f09bd5..9af42f82f 100644 --- a/app/views/note_versions/index.html.erb +++ b/app/views/note_versions/index.html.erb @@ -1,38 +1,44 @@ - - - - - - - - - - - - - - - <% @note_versions.each do |note_version| %> - - - - - - - - - - - <% end %> - -
PostNoteBodyIP AddressEdited ByDateOptions
<%= link_to note.post_id, post_path(note_version.post_id) %><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %> - <% if CurrentUser.is_janitor? %> - <%= note_version.ip_addr %> - <% end %> - <%= link_to note_version.updater.name, user_path(note_version.updater) %><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %><%= link_to "Revert", revert_note_path(note_version.note_id, :version => note_version.id), :remote => true, :confirm => "Do you really want to revert to this version?" %>
+
+
+ + + + + + + + + + + + + + + <% @note_versions.each do |note_version| %> + + + + + + + + + + + <% end %> + +
PostNoteBodyIP AddressEdited ByDateOptions
<%= link_to note_version.post_id, post_path(note_version.post_id) %><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %> + <% if CurrentUser.is_janitor? %> + <%= note_version.updater_ip_addr %> + <% end %> + <%= link_to note_version.updater.name, user_path(note_version.updater) %><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %><%= link_to "Revert", revert_note_path(note_version.note_id, :version => note_version.id), :remote => true, :confirm => "Do you really want to revert to this version?" %>
-
- <%= sequential_paginator(@note_versions) %> +
+ <%= sequential_paginator(@note_versions) %> +
+ + <%= render :partial => "notes/secondary_links" %> + +
-<%= render :partial => "footer" %> diff --git a/app/views/pools/show.html.erb b/app/views/pools/show.html.erb index b1ede6d9e..60049d9f4 100644 --- a/app/views/pools/show.html.erb +++ b/app/views/pools/show.html.erb @@ -7,7 +7,7 @@
- <%= @post_set.presenter.post_previews_html %> + <%= @post_set.presenter.post_previews_html(self) %>
diff --git a/db/migrate/20100224172146_create_note_versions.rb b/db/migrate/20100224172146_create_note_versions.rb index 980039d7d..c6104be72 100644 --- a/db/migrate/20100224172146_create_note_versions.rb +++ b/db/migrate/20100224172146_create_note_versions.rb @@ -2,6 +2,7 @@ class CreateNoteVersions < ActiveRecord::Migration def self.up create_table :note_versions do |t| t.column :note_id, :integer, :null => false + t.column :post_id, :integer, :null => false t.column :updater_id, :integer, :null => false t.column :updater_ip_addr, "inet", :null => false t.column :x, :integer, :null => false @@ -14,6 +15,7 @@ class CreateNoteVersions < ActiveRecord::Migration end add_index :note_versions, :note_id + add_index :note_versions, :post_id add_index :note_versions, :updater_id add_index :note_versions, :updater_ip_addr end diff --git a/db/seeds.rb b/db/seeds.rb index 132843e4a..f80b1eaa9 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -66,7 +66,7 @@ end if TagAlias.count == 0 puts "Creating tag aliases" - 11.upto(99) do |i| + 100.upto(199) do |i| TagAlias.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s) end else @@ -76,9 +76,20 @@ end if TagImplication.count == 0 puts "Creating tag implictions" - 10_000.upto(10_100) do |i| + 100_000.upto(100_100) do |i| TagImplication.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s) end else puts "Skipping tag implications" -end \ No newline at end of file +end + +if Pool.count == 0 + puts "Creating pools" + + 1.upto(20) do |i| + pool = Pool.create(:name => i.to_s) + 33.times do |j| + pool.add!(Post.order("random()").first) + end + end +end