Merge branch 'master' of https://github.com/r888888888/danbooru
This commit is contained in:
@@ -15,6 +15,10 @@
|
|||||||
Danbooru.PostModeMenu.initialize_shortcuts = function() {
|
Danbooru.PostModeMenu.initialize_shortcuts = function() {
|
||||||
$(document).bind("keypress", "1 2 3 4 5 6 7 8 9 0", Danbooru.PostModeMenu.change_tag_script);
|
$(document).bind("keypress", "1 2 3 4 5 6 7 8 9 0", Danbooru.PostModeMenu.change_tag_script);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Danbooru.PostModeMenu.show_notice = function(i) {
|
||||||
|
Danbooru.notice("Switched to tag script #" + i + ". To switch tag scripts, use the number keys.");
|
||||||
|
}
|
||||||
|
|
||||||
Danbooru.PostModeMenu.change_tag_script = function(e) {
|
Danbooru.PostModeMenu.change_tag_script = function(e) {
|
||||||
if ($("#mode-box select").val() === "tag-script") {
|
if ($("#mode-box select").val() === "tag-script") {
|
||||||
@@ -27,7 +31,7 @@
|
|||||||
$("#tag-script-field").val(new_tag_script);
|
$("#tag-script-field").val(new_tag_script);
|
||||||
Danbooru.Cookie.put("current_tag_script_id", new_tag_script_id);
|
Danbooru.Cookie.put("current_tag_script_id", new_tag_script_id);
|
||||||
if (old_tag_script_id != new_tag_script_id) {
|
if (old_tag_script_id != new_tag_script_id) {
|
||||||
Danbooru.notice("Switched to tag script #" + new_tag_script_id + ". To switch tag scripts, use the number keys.");
|
Danbooru.PostModeMenu.show_notice(new_tag_script_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@@ -121,6 +125,7 @@
|
|||||||
var script = Danbooru.Cookie.get("tag-script-" + current_script_id);
|
var script = Danbooru.Cookie.get("tag-script-" + current_script_id);
|
||||||
|
|
||||||
$("#tag-script-field").val(script).show();
|
$("#tag-script-field").val(script).show();
|
||||||
|
Danbooru.PostModeMenu.show_notice(current_script_id);
|
||||||
} else {
|
} else {
|
||||||
$("#tag-script-field").hide();
|
$("#tag-script-field").hide();
|
||||||
}
|
}
|
||||||
|
|||||||
5
app/assets/stylesheets/specific/meta_searches.css.scss
Normal file
5
app/assets/stylesheets/specific/meta_searches.css.scss
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
#c-meta-searches {
|
||||||
|
section {
|
||||||
|
margin-bottom: 2em;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,24 +9,8 @@ module Admin
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
@user = User.find(params[:id])
|
@user = User.find(params[:id])
|
||||||
sanitize_params!
|
@user.promote_to!(params[:user][:level])
|
||||||
@user.level = params[:user][:level]
|
|
||||||
@user.inviter_id = CurrentUser.id
|
|
||||||
TransactionLogItem.record_account_upgrade(@user)
|
|
||||||
@user.save
|
|
||||||
redirect_to edit_admin_user_path(@user), :notice => "User updated"
|
redirect_to edit_admin_user_path(@user), :notice => "User updated"
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
def sanitize_params!
|
|
||||||
# admins can do anything
|
|
||||||
return if CurrentUser.is_admin?
|
|
||||||
|
|
||||||
# can't promote/demote moderators
|
|
||||||
raise User::PrivilegeError if @user.is_moderator?
|
|
||||||
|
|
||||||
# can't promote to admin
|
|
||||||
raise User::PrivilegeError if params[:user] && params[:user][:level].to_i >= User::Levels::ADMIN
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
6
app/controllers/meta_searches_controller.rb
Normal file
6
app/controllers/meta_searches_controller.rb
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
class MetaSearchesController < ApplicationController
|
||||||
|
def tags
|
||||||
|
@meta_search = MetaSearches::Tag.new(params)
|
||||||
|
@meta_search.load_all
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -12,14 +12,6 @@ class TagAliasesController < ApplicationController
|
|||||||
respond_with(@tag_alias)
|
respond_with(@tag_alias)
|
||||||
end
|
end
|
||||||
|
|
||||||
def general_search
|
|
||||||
if params[:commit] == "Search Aliases"
|
|
||||||
redirect_to tag_aliases_path(:search => {:name_matches => params[:query]})
|
|
||||||
else
|
|
||||||
redirect_to tag_implications_path(:search => {:name_matches => params[:query]})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@search = TagAlias.search(params[:search])
|
@search = TagAlias.search(params[:search])
|
||||||
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
@tag_aliases = @search.order("(case status when 'pending' then 0 when 'queued' then 1 else 2 end), antecedent_name, consequent_name").paginate(params[:page], :limit => params[:limit])
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ class UserNameChangeRequestsController < ApplicationController
|
|||||||
|
|
||||||
private
|
private
|
||||||
def check_privileges!(change_request)
|
def check_privileges!(change_request)
|
||||||
return if CurrentUser.is_janitor?
|
return if CurrentUser.is_admin?
|
||||||
raise User::PrivilegeError if change_request.user_id != CurrentUser.user.id
|
raise User::PrivilegeError if change_request.user_id != CurrentUser.user.id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
module ApplicationHelper
|
module ApplicationHelper
|
||||||
|
def wordbreakify(string)
|
||||||
|
raw(string.gsub(/(.{10})/, "\\1<wbr>"))
|
||||||
|
end
|
||||||
|
|
||||||
def nav_link_to(text, url, options = nil)
|
def nav_link_to(text, url, options = nil)
|
||||||
if nav_link_match(params[:controller], url)
|
if nav_link_match(params[:controller], url)
|
||||||
klass = "current"
|
klass = "current"
|
||||||
@@ -139,7 +143,7 @@ protected
|
|||||||
when "artists", "artist_versions"
|
when "artists", "artist_versions"
|
||||||
/^\/artist/
|
/^\/artist/
|
||||||
|
|
||||||
when "tags"
|
when "tags", "meta_searches"
|
||||||
/^\/tags/
|
/^\/tags/
|
||||||
|
|
||||||
when "pools", "pool_versions"
|
when "pools", "pool_versions"
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ module PostVersionsHelper
|
|||||||
html = []
|
html = []
|
||||||
diff[:added_tags].each do |tag|
|
diff[:added_tags].each do |tag|
|
||||||
prefix = diff[:obsolete_added_tags].include?(tag) ? '+<ins class="obsolete">' : '<ins>+'
|
prefix = diff[:obsolete_added_tags].include?(tag) ? '+<ins class="obsolete">' : '<ins>+'
|
||||||
html << prefix + link_to(tag, posts_path(:tags => tag)) + '</ins>'
|
html << prefix + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '</ins>'
|
||||||
end
|
end
|
||||||
diff[:removed_tags].each do |tag|
|
diff[:removed_tags].each do |tag|
|
||||||
prefix = diff[:obsolete_removed_tags].include?(tag) ? '-<del class="obsolete">' : '<del>-'
|
prefix = diff[:obsolete_removed_tags].include?(tag) ? '-<del class="obsolete">' : '<del>-'
|
||||||
html << prefix + link_to(tag, posts_path(:tags => tag)) + '</del>'
|
html << prefix + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '</del>'
|
||||||
end
|
end
|
||||||
diff[:unchanged_tags].each do |tag|
|
diff[:unchanged_tags].each do |tag|
|
||||||
html << '<span>' + link_to(tag, posts_path(:tags => tag)) + '</span>'
|
html << '<span>' + link_to(wordbreakify(tag), posts_path(:tags => tag)) + '</span>'
|
||||||
end
|
end
|
||||||
return html.join(" ").html_safe
|
return html.join(" ").html_safe
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ module PostsHelper
|
|||||||
|
|
||||||
def post_source_tag(post)
|
def post_source_tag(post)
|
||||||
if post.source =~ %r!http://img\d+\.pixiv\.net/img/([^\/]+)/!
|
if post.source =~ %r!http://img\d+\.pixiv\.net/img/([^\/]+)/!
|
||||||
text = "pixiv/#{$1}"
|
text = "pixiv/<wbr>#{wordbreakify($1)}"
|
||||||
source_link = link_to(text, post.normalized_source)
|
source_link = link_to(text, post.normalized_source)
|
||||||
source_search = "source:#{text}/"
|
source_search = "source:#{text}/"
|
||||||
elsif post.source =~ %r!http://i\d\.pixiv\.net/img\d+/img/([^\/]+)/!
|
elsif post.source =~ %r!http://i\d\.pixiv\.net/img\d+/img/([^\/]+)/!
|
||||||
text = "pixiv/#{$1}"
|
text = "pixiv/<wbr>#{wordbreakify($1)}"
|
||||||
source_link = link_to(text, post.normalized_source)
|
source_link = link_to(text, post.normalized_source)
|
||||||
source_search = "source:#{text}/"
|
source_search = "source:#{text}/"
|
||||||
elsif post.source =~ %r{\Ahttps?://}
|
elsif post.source =~ %r{\Ahttps?://}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
class ApiCacheGenerator
|
class ApiCacheGenerator
|
||||||
def generate_tag_cache
|
def generate_tag_cache
|
||||||
FileUtils.mkdir_p("/var/www/danbooru2/shared/system/cache")
|
path = File.expand_path(File.join(Rails.root, "..", "shared"))
|
||||||
File.open("/var/www/danbooru2/shared/system/cache/tags.json", "w") do |f|
|
FileUtils.mkdir_p("#{path}/system/cache")
|
||||||
|
File.open("#{path}/system/cache/tags.json", "w") do |f|
|
||||||
f.print("[")
|
f.print("[")
|
||||||
Tag.without_timeout do
|
Tag.without_timeout do
|
||||||
Tag.find_each do |tag|
|
Tag.find_each do |tag|
|
||||||
@@ -20,11 +21,11 @@ class ApiCacheGenerator
|
|||||||
f.seek(-2, IO::SEEK_END)
|
f.seek(-2, IO::SEEK_END)
|
||||||
f.print("]\n")
|
f.print("]\n")
|
||||||
end
|
end
|
||||||
Zlib::GzipWriter.open("/var/www/danbooru2/shared/system/cache/tags.json.gz") do |gz|
|
Zlib::GzipWriter.open("#{path}/system/cache/tags.json.gz") do |gz|
|
||||||
gz.write(IO.binread("/var/www/danbooru2/shared/system/cache/tags.json"))
|
gz.write(IO.binread("#{path}/system/cache/tags.json"))
|
||||||
gz.close
|
gz.close
|
||||||
end
|
end
|
||||||
RemoteFileManager.new("/var/www/danbooru2/shared/system/cache/tags.json").distribute
|
RemoteFileManager.new("#{path}/system/cache/tags.json").distribute
|
||||||
RemoteFileManager.new("/var/www/danbooru2/shared/system/cache/tags.json.gz").distribute
|
RemoteFileManager.new("#{path}/shared/system/cache/tags.json.gz").distribute
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class DailyMaintenance
|
|||||||
ModAction.delete_all(['created_at < ?', 3.days.ago])
|
ModAction.delete_all(['created_at < ?', 3.days.ago])
|
||||||
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
Delayed::Job.delete_all(['created_at < ?', 7.days.ago])
|
||||||
PostVote.delete_all(['created_at < ?', 1.month.ago])
|
PostVote.delete_all(['created_at < ?', 1.month.ago])
|
||||||
|
CommentVote.delete_all(['created_at < ?', 1.month.ago])
|
||||||
TagSubscription.process_all
|
TagSubscription.process_all
|
||||||
ApiCacheGenerator.new.generate_tag_cache
|
ApiCacheGenerator.new.generate_tag_cache
|
||||||
end
|
end
|
||||||
|
|||||||
30
app/logical/meta_searches/tag.rb
Normal file
30
app/logical/meta_searches/tag.rb
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
class MetaSearches::Tag
|
||||||
|
MAX_RESULTS = 25
|
||||||
|
attr_reader :search_params, :tags, :tag_aliases, :tag_implications
|
||||||
|
|
||||||
|
def initialize(search_params)
|
||||||
|
@search_params = search_params
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_all
|
||||||
|
load_tags
|
||||||
|
load_tag_aliases
|
||||||
|
load_tag_implications
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_tags
|
||||||
|
@tags = ::Tag.name_matches(name_param).limit(MAX_RESULTS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_tag_aliases
|
||||||
|
@tag_aliases = TagAlias.name_matches(name_param).limit(MAX_RESULTS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_tag_implications
|
||||||
|
@tag_implications = TagImplication.name_matches(name_param).limit(MAX_RESULTS)
|
||||||
|
end
|
||||||
|
|
||||||
|
def name_param
|
||||||
|
search_params[:name] || ""
|
||||||
|
end
|
||||||
|
end
|
||||||
78
app/logical/user_promotion.rb
Normal file
78
app/logical/user_promotion.rb
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
class UserPromotion
|
||||||
|
attr_reader :user, :promoter, :new_level
|
||||||
|
|
||||||
|
def initialize(user, promoter, new_level)
|
||||||
|
@user = user
|
||||||
|
@promoter = promoter
|
||||||
|
@new_level = new_level
|
||||||
|
end
|
||||||
|
|
||||||
|
def promote!
|
||||||
|
user.level = new_level
|
||||||
|
user.inviter_id = promoter.id
|
||||||
|
|
||||||
|
validate
|
||||||
|
create_transaction_log_item
|
||||||
|
create_user_feedback
|
||||||
|
create_dmail
|
||||||
|
|
||||||
|
user.save
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def validate
|
||||||
|
# admins can do anything
|
||||||
|
return if promoter.is_admin?
|
||||||
|
|
||||||
|
# can't promote/demote moderators
|
||||||
|
raise User::PrivilegeError if user.is_moderator?
|
||||||
|
|
||||||
|
# can't promote to admin
|
||||||
|
raise User::PrivilegeError if new_level.to_i >= User::Levels::ADMIN
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_transaction_log_item
|
||||||
|
TransactionLogItem.record_account_upgrade(user)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_user_feedback
|
||||||
|
if user.level > user.level_was
|
||||||
|
body_prefix = "Promoted"
|
||||||
|
elsif user.level < user.level_was
|
||||||
|
body_prefix = "Demoted"
|
||||||
|
else
|
||||||
|
body_prefix = "Updated"
|
||||||
|
end
|
||||||
|
|
||||||
|
user.feedback.create(
|
||||||
|
:category => "neutral",
|
||||||
|
:body => "#{body_prefix} by #{promoter.name} from #{user.level_string_was} to #{user.level_string}",
|
||||||
|
:disable_dmail_notification => true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_dmail
|
||||||
|
if user.level >= user.level_was
|
||||||
|
create_promotion_dmail
|
||||||
|
else
|
||||||
|
create_demotion_dmail
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_promotion_dmail
|
||||||
|
Dmail.create_split(
|
||||||
|
:to_id => user.id,
|
||||||
|
:title => "You have been promoted",
|
||||||
|
:body => "You have been promoted to a #{user.level_string} level account."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_demotion_dmail
|
||||||
|
Dmail.create_split(
|
||||||
|
:to_id => user.id,
|
||||||
|
:title => "You have been demoted",
|
||||||
|
:body => "You have been demoted to a #{user.level_string} level account."
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -624,7 +624,7 @@ class Post < ActiveRecord::Base
|
|||||||
|
|
||||||
module FavoriteMethods
|
module FavoriteMethods
|
||||||
def clean_fav_string?
|
def clean_fav_string?
|
||||||
rand(100) < [Math.log(fav_string.size, 2), 5].min
|
rand(100) < 50
|
||||||
end
|
end
|
||||||
|
|
||||||
def clean_fav_string!
|
def clean_fav_string!
|
||||||
|
|||||||
@@ -242,8 +242,8 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def promote_to(level)
|
def promote_to!(new_level)
|
||||||
update_attributes({:level => level}, :as => :admin)
|
UserPromotion.new(self, CurrentUser.user, new_level).promote!
|
||||||
end
|
end
|
||||||
|
|
||||||
def promote_to_admin_if_first_user
|
def promote_to_admin_if_first_user
|
||||||
@@ -281,6 +281,10 @@ class User < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def level_string_was
|
||||||
|
level_string(level_was)
|
||||||
|
end
|
||||||
|
|
||||||
def level_string(value = nil)
|
def level_string(value = nil)
|
||||||
case (value || level)
|
case (value || level)
|
||||||
when Levels::BLOCKED
|
when Levels::BLOCKED
|
||||||
@@ -357,7 +361,7 @@ class User < ActiveRecord::Base
|
|||||||
|
|
||||||
def create_mod_action
|
def create_mod_action
|
||||||
if level_changed?
|
if level_changed?
|
||||||
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string(level_was)} -> #{level_string}})
|
ModAction.create(:description => %{"#{name}":/users/#{id} level changed #{level_string_was} -> #{level_string}})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,8 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :creator, :class_name => "User"
|
belongs_to :creator, :class_name => "User"
|
||||||
before_validation :initialize_creator, :on => :create
|
before_validation :initialize_creator, :on => :create
|
||||||
attr_accessible :body, :user_id, :category, :user_name
|
attr_accessor :disable_dmail_notification
|
||||||
|
attr_accessible :body, :user_id, :category, :user_name, :disable_dmail_notification
|
||||||
validates_presence_of :user, :creator, :body, :category
|
validates_presence_of :user, :creator, :body, :category
|
||||||
validates_inclusion_of :category, :in => %w(positive negative neutral)
|
validates_inclusion_of :category, :in => %w(positive negative neutral)
|
||||||
validate :creator_is_gold
|
validate :creator_is_gold
|
||||||
@@ -74,8 +75,10 @@ class UserFeedback < ActiveRecord::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_dmail
|
def create_dmail
|
||||||
body = %{#{creator_name} created a "#{category} record":/user_feedbacks?search[user_id]=#{user_id} for your account. #{body}}
|
unless disable_dmail_notification
|
||||||
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
|
body = %{#{creator_name} created a "#{category} record":/user_feedbacks?search[user_id]=#{user_id} for your account. #{body}}
|
||||||
|
Dmail.create_split(:to_id => user_id, :title => "Your user record has been updated", :body => body)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def creator_is_gold
|
def creator_is_gold
|
||||||
|
|||||||
129
app/views/meta_searches/tags.html.erb
Normal file
129
app/views/meta_searches/tags.html.erb
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<div id="c-meta-searches">
|
||||||
|
<div id="a-tags">
|
||||||
|
<h1>MetaSearch Tags</h1>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<%= form_tag(meta_searches_tags_path, :method => :get) do %>
|
||||||
|
<%= text_field_tag "name", params[:name] %>
|
||||||
|
<%= submit_tag "Go" %>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Tags</h2>
|
||||||
|
|
||||||
|
<% if @meta_search.tags.empty? %>
|
||||||
|
<p>No results</p>
|
||||||
|
<% else %>
|
||||||
|
<table width="100%" class="striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Count</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @meta_search.tags.each do |tag| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= tag.name %></td>
|
||||||
|
<td><%= tag.post_count %></td>
|
||||||
|
<td>
|
||||||
|
<% if tag.editable_by?(CurrentUser.user) %>
|
||||||
|
<%= link_to "edit", edit_tag_path(tag) %>
|
||||||
|
<% end %>
|
||||||
|
<% if CurrentUser.is_builder? %>
|
||||||
|
| <%= link_to "fix", new_tag_correction_path(:tag_id => tag.id) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Tag Aliases</h2>
|
||||||
|
<% if @meta_search.tag_aliases.empty? %>
|
||||||
|
<p>No results</p>
|
||||||
|
<% else %>
|
||||||
|
<table width="100%" class="striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>From</th>
|
||||||
|
<th>To</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @meta_search.tag_aliases.each do |tag_alias| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= tag_alias.antecedent_name %></td>
|
||||||
|
<td><%= tag_alias.consequent_name %></td>
|
||||||
|
<td>
|
||||||
|
<%= link_to "Show", tag_alias_path(tag_alias) %>
|
||||||
|
<% if tag_alias.deletable_by?(CurrentUser.user) %>
|
||||||
|
| <%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_admin? && tag_alias.is_pending? %>
|
||||||
|
| <%= link_to "Approve", approve_tag_alias_path(tag_alias), :remote => true, :method => :post %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% if CurrentUser.is_janitor? %>
|
||||||
|
| <%= link_to "Fix", tag_alias_correction_path(:tag_alias_id => tag_alias.id) %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section>
|
||||||
|
<h2>Tag Implications</h2>
|
||||||
|
<% if @meta_search.tag_implications.empty? %>
|
||||||
|
<p>No results</p>
|
||||||
|
<% else %>
|
||||||
|
<table width="100%" class="striped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>From</th>
|
||||||
|
<th>To</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<% @meta_search.tag_implications.each do |tag_implication| %>
|
||||||
|
<tr>
|
||||||
|
<td><%= tag_implication.antecedent_name %></td>
|
||||||
|
<td><%= tag_implication.consequent_name %></td>
|
||||||
|
<td>
|
||||||
|
<%= link_to "Show", tag_implication_path(tag_implication) %>
|
||||||
|
<% if tag_implication.deletable_by?(CurrentUser.user) %>
|
||||||
|
| <%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
|
||||||
|
<% end %>
|
||||||
|
<% if CurrentUser.user.is_admin? && tag_implication.is_pending? %>
|
||||||
|
| <%= link_to "Approve", approve_tag_implication_path(tag_implication), :remote => true, :method => :post %>
|
||||||
|
<% end %>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<% end %>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<%= render "tags/secondary_links" %>
|
||||||
|
|
||||||
|
<% content_for(:page_title) do %>
|
||||||
|
MetaSearch - Tags - <%= Danbooru.config.app_name %>
|
||||||
|
<% end %>
|
||||||
@@ -22,6 +22,6 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</select>
|
</select>
|
||||||
</form>
|
</form>
|
||||||
|
<input id="tag-script-field" placeholder="Enter tag script" style="display: none; margin-top: 0.5em;"></input>
|
||||||
</section>
|
</section>
|
||||||
<input id="tag-script-field" placeholder="Enter tag script" style="display: none;"></input>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tag_aliases_path %></li>
|
<li><%= link_to "Listing", tag_aliases_path %></li>
|
||||||
|
<li><%= link_to "MetaSearch", meta_searches_tags_path %></li>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<li><%= link_to "New", new_tag_alias_path %></li>
|
<li><%= link_to "New", new_tag_alias_path %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<div id="c-tag-aliases">
|
<div id="c-tag-aliases">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<%= form_tag(general_search_tag_aliases_path, :method => :get) do %>
|
<%= form_tag(tag_aliases_path, :method => :get) do %>
|
||||||
<%= text_field_tag "query", params[:query], :value => params[:search][:name_matches] %>
|
<%= text_field :search, :name_matches, :value => params[:search][:name_matches] %>
|
||||||
<%= submit_tag "Search Aliases" %>
|
<%= submit_tag "Search" %>
|
||||||
<%= submit_tag "Search Implications" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<% content_for(:secondary_links) do %>
|
<% content_for(:secondary_links) do %>
|
||||||
<menu>
|
<menu>
|
||||||
<li><%= link_to "Listing", tag_implications_path %></li>
|
<li><%= link_to "Listing", tag_implications_path %></li>
|
||||||
|
<li><%= link_to "MetaSearch", meta_searches_tags_path %></li>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<li><%= link_to "New", new_tag_implication_path %></li>
|
<li><%= link_to "New", new_tag_implication_path %></li>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
<div id="c-tag-implications">
|
<div id="c-tag-implications">
|
||||||
<div id="a-index">
|
<div id="a-index">
|
||||||
<div class="search">
|
<div class="search">
|
||||||
<%= form_tag(general_search_tag_aliases_path, :method => :get) do %>
|
<%= form_tag(tag_implications_path, :method => :get) do %>
|
||||||
<%= text_field_tag "query", params[:query], :value => params[:search][:name_matches] %>
|
<%= text_field :search, :name_matches, :value => params[:search][:name_matches] %>
|
||||||
<%= submit_tag "Search Implications" %>
|
<%= submit_tag "Search" %>
|
||||||
<%= submit_tag "Search Aliases" %>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
<menu>
|
<menu>
|
||||||
<li><%= render "tags/quick_search" %></li>
|
<li><%= render "tags/quick_search" %></li>
|
||||||
<li><%= link_to "Listing", tags_path %></li>
|
<li><%= link_to "Listing", tags_path %></li>
|
||||||
<li><%= link_to "Aliases", tag_aliases_path %></li>
|
<li><%= link_to "MetaSearch", meta_searches_tags_path %></li>
|
||||||
<li><%= link_to "Implications", tag_implications_path %></li>
|
|
||||||
<li><%= link_to "Cheatsheet", wiki_pages_path(:search => {:title => "help:cheatsheet"}) %></li>
|
<li><%= link_to "Cheatsheet", wiki_pages_path(:search => {:title => "help:cheatsheet"}) %></li>
|
||||||
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:tags"}) %></li>
|
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:tags"}) %></li>
|
||||||
<% if @tag %>
|
<% if @tag %>
|
||||||
|
|||||||
@@ -1,28 +1,24 @@
|
|||||||
<div class="box">
|
<% if presenter.has_uploads? %>
|
||||||
<h2><%= link_to "Uploads", posts_path(:tags => "user:#{user.name}") %></h2>
|
<div class="box">
|
||||||
<% if presenter.has_uploads? %>
|
<h2><%= link_to "Uploads", posts_path(:tags => "user:#{user.name}") %></h2>
|
||||||
<div>
|
<div>
|
||||||
<% presenter.uploads.each do |post| %>
|
<% presenter.uploads.each do |post| %>
|
||||||
<%= PostPresenter.preview(post, :tags => "user:#{user.name}") %>
|
<%= PostPresenter.preview(post, :tags => "user:#{user.name}") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
</div>
|
||||||
<p>None</p>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="box">
|
<% if presenter.has_favorites? %>
|
||||||
<h2><%= link_to "Favorites", favorites_path(:user_id => user.id) %></h2>
|
<div class="box">
|
||||||
<% if presenter.has_favorites? %>
|
<h2><%= link_to "Favorites", favorites_path(:user_id => user.id) %></h2>
|
||||||
<div>
|
<div>
|
||||||
<% presenter.favorites.each do |post| %>
|
<% presenter.favorites.each do |post| %>
|
||||||
<%= PostPresenter.preview(post, :tags => "fav:#{user.name}") %>
|
<%= PostPresenter.preview(post, :tags => "fav:#{user.name}") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
</div>
|
||||||
<p>None</p>
|
<% end %>
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<% presenter.subscriptions.each do |subscription| %>
|
<% presenter.subscriptions.each do |subscription| %>
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
|||||||
@@ -14,6 +14,10 @@ set :whenever_command, "bundle exec whenever"
|
|||||||
set :whenever_environment, defer {stage}
|
set :whenever_environment, defer {stage}
|
||||||
require 'whenever/capistrano'
|
require 'whenever/capistrano'
|
||||||
|
|
||||||
|
require 'securerandom'
|
||||||
|
set :secret_1, SecureRandom.base64(32)
|
||||||
|
set :secret_2, SecureRandom.base64(32)
|
||||||
|
|
||||||
set :application, "danbooru"
|
set :application, "danbooru"
|
||||||
set :repository, "git://github.com/r888888888/danbooru.git"
|
set :repository, "git://github.com/r888888888/danbooru.git"
|
||||||
set :scm, :git
|
set :scm, :git
|
||||||
@@ -30,6 +34,15 @@ namespace :local_config do
|
|||||||
run "mkdir -p #{deploy_to}/shared/config"
|
run "mkdir -p #{deploy_to}/shared/config"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
desc "Initialize the secrets"
|
||||||
|
task :setup_secrets do
|
||||||
|
run "mkdir -p ~/.danbooru"
|
||||||
|
run "if [[ ! -e ~/.danbooru/session_secret_key ]] ; then echo '#{secret_1}' > ~/.danbooru/session_secret_key ; fi"
|
||||||
|
run "if [[ ! -e ~/.danbooru/secret_token ]] ; then echo '#{secret_2}' > ~/.danbooru/secret_token ; fi"
|
||||||
|
run "chmod -R 600 ~/.danbooru"
|
||||||
|
run "chown -R #{user}:#{user} ~/.danbooru"
|
||||||
|
end
|
||||||
|
|
||||||
desc "Initialize local config files"
|
desc "Initialize local config files"
|
||||||
task :setup_local_files do
|
task :setup_local_files do
|
||||||
run "curl -s https://raw.github.com/r888888888/danbooru/master/script/install/danbooru_local_config.rb.templ > #{deploy_to}/shared/config/danbooru_local_config.rb"
|
run "curl -s https://raw.github.com/r888888888/danbooru/master/script/install/danbooru_local_config.rb.templ > #{deploy_to}/shared/config/danbooru_local_config.rb"
|
||||||
@@ -138,6 +151,7 @@ after "deploy:setup", "reset_ownership_of_common_directory"
|
|||||||
after "deploy:setup", "local_config:setup_shared_directory"
|
after "deploy:setup", "local_config:setup_shared_directory"
|
||||||
after "deploy:setup", "local_config:setup_local_files"
|
after "deploy:setup", "local_config:setup_local_files"
|
||||||
after "deploy:setup", "data:setup_directories"
|
after "deploy:setup", "data:setup_directories"
|
||||||
|
after "deploy:setup", "local_config:setup_secrets"
|
||||||
after "deploy:create_symlink", "local_config:link_local_files"
|
after "deploy:create_symlink", "local_config:link_local_files"
|
||||||
after "deploy:create_symlink", "data:link_directories"
|
after "deploy:create_symlink", "data:link_directories"
|
||||||
after "deploy:start", "delayed_job:start"
|
after "deploy:start", "delayed_job:start"
|
||||||
|
|||||||
@@ -202,9 +202,6 @@ Danbooru::Application.routes.draw do
|
|||||||
member do
|
member do
|
||||||
post :approve
|
post :approve
|
||||||
end
|
end
|
||||||
collection do
|
|
||||||
get :general_search
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
resource :tag_alias_request, :only => [:new, :create]
|
resource :tag_alias_request, :only => [:new, :create]
|
||||||
resources :tag_implications do
|
resources :tag_implications do
|
||||||
@@ -370,6 +367,7 @@ Danbooru::Application.routes.draw do
|
|||||||
match "/static/contact" => "static#contact", :as => "contact"
|
match "/static/contact" => "static#contact", :as => "contact"
|
||||||
match "/static/benchmark" => "static#benchmark"
|
match "/static/benchmark" => "static#benchmark"
|
||||||
match "/static/name_change" => "static#name_change", :as => "name_change"
|
match "/static/name_change" => "static#name_change", :as => "name_change"
|
||||||
|
match "/meta_searches/tags" => "meta_searches#tags", :as => "meta_searches_tags"
|
||||||
|
|
||||||
root :to => "posts#index"
|
root :to => "posts#index"
|
||||||
end
|
end
|
||||||
|
|||||||
36
test/unit/meta_searches/tag_test.rb
Normal file
36
test/unit/meta_searches/tag_test.rb
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
module MetaSearches
|
||||||
|
class TagTest < ActionMailer::TestCase
|
||||||
|
context "The tag metasearcg" do
|
||||||
|
setup do
|
||||||
|
CurrentUser.user = FactoryGirl.create(:user)
|
||||||
|
CurrentUser.ip_addr = "127.0.0.1"
|
||||||
|
FactoryGirl.create(:tag, :name => "xxx")
|
||||||
|
FactoryGirl.create(:tag_alias, :antecedent_name => "aaa", :consequent_name => "bbb")
|
||||||
|
FactoryGirl.create(:tag_implication, :antecedent_name => "ccc", :consequent_name => "ddd")
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find the tag" do
|
||||||
|
meta_search = Tag.new(:name => "xxx")
|
||||||
|
meta_search.load_all
|
||||||
|
assert_equal(1, meta_search.tags.size)
|
||||||
|
assert_equal("xxx", meta_search.tags.first.name)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find the alias" do
|
||||||
|
meta_search = Tag.new(:name => "aaa")
|
||||||
|
meta_search.load_all
|
||||||
|
assert_equal(1, meta_search.tag_aliases.size)
|
||||||
|
assert_equal("aaa", meta_search.tag_aliases.first.antecedent_name)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "find the implication" do
|
||||||
|
meta_search = Tag.new(:name => "ccc")
|
||||||
|
meta_search.load_all
|
||||||
|
assert_equal(1, meta_search.tag_implications.size)
|
||||||
|
assert_equal("ccc", meta_search.tag_implications.first.antecedent_name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -13,6 +13,32 @@ class UserTest < ActiveSupport::TestCase
|
|||||||
CurrentUser.user = nil
|
CurrentUser.user = nil
|
||||||
CurrentUser.ip_addr = nil
|
CurrentUser.ip_addr = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "promoting a user" do
|
||||||
|
setup do
|
||||||
|
CurrentUser.user = FactoryGirl.create(:moderator_user)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a transaction log item" do
|
||||||
|
assert_difference("TransactionLogItem.count") do
|
||||||
|
@user.promote_to!(User::Levels::GOLD)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a neutral feedback" do
|
||||||
|
assert_difference("UserFeedback.count") do
|
||||||
|
@user.promote_to!(User::Levels::GOLD)
|
||||||
|
end
|
||||||
|
|
||||||
|
assert_equal("Promoted by #{CurrentUser.user.name} from Member to Gold", @user.feedback.last.body)
|
||||||
|
end
|
||||||
|
|
||||||
|
should "create a dmail" do
|
||||||
|
assert_difference("Dmail.count", 2) do
|
||||||
|
@user.promote_to!(User::Levels::GOLD)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "favoriting a post" do
|
context "favoriting a post" do
|
||||||
setup do
|
setup do
|
||||||
|
|||||||
Reference in New Issue
Block a user