forked from e621ng/e621ng
changes
This commit is contained in:
parent
bd3af50e10
commit
085995126c
@ -3,7 +3,7 @@ class ArtistVersionsController < ApplicationController
|
||||
|
||||
def index
|
||||
@search = ArtistVersion.search(params[:search])
|
||||
@artist_versions = @search.paginate :page => params[:page]
|
||||
@artist_versions = @search.paginate(params[:page])
|
||||
respond_with(@artist_versions)
|
||||
end
|
||||
end
|
||||
|
@ -63,6 +63,8 @@ module PaginationHelper
|
||||
end
|
||||
|
||||
def numbered_paginator_item(page, current_page)
|
||||
return "" if page.to_i > Danbooru.config.max_numbered_pages
|
||||
|
||||
html = "<li>"
|
||||
if page == "..."
|
||||
html << "..."
|
||||
|
@ -1,11 +1,18 @@
|
||||
module PostSets
|
||||
class Pool < Base
|
||||
module ActiveRecordExtension
|
||||
attr_accessor :total_pages, :current_page
|
||||
end
|
||||
|
||||
attr_reader :pool, :page, :posts
|
||||
|
||||
def initailize(pool, page)
|
||||
def initialize(pool, page)
|
||||
@pool = pool
|
||||
@page = page
|
||||
@posts = pool.posts(:offset => offset, :limit => limit)
|
||||
@posts.extend(ActiveRecordExtension)
|
||||
@posts.total_pages = total_pages
|
||||
@posts.current_page = current_page
|
||||
end
|
||||
|
||||
def offset
|
||||
@ -27,5 +34,13 @@ module PostSets
|
||||
def presenter
|
||||
@presenter ||= PostSetPresenters::Pool.new(self)
|
||||
end
|
||||
|
||||
def total_pages
|
||||
(pool.post_count.to_f / limit).ceil
|
||||
end
|
||||
|
||||
def current_page
|
||||
(offset.to_f / pool.post_count).floor
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -23,7 +23,7 @@ class PostPresenter < Presenter
|
||||
|
||||
def image_html(template)
|
||||
return template.content_tag("p", "This image was deleted.") if @post.is_deleted? && !CurrentUser.user.is_janitor?
|
||||
return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_see_post?(@post, CurrentUser.user)
|
||||
return template.content_tag("p", "You need a privileged account to see this image.") if !Danbooru.config.can_user_see_post?(CurrentUser.user, @post)
|
||||
|
||||
if @post.is_flash?
|
||||
template.render(:partial => "posts/partials/show/flash", :locals => {:post => @post})
|
||||
|
@ -1,36 +1,40 @@
|
||||
<h4>Artist History</h4>
|
||||
<div id="c-artist-versions">
|
||||
<div id="a-index">
|
||||
<h1>Artist History</h1>
|
||||
|
||||
<div>
|
||||
<table width="100%" class="highlightable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Other Names</th>
|
||||
<th>Group</th>
|
||||
<th>Updated</th>
|
||||
<th>Updated by</th>
|
||||
<th>Active</th>
|
||||
<th>URLs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @artist_versions.each do |artist_version| %>
|
||||
<tr class="<%= cycle 'even', 'odd' %>">
|
||||
<td><%= link_to h(artist_version.name), artist_versions_path(:artist_id => artist_version.artist_id) %></td>
|
||||
<td><%= h artist_version.other_names %></td>
|
||||
<td><%= h artist_version.group_name %></td>
|
||||
<td><%= time_ago_in_words artist_version.created_at %> ago</td>
|
||||
<td><%= link_to artist_version.updater_name, user_path(artist_version.updater_id) %></td>
|
||||
<td><%= artist_version.is_active? %></td>
|
||||
<td><%= artist_version.url_string %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div>
|
||||
<table width="100%" class="highlightable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Other Names</th>
|
||||
<th>Group</th>
|
||||
<th>Updated</th>
|
||||
<th>Updated by</th>
|
||||
<th>Active</th>
|
||||
<th>URLs</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @artist_versions.each do |artist_version| %>
|
||||
<tr class="<%= cycle 'even', 'odd' %>">
|
||||
<td><%= link_to h(artist_version.name), artist_versions_path(:artist_id => artist_version.artist_id) %></td>
|
||||
<td><%= h artist_version.other_names %></td>
|
||||
<td><%= h artist_version.group_name %></td>
|
||||
<td><%= time_ago_in_words artist_version.created_at %> ago</td>
|
||||
<td><%= link_to artist_version.updater_name, user_path(artist_version.updater_id) %></td>
|
||||
<td><%= artist_version.is_active? %></td>
|
||||
<td><%= artist_version.url_string %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div id="paginator">
|
||||
<%= sequential_paginator(@artist_versions) %>
|
||||
<div class="paginator">
|
||||
<%= sequential_paginator(@artist_versions) %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= render "artists/secondary_links" %>
|
||||
|
@ -3,33 +3,39 @@
|
||||
<table class="striped" width="100%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5%"></th>
|
||||
<th width="95%">Name</th>
|
||||
<th width="45%">Primary Name</th>
|
||||
<th width="45%">Secondary Names</th>
|
||||
<th width="10%">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @artists.each do |artist| %>
|
||||
<%= content_tag(:tr, :id => "artist-#{artist.id}") do %>
|
||||
<td>
|
||||
<%= link_to "P", posts_path(:tags => artist.name), :title => "Find posts for artist" %>
|
||||
<%= link_to "E", edit_artist_path(artist), :title => "Edit artist" %>
|
||||
<%= link_to "D", artist_path(artist, :method => :delete, :confirm => "Do you really want to delete this artist?") %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to h(artist.name), artist_path(artist) %>
|
||||
<% if !artist.group_name.blank? %>
|
||||
(group:<%= link_to(artist.group_name, artist_path(artist)) %>)
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= artist.other_names %></td>
|
||||
<td>
|
||||
<% if artist.is_active? %>
|
||||
Active
|
||||
<% else %>
|
||||
Deleted
|
||||
<% end %>
|
||||
|
||||
<% if artist.is_banned? %>
|
||||
Banned
|
||||
<% end %>
|
||||
</td>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="paginator">
|
||||
<%= numbered_paginator(@artists) do |page| %>
|
||||
<%= link_to(page, artists_path(:page => page, :search => params[:search])) %>
|
||||
<% end %>
|
||||
<div class="paginator">
|
||||
<%= numbered_paginator(@artists) %>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
@ -25,7 +25,7 @@
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div id="paginator">
|
||||
<div class="paginator">
|
||||
<%= sequential_paginator(@pools) %>
|
||||
</div>
|
||||
|
||||
|
@ -12,9 +12,7 @@
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="paginator">
|
||||
<%= numbered_paginator(@post_set) do |page| %>
|
||||
<%= link_to(page, pool_path(@pool, :page => page)) %>
|
||||
<% end %>
|
||||
<%= numbered_paginator(@post_set) %>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
@ -22,7 +22,11 @@
|
||||
<tr id="tag-alias-<%= tag_alias.id %>">
|
||||
<td><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>)</td>
|
||||
<td><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>)</td>
|
||||
<td><%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %></td>
|
||||
<td>
|
||||
<% if tag_alias.forum_topic_id %>
|
||||
<%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
|
||||
@ -35,10 +39,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="paginator">
|
||||
<%= numbered_paginator(@tag_aliases) do |page| %>
|
||||
<%= link_to(page, tag_aliases_path(:page => page)) %>
|
||||
<% end %>
|
||||
<div class="paginator">
|
||||
<%= numbered_paginator(@tag_aliases) %>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
@ -22,7 +22,11 @@
|
||||
<tr id="tag-implication-<%= tag_implication.id %>">
|
||||
<td><%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> (<%= tag_implication.antecedent_tag.post_count rescue 0 %>)</td>
|
||||
<td><%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> (<%= tag_implication.consequent_tag.post_count rescue 0 %>)</td>
|
||||
<td><%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %></td>
|
||||
<td>
|
||||
<% if tag_implication.forum_topic_id %>
|
||||
<%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if CurrentUser.is_admin? %>
|
||||
<%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
|
||||
@ -35,10 +39,8 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="paginator">
|
||||
<%= numbered_paginator(@tag_implications) do |page| %>
|
||||
<%= link_to(page, tag_impliactions_path(:page => page)) %>
|
||||
<% end %>
|
||||
<div class="paginator">
|
||||
<%= numbered_paginator(@tag_implications) %>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
@ -19,9 +19,7 @@
|
||||
</table>
|
||||
|
||||
<div class="paginator">
|
||||
<%= numbered_paginator(@tags) do |page| %>
|
||||
<%= link_to(page, tags_path(:page => page)) %>
|
||||
<% end %>
|
||||
<%= numbered_paginator(@tags) %>
|
||||
</div>
|
||||
|
||||
<%= render "secondary_links" %>
|
||||
|
@ -109,7 +109,7 @@ module Danbooru
|
||||
|
||||
# After this many pages, the paginator will switch to sequential mode.
|
||||
def max_numbered_pages
|
||||
2
|
||||
10
|
||||
end
|
||||
|
||||
# Max number of tag subscriptions per user
|
||||
|
@ -6,7 +6,7 @@ module Danbooru
|
||||
end
|
||||
|
||||
def posts_per_page
|
||||
1
|
||||
3
|
||||
end
|
||||
|
||||
def is_user_restricted?(user)
|
||||
|
91
db/seeds.rb
91
db/seeds.rb
@ -1,7 +1,84 @@
|
||||
# This file should contain all the record creation needed to seed the database with its default values.
|
||||
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
||||
#
|
||||
# Examples:
|
||||
#
|
||||
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
|
||||
# Mayor.create(:name => 'Daley', :city => cities.first)
|
||||
if User.count == 0
|
||||
puts "Creating users"
|
||||
user = User.create(
|
||||
:name => "albert",
|
||||
:password => "password1",
|
||||
:password_confirmation => "password1"
|
||||
)
|
||||
else
|
||||
puts "Skipping users"
|
||||
user = User.first
|
||||
end
|
||||
|
||||
CurrentUser.user = user
|
||||
CurrentUser.ip_addr = "127.0.0.1"
|
||||
|
||||
if Upload.count == 0
|
||||
puts "Creating uploads"
|
||||
1.upto(100) do |i|
|
||||
url = "http://dummyimage.com/#{i * 10}x400/000/fff"
|
||||
tags = (i * i * i).to_s.scan(/./).uniq.join(" ")
|
||||
|
||||
Upload.create(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags)
|
||||
end
|
||||
else
|
||||
puts "Skipping uploads"
|
||||
end
|
||||
|
||||
if Post.count == 0
|
||||
puts "Creating posts"
|
||||
Upload.all.each do |upload|
|
||||
upload.process!
|
||||
end
|
||||
else
|
||||
puts "Skipping posts"
|
||||
end
|
||||
|
||||
if Comment.count == 0
|
||||
puts "Creating comments"
|
||||
Post.all.each do |post|
|
||||
Comment.create(:post_id => post.id, :body => rand(1_000_000).to_s)
|
||||
end
|
||||
else
|
||||
puts "Skipping comments"
|
||||
end
|
||||
|
||||
if Note.count == 0
|
||||
puts "Creating notes"
|
||||
Post.all.each do |post|
|
||||
3.times do
|
||||
Note.create(:post_id => post.id, :x => 0, :y => 0, :width => 100, :height => 100, :body => rand(1_000_000).to_s)
|
||||
end
|
||||
end
|
||||
else
|
||||
puts "Skipping notes"
|
||||
end
|
||||
|
||||
if Artist.count == 0
|
||||
puts "Creating artists"
|
||||
0.upto(100) do |i|
|
||||
Artist.create(:name => i.to_s)
|
||||
end
|
||||
else
|
||||
puts "Skipping artists"
|
||||
end
|
||||
|
||||
if TagAlias.count == 0
|
||||
puts "Creating tag aliases"
|
||||
|
||||
11.upto(99) do |i|
|
||||
TagAlias.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s)
|
||||
end
|
||||
else
|
||||
puts "Skipping tag aliases"
|
||||
end
|
||||
|
||||
if TagImplication.count == 0
|
||||
puts "Creating tag implictions"
|
||||
|
||||
10_000.upto(10_100) do |i|
|
||||
TagImplication.create(:antecedent_name => i.to_s, :consequent_name => (i * 100).to_s)
|
||||
end
|
||||
else
|
||||
puts "Skipping tag implications"
|
||||
end
|
@ -52,7 +52,7 @@ module Danbooru
|
||||
page = [page.to_i, 1].max
|
||||
|
||||
if page > Danbooru.config.max_numbered_pages
|
||||
raise Error.new("You cannot go beyond page #{Danbooru.config.max_numbered_pages}. Please narrow your search terms.")
|
||||
raise "You cannot go beyond page #{Danbooru.config.max_numbered_pages}. Please narrow your search terms."
|
||||
end
|
||||
|
||||
limit(records_per_page).offset((page - 1) * records_per_page).tap do |obj|
|
||||
|
@ -1,6 +0,0 @@
|
||||
module Danbooru
|
||||
module Paginator
|
||||
class Error < Exception
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user