diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index b664ef778ff..ba0a2170f7e 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -11,6 +11,8 @@ class BookmarksController < ApplicationController def load_bookmarkable if params[:work_id] @bookmarkable = Work.find(params[:work_id]) + elsif params[:chapter_id] + @bookmarkable = Chapter.find(params[:chapter_id]).try(:work) elsif params[:external_work_id] @bookmarkable = ExternalWork.find(params[:external_work_id]) elsif params[:series_id] @@ -151,13 +153,25 @@ def new @bookmark = Bookmark.new respond_to do |format| format.html - format.js + format.js { + @button_name = ts("Create") + @action = :create + render :action => "bookmark_form_dynamic" + } end end # GET /bookmarks/1/edit def edit @bookmarkable = @bookmark.bookmarkable + respond_to do |format| + format.html + format.js { + @button_name = ts("Update") + @action = :update + render :action => "bookmark_form_dynamic" + } + end end # POST /bookmarks @@ -204,7 +218,7 @@ def fetch_recent @bookmarkable = @bookmark.bookmarkable respond_to do |format| format.js { - @recent_bookmarks = @bookmarkable.bookmarks.visible(:order => "created_at DESC").offset(1).limit(4) + @bookmarks = @bookmarkable.bookmarks.visible(:order => "created_at DESC").offset(1).limit(4) } format.html do id_symbol = (@bookmarkable.class.to_s.underscore + '_id').to_sym diff --git a/app/controllers/collection_items_controller.rb b/app/controllers/collection_items_controller.rb index 1cf85b1ece0..0e439b2be52 100644 --- a/app/controllers/collection_items_controller.rb +++ b/app/controllers/collection_items_controller.rb @@ -69,10 +69,6 @@ def load_collectible_item end def new - respond_to do |format| - format.html - format.js - end end def create diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 02dfc9339db..b7a35a39155 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,7 +8,7 @@ module ApplicationHelper def classes_for_main class_names = controller.controller_name + '-' + controller.action_name show_sidebar = ((@user || @admin_posts || @collection || show_wrangling_dashboard) && !@hide_dashboard) - class_names += " sidebar" if show_sidebar + class_names += " dashboard" if show_sidebar class_names end @@ -31,7 +31,7 @@ def link_to_rss(link_to_feed) link_to (ts("Subscribe with RSS ") + image_tag("feed-icon-14x14.png", :size => "14x14", :alt => "")).html_safe , link_to_feed, :class => "rsslink" end - def allowed_html_instructions(show_list = true) + def allowed_html_instructions(show_list = false) h(ts("Plain text with limited html")) + link_to_help("html-help") + (show_list ? "a, abbr, acronym, address, [alt], [axis], b, big, blockquote, br, caption, center, cite, [class], code, diff --git a/app/helpers/bookmarks_helper.rb b/app/helpers/bookmarks_helper.rb index d5e4a138a54..91c55c16db0 100644 --- a/app/helpers/bookmarks_helper.rb +++ b/app/helpers/bookmarks_helper.rb @@ -1,48 +1,53 @@ module BookmarksHelper - # Generates a draggable, pop-up div which contains the bookmark form - def bookmark_link(bookmarkable, blurb=false) - # blurb=true is passed from the bookmark blurb to generate a save/saved link - if logged_in? - if bookmarkable.class == Chapter - bookmarkable = bookmarkable.work - end - - if bookmarkable.class == Work - fallback = new_work_bookmark_path(bookmarkable) - blurb == true ? text = ts("Save") : text = ts("Bookmark") - elsif bookmarkable.class == ExternalWork - fallback = new_external_work_bookmark_path(bookmarkable) - blurb == true ? text = ts("Save") : text = ts("Add A New Bookmark") - elsif bookmarkable.class == Series - fallback = new_series_bookmark_path(bookmarkable) - blurb == true ? text = ts("Save") : text = ts("Bookmark Series") - end - # Check to see if the user has an existing bookmark on this object. Note: on work page we eventually want to change this so an - # existing bookmark is opened for editing but a new bookmark can be created by selecting a different pseud on the form. - @existing = Bookmark.find(:all, :conditions => ["bookmarkable_type = ? AND bookmarkable_id = ? AND pseud_id IN (?)", bookmarkable.class.name.to_s, bookmarkable.id, current_user.pseuds.collect(&:id)]) - if @existing.blank? - link_to text, {:url => fallback, :method => :get}, :remote => true, :href => fallback - else - # eventually we want to add the option here to remove the existing bookmark - # Enigel Dec 10 08 - adding an edit link for now - if blurb == true - if @existing.many? - id_symbol = (bookmarkable.class.to_s.underscore + '_id').to_sym - link_to ts("Saved"), {:controller => :bookmarks, :action => :index, id_symbol => bookmarkable, :existing => true} - else - link_to ts("Saved"), bookmark_path(@existing) - end - else - if @existing.many? - link_to ts("Edit/Add Bookmark"), edit_bookmark_path(@existing.last, :existing => true) - else - link_to ts("Edit/Add Bookmark"), edit_bookmark_path(@existing.last, :existing => false) - end - end - end + # if the current user has the current object bookmarked return the existing bookmark + # since the user may have multiple bookmarks for different pseuds we prioritize by current default pseud if more than one bookmark exists + def bookmark_if_exists(bookmarkable) + return nil unless logged_in? + bookmarkable = bookmarkable.work if bookmarkable.class == Chapter + bookmarks = Bookmark.where(:bookmarkable_id => bookmarkable.id, :bookmarkable_type => bookmarkable.class.name.to_s, :pseud_id => current_user.pseuds.collect(&:id)) + if bookmarks.count > 1 + bookmarks.where(:pseud_id => current_user.default_pseud.id).first || bookmarks.last + else + bookmarks.last + end + end + + # returns just a url to the new bookmark form + def get_new_bookmark_path(bookmarkable) + return case bookmarkable.class.to_s + when "Chapter" + new_work_bookmark_path(bookmarkable.work) + when "Work" + new_work_bookmark_path(bookmarkable) + when "ExternalWork" + new_external_work_bookmark_path(bookmarkable) + when "Series" + new_series_bookmark_path(bookmarkable) + end + end + + def get_bookmark_link_text(bookmarkable, blurb=false) + @bookmark = bookmark_if_exists(bookmarkable) + case bookmarkable.class.to_s + when blurb == true + @bookmark ? ts("Saved") : ts("Save") + when "Series" + @bookmark ? ts("Edit Series Bookmark") : ts("Bookmark Series") + when "ExternalWork" + @bookmark ? ts("Edit Bookmark") : ts("Add A New Bookmark") + else + @bookmark ? ts("Edit Bookmark") : ts("Bookmark") end end + + # Link to bookmark + def bookmark_link(bookmarkable, blurb=false) + return "" unless logged_in? + url = get_bookmark_path(bookmarkable) + text = get_bookmark_link_text(bookmarkable, blurb) + link_to text, url + end def link_to_new_bookmarkable_bookmark(bookmarkable) id_symbol = (bookmarkable.class.to_s.underscore + '_id').to_sym diff --git a/app/helpers/tags_helper.rb b/app/helpers/tags_helper.rb index d422b6039ed..7200b432d65 100644 --- a/app/helpers/tags_helper.rb +++ b/app/helpers/tags_helper.rb @@ -2,15 +2,7 @@ module TagsHelper # Takes an array of tags and returns a marked-up, comma-separated list of links to them def tag_link_list(tags, link_to_works=false) - tags = tags.uniq.compact - if !tags.blank? && tags.respond_to?(:collect) - last_tag = tags.pop - tag_list = tags.collect{|tag| "
  • " + (link_to_works ? link_to_tag_works(tag) : link_to_tag(tag)) + ",
  • "}.join - tag_list += content_tag(:li, (link_to_works ? link_to_tag_works(last_tag) : link_to_tag(last_tag))) - tag_list.html_safe - else - "" - end + tags = tags.uniq.compact.map {|tag| content_tag(:li, link_to_works ? link_to_tag_works(tag) : link_to_tag(tag))}.join.html_safe end def description(tag) @@ -203,7 +195,6 @@ def blurb_tag_block(item, tag_groups=nil) item_class = item.class.to_s.underscore tag_groups ||= item.tag_groups categories = ['Warning', 'Relationship', 'Character', 'Freeform'] - last_tag = categories.collect { |c| tag_groups[c] }.flatten.compact.last tag_block = "" categories.each do |category| @@ -212,15 +203,14 @@ def blurb_tag_block(item, tag_groups=nil) if (class_name == "warnings" && hide_warnings?(item)) || (class_name == "freeforms" && hide_freeform?(item)) open_tags = "
  • " close_tags = "
  • " - delimiter = (class_name == 'freeforms' || last_tag.is_a?(Warning)) ? '' : ArchiveConfig.DELIMITER_FOR_OUTPUT - tag_block << open_tags + show_hidden_tags_link(item, class_name) + delimiter + close_tags + tag_block << open_tags + show_hidden_tags_link(item, class_name) + close_tags elsif class_name == "warnings" open_tags = "
  • " close_tags = "
  • " - link_array = tags.collect{|tag| link_to_tag(tag) + (tag == last_tag ? '' : ArchiveConfig.DELIMITER_FOR_OUTPUT) } + link_array = tags.collect{|tag| link_to_tag(tag)} tag_block << open_tags + link_array.join("
  • ") + close_tags else - link_array = tags.collect{|tag| link_to_tag(tag) + (tag == last_tag ? '' : ArchiveConfig.DELIMITER_FOR_OUTPUT) } + link_array = tags.collect{|tag| link_to_tag(tag)} tag_block << "
  • " + link_array.join("
  • ") + '
  • ' end end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index ab2707f174e..63e9b7e9578 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -21,7 +21,7 @@ def print_pseuds(user) end # Determine which icon to show on user pages - def standard_icon(user, pseud=nil) + def standard_icon(user=nil, pseud=nil) if pseud pseud.icon.url(:standard) elsif user && user.default_pseud @@ -31,18 +31,9 @@ def standard_icon(user, pseud=nil) end end - def standard_icon_display(user, pseud=nil) - pseud ||= user.default_pseud - image_tag(standard_icon(user, pseud), :alt => (pseud.try(:icon_file_name) ? pseud.icon_alt_text : "Archive of Our Own default icon: the AO3 logo in grey, on a white background"), :class => "icon") - end - - def icon_display(user, pseud=nil) - pseud ||= user.default_pseud - if current_user == user - link_to standard_icon_display(user, pseud), [:edit, user, pseud], :title => "Edit pseud" - else - standard_icon_display(user, pseud) - end + def icon_display(user=nil, pseud=nil) + pseud ||= user.default_pseud if user + image_tag(standard_icon(user, pseud), :alt => (pseud.try(:icon_file_name) ? pseud.icon_alt_text : "default AO3 icon"), :class => "icon") end # Prints coauthors diff --git a/app/helpers/works_helper.rb b/app/helpers/works_helper.rb index d014456a744..b0441b22ae1 100755 --- a/app/helpers/works_helper.rb +++ b/app/helpers/works_helper.rb @@ -109,7 +109,7 @@ def marktoread_link(work) if reading && reading.toread? link_to "Mark as read", marktoread_work_path(work) else - link_to "Mark to read later", marktoread_work_path(work) + link_to "Mark for later", marktoread_work_path(work) end end end @@ -154,6 +154,13 @@ def get_bookmark_embed_link(bookmark) [work_embed, tags_text, bookmark_text].compact.join("\n") end end + + def get_endnotes_link + current_page?(:controller => 'chapters', :action => 'show') ? + chapter_path(@work.last_chapter.id, :anchor => 'work_endnotes') : + "#work_endnotes" + end + def download_url_for_work(work, format) url_for ("/downloads/#{work.download_authors}/#{work.id}/#{work.download_title}.#{format}").gsub(' ', '%20') diff --git a/app/views/abuse_reports/index.html.erb b/app/views/abuse_reports/index.html.erb index e12f34cbeaf..5153075e866 100644 --- a/app/views/abuse_reports/index.html.erb +++ b/app/views/abuse_reports/index.html.erb @@ -1,3 +1,4 @@ +

    <%=h t('.about', :default => "All Abuse Reports:") %>

    diff --git a/app/views/abuse_reports/new.html.erb b/app/views/abuse_reports/new.html.erb index b4ef6091579..98325266eb8 100644 --- a/app/views/abuse_reports/new.html.erb +++ b/app/views/abuse_reports/new.html.erb @@ -6,7 +6,7 @@ -<%= form_for(@abuse_report) do |f| %> +<%= form_for(@abuse_report), :class =>"post", do |f| %>
    Link and Describe Abuse
    @@ -38,12 +38,10 @@ <%= f.hidden_field :ip_address, :value => request.remote_ip %> -
    -
    -
    - Send Message to Abuse Team -

    <%= f.submit t('.submit', :default => "Submit") %>

    +
    Send to Abuse Team
    +
    <%= f.submit t('.submit', :default => "Submit") %>
    +
    <% end %> - \ No newline at end of file + diff --git a/app/views/abuse_reports/show.html.erb b/app/views/abuse_reports/show.html.erb index 6149ac24ecd..c6cfb19a6be 100644 --- a/app/views/abuse_reports/show.html.erb +++ b/app/views/abuse_reports/show.html.erb @@ -2,7 +2,7 @@ -
    diff --git a/app/views/comments/_commentable.html.erb b/app/views/comments/_commentable.html.erb index b6a1a3ad1c9..9bda4d2f70c 100644 --- a/app/views/comments/_commentable.html.erb +++ b/app/views/comments/_commentable.html.erb @@ -1,5 +1,5 @@ - diff --git a/app/views/comments/_confirm_delete.html.erb b/app/views/comments/_confirm_delete.html.erb index 0dc7c9942c9..0ac2cb761cb 100644 --- a/app/views/comments/_confirm_delete.html.erb +++ b/app/views/comments/_confirm_delete.html.erb @@ -1,5 +1,5 @@

    <%= ts("Are you sure you want to delete this comment?") %>

    -