Merge branch 'master' of github.com:r888888888/danbooru
This commit is contained in:
@@ -76,25 +76,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Post.nav_scroll_down = function() {
|
|
||||||
var scroll_top = $(window).scrollTop() + ($(window).height() * 0.85);
|
|
||||||
Danbooru.scroll_to(scroll_top);
|
|
||||||
}
|
|
||||||
|
|
||||||
Danbooru.Post.nav_scroll_up = function() {
|
|
||||||
var scroll_top = $(window).scrollTop() - ($(window).height() * 0.85);
|
|
||||||
if (scroll_top < 0) {
|
|
||||||
scroll_top = 0;
|
|
||||||
}
|
|
||||||
Danbooru.scroll_to(scroll_top);
|
|
||||||
}
|
|
||||||
|
|
||||||
Danbooru.Post.initialize_shortcuts = function() {
|
Danbooru.Post.initialize_shortcuts = function() {
|
||||||
$(document).bind("keydown.q", function(e) {
|
|
||||||
$("#tags").trigger("focus").selectEnd();
|
|
||||||
e.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($("#a-show").length) {
|
if ($("#a-show").length) {
|
||||||
$(document).bind("keydown.e", function(e) {
|
$(document).bind("keydown.e", function(e) {
|
||||||
$("#post-edit-link").trigger("click");
|
$("#post-edit-link").trigger("click");
|
||||||
@@ -113,18 +95,10 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$(document).bind("keydown.f", function(e) {
|
$(document).bind("keydown.f", function(e) {
|
||||||
$("#add-to-favorites").filter(":visible").trigger("click");
|
$("#add-to-favorites:visible").trigger("click");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).bind("keydown.s", function(e) {
|
|
||||||
Danbooru.Post.nav_scroll_down();
|
|
||||||
})
|
|
||||||
|
|
||||||
$(document).bind("keydown.w", function(e) {
|
|
||||||
Danbooru.Post.nav_scroll_up();
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Post.initialize_links = function() {
|
Danbooru.Post.initialize_links = function() {
|
||||||
|
|||||||
36
app/assets/javascripts/shortcuts.js
Normal file
36
app/assets/javascripts/shortcuts.js
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
(function() {
|
||||||
|
Danbooru.Shortcuts = {};
|
||||||
|
|
||||||
|
Danbooru.Shortcuts.initialize = function() {
|
||||||
|
$(document).bind("keydown.s", function(e) {
|
||||||
|
Danbooru.Shortcuts.nav_scroll_down();
|
||||||
|
})
|
||||||
|
|
||||||
|
$(document).bind("keydown.w", function(e) {
|
||||||
|
Danbooru.Shortcuts.nav_scroll_up();
|
||||||
|
})
|
||||||
|
|
||||||
|
$(document).bind("keydown.q", function(e) {
|
||||||
|
$("#tags, #search_name, #search_name_matches, #query").trigger("focus").selectEnd();
|
||||||
|
e.preventDefault();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Danbooru.Shortcuts.nav_scroll_down = function() {
|
||||||
|
var scroll_top = $(window).scrollTop() + ($(window).height() * 0.85);
|
||||||
|
Danbooru.scroll_to(scroll_top);
|
||||||
|
}
|
||||||
|
|
||||||
|
Danbooru.Shortcuts.nav_scroll_up = function() {
|
||||||
|
var scroll_top = $(window).scrollTop() - ($(window).height() * 0.85);
|
||||||
|
if (scroll_top < 0) {
|
||||||
|
scroll_top = 0;
|
||||||
|
}
|
||||||
|
Danbooru.scroll_to(scroll_top);
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
|
||||||
|
|
||||||
|
$(document).ready(function() {
|
||||||
|
Danbooru.Shortcuts.initialize();
|
||||||
|
});
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
class ArtistsController < ApplicationController
|
class ArtistsController < ApplicationController
|
||||||
respond_to :html, :xml, :json
|
respond_to :html, :xml, :json
|
||||||
before_filter :member_only, :except => [:index, :show, :banned]
|
before_filter :member_only, :except => [:index, :show, :banned]
|
||||||
|
before_filter :builder_only, :only => [:edit_name, :update_name, :destroy]
|
||||||
before_filter :admin_only, :only => [:ban]
|
before_filter :admin_only, :only => [:ban]
|
||||||
before_filter :builder_only, :only => [:edit_name, :update_name]
|
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@artist = Artist.new_with_defaults(params)
|
@artist = Artist.new_with_defaults(params)
|
||||||
@@ -82,6 +82,24 @@ class ArtistsController < ApplicationController
|
|||||||
respond_with(@artist)
|
respond_with(@artist)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
@artist = Artist.find(params[:id])
|
||||||
|
if !@artist.deletable_by?(CurrentUser.user)
|
||||||
|
raise User::PrivilegeError
|
||||||
|
end
|
||||||
|
@artist.update_attribute(:is_active, false)
|
||||||
|
redirect_to(artist_path(@artist), :notice => "Artist deleted")
|
||||||
|
end
|
||||||
|
|
||||||
|
def undelete
|
||||||
|
@artist = Artist.find(params[:id])
|
||||||
|
if !@artist.deletable_by?(CurrentUser.user)
|
||||||
|
raise User::PrivilegeError
|
||||||
|
end
|
||||||
|
@artist.update_attribute(:is_active, true)
|
||||||
|
redirect_to(artist_path(@artist), :notice => "Artist undeleted")
|
||||||
|
end
|
||||||
|
|
||||||
def revert
|
def revert
|
||||||
@artist = Artist.find(params[:id])
|
@artist = Artist.find(params[:id])
|
||||||
@version = ArtistVersion.find(params[:version_id])
|
@version = ArtistVersion.find(params[:version_id])
|
||||||
|
|||||||
@@ -270,8 +270,12 @@ class PostQueryBuilder
|
|||||||
|
|
||||||
relation = add_tag_string_search_relation(q[:tags], relation)
|
relation = add_tag_string_search_relation(q[:tags], relation)
|
||||||
|
|
||||||
if q[:order] == "rank" || q[:order] == "rank2"
|
if q[:order] == "rank"
|
||||||
relation = relation.where("posts.score > 0 and posts.created_at >= ?", 2.days.ago)
|
relation = relation.where("posts.score > 0 and posts.created_at >= ?", 2.days.ago)
|
||||||
|
elsif q[:order] == "rank2"
|
||||||
|
relation = relation.where("posts.fav_count > 0 and posts.created_at >= ?", 2.days.ago)
|
||||||
|
elsif q[:order] == "landscape" || q[:order] == "portrait"
|
||||||
|
relation = relation.where("posts.image_width IS NOT NULL and posts.image_height IS NOT NULL")
|
||||||
end
|
end
|
||||||
|
|
||||||
case q[:order]
|
case q[:order]
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class Artist < ActiveRecord::Base
|
|||||||
if new_wiki_page
|
if new_wiki_page
|
||||||
# Merge the old wiki page into the new one
|
# Merge the old wiki page into the new one
|
||||||
new_wiki_page.update_attributes(:body => new_wiki_page.body + "\n\n" + notes)
|
new_wiki_page.update_attributes(:body => new_wiki_page.body + "\n\n" + notes)
|
||||||
else
|
elsif wiki_page
|
||||||
wiki_page.update_attribute(:title, new_name)
|
wiki_page.update_attribute(:title, new_name)
|
||||||
end
|
end
|
||||||
reload
|
reload
|
||||||
@@ -317,8 +317,10 @@ class Artist < ActiveRecord::Base
|
|||||||
extend SearchMethods
|
extend SearchMethods
|
||||||
|
|
||||||
def status
|
def status
|
||||||
if is_banned?
|
if is_banned? && is_active?
|
||||||
"Banned"
|
"Banned"
|
||||||
|
elsif is_banned?
|
||||||
|
"Banned Deleted"
|
||||||
elsif is_active?
|
elsif is_active?
|
||||||
"Active"
|
"Active"
|
||||||
else
|
else
|
||||||
@@ -341,4 +343,8 @@ class Artist < ActiveRecord::Base
|
|||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def deletable_by?(user)
|
||||||
|
user.is_builder?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -182,6 +182,11 @@ class Upload < ActiveRecord::Base
|
|||||||
def add_dimension_tags!
|
def add_dimension_tags!
|
||||||
return if !Danbooru.config.enable_dimension_autotagging
|
return if !Danbooru.config.enable_dimension_autotagging
|
||||||
|
|
||||||
|
%w(incredibly_absurdres absurdres highres lowres).each do |tag|
|
||||||
|
escaped_tag = Regexp.escape(tag)
|
||||||
|
self.tag_string = tag_string.gsub(/(?:\A| )#{escaped_tag}(?:\Z| )/, " ").strip
|
||||||
|
end
|
||||||
|
|
||||||
if image_width >= 10_000 || image_height >= 10_000
|
if image_width >= 10_000 || image_height >= 10_000
|
||||||
self.tag_string = "#{tag_string} incredibly_absurdres".strip
|
self.tag_string = "#{tag_string} incredibly_absurdres".strip
|
||||||
elsif image_width >= 3200 || image_height >= 2400
|
elsif image_width >= 3200 || image_height >= 2400
|
||||||
|
|||||||
@@ -12,9 +12,6 @@
|
|||||||
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
<%= f.input :other_names_comma, :hint => "Separate with commas", :as => :text, :label => "Other names" %>
|
||||||
<%= f.input :group_name %>
|
<%= f.input :group_name %>
|
||||||
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
<%= f.input :url_string, :label => "URLs", :as => :text, :input_html => {:size => "50x5"} %>
|
||||||
<% if CurrentUser.is_builder? %>
|
|
||||||
<%= f.input :is_active %>
|
|
||||||
<% end %>
|
|
||||||
|
|
||||||
<%= dtext_field "artist", "notes" %>
|
<%= dtext_field "artist", "notes" %>
|
||||||
<%= f.button :submit, "Submit" %>
|
<%= f.button :submit, "Submit" %>
|
||||||
|
|||||||
@@ -16,8 +16,15 @@
|
|||||||
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
<li><%= link_to "Edit name", edit_name_artist_path(@artist) %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
<li><%= link_to "History", artist_versions_path(:search => {:artist_id => @artist.id}) %></li>
|
||||||
|
<% if @artist.deletable_by?(CurrentUser.user) %>
|
||||||
|
<% if @artist.is_active? %>
|
||||||
|
<li><%= link_to "Delete", artist_path(@artist), :method => :delete, :confirm => "Are you sure you want to delete this artist?" %></li>
|
||||||
|
<% else %>
|
||||||
|
<li><%= link_to "Undelete", undelete_artist_path(@artist), :method => :post, :confirm => "Are you sure you want to undelete this artist?" %></li>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
<% if CurrentUser.is_admin? %>
|
<% if CurrentUser.is_admin? %>
|
||||||
<%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %>
|
<li><%= link_to "Ban", ban_artist_path(@artist), :method => :put, :confirm => "Are you sure you want to ban this artist?" %></li>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<li><span class="key">a</span> Previous page</li>
|
<li><span class="key">a</span> Previous page</li>
|
||||||
<li><span class="key">d</span> Next page</li>
|
<li><span class="key">d</span> Next page</li>
|
||||||
<li><span class="key">q</span> Search</li>
|
<li><span class="key">q</span> Search</li>
|
||||||
|
<li><span class="key">w</span> Scroll up</li>
|
||||||
|
<li><span class="key">s</span> Scroll down</li>
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,8 @@
|
|||||||
<div class="prose">
|
<div class="prose">
|
||||||
<%= format_text(post_set.wiki_page.presenter.excerpt) %>
|
<%= format_text(post_set.wiki_page.presenter.excerpt) %>
|
||||||
|
|
||||||
|
<%= wiki_page_alias_and_implication_list(post_set.wiki_page) %>
|
||||||
|
|
||||||
<p>Read the <%= link_to "full article", wiki_page_path(post_set.wiki_page.id) %>.</p>
|
<p>Read the <%= link_to "full article", wiki_page_path(post_set.wiki_page.id) %>.</p>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<%= error_messages_for("wiki_page") %>
|
<%= error_messages_for("wiki_page") %>
|
||||||
|
|
||||||
<%= simple_form_for(@wiki_page) do |f| %>
|
<%= simple_form_for(@wiki_page) do |f| %>
|
||||||
<% if !@wiki_page.new_record? && CurrentUser.user.is_builder? %>
|
<% if @wiki_page.new_record? || CurrentUser.user.is_builder? %>
|
||||||
<%= f.input :title, :as => :string %>
|
<%= f.input :title, :as => :string %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ Danbooru::Application.routes.draw do
|
|||||||
put :ban
|
put :ban
|
||||||
get :edit_name
|
get :edit_name
|
||||||
put :update_name
|
put :update_name
|
||||||
|
post :undelete
|
||||||
end
|
end
|
||||||
collection do
|
collection do
|
||||||
get :show_or_new
|
get :show_or_new
|
||||||
|
|||||||
Reference in New Issue
Block a user