add new options for moving nav links

This commit is contained in:
albert
2013-03-07 18:31:20 -05:00
parent f8619e689e
commit d907dfedbb
13 changed files with 70 additions and 44 deletions

View File

@@ -127,25 +127,6 @@
}
Danbooru.Post.initialize_nav_help_link = function() {
$("#close-nav-help-link").click(function(e) {
Danbooru.Cookie.put("close-nav-help", "1");
$("#nav-help").hide();
e.preventDefault();
});
if (Danbooru.Cookie.get("close-nav-help") === "1") {
$("#nav-help").hide();
}
$("#close-search-seq-nav").click(function(e) {
Danbooru.Cookie.put("close-search-seq", "1");
$("#search-seq-nav").hide();
e.preventDefault();
});
if (Danbooru.Cookie.get("close-search-seq") === "1") {
$("#search-seq-nav").hide();
}
}
Danbooru.Post.initialize_titles = function() {

View File

@@ -231,9 +231,18 @@ div#c-posts {
margin: 0 1em;
}
#pool-nav, #search-seq-nav, #nav-help {
#nav-links {
margin: 1em 0;
padding: 1em 0.5em;
#keyboard-shortcuts-link {
margin-top: 1em;
font-size: 80%;
font-style: italic;
}
}
#pool-nav, #search-seq-nav, #nav-help {
li {
position: relative;
text-align: center;

View File

@@ -149,6 +149,18 @@ class AnonymousUser
0
end
def enable_post_navigation
true
end
def new_post_navigation_layout
true
end
def enable_privacy_mode
false
end
%w(member banned privileged builder platinum contributor janitor moderator admin).each do |name|
define_method("is_#{name}?") do
false

View File

@@ -17,7 +17,7 @@ class User < ActiveRecord::Base
end
attr_accessor :password, :old_password
attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :as => [:moderator, :janitor, :contributor, :privileged, :member, :anonymous, :default, :builder, :admin]
attr_accessible :level, :as => :admin
validates_length_of :name, :within => 2..100, :on => :create
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"

View File

@@ -85,6 +85,10 @@ class PostPresenter < Presenter
@tag_set_presenter.split_tag_list_html(template, options.merge(:show_extra_links => CurrentUser.user.is_privileged?))
end
def has_nav_links?(template)
template.params[:tags].present? || @post.pools.active.any?
end
def post_footer_for_pool_html(template)
if template.params[:pool_id]
pool = Pool.where(:id => template.params[:pool_id]).first

View File

@@ -0,0 +1,13 @@
<% if (position == "bottom" && CurrentUser.user.new_post_navigation_layout) || (position == "top" && !CurrentUser.user.new_post_navigation_layout) %>
<div id="nav-links" class="ui-corner-all nav-notice">
<% if params[:tags].present? && CurrentUser.user.enable_post_navigation && params[:tags] !~ /order:/ %>
<%= render "posts/partials/show/search_seq", :post => post %>
<% end %>
<% if post.pools.active.any? %>
<%= render "posts/partials/show/pools", :post => post %>
<% end %>
<p id="keyboard-shortcuts-link"><%= link_to "Keyboard shortcuts available", keyboard_shortcuts_path %></p>
</div>
<% end %>

View File

@@ -1,3 +1,3 @@
<div id="pool-nav" class="ui-corner-all nav-notice">
<div id="pool-nav">
<%= @post.presenter.pool_html(self) %>
</div>

View File

@@ -1,4 +1,4 @@
<div id="search-seq-nav" class="ui-corner-all nav-notice">
<div id="search-seq-nav">
<ul>
<li class="active">
<%= link_to "&laquo;prev".html_safe, show_seq_post_path(post, :tags => params[:tags], :seq => "prev"), :rel => "prev", :class => "prev" %>
@@ -6,6 +6,4 @@
<%= link_to "next&raquo;".html_safe, show_seq_post_path(post, :tags => params[:tags], :seq => "next"), :rel => "next", :class => "next" %>
</li>
</ul>
<span class="close-button ui-icon ui-icon-closethick" id="close-search-seq-nav"></span>
</div>

View File

@@ -30,6 +30,10 @@
</aside>
<section id="content">
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "top" %>
<% end %>
<%= render "posts/partials/show/notices", :post => @post %>
<%= render_advertisement("horizontal") %>
@@ -39,16 +43,8 @@
<%= @post.presenter.image_html(self) %>
</section>
<% if params[:tags] || @post.pools.active.any? %>
<%= render "posts/partials/show/nav_help" %>
<% end %>
<% if params[:tags] %>
<%= render "posts/partials/show/search_seq", :post => @post %>
<% end %>
<% if @post.pools.active.any? %>
<%= render "posts/partials/show/pools", :post => @post %>
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
<% end %>
<menu id="post-sections">

View File

@@ -17,6 +17,9 @@
<li><span class="key">n</span> New note</li>
<li><span class="key">e</span> Edit tags</li>
<li><span class="key">/</span> Search</li>
<li><span class="key">space</span> Scroll down/next post</li>
<li><span class="key">&larr;</span> Previous post</li>
<li><span class="key">&rarr;</span> Next post</li>
</ul>
</section>
</div>

View File

@@ -4,16 +4,14 @@
<%= simple_form_for @user do |f| %>
<fieldset>
<% if @user.feedback.negative.count == 0 %>
<%#= f.input :name, :as => :string %>
<% end %>
<%= f.input :email, :required => Danbooru.config.enable_email_verification?, :hint => "Used for messages and for password resets", :as => :email %>
<%= f.input :time_zone %>
<%= f.input :receive_email_notifications %>
<%= f.input :time_zone, :include_blank => false %>
<%= f.input :receive_email_notifications, :as => :select, :include_blank => false %>
<%= f.input :comment_threshold, :hint => "Comments below this score will be hidden by default" %>
<%= f.input :always_resize_images %>
<%= f.input :always_resize_images, :as => :select, :include_blank => false %>
<%= f.input :default_image_size, :hint => "Large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is", :collection => %w(large original), :include_blank => false %>
<%= f.input :enable_post_navigation, :as => :select, :include_blank => false, :hint => "When searching, do you want to navigate from post to post?" %>
<%= f.input :new_post_navigation_layout, :as => :select, :label => "Pool links", :include_blank => false, :collection => [["Bottom", "true"], ["Top", "false"]], :hint => "When browsing pools, where do you want the navigation links to be placed?" %>
<%= f.input :favorite_tags, :hint => "A list of whitespace delimited tags that show up in your profile", :input_html => {:size => "40x5"} %>
<%= f.input :blacklisted_tags, :hint => "A list of newline delimited tags that you never want to see", :input_html => {:size => "40x5"} %>
</fieldset>

View File

@@ -0,0 +1,7 @@
class AddSettingsToUsers < ActiveRecord::Migration
def change
add_column :users, :enable_post_navigation, :boolean, :null => false, :default => true
add_column :users, :new_post_navigation_layout, :boolean, :null => false, :default => true
add_column :users, :enable_privacy_mode, :boolean, :null => false, :default => false
end
end

View File

@@ -2597,7 +2597,10 @@ CREATE TABLE users (
favorite_tags text,
blacklisted_tags text,
time_zone character varying(255) DEFAULT 'Eastern Time (US & Canada)'::character varying NOT NULL,
bcrypt_password_hash text
bcrypt_password_hash text,
enable_post_navigation boolean DEFAULT true NOT NULL,
new_post_navigation_layout boolean DEFAULT true NOT NULL,
enable_privacy_mode boolean DEFAULT false NOT NULL
);
@@ -6227,3 +6230,5 @@ INSERT INTO schema_migrations (version) VALUES ('20130221214811');
INSERT INTO schema_migrations (version) VALUES ('20130302214500');
INSERT INTO schema_migrations (version) VALUES ('20130305005138');
INSERT INTO schema_migrations (version) VALUES ('20130307225324');