forked from e621ng/e621ng
fixes
This commit is contained in:
parent
085995126c
commit
a16dfdf0dd
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -53,6 +53,9 @@ protected
|
||||
|
||||
when "note_versions"
|
||||
/^\/note/
|
||||
|
||||
when "artist_versions"
|
||||
/^\/artist/
|
||||
|
||||
else
|
||||
/^\/#{controller}/
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -10,4 +10,6 @@
|
||||
<%= f.button :submit, "Search" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "comments/secondary_links" %>
|
@ -1,38 +1,44 @@
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th width="5%">Post</th>
|
||||
<th width="5%">Note</th>
|
||||
<th width="50%">Body</th>
|
||||
<th width="10%">IP Address</th>
|
||||
<th width="10%">Edited By</th>
|
||||
<th width="10%">Date</th>
|
||||
<th width="10%">Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @note_versions.each do |note_version| %>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><%= link_to note.post_id, post_path(note_version.post_id) %></td>
|
||||
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %></td>
|
||||
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
||||
<td>
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
<%= note_version.ip_addr %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to note_version.updater.name, user_path(note_version.updater) %></td>
|
||||
<td><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %></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>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<div id="c-note-versions">
|
||||
<div id="a-index">
|
||||
<table width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th width="5%">Post</th>
|
||||
<th width="5%">Note</th>
|
||||
<th width="50%">Body</th>
|
||||
<th width="10%">IP Address</th>
|
||||
<th width="10%">Edited By</th>
|
||||
<th width="10%">Date</th>
|
||||
<th width="10%">Options</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @note_versions.each do |note_version| %>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td><%= link_to note_version.post_id, post_path(note_version.post_id) %></td>
|
||||
<td><%= link_to "#{note_version.note_id}", note_versions_path(:search => {:note_id_eq => note_version.note_id}) %></td>
|
||||
<td><%= h(note_version.body) %> <% unless note_version.is_active? %>(deleted)<% end %></td>
|
||||
<td>
|
||||
<% if CurrentUser.is_janitor? %>
|
||||
<%= note_version.updater_ip_addr %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to note_version.updater.name, user_path(note_version.updater) %></td>
|
||||
<td><%= note_version.updated_at.strftime("%Y-%m-%d %H:%M") %></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>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="paginator">
|
||||
<%= sequential_paginator(@note_versions) %>
|
||||
<div class="paginator">
|
||||
<%= sequential_paginator(@note_versions) %>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "notes/secondary_links" %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render :partial => "footer" %>
|
||||
|
@ -7,7 +7,7 @@
|
||||
</div>
|
||||
|
||||
<section id="content">
|
||||
<%= @post_set.presenter.post_previews_html %>
|
||||
<%= @post_set.presenter.post_previews_html(self) %>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
|
||||
|
@ -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
|
||||
|
17
db/seeds.rb
17
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
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user