major refactoring of javascripts

This commit is contained in:
albert
2011-03-10 17:59:42 -05:00
parent efa6856b4a
commit 9c0a961ab2
28 changed files with 168 additions and 415 deletions

View File

@@ -9,11 +9,9 @@ class FavoritesController < ApplicationController
def create
Post.find(params[:id]).add_favorite(CurrentUser.user)
render :nothing => true
end
def destroy
Post.find(params[:id]).remove_favorite(CurrentUser.user)
render :nothing => true
end
end

View File

@@ -1,17 +1,12 @@
class TagAliasesController < ApplicationController
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy]
respond_to :html, :xml, :json
before_filter :admin_only, :only => [:new, :create, :destroy]
respond_to :html, :xml, :json, :js
def new
@tag_alias = TagAlias.new(params[:tag_alias])
respond_with(@tag_alias)
end
def edit
@tag_alias = TagAlias.find(params[:id])
respond_with(@tag_alias)
end
def index
@search = TagAlias.search(params[:search])
@tag_aliases = @search.paginate(:page => params[:page])
@@ -20,19 +15,13 @@ class TagAliasesController < ApplicationController
def create
@tag_alias = TagAlias.create(params[:tag_alias])
respond_with(@tag_alias)
end
def update
@tag_alias = TagAlias.find(params[:id])
@tag_alias.update_attributes(params[:tag_alias])
respond_with(@tag_alias)
respond_with(@tag_alias, :location => tag_aliases_path(:search => {:id_eq => @tag_alias.id}))
end
def destroy
@tag_alias = TagAlias.find(params[:id])
@tag_alias.destroy
respond_with(@tag_alias)
respond_with(@tag_alias, :location => tag_aliases_path)
end
def cache

View File

@@ -1,32 +1,21 @@
class TagImplicationsController < ApplicationController
before_filter :admin_only, :only => [:new, :edit, :create, :update, :destroy]
respond_to :html, :xml, :json
before_filter :admin_only, :only => [:new, :create, :destroy]
respond_to :html, :xml, :json, :js
def new
@tag_implication = TagImplication.new
respond_with(@tag_implication)
end
def edit
@tag_implication = TagImplication.find(params[:id])
respond_with(@tag_implication)
end
def index
@search = TagImplication.search(params[:search])
@tag_implicationes = @search.paginate(:page => params[:page])
@tag_implications = @search.paginate(:page => params[:page])
respond_with(@tag_implicationes)
end
def create
@tag_implication = TagImplication.create(params[:tag_implication])
respond_with(@tag_implication)
end
def update
@tag_implication = TagImplication.find(params[:id])
@tag_implication.update_attributes(params[:tag_implication])
respond_with(@tag_implication)
respond_with(@tag_implication, :location => tag_implications_path(:search => {:id_eq => @tag_implication.id}))
end
def destroy

View File

@@ -10,6 +10,10 @@ class JanitorTrial < ActiveRecord::Base
self.creator_id = CurrentUser.id
end
def user_name=(name)
self.user_id = User.name_to_id(name)
end
def send_dmail
body = "You have been selected as a test janitor. You can now approve pending posts and have access to the moderation interface.\n\nOver the next several weeks your approvals will be monitored. If the majority of them are quality uploads, then you will be promoted to full janitor status which grants you the ability to delete and undelete posts, ban users, and revert tag changes from vandals. If you fail the trial period, you will be demoted back to your original level and you'll receive a negative user record indicating you previously attempted and failed a test janitor trial.\n\nThere is a minimum quota of 5 approvals a week to indicate that you are being active. Remember, the goal isn't to approve as much as possible. It's to filter out borderline-quality art.\n\nIf you have any questions please respond to this message."

View File

@@ -1,5 +1,3 @@
<% if @error %>
alert("<%= escape_javascript(@error.to_s) %>");
<% else %>
$("#score-for-comment-<%= @comment.id %>").html("<%= pluralize @comment.score, 'point' %>");
<% end %>

View File

@@ -6,13 +6,12 @@
<%= time_ago_in_words(comment.created_at) %> ago
</time>
</p>
<p><span class="comment-score" id="score-for-comment-<%= comment.id %>"><%= pluralize comment.score, "point" %></span></p>
</div>
<div class="content">
<div>
<%= format_text(comment.body) %>
</div>
<menu>
<menu>
<li><span class="link">Reply</span></li>
<% if CurrentUser.user.is_janitor? || CurrentUser.user.id == comment.creator_id %>
<li><%= link_to "Delete", comment_path(comment.id), :confirm => "Do you really want to delete this comment?", :method => :delete %></li>

View File

@@ -0,0 +1,2 @@
$("a#add-to-favorites").hide();
$("a#remove-from-favorites").show();

View File

@@ -0,0 +1,2 @@
$("a#add-to-favorites").show();
$("a#remove-from-favorites").hide();

View File

@@ -5,7 +5,7 @@
<% if @pool %>
<li>|</li>
<li><%= link_to "Show", pool_path(@pool) %></li>
<li><%= link_to "Search", posts_path(:tags => "pool:#{@pool.id}") %></li>
<li><%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %></li>
<li><%= link_to "Simple Edit", edit_pool_path(@pool) %></li>
<li><%= link_to "Advanced Edit", edit_pool_path(@pool, :advanced => true) %></li>
<% end %>

View File

@@ -1,16 +1,16 @@
<ul>
<%= resize_image_links(post, CurrentUser.user) %>
<li><%= link_to "Favorite", "#", :id => "add-to-favorites" %> <%= wait_image("add-to-favorites-wait") %></li>
<li><%= link_to "Unfavorite", "#", :id => "remove-from-favorites" %> <%= wait_image("remove-from-favorites-wait") %></li>
<li><%= link_to "Favorite", favorite_path(post), :remote => true, :method => :post, :id => "add-to-favorites" %></li>
<li><%= link_to "Unfavorite", favorite_path(post), :remote => true, :method => :delete, :id => "remove-from-favorites" %></li>
<li><%= link_to "Translate", "#" %></li>
<li><%= link_to "Unapprove", new_unapproval_path(:post_id => post.id), :id => "unapprove" %></li>
<% if CurrentUser.is_janitor? %>
<li><%= link_to "Approve", "#", :id => "approve" %> <%= wait_image("approve-wait") %></li>
<li><%= link_to "Disapprove", "#", :id => "disapprove" %> <%= wait_image("disapprove-wait") %></li>
<li><%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put, :id => "approve" %></li>
<li><%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put, :id => "disapprove" %></li>
<% end %>
<% if CurrentUser.is_moderator? %>
<li><%= link_to "Undelete", "#", :id => "undelete" %> <%= wait_image("undelete-wait") %></li>
<li><%= link_to "Delete", "#", :id => "delete" %> <%= wait_image("delete-wait") %></li>
<li><%= link_to "Undelete", post_moderation_undelete_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %></li>
<li><%= link_to "Delete", post_moderation_delete_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
<% end %>
<li><%= link_to "Pool", "#", :id => "pool" %></li>
</ul>

View File

@@ -0,0 +1 @@
$("#tag-alias-<%= @tag_alias.id %>").remove();

View File

@@ -19,13 +19,13 @@
</thead>
<tbody>
<% @tag_aliases.each do |tag_alias| %>
<tr>
<tr id="tag-alias-<%= tag_alias.id %>">
<td><%= link_to tag_alias.antecedent_name, posts_path(:tags => tag_alias.antecedent_name) %> (<%= tag_alias.antecedent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_alias.consequent_name, posts_path(:tags => tag_alias.consequent_name) %> (<%= tag_alias.consequent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_alias.forum_topic_id, forum_topic_path(tag_alias.forum_topic_id) %></td>
<td>
<% if CurrentUser.is_admin? %>
<%= link_to "Delete", :url => tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
<%= link_to "Delete", tag_alias_path(tag_alias), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this alias?" %>
<% end %>
</td>
</tr>

View File

@@ -0,0 +1,7 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", tag_implications_path %></li>
<li><%= link_to "Add", new_tag_implication_path %></li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %></li>
</menu>
<% end %>

View File

@@ -0,0 +1 @@
$("#tag-implication-<%= @tag_implication.id %>").remove();

View File

@@ -1,95 +1,42 @@
<div style="margin-bottom: 1em;">
<% form_tag({:action => "index"}, :method => :get) do %>
<%= text_field_tag "query", params[:query] %>
<%= submit_tag "Search Implications" %>
<%= submit_tag "Search Aliases" %>
<% end %>
</div>
<% form_tag(:action => "update") do %>
<table class="highlightable" width="100%">
<thead>
<tr>
<th width="1%"></th>
<th width="19%">Predicate</th>
<th width="20%">Consequent</th>
<th width="60%">Reason</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">
<% if @current_user.is_admin_or_higher? %>
<%= button_to_function "Select pending", "$$('.pending').each(function(x) {x.checked = true})" %>
<%= submit_tag "Approve" %>
<%= button_to_function "Delete", "$('reason-box').show(); $('reason').focus()" %>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<%= button_to_function "Add", "$('add-box').show().scrollTo(); $('tag_implication_predicate').focus()" %>
<% else %>
<%= button_to_function "Add", "window.location = '/forum/new?type=impl'" %>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<div id="reason-box" style="display: none; margin-top: 1em;">
<strong>Reason:</strong>
<%= text_field_tag "reason", "", :size => 40 %>
<%= submit_tag "Delete" %>
</div>
<% end %>
</td>
</tr>
</tfoot>
<tbody>
<% @implications.each do |i| %>
<tr class="<%= cycle 'even', 'odd' %> <%= i.is_pending? ? 'pending-tag' : nil %>">
<td><input type="checkbox" value="1" name="implications[<%= i.id %>]" <%= i.is_pending? ? 'class="pending"' : nil %>></td>
<td><%= link_to h(i.predicate.name), :controller => "post", :action => "index", :tags => i.predicate.name %> (<%= i.predicate.post_count %>)</td>
<td><%= link_to h(i.consequent.name), :controller => "post", :action => "index", :tags => i.consequent.name %> (<%= i.consequent.post_count %>)</td>
<td><%= h i.reason %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<% if @current_user.is_admin_or_higher? %>
<div id="add-box" <% unless params[:to_name] %>style="display: none;"<% end %>>
<% form_tag(:action => "create") do %>
<h4>Add Implication</h4>
<% unless @current_user.is_anonymous? %>
<%= hidden_field_tag "tag_implication[creator_id]", @current_user.id %>
<div id="c-tag-implications">
<div id="a-index">
<div class="search">
<% form_tag(tag_implications_path, :method => :get) do %>
<%= text_field_tag "query", params[:query] %>
<%= submit_tag "Search Aliases" %>
<%= submit_tag "Search Implications" %>
<% end %>
<table>
</div>
<table width="100%" class="highlightable">
<thead>
<tr>
<th><label for="tag_implication_predicate">Predicate</label></th>
<td><%= text_field "tag_implication", "predicate", :size => 40, :value => params[:from_name] %></td>
</tr>
<tr>
<th><label for="tag_implication_consequent">Consequent</label></th>
<td><%= text_field "tag_implication", "consequent", :size => 40, :value => params[:to_name] %></td>
</tr>
<tr>
<th><label for="tag_implication_reason">Reason</label></th>
<td><%= text_area "tag_implication", "reason", :size => "40x2", :value => params[:reason] %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Submit" %></td>
</tr>
</table>
<% end %>
<th width="20%">From</th>
<th width="20%">To</th>
<th width="20%">Reference</th>
<th width="40%"></th>
</tr>
</thead>
<tbody>
<% @tag_implications.each do |tag_implication| %>
<tr id="tag-implication-<%= tag_implication.id %>">
<td><%= link_to tag_implication.antecedent_name, posts_path(:tags => tag_implication.antecedent_name) %> (<%= tag_implication.antecedent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_implication.consequent_name, posts_path(:tags => tag_implication.consequent_name) %> (<%= tag_implication.consequent_tag.post_count rescue 0 %>)</td>
<td><%= link_to tag_implication.forum_topic_id, forum_topic_path(tag_implication.forum_topic_id) %></td>
<td>
<% if CurrentUser.is_admin? %>
<%= link_to "Delete", tag_implication_path(tag_implication), :remote => true, :method => :delete, :confirm => "Are you sure you want to delete this implication?" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<% end %>
</div>
<div id="paginator">
<%= will_paginate(@implications) %>
</div>
<% content_for("subnavbar") do %>
<li><%= link_to "List", :controller => "tag_implication", :action => "index" %></li>
<li><%= link_to "Add", :controller => "tag_implication", :action => "new" %></li>
<li><%= link_to "Help", :controller => "help", :action => "tag_implications" %></li>
<% end %>
<%= render "secondary_links" %>

View File

@@ -1,20 +1,13 @@
<% form_tag(:controller => "forum", :action => "create") do %>
<p>You can create a forum thread to suggest the creation of an implication.</p>
<table>
<tr>
<th><label for="tag_implication_predicate">From</label></th>
<td><%= text_field "tag_implication", "predicate", :size => 40 %></td>
</tr>
<tr>
<th><label for="tag_implication_consequent">To</label></th>
<td><%= text_field "tag_implication", "consequent", :size => 40 %></td>
</tr>
<tr>
<th><label for="tag_implication_reason">Reason</label></th>
<td><%= text_area "tag_implication", "reason", :rows => 10, :cols => 60 %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Submit" %></td>
</tr>
</table>
<% end %>
<div id="c-tag-aliases">
<div id="a-new">
<h1>New Tag Implication</h1>
<%= simple_form_for(@tag_implication) do |f| %>
<%= f.input :antecedent_name, :label => "From" %>
<%= f.input :consequent_name, :label => "To" %>
<%= f.input :forum_topic_id, :label => "Forum" %>
<%= f.button :submit %>
<% end %>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -12,7 +12,7 @@
<tr>
<td><%= tag.post_count %></td>
<td class="tag-category-<%= tag.category_name %>">
<%= link_to("?", wiki_pages_path(:search => {:title_equals => tag.name})) %>
<%= link_to("?", wiki_pages_path(:title => tag.name)) %>
<%= link_to(tag.name, posts_path(:tags => tag.name)) %>
</td>
</tr>