forked from e621ng/e621ng
fixes #1371, additional fixes to seed script
This commit is contained in:
parent
5327ac7820
commit
7a747e9ac0
@ -97,7 +97,12 @@
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.posts = function() {
|
||||
return $(".post-preview");
|
||||
var previews = $(".post-preview");
|
||||
if (previews.length) {
|
||||
return previews;
|
||||
} else {
|
||||
return $("#image");
|
||||
}
|
||||
}
|
||||
|
||||
Danbooru.Blacklist.post_match = function(post, entry) {
|
||||
|
@ -18,7 +18,7 @@ a.blacklisted-active {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.post-preview.blacklisted-active {
|
||||
.post-preview.blacklisted-active, #image.blacklisted-active {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
@ -262,6 +262,15 @@ class Post < ActiveRecord::Base
|
||||
@presenter ||= PostPresenter.new(self)
|
||||
end
|
||||
|
||||
def status_flags
|
||||
flags = []
|
||||
flags << "pending" if is_pending?
|
||||
flags << "flagged" if is_flagged?
|
||||
flags << "deleted" if is_deleted?
|
||||
flags << "banned" if is_banned?
|
||||
flags.join(" ")
|
||||
end
|
||||
|
||||
def pretty_rating
|
||||
case rating
|
||||
when "q"
|
||||
|
@ -12,15 +12,9 @@ class PostPresenter < Presenter
|
||||
return ""
|
||||
end
|
||||
|
||||
flags = []
|
||||
flags << "pending" if post.is_pending?
|
||||
flags << "flagged" if post.is_flagged?
|
||||
flags << "deleted" if post.is_deleted?
|
||||
flags << "banned" if post.is_banned?
|
||||
|
||||
path = options[:path_prefix] || "/posts"
|
||||
|
||||
html = %{<article class="post-preview" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{flags.join(' ')}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}" data-score="#{post.score}">}
|
||||
html = %{<article class="post-preview" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{post.status_flags}" data-parent-id="#{post.parent_id}" data-has-children="#{post.has_children?}" data-score="#{post.score}" data-fav-count="#{post.fav_count}">}
|
||||
if options[:tags].present?
|
||||
tag_param = "?tags=#{CGI::escape(options[:tags])}"
|
||||
elsif options[:pool_id]
|
||||
|
@ -1,2 +1,2 @@
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height) %>
|
||||
<%= image_tag(post.file_url_for(CurrentUser.user), :width => post.image_width_for(CurrentUser.user), :height => post.image_height_for(CurrentUser.user), :id => "image", "data-original-width" => post.image_width, "data-original-height" => post.image_height, "data-large-width" => post.large_image_width, "data-large-height" => post.large_image_height, "data-tags" => post.tag_string, "data-uploader" => post.uploader_name, "data-rating" => post.rating, "data-flags" => post.status_flags, "data-parent-id" => post.parent_id, "data-has-children" => post.has_children?, "data-score" => post.score, "data-fav-count" => post.fav_count) %>
|
||||
|
||||
|
@ -14,6 +14,8 @@
|
||||
<%= render "posts/partials/show/information", :post => @post %>
|
||||
</section>
|
||||
|
||||
<%= render "posts/partials/index/blacklist" %>
|
||||
|
||||
<% if CurrentUser.is_member? %>
|
||||
<section>
|
||||
<h1>Options</h1>
|
||||
|
52
db/seeds.rb
52
db/seeds.rb
@ -4,7 +4,7 @@ CurrentUser.ip_addr = "127.0.0.1"
|
||||
Delayed::Worker.delay_jobs = false
|
||||
$used_names = Set.new([""])
|
||||
|
||||
def rand_string(n)
|
||||
def rand_string(n, unique = false)
|
||||
string = ""
|
||||
|
||||
n = rand(n) + 1
|
||||
@ -17,22 +17,23 @@ def rand_string(n)
|
||||
string << consonants[rand(consonants.size)]
|
||||
string << vowels[rand(vowels.size)]
|
||||
end
|
||||
return string unless unique
|
||||
end
|
||||
|
||||
$used_names.add(string)
|
||||
string
|
||||
end
|
||||
|
||||
def rand_sentence(n)
|
||||
(0..n).map {rand_string(6)}.join(" ") + "."
|
||||
def rand_sentence(n, unique = false)
|
||||
(0..n).map {rand_string(n, unique)}.join(" ") + "."
|
||||
end
|
||||
|
||||
def rand_paragraph(n)
|
||||
(0..n).map {rand_sentence(6)}.join(" ")
|
||||
def rand_paragraph(n, unique = false)
|
||||
(0..n).map {rand_sentence(n, unique)}.join(" ")
|
||||
end
|
||||
|
||||
def rand_document(n)
|
||||
(0..n).map {rand_pargraph(6)}.join("\n\n")
|
||||
def rand_document(n, unique = false)
|
||||
(0..n).map {rand_paragraph(n, unique)}.join("\n\n")
|
||||
end
|
||||
|
||||
if User.count == 0
|
||||
@ -45,17 +46,18 @@ if User.count == 0
|
||||
|
||||
0.upto(10) do |i|
|
||||
User.create(
|
||||
:name => rand_string(8),
|
||||
:name => rand_string(8, true),
|
||||
:password => i.to_s * 5,
|
||||
:password_confirmation => i.to_s * 5
|
||||
)
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping users"
|
||||
user = User.find_by_name("albert")
|
||||
end
|
||||
|
||||
CurrentUser.user = user
|
||||
CurrentUser.user = User.admins.first
|
||||
|
||||
if Upload.count == 0
|
||||
puts "Creating uploads"
|
||||
@ -65,7 +67,7 @@ if Upload.count == 0
|
||||
width = rand(2000) + 100
|
||||
height = rand(2000) + 100
|
||||
url = "http://ipsumimage.appspot.com/#{width}x#{height}"
|
||||
tags = rand_sentence(6).scan(/[a-z]+/).join(" ")
|
||||
tags = rand_sentence(12).scan(/[a-z]+/).join(" ")
|
||||
|
||||
Upload.create(:source => url, :content_type => "image/gif", :rating => "q", :tag_string => tags, :server => Socket.gethostname)
|
||||
end
|
||||
@ -85,7 +87,7 @@ end
|
||||
if Comment.count == 0
|
||||
puts "Creating comments"
|
||||
Post.all.each do |post|
|
||||
rand(30).times do
|
||||
rand(10).times do
|
||||
Comment.create(:post_id => post.id, :body => rand_paragraph(6))
|
||||
end
|
||||
end
|
||||
@ -95,11 +97,11 @@ end
|
||||
|
||||
if Note.count == 0
|
||||
puts "Creating notes"
|
||||
Post.all.each do |post|
|
||||
rand(10).times do
|
||||
note = Note.create(:post_id => post.id, :x => 0, :y => 0, :width => 100, :height => 100, :body => Time.now.to_f.to_s)
|
||||
Post.order("random()").limit(10).each do |post|
|
||||
rand(5).times do
|
||||
note = Note.create(:post_id => post.id, :x => rand(post.image_width), :y => rand(post.image_height), :width => 100, :height => 100, :body => Time.now.to_f.to_s)
|
||||
|
||||
rand(30).times do |i|
|
||||
rand(10).times do |i|
|
||||
note.update_attributes(:body => rand_sentence(6))
|
||||
end
|
||||
end
|
||||
@ -110,9 +112,10 @@ end
|
||||
|
||||
if Artist.count == 0
|
||||
puts "Creating artists"
|
||||
0.upto(100) do |i|
|
||||
Artist.create(:name => rand_string(6))
|
||||
20.times do |i|
|
||||
Artist.create(:name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping artists"
|
||||
end
|
||||
@ -120,9 +123,10 @@ end
|
||||
if TagAlias.count == 0
|
||||
puts "Creating tag aliases"
|
||||
|
||||
100.upto(199) do |i|
|
||||
TagAlias.create(:antecedent_name => rand_string(6), :consequent_name => rand_string(6))
|
||||
20.times do |i|
|
||||
TagAlias.create(:antecedent_name => rand_string(9, true), :consequent_name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping tag aliases"
|
||||
end
|
||||
@ -130,9 +134,10 @@ end
|
||||
if TagImplication.count == 0
|
||||
puts "Creating tag implictions"
|
||||
|
||||
100_000.upto(100_100) do |i|
|
||||
TagImplication.create(:antecedent_name => rand_string(6), :consequent_name => rand_string(6))
|
||||
20.times do |i|
|
||||
TagImplication.create(:antecedent_name => rand_string(9, true), :consequent_name => rand_string(9, true))
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
else
|
||||
puts "Skipping tag implications"
|
||||
end
|
||||
@ -141,11 +146,12 @@ if Pool.count == 0
|
||||
puts "Creating pools"
|
||||
|
||||
1.upto(20) do |i|
|
||||
pool = Pool.create(:name => i.to_s)
|
||||
pool = Pool.create(:name => rand_string(9, true))
|
||||
rand(33).times do |j|
|
||||
pool.add!(Post.order("random()").first)
|
||||
end
|
||||
end
|
||||
$used_names = Set.new([""])
|
||||
end
|
||||
|
||||
if Favorite.count == 0
|
||||
@ -163,7 +169,7 @@ end
|
||||
if ForumTopic.count == 0
|
||||
puts "Creating forum posts"
|
||||
|
||||
100.times do |i|
|
||||
20.times do |i|
|
||||
topic = ForumTopic.create(:title => rand_sentence(6))
|
||||
|
||||
rand(100).times do |j|
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
bundle exec rake db:drop db:create
|
||||
psql -c 'create language plpgsql;' danbooru2
|
||||
bundle exec rake db:migrate
|
||||
bundle exec rake db:seed
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user