stubbed in view code from old danbooru; only janitors can lock a wiki page

This commit is contained in:
albert
2011-02-28 14:18:39 -05:00
parent 6d0157265c
commit 9e7efbd295
47 changed files with 1124 additions and 79 deletions

View File

@@ -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")

View File

@@ -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

View File

@@ -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)

View File

@@ -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 = {})

View File

@@ -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}")

View File

@@ -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

View File

@@ -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" %>
<div id="preview">
</div>

View File

@@ -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("&raquo;".html_safe, site_map_path) %>
</menu>

View File

@@ -0,0 +1,38 @@
<table width="100%" class="row-highlight">
<thead>
<tr>
<th></th>
<th width="5%">Post</th>
<th width="5%">Note</th>
<th width="50%">Body</th>
<th width="10%">IP Address</th>
<th width="10%">Edited By</th>
<th width="10%">Date</th>
<th width="10%">Options</th>
</tr>
</thead>
<tbody>
<% @notes.each do |note| %>
<tr class="<%= cycle 'even', 'odd' %>">
<td style="background: <%= id_to_color(note.post_id) %>;"></td>
<td><%= link_to note.post_id, :controller => "post", :action => "show", :id => note.post_id %></td>
<td><%= link_to "#{note.note_id}.#{note.version}", :controller => "note", :action => "history", :id => note.note_id %></td>
<td><%= h(note.body) %> <% unless note.is_active? %>(deleted)<% end %></td>
<td>
<% if @current_user.is_admin? %>
<%= note.ip_addr %>
<% end %>
</td>
<td><%= link_to h(note.author), :controller => "user", :action => "show", :id => note.user_id %></td>
<td><%= note.updated_at.strftime("%Y-%m-%d %H:%M") %></td>
<td><%= 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?" %></td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= will_paginate(@notes) %>
</div>
<%= render :partial => "footer" %>

View File

@@ -0,0 +1,7 @@
<% content_for("subnavbar") do %>
<li><%= link_to "List", :action => "index" %></li>
<li><%= link_to "Search", :action => "search" %></li>
<li><%= link_to "History", :action => "history" %></li>
<li><%= link_to "Requests", :controller => "post", :action => "index", :tags => "translation_request" %></li>
<li><%= link_to "Help", :controller => "help", :action => "notes" %></li>
<% end %>

View File

@@ -0,0 +1,9 @@
<div id="note-list">
<%= render :partial => "post/posts", :locals => {:posts => @posts} %>
<div id="paginator">
<%= will_paginate(@posts) %>
</div>
<%= render :partial => "footer" %>
</div>

View File

@@ -0,0 +1,47 @@
<div id="pool-history">
<h4>Pool History: <%= h(@pool.pretty_name) %></h4>
<table width="100%" class="highlightable">
<thead>
<tr>
<th>Post Count</th>
<th>Changes</th>
<th>Updater</th>
<th>IP Address</th>
<th>Date</th>
<th></th>
</tr>
</thead>
<tbody>
<% @updates.each_with_index do |update, i| %>
<tr class="<%= cycle 'even', 'odd' %>">
<td><%= link_to update.post_count, :action => "show_historical", :id => update.id %></td>
<td><%= pool_update_diff(@updates, i) %></td>
<td><%= link_to update.updater_name, :controller => "user", :action => "show", :id => update.user_id %></td>
<td>
<% if @current_user.is_admin? %>
<%= h update.ip_addr %>
<% end %>
</td>
<td><%= update.created_at.strftime("%Y-%m-%d %H:%M") %></td>
<td><%= link_to "Revert", :action => "revert", :id => update.id %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
<div id="paginator">
<%= will_paginate(@updates) %>
</div>
<% content_for("footer") do %>
<li>|</li>
<li><%= link_to "Show", :action => "show", :id => params[:id] %></li>
<li><%= link_to "Edit", :action => "update", :id => params[:id] %></li>
<li><%= link_to "Delete", :action => "destroy", :id => params[:id] %></li>
<li><%= link_to "Order", :action => "order", :id => params[:id] %></li>
<li><%= link_to "Import", :action => "import", :id => params[:id] %></li>
<li><%= link_to "History", :action => "history", :id => params[:id] %></li>
<% end %>
<%= render :partial => "footer" %>

View File

@@ -0,0 +1,56 @@
<form method="get" action="/post/moderate">
<%= text_field_tag "query", params[:query], :size => 40 %>
<%= submit_tag "Search" %>
</form>
<script type="text/javascript" charset="utf-8">
Post.mod_queue = $A(<%= @posts.map(&:id).to_json %>)
</script>
<div style="margin-bottom: 2em;">
<h2>Moderation Queue</h2>
<div style="margin: 1em 0;">
<h4>Deletion Guidelines</h4>
<p>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 %></p>
<p>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')}" %></p>
</div>
<table width="100%">
<tbody>
<% @posts.each do |p| %>
<tr id="mod-row-<%= p.id %>" class="<% if p.cached_tags =~ /(^| )duplicate($| )/ %>dupe<% elsif p.score > 2 %>good<% elsif p.score < -2 %>bad<% else %><%= cycle 'even', 'odd' %><% end %>">
<td width="10%"><%= 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" %></td>
<td width="90%">
<ul>
<li>
<%= 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')" %>
</li>
<li>Rating: <%= p.pretty_rating %></li>
<li>Hidden: <%= p.mod_hidden_count %></li>
<% if p.pools.any? %>
<li>Pools: <%= h p.pools.map {|x| x.pretty_name}.join(", ") %></li>
<% end %>
<% if p.parent_id %>
<li>Parent: <%= fast_link_to p.parent_id, :action => "moderate", :query => "parent:#{p.parent_id}" %></li>
<% end %>
<li>Tags: <%= h p.cached_tags %></li>
<li>Score: <span id="post-score-<%= p.id %>"><%= p.score %></span> (vote <%= link_to_function "down", "Post.vote(-1, #{p.id})" %>)</li>
<% if p.flag_detail && p.flag_detail.reason %>
<li>Flagged: <%= h p.flag_detail.reason %></li>
<% end %>
<li>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}" %>)</li>
</ul>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
<%= render :partial => "footer" %>

View File

@@ -1,21 +1,67 @@
<div class="post_versions">
<div class="index">
<h1>Post Versions</h1>
<table class="striped">
<div>
<div style="margin-bottom: 1em;">
<div class="history-search-row">
<div class="history-search-label">
<label for="user_name">User</label>
</div>
<div>
<% form_tag({:action => "index"}, :method => :get) do %>
<%= text_field_tag "user_name", params[:user_name], :id => "user_name", :size => 20 %> <%= submit_tag "Search" %>
<% end %>
</div>
</div>
<div class="history-search-row">
<div class="history-search-label">
<label for="post_id">Post ID</label>
</div>
<div>
<% form_tag({:action => "index"}, :method => :get) do %>
<%= text_field_tag "post_id", params[:post_id], :id => "post_id", :size => 10 %> <%= submit_tag "Search" %>
<% end %>
</div>
</div>
</div>
<div style="clear: left;">
<table width="100%" class="highlightable" id="history">
<thead>
<tr>
<th>Date</th>
<th>Updater</th>
<th>Changes</th>
<th width="1%"></th>
<th width="4%">Post</th>
<th width="15%">Date</th>
<th width="10%">User</th>
<th width="5%">Rating</th>
<th width="5%">Parent</th>
<th width="10%">IP Address</th>
<th width="50%">Tags</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="8">
<%= button_to_function "Undo", "PostTagHistory.undo()", :id => "undo" %>
<%= button_to_function "Revert to", "PostTagHistory.revert()", :id => "revert" %>
</td>
</tr>
</tfoot>
<tbody>
<% @post_versions.each do |post_version| %>
<tr>
<td><%= time_ago_in_words post_version.updated_at %></td>
<td><%= post_version.presenter.updater_name %></td>
<td><%= post_version.presenter.changes %></td>
<% @change_list.each do |change| %>
<tr class="<%= cycle 'even', 'odd' %>" id="r<%= change[:change].id %>" >
<td style="background: <%= id_to_color(change[:change].post_id) %>;"></td>
<td><%= link_to change[:change].post_id, :controller => "post", :action => "show", :id => change[:change].post_id %></td>
<td><%= change[:change].created_at.strftime("%Y-%m-%d %H:%M") %></td>
<td><%= link_to change[:change].author, :controller => "user", :action => "show", :id => change[:change].user_id %></td>
<td><%= change[:change].rating %></td>
<td><%= change[:parent_id] %></td>
<td>
<% if @current_user.is_admin? %>
<%= change[:ip_addr] %>
<% end %>
</td>
<td>
<span class="added-tags"><%= tag_list(change[:added_tags], :obsolete => change[:obsolete_added_tags], :prefix => "+") %></span>
<span class="removed-tags"><%= tag_list(change[:removed_tags], :obsolete=>change[:obsolete_removed_tags], :prefix=>"-") %></span>
<span class="unchanged-tags"><%= tag_list(change[:unchanged_tags], :prefix => "") %></span>
</td>
</tr>
<% end %>
</tbody>
@@ -23,3 +69,13 @@
</div>
</div>
<script type="text/javascript">
<% @change_list.each do |change| %>
PostTagHistory.add_change(<%= change[:change].id %>, <%= change[:change].post_id %>, '<%= escape_javascript(change[:change].author) %>')
<% end %>
PostTagHistory.init()
</script>
<div id="paginator">
<%= tag_history_pagination_links(@changes) %>
</div>

View File

@@ -0,0 +1,66 @@
<h4>Report: <%= @report_title %></h4>
<div>
<div style="margin-bottom: 1em;">
<% form_tag({:action => params[:action]}, :method => :get) do %>
<table width="100%">
<tfoot>
<tr>
<td colspan="2"><%= submit_tag "Search" %></td>
</tr>
</tfoot>
<tbody>
<tr>
<th width="15%"><label for="start_date">Start Date</label></th>
<td width="85%"><%= text_field_tag "start_date", @start_date, :size => 10 %></td>
</tr>
<tr>
<th><label for="end_date">End Date</label></th>
<td><%= text_field_tag "end_date", @end_date, :size => 10 %></td>
</tr>
<tr>
<th><label for="limit">Limit</label></th>
<td><%= text_field_tag "limit", @limit, :size => 5 %></td>
</tr>
<tr>
<td><label for="level">Level</label></td>
<td><%= user_level_select_tag "level", :include_blank => true %></td>
</tr>
</tbody>
</table>
<% end %>
</div>
<div>
<table width="100%" class="highlightable">
<thead>
<tr>
<th width="15%">User</th>
<th width="10%">Changes</th>
<th width="75%">Percentage</th>
</tr>
</thead>
<tfoot>
<td>Total</td>
<td><%= @users[0]["sum"].to_i %></td>
<td></td>
</tfoot>
<tbody>
<% @users.each do |user| %>
<tr class="<%= cycle 'even', 'odd' %>">
<td><%= link_to_unless user["id"].nil?, h(user["name"]), :controller => "user", :action => "show", :id => user["id"] %></td>
<td><%= link_to_unless user["id"].nil?, user["change_count"], @change_params.call(user["id"]) %></td>
<td><%= number_to_percentage 100 * user["change_count"] / user["sum"], :precision => 1 %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<% content_for("subnavbar") do %>
<li><%= link_to "Tags", :action => "tag_updates", :start_date => @start_date, :end_date => @end_date %></li>
<li><%= link_to "Notes", :action => "note_updates", :start_date => @start_date, :end_date => @end_date %></li>
<li><%= link_to "Wiki", :action => "wiki_updates", :start_date => @start_date, :end_date => @end_date %></li>
<li><%= link_to "Uploads", :action => "post_uploads", :start_date => @start_date, :end_date => @end_date %></li>
<% end %>

View File

@@ -0,0 +1,40 @@
<script language="javascript" type="text/javascript" src="/javascripts/flotr-0.2.0-alpha.js"></script>
<% form_tag({:action => "tag_history"}, :method => :get) do %>
<table width="100%">
<tbody>
<tr>
<th width="10%">Tags</th>
<td width="90%"><%= text_field_tag "tag", params[:tag], :size => 50 %></td>
</tr>
<tr>
<th>Start Date</th>
<td><%= text_field_tag "start_date", @start_date %></td>
</tr>
<tr>
<th>End Date</th>
<td><%= text_field_tag "end_date", @end_date %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Search" %></td>
</tr>
</tbody>
</table>
<% end %>
<div id="container" style="width: 100%; height: 400px"></div>
<% if @counts %>
<script type="text/javascript" charset="utf-8">
Flotr.draw(
$("container"), [<%= @counts.map {|x| "{data: #{x[1].to_json}, label: #{x[0].to_json}}"}.join(", ") %>],
{
lines: {show: true},
xaxis: {ticks: <%= @ticks.to_json %>},
yaxis: {noTicks: 10, tickDecimals: 0},
legend: {show: true},
shadowSize: 0
}
)
</script>
<% end %>

View File

@@ -0,0 +1,30 @@
<h1>Moderator Report For <%= Date.today %></h1>
<div style="margin-bottom: 2em;">
<table width="100%">
<thead>
<tr>
<th width="15%" style="text-align: left;">Name</th>
<th width="10%" style="text-align: left;">Level</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past day">Appr 1</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past seven days">Appr 7</th>
<th width="10%" style="text-align: right;" title="Number of posts approved in past fourteen days">Appr 14</th>
<th width="10%" style="text-align: right;" title="Number of comments posted in past seven days">Comm</th>
<th width="35%" style="text-align: right;" title="Number of forum posts posted in past seven days">Forum</th>
</tr>
</thead>
<tbody>
<% User.find(:all, :conditions => ["level >= ?", CONFIG["user_levels"]["Test Janitor"]], :order => "level, name").each do |user| %>
<tr>
<td><%= h user.name %></td>
<td><%= h user.pretty_level %></td>
<td style="text-align: right;"><%= 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]) %></td>
<td style="text-align: right;"><%= 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]) %></td>
<td style="text-align: right;"><%= 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]) %></td>
<td style="text-align: right;"><%= Comment.count(:conditions => ["created_at >= ? AND user_id = ?", 7.days.ago, user.id]) %></td>
<td style="text-align: right;"><%= ForumPost.count(:conditions => ["created_at >= ? AND creator_id = ?", 7.days.ago, user.id]) %></td>
</tr>
<% end %>
</tbody>
</table>
</div>

View File

@@ -3,6 +3,7 @@
<section>
<h2>Sign In</h2>
<%= form_tag(session_path) do %>
<%= hidden_field_tag "url", params[:url] %>
<table width="100%">
<tfoot>
<tr>

View File

@@ -0,0 +1,7 @@
<h1><%= @ex.class.to_s %> exception raised</h1>
<ul style="font-family: monospace; font-size: 1.2em; list-style-type: none;">
<li><%= @ex.message %></li>
<%- @ex.backtrace.each do |b| -%>
<li style="list-style-type: none;"><%= b %></li>
<%- end -%>
</ul>

View File

@@ -0,0 +1,11 @@
<div style="text-align: center;">
<%= print_advertisement("horizontal") %>
<div style="width: 50em; margin: 1em auto;">
<h4>&ldquo;No one else could gain admittance here, because this entrance was meant solely for you. I am now going to shut it.&rdquo;</h4>
</div>
<p>You have to <a href="/user/login">login</a> to view this page.</p>
<p>You can create a <a href="/user/signup">free basic account</a>.</p>
<p>Learn more about <a href="/help/users">accounts</a>.</p>
</div>

View File

@@ -0,0 +1,60 @@
<div style="width: 40em; margin: 5em auto;">
<div class="section">
<h4>Terms of Service</h4>
<p>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.</p>
<ul>
<li>The Site reserves the right to change these terms at any time.</li>
<li>If you are a minor, then you will not use the Site.</li>
<li>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.</li>
<li>The Site reserves the right to delete or modify your account, or any content you have posted to the site.</li>
<li>You will make a best faith effort to upload only high quality anime-related images.</li>
<li>You have read the <%= link_to "tagging guidelines", :controller => "help", :action => "tags" %>.</li>
</ul>
<div class="section">
<h6>Post/Comment Limiting</h6>
<p>You cannot upload a post or comment during the first week of signing up.</p>
<p>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.</p>
</div>
<div class="section">
<h6>Prohibited Content</h6>
<p>In addition, you may not use the Site to upload any of the following:</p>
<ul>
<li>Non-anime: Photographs of American porn actresses, for example, are prohibited. Photographs of cosplayers, figures, or prominent figures in the industry are acceptable.</li>
<li>Furry: Any image or movie where a person's skin is made of fur or scales.</li>
<li>Watermarked: Any image where a person who is not the original copyright owner has placed a watermark on the image.</li>
<li>Poorly compressed: Any image where compression artifacts are easily visible.</li>
<li>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).</li>
<li>Manga: Uploading entire manga or doujinshi chapters is discouraged. Individual pages can be uploaded if they meet the quality criterion.</li>
<li>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.</li>
</ul>
</div>
</div>
<div class="section">
<h4>Copyright Infringement</h4>
<p>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:</p>
<ul>
<li>The URL of the infringing post.</li>
<li>Proof that you own the copyright.</li>
<li>An email address that will be provided to the person who uploaded the infringing post to facilitate communication.</li>
</ul>
</div>
<div class="section">
<h4>Privacy Policy</h4>
<p>The Site will not disclose the IP address, email address, password, or DMails of any user except to the staff.</p>
<p>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.</p>
</div>
<div>
<h4>Agreement</h4>
<p>By clicking on the "I Agree" link, you have read all the terms and have agreed to them.</p>
<p><%= link_to("I Agree", params[:url] || "/", :onclick => "Cookie.put('tos', '1')") %> | <%= link_to("Cancel", "/") %></p>
</div>
</div>

View File

@@ -0,0 +1,92 @@
<div style="margin-bottom: 1em;">
<% form_tag({:action => "index"}, :method => :get) do %>
<%= text_field_tag "query", params[:query] %>
<%= submit_tag "Search Aliases" %>
<%= submit_tag "Search Implications" %>
<% end %>
</div>
<div id="aliases">
<% form_tag(:action => "update") do %>
<table width="100%" class="highlightable">
<thead>
<tr>
<th width="1%"></th>
<th width="19%">Alias</th>
<th width="20%">To</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()" %>
<%= submit_tag "Fix" %>
<%= button_to_function "Add", "$('add-box').show().scrollTo(); $('tag_alias_name').focus()" %>
<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>
<% @aliases.each do |a| %>
<tr class="<%= cycle 'even', 'odd' %> <%= a.is_pending? ? 'pending-tag' : nil %>">
<td><input type="checkbox" name="aliases[<%= a.id %>]" value="1" <%= a.is_pending? ? 'class="pending"' : nil %>></td>
<td><%= link_to h(a.name), :controller => "post", :action => "index", :tags => a.name %> (<%= Tag.find_by_name(a.name).post_count rescue 0 %>)</td>
<td><%= link_to h(a.alias_name), :controller => "post", :action => "index", :tags => a.alias_name %> (<%= Tag.find(a.alias_id).post_count rescue 0 %>)</td>
<td><%= format_text(a.reason) %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
<% 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 Alias</h4>
<% unless @current_user.is_anonymous? %>
<%= hidden_field_tag "tag_alias[creator_id]", @current_user.id %>
<% end %>
<table>
<tr>
<th><label for="tag_alias_name">Name</label></th>
<td><%= text_field "tag_alias", "name", :size => 40, :value => params[:from_name] %></td>
</tr>
<tr>
<th><label for="tag_alias_alias">Alias to</label></th>
<td><%= text_field "tag_alias", "alias", :size => 40, :value => params[:to_name] %></td>
</tr>
<tr>
<th><label for="tag_alias_reason">Reason</label></th>
<td><%= text_area "tag_alias", "reason", :size => "40x2", :value => params[:reason] %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Submit" %></td>
</tr>
</table>
<% end %>
</div>
<% end %>
<div id="paginator">
<%= will_paginate(@aliases) %>
</div>
<% content_for("subnavbar") do %>
<li><%= link_to "List", :controller => "tag_alias", :action => "index" %></li>
<li><%= link_to "Add", :controller => "tag_alias", :action => "new" %></li>
<li><%= link_to "Help", :controller => "help", :action => "tag_aliases" %></li>
<% end %>

View File

@@ -0,0 +1,20 @@
<% form_tag(:controller => "forum", :action => "create") do %>
<p>You can create a forum thread to suggest the creation of an alias.</p>
<table>
<tr>
<th><label for="tag_alias_name">From</label></th>
<td><%= text_field "tag_alias", "name", :size => 40 %></td>
</tr>
<tr>
<th><label for="tag_alias_alias">To</label></th>
<td><%= text_field "tag_alias", "alias", :size => 40 %></td>
</tr>
<tr>
<th><label for="tag_alias_reason">Reason</label></th>
<td><%= text_area "tag_alias", "reason", :rows => 10, :cols => 60 %></td>
</tr>
<tr>
<td colspan="2"><%= submit_tag "Submit" %></td>
</tr>
</table>
<% end %>

View File

@@ -0,0 +1,95 @@
<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 %>
<% end %>
<table>
<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 %>
</div>
<% end %>
<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 %>

View File

@@ -0,0 +1,20 @@
<% 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 %>

View File

@@ -0,0 +1,14 @@
<% form_tag(:action => "update") do %>
<h4>Edit Tag Subscriptions</h4>
<div style="margin-bottom: 1em;">
You can only create up to <%= CONFIG["max_tag_subscriptions"] %> groups and each group can have up to 20 tags.
</div>
<table width="100%" class="highlightable">
<%= render :partial => "listing", :locals => {:tag_subscriptions => @tag_subscriptions} %>
</table>
<% end %>
<% content_for("subnavbar") do %>
<li><%= link_to "Help", :controller => "help", :action => "tag_subscriptions" %></li>
<% end %>

View File

@@ -0,0 +1,8 @@
<div>
<%= 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 %>
</div>

View File

@@ -0,0 +1,8 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", tags_path %></li>
<li><%= link_to "Aliases", tag_aliases_path %></li>
<li><%= link_to "Implications", tag_implications_path %></li>
<li><%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:tags"}) %></li>
</menu>
<% end %>

View File

@@ -0,0 +1,27 @@
<%= render "search" %>
<table width="100%" class="highlightable">
<thead>
<tr>
<th>Count</th>
<th>Name</th>
</tr>
</thead>
<tbody>
<% @tags.each do |tag| %>
<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(tag.name, posts_path(:tags => tag.name)) %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= will_paginate(@tags) %>
</div>
<%= render "secondary_links" %>

View File

@@ -0,0 +1,7 @@
<% if @user %>
<% content_for("subnavbar") do %>
<li><%= link_to "Add", :action => "create", :user_id => @user.id %></li>
<li><%= link_to "List for user", :action => "index", :user_id => @user.id %></li>
<li><%= link_to "List for all", :action => "index", :user_id => nil %></li>
<% end %>
<% end %>

View File

@@ -0,0 +1,42 @@
<div id="user-record">
<h4>Record</h4>
<table width="100%">
<thead>
<tr>
<th width="15%">User</th>
<th width="15%">Reporter</th>
<th width="15%">When</th>
<th width="50%">Body</th>
<th width="5%"></th>
</tr>
</thead>
<tbody>
<% @user_records.each do |rec| %>
<tr class="<%= rec.is_positive? ? 'positive-record' : 'negative-record' %>" id="record-<%= rec.id %>">
<td>
<% 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 %>
</td>
<td><%= h(rec.reporter.pretty_name) %></td>
<td><%= time_ago_in_words(rec.created_at) %> ago</td>
<td><%= format_text(rec.body) %></td>
<td>
<% if @current_user.is_mod_or_higher? || @current_user.id == rec.reported_by %>
<%= link_to_function "Delete", "UserRecord.destroy(#{rec.id})" %>
<% end %>
</td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= will_paginate(@user_records) %>
</div>
<%= render :partial => "footer" %>
</div>

View File

@@ -0,0 +1,29 @@
<h4>Add Record for <%= h(@user.pretty_name) %></h4>
<div id="preview" style="margin-bottom: 1em;">
</div>
<% form_tag(:action => "create") do %>
<%= hidden_field_tag "user_id", @user.id %>
<table width="100%">
<tbody>
<tr>
<th width="10%"><label>Positive</label></th>
<td width="90%"><%= check_box "user_record", "is_positive" %></td>
</tr>
<tr>
<th><label>Reason</label></th>
<td><%= text_area "user_record", "body", :size => "20x8" %></td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="2">
<%= submit_tag "Submit" %>
<%= submit_to_remote "preview", "Preview", :url => {:action => "preview"}, :update => "preview", :method => :get %>
<%= button_to_function "Cancel", "location.back()" %>
</td>
</tr>
</tfoot>
</table>
<% end %>

View File

@@ -1,5 +0,0 @@
<h1>Delete My Account</h1>
<p>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.</p>
<p>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.</p>

View File

@@ -0,0 +1,70 @@
<%= render :partial => "sidebar" %>
<div class="content">
<% form_tag({:action => "diff"}, :method => :get) do %>
<%= hidden_field_tag "title", params[:title] %>
<table width="100%">
<thead>
<tr>
<th width="5%">From</th>
<th width="5%">To</th>
<th width="10%">IP Address</th>
<th width="80%">Last edited</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2"><%= submit_tag "Compare" %></td>
</tr>
</tfoot>
<tbody>
<% @wiki_pages.each_with_index do |wiki_page, i| %>
<tr class="<%= cycle 'even', 'odd' %>">
<td><%= radio_button_tag "from", wiki_page.version, i==1, :id => "from_#{wiki_page.version}" %></td>
<td><%= radio_button_tag "to", wiki_page.version, i==0, :id => "to_#{wiki_page.version}" %></td>
<td>
<% if @current_user.is_admin? %>
<%= h wiki_page.ip_addr %>
<% end %>
</td>
<td><%= 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 %></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
<script type="text/javascript">
var from;
var to;
function validateFrom(self)
{
if(Number(self.value) >= to) return false;
from = new Number(self.value);
return true;
}
function validateTo(self)
{
if(Number(self.value) <= from) return false;
to = new Number(self.value);
return true;
}
for(var i=1, elem; i <= <%= @wiki_pages.length %>; i++)
{
elem = $("from_"+i);
elem.onclick = function() {return validateFrom(this);};
if(elem.checked) from = i;
elem = $("to_"+i);
elem.onclick = function() {return validateTo(this);};
if(elem.checked) to = i;
}
</script>
</div>
<%= render :partial => "footer" %>

View File

@@ -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" %>

View File

@@ -0,0 +1,8 @@
<section>
<h1>Recent Changes (<%= link_to "all", wiki_pages_path(:meta_sort => "updated_at.desc") %>)</h1>
<ul>
<% WikiPage.recent.each do |page| %>
<li class="tag-category-<%= page.category_name %>"><%= link_to page.pretty_title, wiki_page_path(page) %></li>
<% end %>
</ul>
</section>

View File

@@ -0,0 +1,16 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", wiki_pages_path %></li>
<li><%= link_to "New", new_wiki_page_path %></li>
<li><%= link_to "Help", wiki_pages_path(:search => {:title_equals => "help:wiki"}) %></li>
<% if @wiki_page %>
<li>|</li>
<li><%= link_to "Posts (#{Post.fast_count(@wiki_page.title)})", posts_path(:tags => @wiki_page.title) %></li>
<li><%= link_to "History", wiki_page_versions_path(:search => {:wiki_page_id_equals => @wiki_page.id}) %></li>
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
<% if CurrentUser.is_moderator? %>
<li><%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :confirm => "Do you want to delete this wiki page?" %></li>
<% end %>
<% end %>
</menu>
<% end %>

View File

@@ -0,0 +1,10 @@
<aside id="sidebar">
<section>
<h1>Search</h1>
<%= simple_form_for(@search) do |f| %>
<%= f.input :title_contains %>
<% end %>
</section>
<%= render "recent_changes" %>
</aside>

View File

@@ -0,0 +1,15 @@
<div id="c-wiki-pages">
<div id="a-edit">
<%= render "sidebar" %>
<section id="content">
<h1 id="wiki-page-title"><%= @wiki_page.pretty_title %> (Editing)</h1>
<%= simple_form_for(@wiki_page) do |f| %>
<%= render :partial => "form", :locals => {:f => f} %>
<% end %>
</section>
<%= render "secondary_links" %>
</div>
</div>

View File

@@ -0,0 +1,26 @@
<div id="c-wiki-pages">
<div id="a-index">
<%= render :partial => "sidebar" %>
<section id="content">
<table>
<tr>
<th>Title</th>
<th>Last edited</th>
</tr>
<% @wiki_pages.each do |wiki_page| %>
<tr>
<td class="tag-category-<%= wiki_page.category_name %>"><%= link_to wiki_page.pretty_title, wiki_page_path(wiki_page, :nordirect => 1) %></td>
<td><%= wiki_page.updated_at.strftime("%m/%d/%Y %I:%M") %> by <%= h wiki_page.creator.name %></td>
</tr>
<% end %>
</table>
<div id="paginator">
<%= will_paginate(@wiki_pages) %>
</div>
</section>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -0,0 +1,16 @@
<div id="c-wiki-pages">
<div id="a-new">
<%= render "sidebar" %>
<section id="content">
<div id="preview">
</div>
<%= simple_form_for(@wiki_page) do |f| %>
<%= render :partial => "form", :locals => {:f => f} %>
<% end %>
</section>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -0,0 +1,57 @@
<div id="c-wiki-pages">
<div id="a-show">
<%= render "sidebar" %>
<section id="content">
<h1 id="wiki-page-title"><%= @wiki_page.pretty_title %></h1>
<div id="wiki-page-body">
<%= format_text(@wiki_page.body) %>
</div>
<div id="wiki-page-posts">
<%= @wiki_page.presenter.posts %>
</div>
</section>
</div>
</div>
<div class="wiki" id="wiki-show">
<%= render :partial => "sidebar" %>
<h2 class="title"><%= @presenter.html_title %></h2>
<div id="body">
<div style="margin-bottom: 1em;">
<%= @presenter.html_body(self) %>
</div>
<div style="margin-bottom: 1em;">
<%= @presenter.html_posts(self) %>
</div>
</div>
<% content_for("footer") do %>
<li>|</li>
<% if @wiki_page.nil? %>
<li><%= link_to "Posts (#{Post.fast_count(params[:title])})", :controller => "post", :action => "index", :tags => params[:title] %></li>
<li><%= link_to "Edit", :controller => "wiki", :action => "edit", :title => params[:title] %></li>
<% else %>
<li><%= link_to "Posts (#{Post.fast_count(params[:title])})", :controller => "post", :action => "index", :tags => @title %></li>
<li><%= link_to "History", :controller => "wiki", :action => "history", :title => @wiki_page.title %></li>
<% if not @wiki_page.is_locked? %>
<li><%= link_to "Edit", :controller => "wiki", :action => "edit", :title => @wiki_page.title, :version => @wiki_page.version %></li>
<% end %>
<% if @wiki_page.is_locked? %>
<li><%= link_to "Unlock", {:controller => "wiki", :action => "unlock", :title => @wiki_page.title}, :method => "post" %></li>
<% else %>
<li><%= 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 %></li>
<li><%= 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 %></li>
<li><%= link_to "Lock", {:controller => "wiki", :action => "lock", :title => @wiki_page.title}, :method => :post %></li>
<li><%= link_to "Rename", :action => "rename", :title => @wiki_page.title %></li>
<% end %>
<% end %>
<% end %>
<%= render :partial => "footer" %>
</div>

View File

@@ -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

View File

@@ -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