Merge branch 'master' of github.com:r888888888/danbooru
This commit is contained in:
@@ -360,7 +360,11 @@ Danbooru.Note = {
|
||||
var $note_box = Danbooru.Note.Box.find(id);
|
||||
var text = $textarea.val();
|
||||
$note_body.data("original-body", text);
|
||||
Danbooru.Note.Body.set_text($note_body, text);
|
||||
Danbooru.Note.Body.set_text($note_body, "Loading...");
|
||||
$.get("/note_previews.json", {body: text}).success(function(data) {
|
||||
Danbooru.Note.Body.set_text($note_body, data.body);
|
||||
$note_body.show();
|
||||
});
|
||||
$this.dialog("close");
|
||||
|
||||
if (id.match(/\d/)) {
|
||||
@@ -386,8 +390,11 @@ Danbooru.Note = {
|
||||
var id = $this.data("id");
|
||||
var $note_body = Danbooru.Note.Body.find(id);
|
||||
var text = $textarea.val();
|
||||
Danbooru.Note.Body.set_text($note_body, text);
|
||||
$note_body.show();
|
||||
Danbooru.Note.Body.set_text($note_body, "Loading...");
|
||||
$.get("/note_previews.json", {body: text}).success(function(data) {
|
||||
Danbooru.Note.Body.set_text($note_body, data.body);
|
||||
$note_body.show();
|
||||
});
|
||||
},
|
||||
|
||||
cancel: function() {
|
||||
|
||||
@@ -14,6 +14,7 @@ class DmailsController < ApplicationController
|
||||
end
|
||||
|
||||
def index
|
||||
cookies[:dmail_folder] = params[:folder]
|
||||
@search = Dmail.visible.search(params[:search])
|
||||
@dmails = @search.order("dmails.created_at desc").paginate(params[:page])
|
||||
respond_with(@dmails) do |format|
|
||||
|
||||
12
app/controllers/note_previews_controller.rb
Normal file
12
app/controllers/note_previews_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class NotePreviewsController < ApplicationController
|
||||
respond_to :json
|
||||
|
||||
def show
|
||||
@body = DText.sanitize(params[:body].to_s)
|
||||
respond_with(@body) do |format|
|
||||
format.json do
|
||||
render :json => {:body => @body}.to_json
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,2 +1,12 @@
|
||||
module DmailsHelper
|
||||
def dmails_current_folder_path
|
||||
case cookies[:dmail_folder]
|
||||
when "sent"
|
||||
dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent")
|
||||
when "all"
|
||||
dmails_path(:search => {:owner_id => CurrentUser.id}, :folder => "all")
|
||||
else
|
||||
dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,6 +69,10 @@ module PostSets
|
||||
tag_string =~ /\*/
|
||||
end
|
||||
|
||||
def is_empty_search?
|
||||
posts.count == 0
|
||||
end
|
||||
|
||||
def current_page
|
||||
[page.to_i, 1].max
|
||||
end
|
||||
|
||||
@@ -9,7 +9,9 @@ module PostSetPresenters
|
||||
end
|
||||
|
||||
def related_tags
|
||||
if post_set.is_pattern_search?
|
||||
if post_set.is_empty_search?
|
||||
suggested_tags
|
||||
elsif post_set.is_pattern_search?
|
||||
pattern_tags
|
||||
elsif post_set.is_tag_subscription?
|
||||
post_set.tag_subscription_tags
|
||||
@@ -39,6 +41,12 @@ 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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<li><%= link_to "Recent changes", artist_versions_path %></li>
|
||||
<% if @artist && !@artist.new_record? %>
|
||||
<li>|</li>
|
||||
<li><%= link_to "Posts", posts_path(:tags => @artist.name) %></li>
|
||||
<li><%= link_to "Posts (#{Post.fast_count(@artist.name)})", posts_path(:tags => @artist.name) %></li>
|
||||
<li><%= link_to "Show", artist_path(@artist) %></li>
|
||||
<% if CurrentUser.is_member? %>
|
||||
<li><%= link_to "Edit", edit_artist_path(@artist) %></li>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<% content_for(:secondary_links) do %>
|
||||
<menu>
|
||||
<li><%= link_to "All", dmails_path %></li>
|
||||
<li><%= link_to "All", dmails_path(:search => {:owner_id => CurrentUser.id}, :folder => "all") %></li>
|
||||
<li><%= link_to "Received", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></li>
|
||||
<li><%= link_to "Sent", dmails_path(:search => {:owner_id => CurrentUser.id, :from_id => CurrentUser.id}, :folder => "sent") %></li>
|
||||
<li><%= link_to "New", new_dmail_path %></li>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<li><%= link_to "Edit subscriptions", tag_subscriptions_path %></li>
|
||||
<% end %>
|
||||
<li><%= link_to "Profile", user_path(CurrentUser.user) %></li>
|
||||
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_path(:search => {:owner_id => CurrentUser.id, :to_id => CurrentUser.id}, :folder => "received") %></li>
|
||||
<li><%= link_to "Messages #{CurrentUser.dmail_count}", dmails_current_folder_path %></li>
|
||||
<% else %>
|
||||
<li><%= link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %></li>
|
||||
<% end %>
|
||||
|
||||
@@ -120,6 +120,7 @@ Danbooru::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
resources :note_versions, :only => [:index]
|
||||
resource :note_previews, :only => [:show]
|
||||
resources :pools do
|
||||
member do
|
||||
put :revert
|
||||
|
||||
Reference in New Issue
Block a user