Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/otwcode/otwarchive into i…
Browse files Browse the repository at this point in the history
…ssue_4099
  • Loading branch information
zz9pzza committed May 3, 2015
2 parents 066f36d + 30d7f56 commit ccfd466
Show file tree
Hide file tree
Showing 21 changed files with 279 additions and 159 deletions.
6 changes: 6 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ def hide_banner
def set_current_user
User.current_user = logged_in_as_admin? ? current_admin : current_user
@current_user = current_user
unless current_user.nil?
@current_user_subscriptions_count, @current_user_visible_work_count, @current_user_bookmarks_count, @current_user_owned_collections_count, @current_user_challenge_signups_count, @current_user_offer_assignments, @current_user_unposted_works_size=
Rails.cache.fetch("user_menu_counts_#{current_user.id}",
expires_in: 2.hours,
race_condition_ttl: 5) { "#{current_user.subscriptions.count}, #{current_user.visible_work_count}, #{current_user.bookmarks.count}, #{current_user.owned_collections.count}, #{current_user.challenge_signups.count}, #{current_user.offer_assignments.undefaulted.count + current_user.pinch_hit_assignments.undefaulted.count}, #{current_user.unposted_works.size}" }.split(",").map(&:to_i)
end
end

def load_collection
Expand Down
16 changes: 9 additions & 7 deletions app/views/bookmarks/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%= form_for @search,
url: (@collection ? collection_bookmarks_path(@collection) : bookmarks_path),
html: {
:method => :get,
:class => 'filters',
:id => 'work_filters'
method: :get,
class: 'narrow-hidden filters',
id: 'bookmark-filters'
} do |f| %>
<h3 class="landmark heading"><%= ts("Filters") %></h3>
<%= field_set_tag ts('Filter results:') do %>
Expand Down Expand Up @@ -83,8 +83,10 @@
<%= hidden_field_tag("user_id", @user.login) if @user %>
</div>
<% end %>
<% end %>

<%= content_for :footer_js do %>
<script src="/javascripts/filters.js" type="text/javascript"></script>
<% # On narrow screens, link jumps to top of index when JavaScript is disabled and closes filters when JavaScript is enabled %>
<p class="narrow-shown hidden">
<a href="#main" id="leave_filters" class="close">
<%= ts("Top of Bookmark Index") %>
</a>
</p>
<% end %>
6 changes: 5 additions & 1 deletion app/views/bookmarks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<!-- /descriptions-->

<!--subnav-->
<% if current_user.is_a?(User) || @tag %>
<% if current_user.is_a?(User) || @tag || @facets.present? %>
<ul class="navigation actions" role="navigation">
<% if logged_in? && (@user == current_user || (@owner.blank? && @bookmarkable.blank?) || @collection) %>
<li><%= link_to ts("Bookmark External Work"), new_external_work_path %></li>
Expand All @@ -26,6 +26,10 @@
<li><%= span_if_current ts('Works'), tag_works_path(@tag) %></li>
<li><%= span_if_current ts('Bookmarks'), tag_bookmarks_path(@tag) %></li>
<% end %>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#bookmark-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
</ul>
<% end %>
<!--/subnav-->
Expand Down
8 changes: 7 additions & 1 deletion app/views/collections/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%= form_tag collections_url, :method => :get, :class => 'filters' do %>
<%= form_tag collections_url, method: :get, class: 'narrow-hidden filters', id: 'collection-filters' do %>
<h3 class="landmark heading"><%= ts("Filters") %></h3>
<%= field_set_tag ts('Filter collections:') do %>
<dl class="filters" role="menu">
Expand Down Expand Up @@ -88,4 +88,10 @@
<dd class="submit actions"><%= submit_tag ts("Sort and Filter") %></dd>
</dl>
<% end %>
<% # On narrow screens, link jumps to top of index when JavaScript is disabled and closes filters when JavaScript is enabled %>
<p class="narrow-shown hidden">
<a href="#main" id="leave_filters" class="close">
<%= ts("Top of Collection Index") %>
</a>
</p>
<% end %>
6 changes: 5 additions & 1 deletion app/views/collections/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
<li><%= link_to ts("New Collection"), new_collection_path %></li>
<% end %>
<% end %>
<% if @sort_and_filter %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#collection-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
</ul>
<% unless @collections.blank? %>
Expand All @@ -58,7 +62,7 @@
<% if @sort_and_filter %>
<!--filters subnav-->
<%= render :partial => 'collections/filters' %>
<%= render 'collections/filters' %>
<!---/subnav-->
<% end %>
Expand Down
12 changes: 11 additions & 1 deletion app/views/inbox/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<!--/descriptions-->

<!--subnav-->
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<p class="narrow-shown hidden actions">
<a href="#inbox-filters" id="go_to_filters"><%= ts("Filters") %></a>
</p>
<!--/subnav-->
<!--main content-->
Expand Down Expand Up @@ -83,7 +87,7 @@
<!--/content-->
<!--subnav-->
<%= form_tag(user_inbox_path(@user), method: :get, class: 'filters', id: 'inbox-filters') do %>
<%= form_tag(user_inbox_path(@user), method: :get, class: 'narrow-hidden filters', id: 'inbox-filters') do %>
<h3 class="landmark heading"><%= ts("Filter") %></h3>
<%= field_set_tag do %>
<dl class="filters" role="menu">
Expand Down Expand Up @@ -140,6 +144,12 @@
<dd class="submit actions"><%= submit_tag ts("Filter") %></dd>
</dl>
<% end %>
<% # On narrow screens, link jumps to top of index when JavaScript is disabled and closes filters when JavaScript is enabled %>
<p class="narrow-shown hidden">
<a href="#main" id="leave_filters" class="close">
<%= ts("Top of Inbox") %>
</a>
</p>
<% end %>
<!--/subnav-->
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/_javascripts.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</script>

<script type="text/javascript">$j = jQuery.noConflict();</script>
<%= javascript_include_tag "jquery.scrollTo.min", "jquery.livequery.min", "rails", "application", "bootstrap/bootstrap-dropdown.min", "jquery-shuffle", "jquery.tokeninput.min", "jquery.trap.min", "ao3modal.min", "jquery.cookie" %>
<%= javascript_include_tag "jquery.scrollTo.min", "jquery.livequery.min", "rails", "application", "bootstrap/bootstrap-dropdown.min", "jquery-shuffle", "jquery.tokeninput.min", "jquery.trap.min", "ao3modal.min", "jquery.cookie", "filters.min" %>

<% if allow_tinymce?(controller) %>
<%= yield :tinymce_init %>
Expand Down
24 changes: 12 additions & 12 deletions app/views/user_sessions/_greeting.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
<%= link_to ts("Hi, %{current_user}!", :current_user => current_user.login, key: 'header'), user_path(current_user) %>
<ul class="menu" role="menu">
<li><%= span_if_current ts('My Dashboard', key: 'header'), user_path(current_user) %></li>
<% if @current_user.subscriptions.count > 0 %>
<% if @current_user_subscriptions_count > 0 %>
<li><%= span_if_current ts('My Subscriptions', key: 'header'), user_subscriptions_path(current_user) %></li>
<% end %>
<% if @current_user.visible_work_count > 0 %>
<li><%= span_if_current ts("My Works (%{works_number})", key: 'header', :works_number => @current_user.visible_work_count), user_works_path(@current_user) %></li>
<% if @current_user_visible_work_count > 0 %>
<li><%= span_if_current ts("My Works", key: 'header'), user_works_path(@current_user) %></li>
<% end %>
<% if @current_user.bookmarks.count > 0 %>
<li><%= span_if_current ts("My Bookmarks (%{bookmark_number})", key: 'header', :bookmark_number => @current_user.bookmarks.count), user_bookmarks_path(current_user) %></li>
<% if @current_user_bookmarks_count > 0 %>
<li><%= span_if_current ts("My Bookmarks", key: 'header'), user_bookmarks_path(current_user) %></li>
<% end %>
<% if @current_user.owned_collections.count > 0 %>
<li><%= span_if_current ts("My Collections (%{coll_number})", key: 'header', :coll_number => @current_user.owned_collections.count), user_collections_path(current_user) %></li>
<% if @current_user_owned_collections_count > 0 %>
<li><%= span_if_current ts("My Collections", key: 'header'), user_collections_path(current_user) %></li>
<% end %>
<% if @current_user.challenge_signups.count > 0 %>
<li><%= span_if_current ts("My Sign-ups (%{signup_number})", key: 'header', :signup_number => @current_user.challenge_signups.count), user_signups_path(current_user) %></li>
<% if @current_user_challenge_signups_count > 0 %>
<li><%= span_if_current ts("My Sign-ups", key: 'header'), user_signups_path(current_user) %></li>
<% end %>
<% if (@current_user.offer_assignments.undefaulted.count || @current_user.pinch_hit_assignments.undefaulted.count) > 0 %>
<li><%= span_if_current ts("My Assignments (%{assignment_number})", key: 'header', :assignment_number => (@current_user.offer_assignments.undefaulted.count + @current_user.pinch_hit_assignments.undefaulted.count)), user_assignments_path(current_user) %></li>
<% if @current_user_offer_assignments > 0 %>
<li><%= span_if_current ts("My Assignments", key: 'header'), user_assignments_path(current_user) %></li>
<% end %>
<% if @current_user.preference.try(:history_enabled?) %>
<li><%= span_if_current ts('My History', key: 'header'), user_readings_path(current_user) %></li>
Expand All @@ -41,7 +41,7 @@
<ul class="menu" role="menu">
<li><%= link_to ts('New Work', key: 'header'), new_work_path %></li>
<li><%= link_to ts('Import Work', key: 'header'), new_work_path(:import => "true") %></li>
<% if @current_user.unposted_works.size > 0 %>
<% if @current_user_unposted_works_size > 0 %>
<li><%= span_if_current ts('From Draft', key: 'header'), drafts_user_works_path(@current_user) %></li>
<% end %>
</ul>
Expand Down
8 changes: 5 additions & 3 deletions app/views/users/change_email.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

<!--subnav-->
<%= render 'edit_header_navigation' %>

<!--/subnav-->

<!--main content-->
Expand All @@ -15,17 +14,20 @@
<% end %>
<dl>

<dt><%= ts("Current Email") %></dt>
<dd><%= @user.email %></dd>

<dt><%= label_tag :new_email, ts("New Email") %></dt>
<dd><%= email_field_tag :new_email %></dd>

<dt><%= label_tag :email_confirmation, ts("Confirm New Email") %></dt>
<dd><%= email_field_tag :email_confirmation %></dd>

<% unless @user.recently_reset? %>
<dt><%= label_tag :password_check, ts("Password") %></dt>
<dd><%= password_field_tag :password_check%></dd>
<% end %>

<dt class="landmark"><%= label_tag :submit, ts("Submit") %></dt>
<dd class="submit actions">
<%= submit_tag ts("Change Email") %>
Expand Down
12 changes: 9 additions & 3 deletions app/views/works/_collection_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%= form_for @search,
url: collected_user_works_path(@user),
html: {
:method => :get,
:class => 'filters',
:id => 'work_filters'
method: :get,
class: 'narrow-hidden filters',
id: 'works-in-collections-filters'
} do |f| %>
<h3 class="landmark heading"><%= ts("Filters") %></h3>
<%= field_set_tag (ts('Filter results:') + link_to_help("filters")).html_safe do %>
Expand Down Expand Up @@ -42,5 +42,11 @@
<%= hidden_field_tag("user_id", @user.login) if @user %>
</div>
<% end %>
<% # On narrow screens, link jumps to top of index when JavaScript is disabled and closes filters when JavaScript is enabled %>
<p class="narrow-shown hidden">
<a href="#main" id="leave_filters" class="close">
<%= ts("Top of Work Index") %>
</a>
</p>
<% end %>

16 changes: 9 additions & 7 deletions app/views/works/_filters.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%= form_for @search,
url: (@collection ? collection_works_path(@collection) : works_path),
html: {
:method => :get,
:class => 'filters',
:id => 'work_filters'
method: :get,
class: 'narrow-hidden filters',
id: 'work-filters'
} do |f| %>
<h3 class="landmark heading"><%= ts("Filters") %></h3>
<%= field_set_tag ts('Filter results:') do %>
Expand Down Expand Up @@ -79,8 +79,10 @@
<%= hidden_field_tag("user_id", @user.login) if @user %>
</div>
<% end %>
<% end %>

<%= content_for :footer_js do %>
<script src="/javascripts/filters.js" type="text/javascript"></script>
<% # On narrow screens, link jumps to top of index when JavaScript is disabled and closes filters when JavaScript is enabled %>
<p class="narrow-shown hidden">
<a href="#main" id="leave_filters" class="close">
<%= ts("Top of Work Index") %>
</a>
</p>
<% end %>
8 changes: 6 additions & 2 deletions app/views/works/collected.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
<% end %>
<li><%= span_if_current ts('Works in Collections'), collected_user_works_path(@user) %></li>
<li><%= span_if_current ts('Works'), user_works_path %></li>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#works-in-collections-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
</ul>
<!--/subnav-->
Expand All @@ -19,7 +23,7 @@
<% end %>
<!--main content-->
<h3 class="landmark heading">Listing Works</h3>
<h3 class="landmark heading"><%= ts("Listing Works") %></h3>
<ol class="work index group">
<% for work in @works %>
<% if work %><%= render 'work_blurb', :work => work %><% end %>
Expand All @@ -30,7 +34,7 @@
<!--filters subnav-->
<% if @facets.present? %>
<%= render :partial => 'collection_filters' %>
<%= render 'collection_filters' %>
<% end %>
<!---/subnav-->
Expand Down
29 changes: 14 additions & 15 deletions app/views/works/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@
<!-- /end descriptions-->

<!--Subnavigation, sorting and actions.-->
<% if (@collection && @collection.gift_exchange?) || @tag || @user %>
<% if @collection || @tag || @user %>
<div class="navigation actions module">

<h3 class="landmark heading"><%= ts("Navigation, Sorting and Actions") %></h3>
<h3 class="landmark heading"><%= ts("Navigation and Actions") %></h3>
<!--gift search subnav-->
<% if @collection && @collection.gift_exchange? %>
<%= render :partial => 'gifts/gift_search' %>
<%= render 'gifts/gift_search' %>
<% end %>

<!--user role subnav-->
<% if @tag || @user %>
<% if @tag || @user || @collection %>
<ul class="user navigation actions" role="navigation">
<% if @user %>
<% if @user == current_user %>
Expand All @@ -24,19 +22,22 @@
<li><%= span_if_current ts('Works in Collections'), collected_user_works_path(@user) %></li>
<li><%= span_if_current ts('Works'), user_works_path(@user) %></li>
<% end %>
<% if @tag %>
<% if @tag && !@collection %>
<li><%= span_if_current ts('Works'), tag_works_path(@tag) %></li>
<li><%= span_if_current ts('Bookmarks'), tag_bookmarks_path(@tag) %></li>
<% end %>
<% if @tag && logged_in? %>
<% if @facets.present? %>
<% # Filters button for narrow screens jumps to filters when JavaScript is disabled and opens filters when JavaScript is enabled %>
<li class="narrow-shown hidden"><a href="#work-filters" id="go_to_filters"><%= ts("Filters") %></a></li>
<% end %>
<% if @tag && logged_in? && !@collection %>
<li><%= render 'favorite_tags/form', current_user: @current_user, favorite_tag: @favorite_tag %></li>
<% end %>
<% if @tag && (%w(Fandom Character Relationship).include?(@tag.type.to_s) || @tag.name == "F/F") %>
<% if @tag && !@collection && (%w(Fandom Character Relationship).include?(@tag.type.to_s) || @tag.name == "F/F") %>
<li><%= link_to_rss feed_tag_path(:id => @tag.id, :format => :atom) %></li>
<% end %>
</ul>
<% end %>

</div>
<% end %>
<!---/subnav-->
Expand All @@ -53,21 +54,19 @@
<h3 class="landmark heading"><%= ts("Listing Works") %></h3>
<ol class="work index group">
<% for work in @works %>
<% if work %><%= render 'work_blurb', :work => work %><% end %>
<% if work %><%= render 'work_blurb', work: work %><% end %>
<% end %>
</ol>
<!--/content-->
<!--filters subnav-->
<% if @facets.present? %>
<%= render :partial => 'filters' %>
<%= render 'filters' %>
<% end %>
<!---/subnav-->
<% if @works.respond_to?(:total_pages) %>
<%= will_paginate @works %>
<% end %>



Loading

0 comments on commit ccfd466

Please sign in to comment.