Merge branch 'master' of github.com:r888888888/danbooru

This commit is contained in:
r888888888
2013-05-13 10:45:42 -07:00
30 changed files with 168 additions and 70 deletions

View File

@@ -7,6 +7,9 @@
}
Danbooru.Dtext.call_preview = function(e, $button, $input, $preview) {
$button.val("Edit");
$input.hide();
$preview.text("Loading...").fadeIn("fast");
$.ajax({
type: "post",
url: "/dtext_preview",
@@ -14,8 +17,6 @@
body: $input.val()
},
success: function(data) {
$button.val("Edit");
$input.hide();
$preview.html(data).fadeIn("fast");
}
});

View File

@@ -66,8 +66,18 @@ Danbooru.Note = {
var $note_box_inner = $(e.currentTarget);
if (e.type === "mouseover") {
Danbooru.Note.Body.show($note_box_inner.data("id"));
if (Danbooru.Note.editing) {
var $this = $(this);
$this.resizable("enable");
$this.draggable("enable");
}
} else if (e.type === "mouseout") {
Danbooru.Note.Body.hide($note_box_inner.data("id"));
if (Danbooru.Note.editing) {
var $this = $(this);
$this.resizable("disable");
$this.draggable("disable");
}
}
e.stopPropagation();
@@ -162,10 +172,6 @@ Danbooru.Note = {
},
show: function(id) {
if (Danbooru.Note.editing) {
return;
}
Danbooru.Note.Body.hide_all();
Danbooru.Note.clear_timeouts();
var $note_body = Danbooru.Note.Body.find(id);
@@ -312,7 +318,7 @@ Danbooru.Note = {
$(".note-box").resizable("enable");
$(".note-box").draggable("enable");
});
// Danbooru.Note.editing = true;
Danbooru.Note.editing = true;
},
parameterize_note: function($note_box, $note_body) {
@@ -410,7 +416,7 @@ Danbooru.Note = {
var id = $this.data("id");
Danbooru.Note.Box.find(id).remove();
Danbooru.Note.Body.find(id).remove();
$(this).dialog("close");
$this.dialog("close");
if (id.match(/\d/)) {
$.ajax("/notes/" + id + ".js", {
@@ -480,7 +486,7 @@ Danbooru.Note = {
dragging: false,
dragStartX: 0,
dragStartY: 0,
dragDistanceY: 0,
dragDistanceX: 0,
dragDistanceY: 0,
x: 0,
y: 0,

View File

@@ -137,10 +137,12 @@
Danbooru.Post.initialize_post_relationship_previews = function() {
var current_post_id = $("meta[name=post-id]").attr("content");
$("#post_" + current_post_id).css("background-color", "rgba(0,0,0,0.05)");
$("#post_" + current_post_id).addClass("current-post");
this.toggle_relationship_preview($("#has-children-relationship-preview"), $("#has-children-relationship-preview-link"));
this.toggle_relationship_preview($("#has-parent-relationship-preview"), $("#has-parent-relationship-preview-link"));
if (Danbooru.Cookie.get("show-relationship-previews") === "0") {
this.toggle_relationship_preview($("#has-children-relationship-preview"), $("#has-children-relationship-preview-link"));
this.toggle_relationship_preview($("#has-parent-relationship-preview"), $("#has-parent-relationship-preview-link"));
}
$("#has-children-relationship-preview-link").click(function(e) {
Danbooru.Post.toggle_relationship_preview($("#has-children-relationship-preview"), $(this));
@@ -157,15 +159,21 @@
preview.toggle();
if (preview.is(":visible")) {
preview_link.html("« hide");
Danbooru.Cookie.put("show-relationship-previews", "1");
}
else {
preview_link.html("show »");
Danbooru.Cookie.put("show-relationship-previews", "0");
}
}
Danbooru.Post.initialize_favlist = function() {
$("#favlist").hide();
$("#hide-favlist-link").hide();
var fav_count = $("#show-favlist-link").prev().text();
if (fav_count === "0") {
$("#show-favlist-link").hide();
}
$("#show-favlist-link").click(function(e) {
$("#favlist").show();
@@ -217,10 +225,10 @@
if (border_colors.length > 1) {
$img.css("border", "2px solid");
if (border_colors.length === 3) {
$img.css("border-color", border_colors[0] + " " + border_colors[2] + " " + border_colors[2] + " " + border_colors[1]);
} else if (border_colors.length === 2) {
if (border_colors.length === 2) {
$img.css("border-color", border_colors[0] + " " + border_colors[1] + " " + border_colors[1] + " " + border_colors[0]);
} else if (border_colors.length === 3) {
$img.css("border-color", border_colors[0] + " " + border_colors[2] + " " + border_colors[2] + " " + border_colors[1]);
}
}
}

View File

@@ -160,8 +160,9 @@
query = query.replace(/_/g, " ");
var header = $("<em/>");
if (match = query.match(/^wiki:(.+)/)) {
header.html($("<a/>").attr("href", "/wiki_pages?title=" + match[1]).attr("target", "_blank").text(query));
var match = query.match(/^wiki:(.+)/);
if (match) {
header.html($("<a/>").attr("href", "/wiki_pages?title=" + encodeURIComponent(match[1])).attr("target", "_blank").text(query));
} else {
header.text(query);
}

View File

@@ -53,4 +53,8 @@ div#c-forum-topics {
span.locked-topic {
color: #666;
}
tr.forum-topic-row td:last-child {
white-space: nowrap;
}
}

View File

@@ -46,6 +46,23 @@ a.blacklisted-active {
border: 2px solid #F00;
}
.post-preview.current-post {
background-color: rgba(0,0,0,0.1);
}
#has-parent-relationship-preview, #has-children-relationship-preview {
overflow-x: auto;
white-space: nowrap;
article.post-preview {
float: none;
width: auto;
border: none;
margin: 0px;
padding: 5px 5px 10px;
}
}
.category-1 a, a.tag-type-1 {
color: #A00;
}
@@ -153,8 +170,8 @@ div#c-posts {
}
div.nav-notice {
padding: 0.5em 0.5em 0;
margin-bottom: 1em;
padding: 0.5em;
margin: 1em 0;
background: #EEE;
border: 1px solid #AAA;
position: relative;
@@ -247,11 +264,6 @@ div#c-posts {
word-wrap: break-word;
}
#nav-links {
margin: 1em 0;
padding: 0.5em;
}
#content.with-ads {
margin-right: 7em;
}
@@ -261,6 +273,10 @@ div#c-posts {
word-wrap: break-word;
}
#search-seq-nav + #pool-nav {
margin-top: 0.5em;
}
#pool-nav, #search-seq-nav, #nav-help {
li {
position: relative;

View File

@@ -27,4 +27,9 @@ div#c-wiki-pages {
margin-left: 15em;
padding-left: 1em;
}
div.redirected-from {
font-size: 0.8em;
margin-bottom: 1em;
}
}

View File

@@ -67,8 +67,15 @@ class WikiPagesController < ApplicationController
def show_or_new
@wiki_page = WikiPage.find_by_title(params[:title])
if @wiki_page
redirect_to wiki_page_path(@wiki_page)
tag_alias = TagAlias.where("status = 'active' and antecedent_name = ?", params[:title]).first
if tag_alias && params[:no_redirect].blank?
redirect_to show_or_new_wiki_pages_path(:title => tag_alias.consequent_name, :redirected_from => params[:title])
elsif @wiki_page
redirect_to wiki_page_path(@wiki_page, :redirected_from => params[:redirected_from])
else
@wiki_page = WikiPage.new(:title => params[:title])
respond_with(@wiki_page)
end
end

View File

@@ -15,7 +15,7 @@ module WikiPagesHelper
if consequent_aliases.any?
html << "<p class='hint'>The following tags are aliased to this tag: "
html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name))}.join(", "))
html << raw(consequent_aliases.map {|x| link_to(x.antecedent_name, show_or_new_wiki_pages_path(:title => x.antecedent_name, :no_redirect => true))}.join(", "))
html << ".</p>"
end
@@ -33,4 +33,17 @@ module WikiPagesHelper
html.html_safe
end
def wiki_page_post_previews(wiki_page)
html = '<div id="wiki-page-posts">'
if Post.fast_count(wiki_page.title) > 0
html << "<h2>Posts</h2>"
html << wiki_page.post_set.presenter.post_previews_html(self)
end
html << "</div>"
html.html_safe
end
end

View File

@@ -5,7 +5,7 @@ module Moderator
def initialize(min_date, max_level)
@min_date = min_date.present? ? min_date.to_date : 1.week.ago
@max_level = max_level.present? ? User::Levels::MEMBER : max_level.to_i
@max_level = max_level.present? ? max_level.to_i : User::Levels::MEMBER
end
def artists

View File

@@ -69,10 +69,6 @@ module PostSets
tag_string =~ /\*/
end
def is_empty_search?
posts.count == 0
end
def current_page
[page.to_i, 1].max
end

View File

@@ -2,7 +2,7 @@ module PostSets
class SearchError < Exception
end
class WikiPage < Post
class WikiPage < PostSets::Post
def presenter
@presenter ||= ::PostSetPresenters::WikiPage.new(self)
end

View File

@@ -47,6 +47,10 @@ class UserFeedback < ActiveRecord::Base
q = q.where("creator_id = (select _.id from users _ where lower(_.name) = ?)", params[:creator_name].mb_chars.downcase)
end
if params[:category].present?
q = q.where("category = ?", params[:category])
end
q
end
end

View File

@@ -13,6 +13,7 @@ module PostSetPresenters
posts.each do |post|
html << PostPresenter.preview(post, :tags => @post_set.tag_string)
html << "\n"
end
html.html_safe

View File

@@ -9,9 +9,7 @@ module PostSetPresenters
end
def related_tags
if post_set.is_empty_search?
suggested_tags
elsif post_set.is_pattern_search?
if post_set.is_pattern_search?
pattern_tags
elsif post_set.is_tag_subscription?
post_set.tag_subscription_tags
@@ -41,12 +39,6 @@ module PostSetPresenters
Tag.name_matches(post_set.tag_string).all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
end
def suggested_tags
if post_set.tag_string.length >= 3
Tag.name_matches("*#{post_set.tag_string}*").where("post_count > 0").all(:select => "name", :limit => Danbooru.config.tag_query_limit, :order => "post_count DESC").map(&:name)
end
end
def related_tags_for_group
RelatedTagCalculator.calculate_from_sample_to_array(post_set.tag_string).map(&:first)
end

View File

@@ -1,5 +1,5 @@
module PostSetPresenters
class WikiPage < Post
class WikiPage < PostSetPresenters::Post
def posts
@post_set.posts
rescue ActiveRecord::StatementInvalid, PGError

View File

@@ -4,6 +4,7 @@
<%= form_tag(comments_path, :class => "simple_form") do %>
<%= hidden_field "comment", "post_id", :value => post.id %>
<%= dtext_field "comment", "body", :input_id => "comment_response_for_#{post.id}", :preview_id => "dtext-preview-for-#{post.id}" %>
<%= submit_tag "Post" %>
<%= dtext_preview_button "comment", "body", :input_id => "comment_response_for_#{post.id}", :preview_id => "dtext-preview-for-#{post.id}" %>
<%= submit_tag "Post" %> <%= check_box "comment", "do_not_bump_post", :id => "comment_do_not_bump_post_#{post.id}" %> <label for="comment_do_not_bump_post_<%= post.id %>">No bump</label>
<%= check_box "comment", "do_not_bump_post", :id => "comment_do_not_bump_post_#{post.id}" %> <label for="comment_do_not_bump_post_<%= post.id %>">No bump</label>
<% end %>

View File

@@ -5,5 +5,11 @@
$("a#remove-from-favorites").show();
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
$("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>);
<% if CurrentUser.is_gold? %>
$("#favlist").html("<%= escape_javascript(post_favlist(@post)) %>");
if (!$("#favlist").is(":visible")) {
$("#show-favlist-link").show();
}
<% end %>
Danbooru.notice("You have favorited this post");
<% end %>

View File

@@ -2,4 +2,10 @@ $("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();
$("#score-for-post-<%= @post.id %>").html(<%= @post.score %>);
$("#favcount-for-post-<%= @post.id %>").html(<%= @post.fav_count %>);
<% if CurrentUser.is_gold? %>
$("#favlist").html("<%= escape_javascript(post_favlist(@post)) %>");
<% if @post.fav_count == 0 %>
$("#show-favlist-link, #hide-favlist-link, #favlist").hide();
<% end %>
<% end %>
Danbooru.notice("You have unfavorited this post");

View File

@@ -37,8 +37,11 @@
<li><%= link_to "Edit", edit_forum_post_path(forum_post.id) %></li>
<% end %>
<% end %>
<li><%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page, :anchor => "forum_post_#{forum_post.id}") %></li>
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
<% if params[:controller] == "forum_posts" %>
<li><%= link_to "Parent", forum_topic_path(forum_post.topic, :page => forum_post.forum_topic_page, :anchor => "forum_post_#{forum_post.id}") %></li>
<% else %>
<li><%= link_to "Permalink", forum_post_path(forum_post) %></li>
<% end %>
</menu>
</div>
<div class="clearfix"></div>

View File

@@ -17,10 +17,10 @@
<section id="content" class="<%= Danbooru.config.can_see_ads?(CurrentUser.user) ? "with-ads" : "without-ads" %>">
<menu id="post-sections">
<li class="active"><a href="#posts" id="show-posts-link">Posts</a></li>
<li class="active"><a href="#" id="show-posts-link">Posts</a></li>
<% if @post_set.has_wiki? %>
<li><a href="#wiki-except" id="show-wiki-excerpt-link">Wiki</a></li>
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-wiki-excerpt-link" %></li>
<% end %>
</menu>

View File

@@ -15,7 +15,7 @@
<li>Rating: <%= post.pretty_rating %></li>
<li>Score: <span id="score-for-post-<%= post.id %>"><%= post.score %></span> <% if CurrentUser.is_gold? %>(vote <%= link_to "up", post_votes_path(:post_id => post.id, :score => "up"), :remote => true, :method => :post %>/<%= link_to "down", post_votes_path(:post_id => post.id, :score => "down"), :remote => true, :method => :post %>)<% end %></li>
<li>Favorites: <span id="favcount-for-post-<%= post.id %>"><%= post.fav_count %></span>
<% if CurrentUser.is_gold? && post.fav_count > 0 %>
<% if CurrentUser.is_gold? %>
<%= link_to "&raquo;".html_safe, "#", :id => "show-favlist-link" %>
<%= link_to "&laquo;".html_safe, "#", :id => "hide-favlist-link" %>
<div id="favlist"><%= post_favlist(post) %></div>

View File

@@ -8,6 +8,7 @@
<li><%= link_to "Help", wiki_pages_path(:search => {:title => "help:tags"}) %></li>
<% if @tag %>
<li>|</li>
<li><%= link_to "Posts (#{Post.fast_count(@tag.name)})", posts_path(:tags => @tag.name) %></li>
<li><%= link_to "Edit", edit_tag_path(@tag) %></li>
<% if @tag.post_count < 1_000 %>
<li><%= link_to "Fix", new_tag_correction_path(:tag_id => @tag.id) %></li>

View File

@@ -3,9 +3,18 @@
<h1>Search User Feedbacks</h1>
<%= form_tag(user_feedbacks_path, :method => :get, :class => "simple_form") do %>
<%= search_field "user_name", :label => "User" %>
<%= search_field "creator_name", :label => "Creator" %>
<%= submit_tag "Search" %>
<div class="input">
<%= search_field "user_name", :label => "User" %>
<%= search_field "creator_name", :label => "Creator" %>
<label for="search_category">Category</label>
<%= select "search", "category", %w(positive negative neutral), :include_blank => true %>
</div>
<div class="input">
<%= submit_tag "Search" %>
</div>
<% end %>
</div>
</div>

View File

@@ -11,3 +11,7 @@
</div>
<%= render "wiki_pages/secondary_links" %>
<% content_for(:page_title) do %>
Wiki Page Versions Comparison - <%= @thispage.pretty_title %> - <%= Danbooru.config.app_name %>
<% end %>

View File

@@ -15,12 +15,7 @@
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
<div id="wiki-page-posts">
<% if Post.fast_count(@wiki_page.title) > 0 %>
<h2>Posts</h2>
<% end %>
<%= @wiki_page.post_set.presenter.post_previews_html(self) %>
</div>
<%= wiki_page_post_previews(@wiki_page) %>
<div class="clearfix"></div>

View File

@@ -12,18 +12,17 @@
<% end %>
</h1>
<% if params[:redirected_from].present? %>
<div class="hint redirected-from">Redirected from <%= link_to params[:redirected_from], show_or_new_wiki_pages_path(:title => params[:redirected_from], :no_redirect => true) %>.</div>
<% end %>
<div id="wiki-page-body" class="prose">
<%= format_text(@wiki_page.body) %>
<%= wiki_page_alias_and_implication_list(@wiki_page) %>
</div>
<div id="wiki-page-posts">
<% if Post.fast_count(@wiki_page.title) > 0 %>
<h2>Posts</h2>
<% end %>
<%= @wiki_page.post_set.presenter.post_previews_html(self) %>
</div>
<%= wiki_page_post_previews(@wiki_page) %>
</section>
</div>
</div>

View File

@@ -4,15 +4,25 @@
<section id="content">
<h1 id="wiki-page-title"><%= params[:title] %></h1>
<div id="wiki-page-body" class="prose">
<p>This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.</p>
<% if params[:redirected_from].present? %>
<div class="hint redirected-from">Redirected from <%= link_to params[:redirected_from], show_or_new_wiki_pages_path(:title => params[:redirected_from], :no_redirect => true) %>.</div>
<% end %>
<div class="ui-corner-all ui-state-highlight notice">
This wiki page does not yet exist. <%= link_to "Create a new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.
</div>
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
<%= wiki_page_post_previews(@wiki_page) %>
</section>
</div>
</div>
<%= render "secondary_links" %>
<% content_for(:page_title) do %>
Wiki - <%= params[:title] %> - <%= Danbooru.config.app_name %>
<% end %>
<%= render "secondary_links" %>

View File

@@ -1,5 +1,6 @@
set :stages, %w(production staging)
set :default_stage, "staging"
set :unicorn_env, "staging"
require 'capistrano/ext/multistage'
require 'bundler/capistrano'

View File

@@ -239,7 +239,13 @@ Danbooru::Application.routes.draw do
match "/comment/index" => redirect {|params, req| "/comments?page=#{req.params[:page]}"}
match "/comment/show/:id" => redirect("/comments/%{id}")
match "/comment/new" => redirect("/comments")
match "/comment/search" => redirect("/comments/search")
match("/comment/search" => redirect do |params, req|
if req.params[:query] =~ /^user:(.+)/i
"/comments?group_by=comment&search[creator_name]=#{CGI::escape($1)}"
else
"/comments/search"
end
end)
match "/favorite" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
match "/favorite/index" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
@@ -283,7 +289,10 @@ Danbooru::Application.routes.draw do
match "/post/view/:id" => redirect("/posts/%{id}")
match "/post/flag/:id" => redirect("/posts/%{id}")
match "/post_tag_history" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
match("/post_tag_history" => redirect do |params, req|
page = req.params[:before_id].present? ? "b#{req.params[:before_id]}" : req.params[:page]
"/post_versions?page=#{page}&search[updater_id]=#{req.params[:user_id]}"
end)
match "/post_tag_history/index" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
match "/tag/index.xml", :controller => "legacy", :action => "tags", :format => "xml"