Skip to content

Commit

Permalink
Rewrite ALL THE THINGS! almost done
Browse files Browse the repository at this point in the history
Signed-off-by: Lim Lim <[email protected]>
  • Loading branch information
Lim Lim committed Oct 8, 2011
1 parent d5ea3de commit 1d9f656
Show file tree
Hide file tree
Showing 437 changed files with 2,377 additions and 2,170 deletions.
18 changes: 16 additions & 2 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 0 additions & 4 deletions app/controllers/collection_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@ def load_collectible_item
end

def new
respond_to do |format|
format.html
format.js
end
end

def create
Expand Down
4 changes: 2 additions & 2 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 ?
"<code>a, abbr, acronym, address, [alt], [axis], b, big, blockquote, br, caption, center, cite, [class], code,
Expand Down
87 changes: 46 additions & 41 deletions app/helpers/bookmarks_helper.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 4 additions & 14 deletions app/helpers/tags_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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| "<li>" + (link_to_works ? link_to_tag_works(tag) : link_to_tag(tag)) + ", </li>"}.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)
Expand Down Expand Up @@ -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|
Expand All @@ -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 = "<li class='#{class_name}' id='#{item_class}_#{item.id}_category_#{class_name}'><strong>"
close_tags = "</strong></li>"
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 = "<li class='#{class_name}'><strong>"
close_tags = "</strong></li>"
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("</strong></li> <li class='#{class_name}'><strong>") + 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 << "<li class='#{class_name}'>" + link_array.join("</li> <li class='#{class_name}'>") + '</li>'
end
end
Expand Down
17 changes: 4 additions & 13 deletions app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
9 changes: 8 additions & 1 deletion app/helpers/works_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions app/views/abuse_reports/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<div class="admin system">
<!--Descriptive page names, messages and instructions-->
<h2><%=h t('.about', :default => "All Abuse Reports:") %></h2>
<!--/descriptions-->
Expand Down
12 changes: 5 additions & 7 deletions app/views/abuse_reports/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!--/subnav-->

<!--main content-->
<%= form_for(@abuse_report) do |f| %>
<%= form_for(@abuse_report), :class =>"post", do |f| %>
<fieldset>
<legend>Link and Describe Abuse</legend>
<dl>
Expand Down Expand Up @@ -38,12 +38,10 @@

<%= f.hidden_field :ip_address, :value => request.remote_ip %>
</dd>
</dl>
</fieldset>
<fieldset>
<legend>Send Message to Abuse Team</legend>
<p class="submit"><%= f.submit t('.submit', :default => "Submit") %></p>
<dt class="landmark">Send to Abuse Team</dt>
<dd class="submit"><%= f.submit t('.submit', :default => "Submit") %></dd>
</dl>
</fieldset>

<% end %>
<!--/content-->
<!--/content-->
6 changes: 3 additions & 3 deletions app/views/abuse_reports/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!--/descriptions-->

<!--subnav-->
<ul class="navigation" role="navigation">
<ul class="navigation actions" role="navigation">
<li><%= link_to t('.index_link', :default => 'All abuse reports'), abuse_reports_path %></li>
</ul>
<!--/subnav-->
Expand Down Expand Up @@ -33,7 +33,7 @@
<!--/content-->

<!--subnav-->
<ul class="navigation" role="navigation">
<ul class="navigation actions" role="navigation">
<li><%= link_to t('.index_link', :default => 'All abuse reports'), abuse_reports_path %></li>
</ul>
<!--/subnav-->
<!--/subnav-->
2 changes: 1 addition & 1 deletion app/views/admin/_admin_nav.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<h3 class="landmark">Admin Navigation</h3>
<ul class="navigation" role="navigation">
<ul class="navigation actions" role="navigation">
<li>
<%= span_if_current "AO3 News", admin_posts_path %>
</li>
Expand Down
6 changes: 4 additions & 2 deletions app/views/admin/_admin_options.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
<!-- BEGIN admin options -->
<h3 class="landmark">Admin Actions</h3>
<ul class="admin navigation" role="navigation">
<div class="admin">
<h3 class="landmark">Admin Actions</h3>
<ul class="navigation actions" role="navigation actions">
<% if item.hidden_by_admin? %>
<li><%= link_to ts('Make Visible'), {:controller=>"admin/user_creations", :action=>"hide", :id=>item, :creation_type => item.class, :hidden=>'false'} %></li>
<% else %>
<li><%= link_to ts('Hide'), {:controller=>"admin/user_creations", :action=>"hide", :id=>item, :creation_type => item.class, :hidden=>'true'} %></li>
<% end %>
<li><%= link_to ts('Delete'), {:controller=>"admin/user_creations", :action=>"destroy", :id=>item, :creation_type => item.class}, :confirm => ts('Are you sure?'), :method => :delete %></li>
</ul>
</div>
<!-- END admin options -->
30 changes: 8 additions & 22 deletions app/views/admin/_header.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
<!-- navigation tabs for admin users -->
<h3 class="landmark">Admins' Main Navigation</h3>
<ul class="admin navigation" role="navigation">
<li><% if current_page?(admin_users_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("users"), admin_users_path %>
<% if current_page?(admin_users_path) %></span><% end %></li>
<li><% if current_page?(notify_admin_users_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("notices"), notify_admin_users_path %>
<% if current_page?(notify_admin_users_path) %></span><% end %></li>
<li><% if current_page?(admin_invitations_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("invitations"), admin_invitations_path %>
<% if current_page?(admin_invitations_path) %></span><% end %></li>
<li><% if current_page?(abuse_reports_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("abuse reports"), abuse_reports_path %>
<% if current_page?(abuse_reports_path) %></span><% end %></li>
<li><% if current_page?(admin_posts_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("admin posts"), admin_posts_path %>
<% if current_page?(admin_posts_path) %></span><% end %></li>
<li><% if current_page?(admin_settings_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("settings"), admin_settings_path %>
<% if current_page?(admin_settings_path) %></span><% end %></li>
<li><% if current_page?(admin_skins_path) %><span class="current"><% end %>
<%= link_to_unless_current ts("skins"), admin_skins_path %>
<% if current_page?(admin_skins_path) %></span><% end %></li>
<ul class="admin navigation actions" role="navigation">
<li><%= span_if_current("Manage Users", admin_users_path) %></li>
<li><%= span_if_current("Notifications", notify_admin_users_path) %></li>
<li><%= span_if_current("Invitations", admin_invitations_path) %></li>
<li><%= span_if_current("Abuse Reports", abuse_reports_path) %></li>
<li><%= span_if_current("Admin Posts", admin_posts_path) %></li>
<li><%= span_if_current("Settings", admin_settings_path) %></li>
<li><%= span_if_current("Skins", admin_skins_path) %></li>
</ul>
2 changes: 1 addition & 1 deletion app/views/admin/admin_invitations/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!--Descriptive page name, messages and instructions--><h2><%=h ts("Invite new users") %></h2>
<!--/descriptions-->
<!--subnav-->
<ul class="navigation" role="navigation">
<ul class="navigation actions" role="navigation actions">
<li><%= link_to "Manage requests", user_invite_requests_path %></li>
<li><%= link_to "Manage queue", manage_invite_requests_path %></li>
</ul>
Expand Down
Loading

0 comments on commit 1d9f656

Please sign in to comment.