fixes
This commit is contained in:
@@ -16,7 +16,7 @@ class ForumPostsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = ForumPost.search(params[:search])
|
@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)
|
respond_with(@forum_posts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -18,13 +18,13 @@ class ForumTopicsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = ForumTopic.search(params[:search])
|
@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)
|
respond_with(@forum_topics)
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@forum_topic = ForumTopic.find(params[:id])
|
@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)
|
respond_with(@forum_topic)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ class NoteVersionsController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = NoteVersion.search(params[:search])
|
@search = NoteVersion.search(params[:search])
|
||||||
@note_versions = @search.paginate(:page => params[:page])
|
@note_versions = @search.paginate(params[:page])
|
||||||
respond_with(@note_versions)
|
respond_with(@note_versions)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class WikiPagesController < ApplicationController
|
|||||||
|
|
||||||
def index
|
def index
|
||||||
@search = WikiPage.search(params[:search])
|
@search = WikiPage.search(params[:search])
|
||||||
@wiki_pages = @search.paginate(:page => params[:page])
|
@wiki_pages = @search.paginate(params[:page])
|
||||||
respond_with(@wiki_pages) do |format|
|
respond_with(@wiki_pages) do |format|
|
||||||
format.html do
|
format.html do
|
||||||
if @wiki_pages.count == 1
|
if @wiki_pages.count == 1
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ protected
|
|||||||
|
|
||||||
when "note_versions"
|
when "note_versions"
|
||||||
/^\/note/
|
/^\/note/
|
||||||
|
|
||||||
|
when "artist_versions"
|
||||||
|
/^\/artist/
|
||||||
|
|
||||||
else
|
else
|
||||||
/^\/#{controller}/
|
/^\/#{controller}/
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def offset
|
def offset
|
||||||
([page.to_i, 1].max - 1) * limit
|
(current_page - 1) * limit
|
||||||
end
|
end
|
||||||
|
|
||||||
def limit
|
def limit
|
||||||
@@ -40,7 +40,7 @@ module PostSets
|
|||||||
end
|
end
|
||||||
|
|
||||||
def current_page
|
def current_page
|
||||||
(offset.to_f / pool.post_count).floor
|
[page.to_i, 1].max
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ class Note < ActiveRecord::Base
|
|||||||
versions.create(
|
versions.create(
|
||||||
:updater_id => updater_id,
|
:updater_id => updater_id,
|
||||||
:updater_ip_addr => updater_ip_addr,
|
:updater_ip_addr => updater_ip_addr,
|
||||||
|
:post_id => post_id,
|
||||||
:x => x,
|
:x => x,
|
||||||
:y => y,
|
:y => y,
|
||||||
:width => width,
|
:width => width,
|
||||||
@@ -73,6 +74,7 @@ class Note < ActiveRecord::Base
|
|||||||
def revert_to(version)
|
def revert_to(version)
|
||||||
self.x = version.x
|
self.x = version.x
|
||||||
self.y = version.y
|
self.y = version.y
|
||||||
|
self.post_id = version.post_id
|
||||||
self.body = version.body
|
self.body = version.body
|
||||||
self.width = version.width
|
self.width = version.width
|
||||||
self.height = version.height
|
self.height = version.height
|
||||||
|
|||||||
@@ -91,6 +91,7 @@ class Pool < ActiveRecord::Base
|
|||||||
offset = options[:offset] || 0
|
offset = options[:offset] || 0
|
||||||
limit = options[:limit] || Danbooru.config.posts_per_page
|
limit = options[:limit] || Danbooru.config.posts_per_page
|
||||||
slice = post_id_array.slice(offset, limit)
|
slice = post_id_array.slice(offset, limit)
|
||||||
|
puts slice.inspect
|
||||||
if slice && slice.any?
|
if slice && slice.any?
|
||||||
Post.where("id in (?)", slice).order(arbitrary_sql_order_clause(slice, "posts"))
|
Post.where("id in (?)", slice).order(arbitrary_sql_order_clause(slice, "posts"))
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module PostSetPresenters
|
module PostSetPresenters
|
||||||
class Pool
|
class Pool
|
||||||
attr_accessor :tag_set_presenter
|
attr_reader :tag_set_presenter, :pool_set
|
||||||
|
|
||||||
def initialize(pool_set)
|
def initialize(pool_set)
|
||||||
@pool_set = pool_set
|
@pool_set = pool_set
|
||||||
|
|||||||
@@ -10,4 +10,6 @@
|
|||||||
<%= f.button :submit, "Search" %>
|
<%= f.button :submit, "Search" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render "comments/secondary_links" %>
|
||||||
@@ -1,38 +1,44 @@
|
|||||||
<table width="100%">
|
<div id="c-note-versions">
|
||||||
<thead>
|
<div id="a-index">
|
||||||
<tr>
|
<table width="100%">
|
||||||
<th></th>
|
<thead>
|
||||||
<th width="5%">Post</th>
|
<tr>
|
||||||
<th width="5%">Note</th>
|
<th></th>
|
||||||
<th width="50%">Body</th>
|
<th width="5%">Post</th>
|
||||||
<th width="10%">IP Address</th>
|
<th width="5%">Note</th>
|
||||||
<th width="10%">Edited By</th>
|
<th width="50%">Body</th>
|
||||||
<th width="10%">Date</th>
|
<th width="10%">IP Address</th>
|
||||||
<th width="10%">Options</th>
|
<th width="10%">Edited By</th>
|
||||||
</tr>
|
<th width="10%">Date</th>
|
||||||
</thead>
|
<th width="10%">Options</th>
|
||||||
<tbody>
|
</tr>
|
||||||
<% @note_versions.each do |note_version| %>
|
</thead>
|
||||||
<tr>
|
<tbody>
|
||||||
<td></td>
|
<% @note_versions.each do |note_version| %>
|
||||||
<td><%= link_to note.post_id, post_path(note_version.post_id) %></td>
|
<tr>
|
||||||
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %></td>
|
<td></td>
|
||||||
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
||||||
<td>
|
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %></td>
|
||||||
<% if CurrentUser.is_janitor? %>
|
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
||||||
<%= note_version.ip_addr %>
|
<td>
|
||||||
<% end %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
</td>
|
<%= note_version.updater_ip_addr %>
|
||||||
<td><%= link_to note_version.updater.name, user_path(note_version.updater) %></td>
|
<% end %>
|
||||||
<td><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %></td>
|
</td>
|
||||||
<td><%= 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?" %></td>
|
<td><%= link_to note_version.updater.name, user_path(note_version.updater) %></td>
|
||||||
</tr>
|
<td><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %></td>
|
||||||
<% end %>
|
<td><%= 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?" %></td>
|
||||||
</tbody>
|
</tr>
|
||||||
</table>
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
<div id="paginator">
|
<div class="paginator">
|
||||||
<%= sequential_paginator(@note_versions) %>
|
<%= sequential_paginator(@note_versions) %>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render :partial => "notes/secondary_links" %>
|
||||||
|
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<%= render :partial => "footer" %>
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<section id="content">
|
<section id="content">
|
||||||
<%= @post_set.presenter.post_previews_html %>
|
<%= @post_set.presenter.post_previews_html(self) %>
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ class CreateNoteVersions < ActiveRecord::Migration
|
|||||||
def self.up
|
def self.up
|
||||||
create_table :note_versions do |t|
|
create_table :note_versions do |t|
|
||||||
t.column :note_id, :integer, :null => false
|
t.column :note_id, :integer, :null => false
|
||||||
|
t.column :post_id, :integer, :null => false
|
||||||
t.column :updater_id, :integer, :null => false
|
t.column :updater_id, :integer, :null => false
|
||||||
t.column :updater_ip_addr, "inet", :null => false
|
t.column :updater_ip_addr, "inet", :null => false
|
||||||
t.column :x, :integer, :null => false
|
t.column :x, :integer, :null => false
|
||||||
@@ -14,6 +15,7 @@ class CreateNoteVersions < ActiveRecord::Migration
|
|||||||
end
|
end
|
||||||
|
|
||||||
add_index :note_versions, :note_id
|
add_index :note_versions, :note_id
|
||||||
|
add_index :note_versions, :post_id
|
||||||
add_index :note_versions, :updater_id
|
add_index :note_versions, :updater_id
|
||||||
add_index :note_versions, :updater_ip_addr
|
add_index :note_versions, :updater_ip_addr
|
||||||
end
|
end
|
||||||
|
|||||||
17
db/seeds.rb
17
db/seeds.rb
@@ -66,7 +66,7 @@ end
|
|||||||
if TagAlias.count == 0
|
if TagAlias.count == 0
|
||||||
puts "Creating tag aliases"
|
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)
|
TagAlias.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@@ -76,9 +76,20 @@ end
|
|||||||
if TagImplication.count == 0
|
if TagImplication.count == 0
|
||||||
puts "Creating tag implictions"
|
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)
|
TagImplication.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
puts "Skipping tag implications"
|
puts "Skipping tag implications"
|
||||||
end
|
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
|
||||||
|
|||||||
Reference in New Issue
Block a user