From 9e7efbd295dc040d422fc901825ee0f60e826e81 Mon Sep 17 00:00:00 2001 From: albert Date: Mon, 28 Feb 2011 14:18:39 -0500 Subject: [PATCH] stubbed in view code from old danbooru; only janitors can lock a wiki page --- app/controllers/uploads_controller.rb | 2 +- app/controllers/wiki_pages_controller.rb | 7 ++ app/models/post.rb | 2 + app/models/tag.rb | 5 +- app/models/user_mailer.rb | 16 --- app/models/wiki_page.rb | 11 +- app/views/admin/tags/edit.html.erb | 10 ++ app/views/layouts/default.html.erb | 2 +- app/views/note_versions/index.html.erb | 38 +++++++ app/views/notes/_secondary_links.html.erb | 7 ++ app/views/notes/index.html.erb | 9 ++ app/views/pool_versions/index.html.erb | 47 ++++++++ app/views/post_moderation/moderate.html.erb | 56 ++++++++++ app/views/post_versions/index.html.erb | 82 +++++++++++--- app/views/report/common.html.erb | 66 ++++++++++++ app/views/report/tag_history.html.erb | 40 +++++++ .../report_mailer/moderator_report.html.erb | 30 ++++++ app/views/sessions/new.html.erb | 1 + app/views/static/500.html.erb | 7 ++ app/views/static/overloaded.html.erb | 11 ++ app/views/static/terms_of_service.html.erb | 60 +++++++++++ app/views/tag_aliases/index.html.erb | 92 ++++++++++++++++ app/views/tag_aliases/new.html.erb | 20 ++++ app/views/tag_implications/index.html.erb | 95 ++++++++++++++++ app/views/tag_implications/new.html.erb | 20 ++++ app/views/tag_subscriptions/index.html.erb | 14 +++ app/views/tags/_search.html.erb | 8 ++ app/views/tags/_secondary_links.html.erb | 8 ++ app/views/tags/edit.html.erb | 0 app/views/tags/index.html.erb | 27 +++++ app/views/tags/show.html.erb | 0 .../user_feedback/_secondary_links.html.erb | 7 ++ app/views/user_feedback/index.html.erb | 42 ++++++++ app/views/user_feedback/new.html.erb | 29 +++++ .../{dmail.html.erb => dmail_notice.html.erb} | 0 .../user_maintenance/delete_account.html.erb | 5 - app/views/wiki_page_versions/index.html.erb | 70 ++++++++++++ app/views/wiki_pages/_form.html.erb | 5 + app/views/wiki_pages/_recent_changes.html.erb | 8 ++ .../wiki_pages/_secondary_links.html.erb | 16 +++ app/views/wiki_pages/_sidebar.html.erb | 10 ++ app/views/wiki_pages/edit.html.erb | 15 +++ app/views/wiki_pages/index.html.erb | 26 +++++ app/views/wiki_pages/new.html.erb | 16 +++ app/views/wiki_pages/show.html.erb | 57 ++++++++++ db/migrate/20100204214746_create_posts.rb | 2 + test/unit/wiki_page_test.rb | 102 +++++++++++------- 47 files changed, 1124 insertions(+), 79 deletions(-) create mode 100644 app/views/admin/tags/edit.html.erb create mode 100644 app/views/notes/_secondary_links.html.erb create mode 100644 app/views/report/common.html.erb create mode 100644 app/views/report/tag_history.html.erb create mode 100644 app/views/report_mailer/moderator_report.html.erb create mode 100644 app/views/static/500.html.erb create mode 100644 app/views/static/overloaded.html.erb create mode 100644 app/views/static/terms_of_service.html.erb create mode 100644 app/views/tags/_search.html.erb create mode 100644 app/views/tags/_secondary_links.html.erb delete mode 100644 app/views/tags/edit.html.erb delete mode 100644 app/views/tags/show.html.erb create mode 100644 app/views/user_feedback/_secondary_links.html.erb rename app/views/user_mailer/{dmail.html.erb => dmail_notice.html.erb} (100%) delete mode 100644 app/views/user_maintenance/delete_account.html.erb create mode 100644 app/views/wiki_pages/_form.html.erb create mode 100644 app/views/wiki_pages/_recent_changes.html.erb create mode 100644 app/views/wiki_pages/_secondary_links.html.erb create mode 100644 app/views/wiki_pages/_sidebar.html.erb diff --git a/app/controllers/uploads_controller.rb b/app/controllers/uploads_controller.rb index 45fe8edad..be15dc4b3 100644 --- a/app/controllers/uploads_controller.rb +++ b/app/controllers/uploads_controller.rb @@ -1,6 +1,6 @@ class UploadsController < ApplicationController before_filter :member_only - respond_to :html, :xml, :json + respond_to :html, :xml, :json, :js def new @upload = Upload.new(:rating => "q") diff --git a/app/controllers/wiki_pages_controller.rb b/app/controllers/wiki_pages_controller.rb index 3d40fdcc9..2f589fbe9 100644 --- a/app/controllers/wiki_pages_controller.rb +++ b/app/controllers/wiki_pages_controller.rb @@ -16,6 +16,13 @@ class WikiPagesController < ApplicationController def index @search = WikiPage.search(params[:search]) @wiki_pages = @search.paginate(:page => params[:page]) + respond_with(@wiki_pages) do |format| + format.html do + if @wiki_pages.count == 1 + redirect_to(wiki_page_path(@wiki_pages.first)) + end + end + end end def show diff --git a/app/models/post.rb b/app/models/post.rb index 3481c175b..488182fdb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -640,8 +640,10 @@ class Post < ActiveRecord::Base if can_be_voted_by?(CurrentUser.user) if score == "up" increment!(:score) + increment!(:up_score) elsif score == "down" decrement!(:score) + decrement!(:down_score) end votes.create(:score => score) diff --git a/app/models/tag.rb b/app/models/tag.rb index 503057af9..b4511a6a1 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -2,7 +2,8 @@ class Tag < ActiveRecord::Base attr_accessible :category after_save :update_category_cache has_one :wiki_page, :foreign_key => "name", :primary_key => "title" - scope :by_pattern, lambda {|name| where(["name LIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])} + scope :name_matches, lambda {|name| where(["name LIKE ? ESCAPE E'\\\\'", name.to_escaped_for_sql_like])} + search_method :name_matches class CategoryMapping Danbooru.config.reverse_tag_category_mapping.each do |value, category| @@ -71,7 +72,7 @@ class Tag < ActiveRecord::Base module NameMethods module ClassMethods def normalize_name(name) - name.downcase.tr(" ", "_").gsub(/\A[-~*]+/, "") + name.downcase.tr(" ", "_").gsub(/\A[-~]+/, "") end def find_or_create_by_name(name, options = {}) diff --git a/app/models/user_mailer.rb b/app/models/user_mailer.rb index 1f464f845..a85855731 100644 --- a/app/models/user_mailer.rb +++ b/app/models/user_mailer.rb @@ -1,22 +1,6 @@ class UserMailer < ActionMailer::Base default :host => Danbooru.config.server_host, :from => Danbooru.config.contact_email, :content_type => "text/html" - def password_reset(user, new_password) - @user = user - @new_password = new_password - mail(:to => @user.email, :subject => "#{Danbooru.config.app_name} - Password Reset") - end - - def name_reminder(user) - @user = user - mail(:to => user.email, :subject => "#{Danbooru.config.app_name} - Name Reminder") - end - - def deletion(user) - @user = user - mail(:to => user.email, :subject => "#{}") - end - def dmail_notice(dmail) @dmail = dmail mail(:to => dmail.to.email, :subject => "#{Danbooru.config.app_name} - Message received from #{dmail.from.name}") diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index b3396a105..f83978ec4 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -5,8 +5,10 @@ class WikiPage < ActiveRecord::Base belongs_to :creator, :class_name => "User" validates_uniqueness_of :title, :case_sensitive => false validates_presence_of :body - attr_accessible :title, :body + validate :validate_locker_is_janitor + attr_accessible :title, :body, :is_locked scope :titled, lambda {|title| where(["title = ?", title.downcase.tr(" ", "_")])} + scope :recent, order("updated_at DESC").limit(25) has_one :tag, :foreign_key => "name", :primary_key => "title" has_one :artist, :foreign_key => "name", :primary_key => "title" has_many :versions, :class_name => "WikiPageVersion", :dependent => :destroy, :order => "wiki_page_versions.id ASC" @@ -29,6 +31,13 @@ class WikiPage < ActiveRecord::Base titled(title).select("title, id").first end + def validate_locker_is_janitor + if is_locked_changed? && !CurrentUser.is_janitor? + errors.add(:is_locked, "can be modified by janitors only") + return false + end + end + def revert_to(version) self.title = version.title self.body = version.body diff --git a/app/views/admin/tags/edit.html.erb b/app/views/admin/tags/edit.html.erb new file mode 100644 index 000000000..17f42b5b8 --- /dev/null +++ b/app/views/admin/tags/edit.html.erb @@ -0,0 +1,10 @@ +<% form_tag({:action => "mass_edit"}, :onsubmit => "return confirm('Are you sure you wish to perform this tag edit?')") do %> + <%= text_field_tag "start", params[:source], :size => 60 %> + <%= text_field_tag "result", params[:name], :size => 60 %> + <%= button_to_function "Preview", "$('preview').innerHTML = 'Loading...'; new Ajax.Updater('preview', '#{url_for(:controller=>"tag",:action=>"edit_preview")}', {method: 'get', parameters: 'tags=' + $F('start')})" %><%= submit_tag "Save" %> +<% end %> + +<%= render :partial => "footer" %> + +
+
diff --git a/app/views/layouts/default.html.erb b/app/views/layouts/default.html.erb index 5b3d94866..8d15208d1 100644 --- a/app/views/layouts/default.html.erb +++ b/app/views/layouts/default.html.erb @@ -36,7 +36,7 @@ <%= nav_link_to("Artists", artists_path(:order => "date")) %> <%= nav_link_to("Tags", tags_path(:order => "date")) %> <%= nav_link_to("Pools", pools_path) %> - <%= nav_link_to("Wiki", wiki_page_path(:id => "help:home")) %> + <%= nav_link_to("Wiki", wiki_pages_path(:search => {:title_equals => "help:home"})) %> <%= nav_link_to("Forum", forum_topics_path, :class => (CurrentUser.user.has_forum_been_updated? ? "forum-updated" : nil)) %> <%= nav_link_to("»".html_safe, site_map_path) %> diff --git a/app/views/note_versions/index.html.erb b/app/views/note_versions/index.html.erb index e69de29bb..9eb9e689d 100644 --- a/app/views/note_versions/index.html.erb +++ b/app/views/note_versions/index.html.erb @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + <% @notes.each do |note| %> + + + + + + + + + + + <% end %> + +
PostNoteBodyIP AddressEdited ByDateOptions
<%= link_to note.post_id, :controller => "post", :action => "show", :id => note.post_id %><%= link_to "#{note.note_id}.#{note.version}", :controller => "note", :action => "history", :id => note.note_id %><%= h(note.body) %> <% unless note.is_active? %>(deleted)<% end %> + <% if @current_user.is_admin? %> + <%= note.ip_addr %> + <% end %> + <%= link_to h(note.author), :controller => "user", :action => "show", :id => note.user_id %><%= note.updated_at.strftime("%Y-%m-%d %H:%M") %><%= link_to "Revert", {:controller => "note", :action => "revert", :id => note.note_id, :version => note.version}, :method => :post, :confirm => "Do you really wish to revert to this note?" %>
+ +
+ <%= will_paginate(@notes) %> +
+ +<%= render :partial => "footer" %> diff --git a/app/views/notes/_secondary_links.html.erb b/app/views/notes/_secondary_links.html.erb new file mode 100644 index 000000000..bee0b6b39 --- /dev/null +++ b/app/views/notes/_secondary_links.html.erb @@ -0,0 +1,7 @@ +<% content_for("subnavbar") do %> +
  • <%= link_to "List", :action => "index" %>
  • +
  • <%= link_to "Search", :action => "search" %>
  • +
  • <%= link_to "History", :action => "history" %>
  • +
  • <%= link_to "Requests", :controller => "post", :action => "index", :tags => "translation_request" %>
  • +
  • <%= link_to "Help", :controller => "help", :action => "notes" %>
  • +<% end %> diff --git a/app/views/notes/index.html.erb b/app/views/notes/index.html.erb index e69de29bb..5e795143f 100644 --- a/app/views/notes/index.html.erb +++ b/app/views/notes/index.html.erb @@ -0,0 +1,9 @@ +
    + <%= render :partial => "post/posts", :locals => {:posts => @posts} %> + +
    + <%= will_paginate(@posts) %> +
    + + <%= render :partial => "footer" %> +
    diff --git a/app/views/pool_versions/index.html.erb b/app/views/pool_versions/index.html.erb index e69de29bb..69596bcce 100644 --- a/app/views/pool_versions/index.html.erb +++ b/app/views/pool_versions/index.html.erb @@ -0,0 +1,47 @@ +
    +

    Pool History: <%= h(@pool.pretty_name) %>

    + + + + + + + + + + + + + <% @updates.each_with_index do |update, i| %> + + + + + + + + + <% end %> + +
    Post CountChangesUpdaterIP AddressDate
    <%= link_to update.post_count, :action => "show_historical", :id => update.id %><%= pool_update_diff(@updates, i) %><%= link_to update.updater_name, :controller => "user", :action => "show", :id => update.user_id %> + <% if @current_user.is_admin? %> + <%= h update.ip_addr %> + <% end %> + <%= update.created_at.strftime("%Y-%m-%d %H:%M") %><%= link_to "Revert", :action => "revert", :id => update.id %>
    +
    + +
    + <%= will_paginate(@updates) %> +
    + +<% content_for("footer") do %> +
  • |
  • +
  • <%= link_to "Show", :action => "show", :id => params[:id] %>
  • +
  • <%= link_to "Edit", :action => "update", :id => params[:id] %>
  • +
  • <%= link_to "Delete", :action => "destroy", :id => params[:id] %>
  • +
  • <%= link_to "Order", :action => "order", :id => params[:id] %>
  • +
  • <%= link_to "Import", :action => "import", :id => params[:id] %>
  • +
  • <%= link_to "History", :action => "history", :id => params[:id] %>
  • +<% end %> + +<%= render :partial => "footer" %> diff --git a/app/views/post_moderation/moderate.html.erb b/app/views/post_moderation/moderate.html.erb index e69de29bb..34603cafa 100644 --- a/app/views/post_moderation/moderate.html.erb +++ b/app/views/post_moderation/moderate.html.erb @@ -0,0 +1,56 @@ +
    + <%= text_field_tag "query", params[:query], :size => 40 %> + <%= submit_tag "Search" %> +
    + + + +
    +

    Moderation Queue

    + +
    +

    Deletion Guidelines

    +

    As a general rule, you should not delete posts. Only approve of posts that you personally like. Posts that are not approved in three days will be automatically deleted. Posts with score -3 or lower are marked red. Posts with score 3 or higher are marked green. Posts tagged as duplicate are marked yellow. <% if params[:hidden] %>Click <%= fast_link_to "here", :action => "moderate", :query => params[:query], :hidden => nil %> to view all posts.<% else %>Click <%= fast_link_to "here", :action => "moderate", :query => params[:query], :hidden => true %> to view hidden posts.<% end %>

    + +

    Mass update: <%= link_to_function "Approve all", "if (confirm('This will approve every pending post on this page. Continue?')) {Post.mass_moderate('Approve')}" %> | <%= link_to_function "Hide all", "if (confirm('This will hide every pending post on this page. Continue?')) {Post.mass_moderate('Hide')}" %>

    +
    + + + + <% @posts.each do |p| %> + + + + + <% end %> + +
    <%= fast_link_to image_tag(p.preview_url, :class => (p.status == "flagged" ? "flagged" : nil), :width => p.preview_dimensions[0], :height => p.preview_dimensions[1]), {:controller => "post", :action => "show", :id => p.id}, :target => "_blank" %> +
      +
    • + <%= link_to_function "Approve", "Post.moderate(#{p.id}, 'Approve')" %> | + <% if @current_user.is_janitor_or_higher? %> + <%= link_to_function "Delete", "Post.moderate(#{p.id}, 'Delete')" %> | + <% end %> + <%= link_to_function "Hide", "Post.moderate(#{p.id}, 'Hide')" %> +
    • +
    • Rating: <%= p.pretty_rating %>
    • +
    • Hidden: <%= p.mod_hidden_count %>
    • + <% if p.pools.any? %> +
    • Pools: <%= h p.pools.map {|x| x.pretty_name}.join(", ") %>
    • + <% end %> + <% if p.parent_id %> +
    • Parent: <%= fast_link_to p.parent_id, :action => "moderate", :query => "parent:#{p.parent_id}" %>
    • + <% end %> +
    • Tags: <%= h p.cached_tags %>
    • +
    • Score: <%= p.score %> (vote <%= link_to_function "down", "Post.vote(-1, #{p.id})" %>)
    • + <% if p.flag_detail && p.flag_detail.reason %> +
    • Flagged: <%= h p.flag_detail.reason %>
    • + <% end %> +
    • Uploaded by <%= fast_link_to h(p.author), :controller => "user", :action => "show", :id => p.user_id %> <%= time_ago_in_words(p.created_at) %> ago (<%= fast_link_to "mod", :action => "moderate", :query => "user:#{p.author}" %>)
    • +
    +
    +
    + +<%= render :partial => "footer" %> diff --git a/app/views/post_versions/index.html.erb b/app/views/post_versions/index.html.erb index ea839b845..25d1359cc 100644 --- a/app/views/post_versions/index.html.erb +++ b/app/views/post_versions/index.html.erb @@ -1,21 +1,67 @@ -
    -
    -

    Post Versions

    - - +
    +
    +
    +
    + +
    +
    + <% form_tag({:action => "index"}, :method => :get) do %> + <%= text_field_tag "user_name", params[:user_name], :id => "user_name", :size => 20 %> <%= submit_tag "Search" %> + <% end %> +
    +
    +
    +
    + +
    +
    + <% form_tag({:action => "index"}, :method => :get) do %> + <%= text_field_tag "post_id", params[:post_id], :id => "post_id", :size => 10 %> <%= submit_tag "Search" %> + <% end %> +
    +
    +
    +
    +
    - - - + + + + + + + + + + + + + - <% @post_versions.each do |post_version| %> - - - - + <% @change_list.each do |change| %> + + + + + + + + + <% end %> @@ -23,3 +69,13 @@ + + +
    + <%= tag_history_pagination_links(@changes) %> +
    diff --git a/app/views/report/common.html.erb b/app/views/report/common.html.erb new file mode 100644 index 000000000..fe7889d59 --- /dev/null +++ b/app/views/report/common.html.erb @@ -0,0 +1,66 @@ +

    Report: <%= @report_title %>

    + +
    +
    + <% form_tag({:action => params[:action]}, :method => :get) do %> +
    DateUpdaterChangesPostDateUserRatingParentIP AddressTags
    + <%= button_to_function "Undo", "PostTagHistory.undo()", :id => "undo" %> + <%= button_to_function "Revert to", "PostTagHistory.revert()", :id => "revert" %> +
    <%= time_ago_in_words post_version.updated_at %><%= post_version.presenter.updater_name %><%= post_version.presenter.changes %>
    <%= link_to change[:change].post_id, :controller => "post", :action => "show", :id => change[:change].post_id %><%= change[:change].created_at.strftime("%Y-%m-%d %H:%M") %><%= link_to change[:change].author, :controller => "user", :action => "show", :id => change[:change].user_id %><%= change[:change].rating %><%= change[:parent_id] %> + <% if @current_user.is_admin? %> + <%= change[:ip_addr] %> + <% end %> + + <%= tag_list(change[:added_tags], :obsolete => change[:obsolete_added_tags], :prefix => "+") %> + <%= tag_list(change[:removed_tags], :obsolete=>change[:obsolete_removed_tags], :prefix=>"-") %> + <%= tag_list(change[:unchanged_tags], :prefix => "") %> +
    + + + + + + + + + + + + + + + + + + + + + + + +
    <%= submit_tag "Search" %>
    <%= text_field_tag "start_date", @start_date, :size => 10 %>
    <%= text_field_tag "end_date", @end_date, :size => 10 %>
    <%= text_field_tag "limit", @limit, :size => 5 %>
    <%= user_level_select_tag "level", :include_blank => true %>
    + <% end %> +
    + +
    + + + + + + + + + + + + + + + <% @users.each do |user| %> + + + + + + <% end %> + +
    UserChangesPercentage
    Total<%= @users[0]["sum"].to_i %>
    <%= link_to_unless user["id"].nil?, h(user["name"]), :controller => "user", :action => "show", :id => user["id"] %><%= link_to_unless user["id"].nil?, user["change_count"], @change_params.call(user["id"]) %><%= number_to_percentage 100 * user["change_count"] / user["sum"], :precision => 1 %>
    +
    +
    + +<% content_for("subnavbar") do %> +
  • <%= link_to "Tags", :action => "tag_updates", :start_date => @start_date, :end_date => @end_date %>
  • +
  • <%= link_to "Notes", :action => "note_updates", :start_date => @start_date, :end_date => @end_date %>
  • +
  • <%= link_to "Wiki", :action => "wiki_updates", :start_date => @start_date, :end_date => @end_date %>
  • +
  • <%= link_to "Uploads", :action => "post_uploads", :start_date => @start_date, :end_date => @end_date %>
  • +<% end %> diff --git a/app/views/report/tag_history.html.erb b/app/views/report/tag_history.html.erb new file mode 100644 index 000000000..6fe89e644 --- /dev/null +++ b/app/views/report/tag_history.html.erb @@ -0,0 +1,40 @@ + + +<% form_tag({:action => "tag_history"}, :method => :get) do %> + + + + + + + + + + + + + + + + + + +
    Tags<%= text_field_tag "tag", params[:tag], :size => 50 %>
    Start Date<%= text_field_tag "start_date", @start_date %>
    End Date<%= text_field_tag "end_date", @end_date %>
    <%= submit_tag "Search" %>
    +<% end %> + +
    + +<% if @counts %> + +<% end %> \ No newline at end of file diff --git a/app/views/report_mailer/moderator_report.html.erb b/app/views/report_mailer/moderator_report.html.erb new file mode 100644 index 000000000..7ac165a4e --- /dev/null +++ b/app/views/report_mailer/moderator_report.html.erb @@ -0,0 +1,30 @@ +

    Moderator Report For <%= Date.today %>

    + +
    + + + + + + + + + + + + + + <% User.find(:all, :conditions => ["level >= ?", CONFIG["user_levels"]["Test Janitor"]], :order => "level, name").each do |user| %> + + + + + + + + + + <% end %> + +
    NameLevelAppr 1Appr 7Appr 14CommForum
    <%= h user.name %><%= h user.pretty_level %><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 1.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 1.days.ago]) %><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 7.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 7.days.ago]) %><%= Post.count(:conditions => ["created_at >= ? AND approver_id = ?", 14.days.ago, user.id]) %>/<%= Post.count(:conditions => ["created_at >= ? AND (approver_id IS NOT NULL OR status = 'pending')", 14.days.ago]) %><%= Comment.count(:conditions => ["created_at >= ? AND user_id = ?", 7.days.ago, user.id]) %><%= ForumPost.count(:conditions => ["created_at >= ? AND creator_id = ?", 7.days.ago, user.id]) %>
    +
    diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 5e85716a6..3874c1374 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -3,6 +3,7 @@

    Sign In

    <%= form_tag(session_path) do %> + <%= hidden_field_tag "url", params[:url] %> diff --git a/app/views/static/500.html.erb b/app/views/static/500.html.erb new file mode 100644 index 000000000..a6d96744c --- /dev/null +++ b/app/views/static/500.html.erb @@ -0,0 +1,7 @@ +

    <%= @ex.class.to_s %> exception raised

    + diff --git a/app/views/static/overloaded.html.erb b/app/views/static/overloaded.html.erb new file mode 100644 index 000000000..487eaa802 --- /dev/null +++ b/app/views/static/overloaded.html.erb @@ -0,0 +1,11 @@ +
    + <%= print_advertisement("horizontal") %> + +
    +

    “No one else could gain admittance here, because this entrance was meant solely for you. I am now going to shut it.”

    +
    + +

    You have to login to view this page.

    +

    You can create a free basic account.

    +

    Learn more about accounts.

    +
    diff --git a/app/views/static/terms_of_service.html.erb b/app/views/static/terms_of_service.html.erb new file mode 100644 index 000000000..a8231eb21 --- /dev/null +++ b/app/views/static/terms_of_service.html.erb @@ -0,0 +1,60 @@ +
    +
    +

    Terms of Service

    +

    By accessing the "<%= CONFIG["app_name"] %>" website ("Site") you agree to the following terms of service. If you do not agree to these terms, then please do not access the Site.

    + +
      +
    • The Site reserves the right to change these terms at any time.
    • +
    • If you are a minor, then you will not use the Site.
    • +
    • The Site is presented to you AS IS, without any warranty, express or implied. You will not hold the Site or its staff members liable for damages caused by the use of the site.
    • +
    • The Site reserves the right to delete or modify your account, or any content you have posted to the site.
    • +
    • You will make a best faith effort to upload only high quality anime-related images.
    • +
    • You have read the <%= link_to "tagging guidelines", :controller => "help", :action => "tags" %>.
    • +
    + +
    +
    Post/Comment Limiting
    +

    You cannot upload a post or comment during the first week of signing up.

    +

    After the initial period, you can post up to one comment an hour and a variable number of posts based on how many of your previous uploads were approved or deleted.

    +
    + +
    +
    Prohibited Content
    +

    In addition, you may not use the Site to upload any of the following:

    +
      +
    • Non-anime: Photographs of American porn actresses, for example, are prohibited. Photographs of cosplayers, figures, or prominent figures in the industry are acceptable.
    • +
    • Furry: Any image or movie where a person's skin is made of fur or scales.
    • +
    • Watermarked: Any image where a person who is not the original copyright owner has placed a watermark on the image.
    • +
    • Poorly compressed: Any image where compression artifacts are easily visible.
    • +
    • Grotesque: Any depiction of extreme mutilation, extreme bodily distension, feces, or bodies that are far outside the realm of normal human proportion (for example, breasts or penises that are larger than two heads in size).
    • +
    • Manga: Uploading entire manga or doujinshi chapters is discouraged. Individual pages can be uploaded if they meet the quality criterion.
    • +
    • Nude Filter: Images that have been edited by someone other than the original creator to remove clothing or censorship. These typically feature crude drawings of breasts or genitalia laid on top of the original image.
    • +
    +
    +
    + +
    +

    Copyright Infringement

    + +

    If you believe a post infringes upon your copyright, please send an email to the <%= mail_to CONFIG["admin_contact"], "webmaster", :encode => "hex" %> with the following pieces of information:

    +
      +
    • The URL of the infringing post.
    • +
    • Proof that you own the copyright.
    • +
    • An email address that will be provided to the person who uploaded the infringing post to facilitate communication.
    • +
    +
    + +
    +

    Privacy Policy

    + +

    The Site will not disclose the IP address, email address, password, or DMails of any user except to the staff.

    +

    The Site is allowed to make public everything else, including but not limited to: uploaded posts, favorited posts, comments, forum posts, wiki edits, and note edits.

    +
    + +
    +

    Agreement

    +

    By clicking on the "I Agree" link, you have read all the terms and have agreed to them.

    +

    <%= link_to("I Agree", params[:url] || "/", :onclick => "Cookie.put('tos', '1')") %> | <%= link_to("Cancel", "/") %>

    +
    +
    + diff --git a/app/views/tag_aliases/index.html.erb b/app/views/tag_aliases/index.html.erb index e69de29bb..7bcd92515 100644 --- a/app/views/tag_aliases/index.html.erb +++ b/app/views/tag_aliases/index.html.erb @@ -0,0 +1,92 @@ +
    + <% form_tag({:action => "index"}, :method => :get) do %> + <%= text_field_tag "query", params[:query] %> + <%= submit_tag "Search Aliases" %> + <%= submit_tag "Search Implications" %> + <% end %> +
    + +
    + <% form_tag(:action => "update") do %> +
    + + + + + + + + + + + + + + + <% @aliases.each do |a| %> + + + + + + + <% end %> + +
    AliasToReason
    + <% 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()" %> + <%= submit_tag "Fix" %> + <%= button_to_function "Add", "$('add-box').show().scrollTo(); $('tag_alias_name').focus()" %> + + + <% end %> + +
    ><%= link_to h(a.name), :controller => "post", :action => "index", :tags => a.name %> (<%= Tag.find_by_name(a.name).post_count rescue 0 %>)<%= link_to h(a.alias_name), :controller => "post", :action => "index", :tags => a.alias_name %> (<%= Tag.find(a.alias_id).post_count rescue 0 %>)<%= format_text(a.reason) %>
    + <% end %> + + +<% if @current_user.is_admin_or_higher? %> +
    style="display: none;"<% end %>> + <% form_tag(:action => "create") do %> +

    Add Alias

    + + <% unless @current_user.is_anonymous? %> + <%= hidden_field_tag "tag_alias[creator_id]", @current_user.id %> + <% end %> + + + + + + + + + + + + + + + + + +
    <%= text_field "tag_alias", "name", :size => 40, :value => params[:from_name] %>
    <%= text_field "tag_alias", "alias", :size => 40, :value => params[:to_name] %>
    <%= text_area "tag_alias", "reason", :size => "40x2", :value => params[:reason] %>
    <%= submit_tag "Submit" %>
    + <% end %> +
    +<% end %> + +
    + <%= will_paginate(@aliases) %> +
    + +<% content_for("subnavbar") do %> +
  • <%= link_to "List", :controller => "tag_alias", :action => "index" %>
  • +
  • <%= link_to "Add", :controller => "tag_alias", :action => "new" %>
  • +
  • <%= link_to "Help", :controller => "help", :action => "tag_aliases" %>
  • +<% end %> diff --git a/app/views/tag_aliases/new.html.erb b/app/views/tag_aliases/new.html.erb index e69de29bb..98d58afe5 100644 --- a/app/views/tag_aliases/new.html.erb +++ b/app/views/tag_aliases/new.html.erb @@ -0,0 +1,20 @@ +<% form_tag(:controller => "forum", :action => "create") do %> +

    You can create a forum thread to suggest the creation of an alias.

    + + + + + + + + + + + + + + + + +
    <%= text_field "tag_alias", "name", :size => 40 %>
    <%= text_field "tag_alias", "alias", :size => 40 %>
    <%= text_area "tag_alias", "reason", :rows => 10, :cols => 60 %>
    <%= submit_tag "Submit" %>
    +<% end %> diff --git a/app/views/tag_implications/index.html.erb b/app/views/tag_implications/index.html.erb index e69de29bb..9a6ada9c9 100644 --- a/app/views/tag_implications/index.html.erb +++ b/app/views/tag_implications/index.html.erb @@ -0,0 +1,95 @@ +
    + <% form_tag({:action => "index"}, :method => :get) do %> + <%= text_field_tag "query", params[:query] %> + <%= submit_tag "Search Implications" %> + <%= submit_tag "Search Aliases" %> + <% end %> +
    + +<% form_tag(:action => "update") do %> + + + + + + + + + + + + + + + + <% @implications.each do |i| %> + + + + + + + <% end %> + +
    PredicateConsequentReason
    + <% 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? %> + + <% end %> +
    ><%= link_to h(i.predicate.name), :controller => "post", :action => "index", :tags => i.predicate.name %> (<%= i.predicate.post_count %>)<%= link_to h(i.consequent.name), :controller => "post", :action => "index", :tags => i.consequent.name %> (<%= i.consequent.post_count %>)<%= h i.reason %>
    +<% end %> + +<% if @current_user.is_admin_or_higher? %> +
    style="display: none;"<% end %>> + <% form_tag(:action => "create") do %> +

    Add Implication

    + <% unless @current_user.is_anonymous? %> + <%= hidden_field_tag "tag_implication[creator_id]", @current_user.id %> + <% end %> + + + + + + + + + + + + + + + + + +
    <%= text_field "tag_implication", "predicate", :size => 40, :value => params[:from_name] %>
    <%= text_field "tag_implication", "consequent", :size => 40, :value => params[:to_name] %>
    <%= text_area "tag_implication", "reason", :size => "40x2", :value => params[:reason] %>
    <%= submit_tag "Submit" %>
    + <% end %> +
    +<% end %> + +
    + <%= will_paginate(@implications) %> +
    + +<% content_for("subnavbar") do %> +
  • <%= link_to "List", :controller => "tag_implication", :action => "index" %>
  • +
  • <%= link_to "Add", :controller => "tag_implication", :action => "new" %>
  • +
  • <%= link_to "Help", :controller => "help", :action => "tag_implications" %>
  • +<% end %> + diff --git a/app/views/tag_implications/new.html.erb b/app/views/tag_implications/new.html.erb index e69de29bb..557d522ec 100644 --- a/app/views/tag_implications/new.html.erb +++ b/app/views/tag_implications/new.html.erb @@ -0,0 +1,20 @@ +<% form_tag(:controller => "forum", :action => "create") do %> +

    You can create a forum thread to suggest the creation of an implication.

    + + + + + + + + + + + + + + + + +
    <%= text_field "tag_implication", "predicate", :size => 40 %>
    <%= text_field "tag_implication", "consequent", :size => 40 %>
    <%= text_area "tag_implication", "reason", :rows => 10, :cols => 60 %>
    <%= submit_tag "Submit" %>
    +<% end %> diff --git a/app/views/tag_subscriptions/index.html.erb b/app/views/tag_subscriptions/index.html.erb index e69de29bb..2d21bd9aa 100644 --- a/app/views/tag_subscriptions/index.html.erb +++ b/app/views/tag_subscriptions/index.html.erb @@ -0,0 +1,14 @@ +<% form_tag(:action => "update") do %> +

    Edit Tag Subscriptions

    +
    + You can only create up to <%= CONFIG["max_tag_subscriptions"] %> groups and each group can have up to 20 tags. +
    + + + <%= render :partial => "listing", :locals => {:tag_subscriptions => @tag_subscriptions} %> +
    +<% end %> + +<% content_for("subnavbar") do %> +
  • <%= link_to "Help", :controller => "help", :action => "tag_subscriptions" %>
  • +<% end %> diff --git a/app/views/tags/_search.html.erb b/app/views/tags/_search.html.erb new file mode 100644 index 000000000..029da5b57 --- /dev/null +++ b/app/views/tags/_search.html.erb @@ -0,0 +1,8 @@ +
    + <%= simple_form_for(@search) do |f| %> + <%= f.input :name_matches, :required => false, :label => "Name" %> + <%= f.input :category_equals, :required => false, :label => "Category" %> + <%= f.input :meta_sort, :collection => [["Name", "name.asc"], ["Count", "post_count.desc"], ["Date", "created_at.desc"]], :label => "Sort", :required => false %> + <%= f.button :submit, "Search" %> + <% end %> +
    diff --git a/app/views/tags/_secondary_links.html.erb b/app/views/tags/_secondary_links.html.erb new file mode 100644 index 000000000..5aa7011f9 --- /dev/null +++ b/app/views/tags/_secondary_links.html.erb @@ -0,0 +1,8 @@ +<% content_for(:secondary_links) do %> + +
  • <%= link_to "Listing", tags_path %>
  • +
  • <%= link_to "Aliases", tag_aliases_path %>
  • +
  • <%= link_to "Implications", tag_implications_path %>
  • +
  • <%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:tags"}) %>
  • +
    +<% end %> diff --git a/app/views/tags/edit.html.erb b/app/views/tags/edit.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb index e69de29bb..d1b92424a 100644 --- a/app/views/tags/index.html.erb +++ b/app/views/tags/index.html.erb @@ -0,0 +1,27 @@ +<%= render "search" %> + + + + + + + + + + <% @tags.each do |tag| %> + + + + + <% end %> + +
    CountName
    <%= tag.post_count %> + <%= link_to("?", wiki_pages_path(:search => {:title_equals => tag.name})) %> + <%= link_to(tag.name, posts_path(:tags => tag.name)) %> +
    + +
    + <%= will_paginate(@tags) %> +
    + +<%= render "secondary_links" %> diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb deleted file mode 100644 index e69de29bb..000000000 diff --git a/app/views/user_feedback/_secondary_links.html.erb b/app/views/user_feedback/_secondary_links.html.erb new file mode 100644 index 000000000..38ecc2771 --- /dev/null +++ b/app/views/user_feedback/_secondary_links.html.erb @@ -0,0 +1,7 @@ +<% if @user %> + <% content_for("subnavbar") do %> +
  • <%= link_to "Add", :action => "create", :user_id => @user.id %>
  • +
  • <%= link_to "List for user", :action => "index", :user_id => @user.id %>
  • +
  • <%= link_to "List for all", :action => "index", :user_id => nil %>
  • + <% end %> +<% end %> diff --git a/app/views/user_feedback/index.html.erb b/app/views/user_feedback/index.html.erb index e69de29bb..c4dfa2b96 100644 --- a/app/views/user_feedback/index.html.erb +++ b/app/views/user_feedback/index.html.erb @@ -0,0 +1,42 @@ +
    +

    Record

    + + + + + + + + + + + + + <% @user_records.each do |rec| %> + + + + + + + + <% end %> + +
    UserReporterWhenBody
    + <% if @user %> + <%= link_to h(rec.user.pretty_name), :controller => "user", :action => "show", :id => rec.user_id %> + <% else %> + <%= link_to h(rec.user.pretty_name), :action => "index", :user_id => rec.user_id %> + <% end %> + <%= h(rec.reporter.pretty_name) %><%= time_ago_in_words(rec.created_at) %> ago<%= format_text(rec.body) %> + <% if @current_user.is_mod_or_higher? || @current_user.id == rec.reported_by %> + <%= link_to_function "Delete", "UserRecord.destroy(#{rec.id})" %> + <% end %> +
    + +
    + <%= will_paginate(@user_records) %> +
    + + <%= render :partial => "footer" %> +
    diff --git a/app/views/user_feedback/new.html.erb b/app/views/user_feedback/new.html.erb index e69de29bb..725c7462a 100644 --- a/app/views/user_feedback/new.html.erb +++ b/app/views/user_feedback/new.html.erb @@ -0,0 +1,29 @@ +

    Add Record for <%= h(@user.pretty_name) %>

    + +
    +
    + +<% form_tag(:action => "create") do %> + <%= hidden_field_tag "user_id", @user.id %> + + + + + + + + + + + + + + + + +
    <%= check_box "user_record", "is_positive" %>
    <%= text_area "user_record", "body", :size => "20x8" %>
    + <%= submit_tag "Submit" %> + <%= submit_to_remote "preview", "Preview", :url => {:action => "preview"}, :update => "preview", :method => :get %> + <%= button_to_function "Cancel", "location.back()" %> +
    +<% end %> diff --git a/app/views/user_mailer/dmail.html.erb b/app/views/user_mailer/dmail_notice.html.erb similarity index 100% rename from app/views/user_mailer/dmail.html.erb rename to app/views/user_mailer/dmail_notice.html.erb diff --git a/app/views/user_maintenance/delete_account.html.erb b/app/views/user_maintenance/delete_account.html.erb deleted file mode 100644 index 26b761822..000000000 --- a/app/views/user_maintenance/delete_account.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -

    Delete My Account

    - -

    In order to maintain accountability, accounts cannot be deleted on this site. If you're worried about someone searching for your name, you can rename your account. But any existing dmail, forum post, comment, or post will still be attributed to you.

    - -

    Exceptions will be made for cases of extreme harassment. This harassment must have occurred on this site, whether through dmails, comments, or forum posts. Please send a dmail to an admin with details and evidence of harassment.

    diff --git a/app/views/wiki_page_versions/index.html.erb b/app/views/wiki_page_versions/index.html.erb index e69de29bb..6a543d2f1 100644 --- a/app/views/wiki_page_versions/index.html.erb +++ b/app/views/wiki_page_versions/index.html.erb @@ -0,0 +1,70 @@ +<%= render :partial => "sidebar" %> + +
    + <% form_tag({:action => "diff"}, :method => :get) do %> + <%= hidden_field_tag "title", params[:title] %> + + + + + + + + + + + + + + + + + <% @wiki_pages.each_with_index do |wiki_page, i| %> + + + + + + + <% end %> + +
    FromToIP AddressLast edited
    <%= submit_tag "Compare" %>
    <%= radio_button_tag "from", wiki_page.version, i==1, :id => "from_#{wiki_page.version}" %><%= radio_button_tag "to", wiki_page.version, i==0, :id => "to_#{wiki_page.version}" %> + <% if @current_user.is_admin? %> + <%= h wiki_page.ip_addr %> + <% end %> + <%= link_to wiki_page.updated_at.strftime("%m/%d/%Y %I:%M"), :action => "show", :title => wiki_page.title, :version => wiki_page.version %> by <%= link_to h(wiki_page.author), :controller => "user", :action => "show", :id => wiki_page.user_id %>
    + <% end %> + + +
    + + +<%= render :partial => "footer" %> diff --git a/app/views/wiki_pages/_form.html.erb b/app/views/wiki_pages/_form.html.erb new file mode 100644 index 000000000..7cda6e1ec --- /dev/null +++ b/app/views/wiki_pages/_form.html.erb @@ -0,0 +1,5 @@ +<%= f.input :title %> +<%= f.input :body %> +<% if CurrentUser. %> +<%= f.input :is_locked %> +<%= f.button :submit, "Save" %><%= f.button :submit, "Cancel" %><%= f.button :submit "Preview" %> diff --git a/app/views/wiki_pages/_recent_changes.html.erb b/app/views/wiki_pages/_recent_changes.html.erb new file mode 100644 index 000000000..43b2a154e --- /dev/null +++ b/app/views/wiki_pages/_recent_changes.html.erb @@ -0,0 +1,8 @@ +
    +

    Recent Changes (<%= link_to "all", wiki_pages_path(:meta_sort => "updated_at.desc") %>)

    +
      + <% WikiPage.recent.each do |page| %> +
    • <%= link_to page.pretty_title, wiki_page_path(page) %>
    • + <% end %> +
    +
    diff --git a/app/views/wiki_pages/_secondary_links.html.erb b/app/views/wiki_pages/_secondary_links.html.erb new file mode 100644 index 000000000..03e95b18a --- /dev/null +++ b/app/views/wiki_pages/_secondary_links.html.erb @@ -0,0 +1,16 @@ +<% content_for(:secondary_links) do %> + +
  • <%= link_to "Listing", wiki_pages_path %>
  • +
  • <%= link_to "New", new_wiki_page_path %>
  • +
  • <%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:wiki"}) %>
  • + <% if @wiki_page %> +
  • |
  • +
  • <%= link_to "Posts (#{Post.fast_count(@wiki_page.title)})", posts_path(:tags => @wiki_page.title) %>
  • +
  • <%= link_to "History", wiki_page_versions_path(:search => {:wiki_page_id_equals => @wiki_page.id}) %>
  • +
  • <%= link_to "Edit", edit_wiki_page_path(@wiki_page) %>
  • + <% if CurrentUser.is_moderator? %> +
  • <%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :confirm => "Do you want to delete this wiki page?" %>
  • + <% end %> + <% end %> +
    +<% end %> diff --git a/app/views/wiki_pages/_sidebar.html.erb b/app/views/wiki_pages/_sidebar.html.erb new file mode 100644 index 000000000..06b86cccb --- /dev/null +++ b/app/views/wiki_pages/_sidebar.html.erb @@ -0,0 +1,10 @@ + diff --git a/app/views/wiki_pages/edit.html.erb b/app/views/wiki_pages/edit.html.erb index e69de29bb..19031c7dd 100644 --- a/app/views/wiki_pages/edit.html.erb +++ b/app/views/wiki_pages/edit.html.erb @@ -0,0 +1,15 @@ +
    +
    + <%= render "sidebar" %> + +
    +

    <%= @wiki_page.pretty_title %> (Editing)

    + <%= simple_form_for(@wiki_page) do |f| %> + <%= render :partial => "form", :locals => {:f => f} %> + <% end %> +
    + + <%= render "secondary_links" %> +
    +
    + diff --git a/app/views/wiki_pages/index.html.erb b/app/views/wiki_pages/index.html.erb index e69de29bb..09a98d9ae 100644 --- a/app/views/wiki_pages/index.html.erb +++ b/app/views/wiki_pages/index.html.erb @@ -0,0 +1,26 @@ +
    +
    + <%= render :partial => "sidebar" %> + +
    + + + + + + <% @wiki_pages.each do |wiki_page| %> + + + + + <% end %> +
    TitleLast edited
    <%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :nordirect => 1) %><%= wiki_page.updated_at.strftime("%m/%d/%Y %I:%M") %> by <%= h wiki_page.creator.name %>
    + +
    + <%= will_paginate(@wiki_pages) %> +
    +
    +
    +
    + +<%= render "secondary_links" %> diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index e69de29bb..2c1ccccdb 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -0,0 +1,16 @@ +
    +
    + <%= render "sidebar" %> + +
    +
    +
    + + <%= simple_form_for(@wiki_page) do |f| %> + <%= render :partial => "form", :locals => {:f => f} %> + <% end %> +
    +
    +
    + +<%= render "secondary_links" %> diff --git a/app/views/wiki_pages/show.html.erb b/app/views/wiki_pages/show.html.erb index e69de29bb..a97054753 100644 --- a/app/views/wiki_pages/show.html.erb +++ b/app/views/wiki_pages/show.html.erb @@ -0,0 +1,57 @@ +
    +
    + <%= render "sidebar" %> + +
    +

    <%= @wiki_page.pretty_title %>

    + +
    + <%= format_text(@wiki_page.body) %> +
    + +
    + <%= @wiki_page.presenter.posts %> +
    +
    +
    +
    + +
    + <%= render :partial => "sidebar" %> + +

    <%= @presenter.html_title %>

    + +
    +
    + <%= @presenter.html_body(self) %> +
    + +
    + <%= @presenter.html_posts(self) %> +
    +
    + + <% content_for("footer") do %> +
  • |
  • + <% if @wiki_page.nil? %> +
  • <%= link_to "Posts (#{Post.fast_count(params[:title])})", :controller => "post", :action => "index", :tags => params[:title] %>
  • +
  • <%= link_to "Edit", :controller => "wiki", :action => "edit", :title => params[:title] %>
  • + <% else %> +
  • <%= link_to "Posts (#{Post.fast_count(params[:title])})", :controller => "post", :action => "index", :tags => @title %>
  • +
  • <%= link_to "History", :controller => "wiki", :action => "history", :title => @wiki_page.title %>
  • + <% if not @wiki_page.is_locked? %> +
  • <%= link_to "Edit", :controller => "wiki", :action => "edit", :title => @wiki_page.title, :version => @wiki_page.version %>
  • + <% end %> + <% if @wiki_page.is_locked? %> +
  • <%= link_to "Unlock", {:controller => "wiki", :action => "unlock", :title => @wiki_page.title}, :method => "post" %>
  • + <% else %> +
  • <%= link_to "Revert", {:controller => "wiki", :action => "revert", :title => @wiki_page.title, :version => @wiki_page.version}, :confirm => "Are you sure you want to revert to this page?", :method => :post %>
  • +
  • <%= link_to "Delete", {:controller => "wiki", :action => "destroy", :title => @wiki_page.title}, :confirm => "Are you sure you want to delete this page (and all versions)?", :method => :post %>
  • +
  • <%= link_to "Lock", {:controller => "wiki", :action => "lock", :title => @wiki_page.title}, :method => :post %>
  • +
  • <%= link_to "Rename", :action => "rename", :title => @wiki_page.title %>
  • + <% end %> + <% end %> + <% end %> + + <%= render :partial => "footer" %> +
    diff --git a/db/migrate/20100204214746_create_posts.rb b/db/migrate/20100204214746_create_posts.rb index bd409003d..3216bea02 100644 --- a/db/migrate/20100204214746_create_posts.rb +++ b/db/migrate/20100204214746_create_posts.rb @@ -3,6 +3,8 @@ class CreatePosts < ActiveRecord::Migration create_table :posts do |t| t.timestamps + t.column :up_score, :integer, :null => false, :default => 0 + t.column :down_score, :integer, :null => false, :default => 0 t.column :score, :integer, :null => false, :default => 0 t.column :source, :string t.column :md5, :string, :null => false diff --git a/test/unit/wiki_page_test.rb b/test/unit/wiki_page_test.rb index 487d00a76..25dd657da 100644 --- a/test/unit/wiki_page_test.rb +++ b/test/unit/wiki_page_test.rb @@ -2,9 +2,6 @@ require_relative '../test_helper' class WikiPageTest < ActiveSupport::TestCase setup do - user = Factory.create(:user) - CurrentUser.user = user - CurrentUser.ip_addr = "127.0.0.1" MEMCACHE.flush_all end @@ -14,50 +11,75 @@ class WikiPageTest < ActiveSupport::TestCase end context "A wiki page" do - should "normalize its title" do - wp = Factory.create(:wiki_page, :title => "HOT POTATO") - assert_equal("hot_potato", wp.title) + context "updated by a janitor" do + setup do + @user = Factory.create(:janitor_user) + CurrentUser.user = @user + CurrentUser.ip_addr = "127.0.0.1" + @wiki_page = Factory.create(:wiki_page) + end + + should "allow the is_locked attribute to be updated" do + @wiki_page.update_attributes(:is_locked => true) + @wiki_page.reload + assert_equal(true, @wiki_page.is_locked?) + end end - should "search by title" do - Factory.create(:wiki_page, :title => "HOT POTATO") - matches = WikiPage.titled("hot potato") - assert_equal(1, matches.count) - assert_equal("hot_potato", matches.first.title) - end - - should "create versions" do - wp = nil + context "updated by a regular user" do + setup do + @user = Factory.create(:user) + CurrentUser.user = @user + CurrentUser.ip_addr = "127.0.0.1" + @wiki_page = Factory.create(:wiki_page, :title => "HOT POTATO") + end - assert_difference("WikiPageVersion.count") do - wp = Factory.create(:wiki_page, :title => "xxx") + should "not allow the is_locked attribute to be updated" do + @wiki_page.update_attributes(:is_locked => true) + assert_equal(["Is locked can be modified by janitors only"], @wiki_page.errors.full_messages) + @wiki_page.reload + assert_equal(false, @wiki_page.is_locked?) + end + + should "normalize its title" do + assert_equal("hot_potato", @wiki_page.title) end - assert_difference("WikiPageVersion.count") do - wp.title = "yyy" - wp.save + should "search by title" do + matches = WikiPage.titled("hot potato") + assert_equal(1, matches.count) + assert_equal("hot_potato", matches.first.title) end - end - - should "revert to a prior version" do - wp = Factory.create(:wiki_page, :title => "xxx") - wp.title = "yyy" - wp.save - version = WikiPageVersion.first - wp.revert_to!(version) - wp.reload - assert_equal("xxx", wp.title) - end - - should "differentiate between updater and creator" do - user = Factory.create(:user) - wp = Factory.create(:wiki_page, :title => "xxx") - CurrentUser.scoped(user, "127.0.0.1") do - wp.title = "yyy" - wp.save + + should "create versions" do + assert_difference("WikiPageVersion.count") do + @wiki_page = Factory.create(:wiki_page, :title => "xxx") + end + + assert_difference("WikiPageVersion.count") do + @wiki_page.title = "yyy" + @wiki_page.save + end + end + + should "revert to a prior version" do + @wiki_page.title = "yyy" + @wiki_page.save + version = WikiPageVersion.first + @wiki_page.revert_to!(version) + @wiki_page.reload + assert_equal("hot_potato", @wiki_page.title) + end + + should "differentiate between updater and creator" do + another_user = Factory.create(:user) + CurrentUser.scoped(another_user, "127.0.0.1") do + @wiki_page.title = "yyy" + @wiki_page.save + end + version = WikiPageVersion.first + assert_not_equal(@wiki_page.creator_id, version.updater_id) end - version = WikiPageVersion.first - assert_not_equal(wp.creator_id, version.updater_id) end end end