refactoring

This commit is contained in:
albert
2011-06-12 16:41:23 -04:00
parent 033f0fc266
commit d6e4283cc7
41 changed files with 197 additions and 429 deletions

View File

@@ -37,9 +37,6 @@
placeholder: "ui-state-placeholder" placeholder: "ui-state-placeholder"
}); });
$("ul#sortable").disableSelection(); $("ul#sortable").disableSelection();
$("ul#sortable span.delete").click(function(e) {
$(e.target).parent().remove();
});
$("div.pools div.edit form#ordering-form").submit(function(e) { $("div.pools div.edit form#ordering-form").submit(function(e) {
$.ajax({ $.ajax({

View File

@@ -419,10 +419,12 @@ div.dtext {
} }
/*** Pools Posts ***/ /*** Pool Elements ***/
div#c-pools-posts { div#c-pool-elements {
div#a-new { div#a-new {
font-size: 0.8em;
form { form {
margin-bottom: 1em; margin-bottom: 1em;
} }
@@ -431,6 +433,10 @@ div#c-pools-posts {
margin-left: 1em; margin-left: 1em;
cursor: pointer; cursor: pointer;
} }
h1 {
font-size: $h3_size;
}
} }
} }
@@ -439,20 +445,31 @@ div#c-pools-posts {
/*** Pools ***/ /*** Pools ***/
div#c-pools { div#c-pools {
div#a-edit { h1 {
p { font-size: $h2_size;
width: 30em; }
}
p {
width: 30em;
}
textarea {
height: 10em;
}
}
/*** Pool Orders ***/
div#c-pool-orders {
h1 {
font-size: $h2_size;
}
div#a-edit {
ul.ui-sortable { ul.ui-sortable {
list-style-type: none; list-style-type: none;
span {
margin: 0;
float: right;
cursor: pointer;
}
li { li {
padding: 0.5em; padding: 0.5em;
} }
@@ -473,7 +490,6 @@ div#c-pools {
} }
} }
/*** Comments ***/ /*** Comments ***/
div.comments-for-post { div.comments-for-post {
@@ -572,7 +588,7 @@ article.post-preview {
div#c-posts { div#c-posts {
div.notice { div.notice {
font-size: 80%; font-size: 0.8em;
padding: 1em; padding: 1em;
margin-bottom: 1em; margin-bottom: 1em;
@@ -688,18 +704,6 @@ div#sessions {
float: left; float: left;
} }
aside {
width: 20em;
float: left;
li {
display: list-item;
margin-bottom: 0.5em;
list-style-type: square;
margin-left: 1em;
}
}
h1 { h1 {
font-size: $h2_size; font-size: $h2_size;
} }
@@ -752,7 +756,7 @@ div#c-users {
} }
li { li {
font-size: 0.9em; font-size: 0.8em;
line-height: 1.5em; line-height: 1.5em;
} }
@@ -940,7 +944,7 @@ div#note-container {
} }
div.note-edit-dialog { div.note-edit-dialog {
font-size: 70%; font-size: 0.8em;
} }

View File

@@ -1,5 +1,6 @@
class ApplicationController < ActionController::Base class ApplicationController < ActionController::Base
protect_from_forgery protect_from_forgery
helper :pagination
before_filter :set_current_user before_filter :set_current_user
after_filter :reset_current_user after_filter :reset_current_user
before_filter :initialize_cookies before_filter :initialize_cookies

View File

@@ -1,11 +1,11 @@
class PoolsPostsController < ApplicationController class PoolElementsController < ApplicationController
respond_to :html, :xml, :json, :js respond_to :html, :xml, :json, :js
before_filter :member_only before_filter :member_only
def create def create
@pool = Pool.find_by_name(params[:pool_name]) || Pool.find(params[:pool_id]) @pool = Pool.find_by_name(params[:pool_name]) || Pool.find(params[:pool_id])
@post = Post.find(params[:post_id]) @post = Post.find(params[:post_id])
@pool.add_post!(@post) @pool.add!(@post)
append_pool_to_session(@pool) append_pool_to_session(@pool)
respond_with(@pool, :location => pool_path(@pool)) respond_with(@pool, :location => pool_path(@pool))
end end
@@ -13,7 +13,7 @@ class PoolsPostsController < ApplicationController
def destroy def destroy
@pool = Pool.find(params[:pool_id]) @pool = Pool.find(params[:pool_id])
@post = Post.find(params[:post_id]) @post = Post.find(params[:post_id])
@pool.remove_post!(@post) @pool.remove!(@post)
respond_with(@pool, :location => pool_path(@pool)) respond_with(@pool, :location => pool_path(@pool))
end end

View File

@@ -0,0 +1,12 @@
class PoolOrdersController < ApplicationController
respond_to :html, :xml, :json, :js
before_filter :member_only
def edit
@pool = Pool.find(params[:pool_id])
respond_with(@pool)
end
def update
end
end

View File

@@ -25,7 +25,9 @@ class PoolsController < ApplicationController
def show def show
@pool = Pool.find(params[:id]) @pool = Pool.find(params[:id])
@post_set = PostSets::Pool.new(@pool, :page => params[:page]) @post_set = PostSets::Base.new(:id => @pool, :page => params[:page])
@post_set.extend(PostSets::Numbered)
@post_set.extend(PostSets::Pool)
respond_with(@pool) respond_with(@pool)
end end

View File

@@ -4,7 +4,8 @@ class PostsController < ApplicationController
respond_to :html, :xml, :json respond_to :html, :xml, :json
def index def index
@post_set = PostSets::Post.new(params[:tags], params) @post_set = PostSets::Base.new(params)
extend_post_set(@post_set)
respond_with(@post_set) respond_with(@post_set)
end end
@@ -29,6 +30,24 @@ class PostsController < ApplicationController
end end
private private
def extend_post_set(post_set)
@post_set.extend(PostSets::Post)
if use_sequential_paginator?
@post_set.extend(PostSets::Sequential)
else
@post_set.extend(PostSets::Numbered)
end
end
def use_sequential_paginator?
if params[:page].to_i > 1000
true
else
false
end
end
def save_recent_tags def save_recent_tags
if params[:tags] || (params[:post] && params[:post][:tags]) if params[:tags] || (params[:post] && params[:post][:tags])
tags = Tag.scan_tags(params[:tags] || params[:post][:tags]) tags = Tag.scan_tags(params[:tags] || params[:post][:tags])

View File

@@ -1,8 +1,10 @@
module PaginationHelper module PaginationHelper
def smart_paginator(set, &block) def smart_paginator(set, &block)
if set.page && set.page > 1000 if params[:page] && set.page > 1000
set.extend(PostSets::Sequential)
sequential_paginator(set) sequential_paginator(set)
else else
set.extend(PostSets::Numbered)
numbered_paginator(set, &block) numbered_paginator(set, &block)
end end
end end
@@ -10,11 +12,11 @@ module PaginationHelper
def sequential_paginator(set) def sequential_paginator(set)
html = "<menu>" html = "<menu>"
unless set.first_page? unless set.is_first_page?
html << '<li>' + link_to("&laquo; Previous", params.merge(:after_id => set.first_id)) + '</li>' html << '<li>' + link_to("&laquo; Previous", params.merge(:after_id => set.first_id)) + '</li>'
end end
unless set.last_page? unless set.is_last_page?
html << '<li>' + link_to("Next &raquo;", params.merge(:before_id => set.last_id)) + '</li>' html << '<li>' + link_to("Next &raquo;", params.merge(:before_id => set.last_id)) + '</li>'
end end

View File

@@ -36,6 +36,14 @@ module PostSets
@page ||= params[:page] ? params[:page].to_i : 1 @page ||= params[:page] ? params[:page].to_i : 1
end end
def total_pages
(count / limit.to_f).ceil
end
def current_page
page
end
def offset def offset
((page < 1) ? 0 : (page - 1)) * limit ((page < 1) ? 0 : (page - 1)) * limit
end end

View File

@@ -41,6 +41,10 @@ module PostSets
@tag_array ||= ::Tag.scan_query(tag_string) @tag_array ||= ::Tag.scan_query(tag_string)
end end
def tags
tag_array
end
def validate def validate
super super
validate_query_count validate_query_count

View File

@@ -18,6 +18,22 @@ module PostSets
end end
end end
def first_id
if posts.any?
posts.first.id
else
nil
end
end
def last_id
if posts.any?
posts.last.id
else
nil
end
end
def pagination_options def pagination_options
{:before_id => before_id, :after_id => after_id} {:before_id => before_id, :after_id => after_id}
end end

View File

@@ -1,3 +1,5 @@
require 'ostruct'
class Pool < ActiveRecord::Base class Pool < ActiveRecord::Base
validates_uniqueness_of :name validates_uniqueness_of :name
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons" validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"

View File

@@ -1,78 +0,0 @@
module Paginators
class Base < Presenter
def sequential_pagination_html(template)
html = "<menu>"
prev_url = template.request.env["HTTP_REFERER"]
next_url = sequential_link(template)
html << %{<li><a href="#{prev_url}">&laquo; Previous</a></li>}
if post_set.posts.any?
html << %{<li><a href="#{next_url}">Next &raquo;</a></li>}
end
html << "</menu>"
html.html_safe
end
def numbered_pagination_html(template)
html = "<menu>"
window = 3
if total_pages <= (window * 2) + 5
1.upto(total_pages) do |page|
html << numbered_pagination_item(template, page, current_page)
end
elsif current_page <= window + 2
1.upto(current_page + window) do |page|
html << numbered_pagination_item(template, page, current_page)
end
html << numbered_pagination_item(template, "...", current_page)
html << numbered_pagination_item(template, total_pages, current_page)
elsif current_page >= total_pages - (window + 1)
html << numbered_pagination_item(template, 1, current_page)
html << numbered_pagination_item(template, "...", current_page)
(current_page - window).upto(total_pages) do |page|
html << numbered_pagination_item(template, page, current_page)
end
else
html << numbered_pagination_item(template, 1, current_page)
html << numbered_pagination_item(template, "...", current_page)
(current_page - window).upto(current_page + window) do |page|
html << numbered_pagination_item(template, page, current_page)
end
html << numbered_pagination_item(template, "...", current_page)
html << numbered_pagination_item(template, total_pages, current_page)
end
html << "</menu>"
html.html_safe
end
protected
def numbered_pagination_item(template, page, current_page)
html = "<li>"
if page == "..."
html << "..."
elsif page == current_page
html << page.to_s
else
html << paginated_link(template, page)
end
html << "</li>"
html.html_safe
end
def total_pages
raise NotImplementedError
end
def current_page
raise NotImplementedError
end
def sequential_link(template)
raise NotImplementedError
end
def paginated_link(template, page)
raise NotImplementedError
end
end
end

View File

@@ -1,22 +0,0 @@
module Paginators
class ForumPost < Base
attr_accessor :forum_posts
def initialize(forum_posts)
@forum_posts = forum_posts
end
protected
def total_pages
forum_posts.total_entries
end
def current_page
forum_posts.current_page
end
def paginated_link(template, page)
template.link_to(page, template.forum_posts_path(:search => template.params[:search], :page => page))
end
end
end

View File

@@ -1,23 +0,0 @@
module Paginators
class ForumTopic < Base
attr_accessor :forum_topic, :forum_posts
def initialize(forum_topic, forum_posts)
@forum_topic = forum_topic
@forum_posts = forum_posts
end
protected
def total_pages
forum_posts.total_pages
end
def current_page
forum_posts.current_page
end
def paginated_link(template, page)
template.link_to(page, template.forum_topic_path(forum_topic, :page => page))
end
end
end

View File

@@ -1,58 +0,0 @@
module Paginators
class Numbered
attr_reader :template, :source
delegate :url, :total_pages, :current_page, :to => :source
def initialize(template, source)
@template = template
@source = source
end
def pagination_html
html = "<menu>"
window = 3
if total_pages <= (window * 2) + 5
1.upto(total_pages) do |page|
html << pagination_item(page, current_page)
end
elsif current_page <= window + 2
1.upto(current_page + window) do |page|
html << pagination_item(page, current_page)
end
html << pagination_item("...", current_page)
html << pagination_item(total_pages, current_page)
elsif current_page >= total_pages - (window + 1)
html << pagination_item(1, current_page)
html << pagination_item("...", current_page)
(current_page - window).upto(total_pages) do |page|
html << pagination_item(page, current_page)
end
else
html << pagination_item(1, current_page)
html << pagination_item("...", current_page)
(current_page - window).upto(current_page + window) do |page|
html << pagination_item(page, current_page)
end
html << pagination_item("...", current_page)
html << pagination_item(total_pages, current_page)
end
html << "</menu>"
html.html_safe
end
protected
def pagination_item(page, current_page)
html = "<li>"
if page == "..."
html << "..."
elsif page == current_page
html << page.to_s
else
html << template.link_to(page, url(template, :page => page))
end
html << "</li>"
html.html_safe
end
end
end

View File

@@ -1,22 +0,0 @@
module Paginators
class Pool < Base
attr_accessor :post_set
def initialize(post_set)
@post_set = post_set
end
protected
def total_pages
(post_set.count.to_f / post_set.limit.to_f).ceil
end
def current_page
[1, post_set.page].max
end
def paginated_link(template, page)
template.link_to(page, template.pool_path(post_set.pool, :page => page))
end
end
end

View File

@@ -1,27 +0,0 @@
module Paginators
class Post < Base
attr_accessor :post_set
def initialize(post_set)
@post_set = post_set
end
protected
def total_pages
(post_set.count.to_f / post_set.limit.to_f).ceil
end
def current_page
[1, post_set.page].max
end
# TODO: this is not compatible with paginating favorites
def sequential_link(template)
template.posts_path(:tags => template.params[:tags], before_id => post_set.posts[-1].id, :page => nil)
end
def paginated_link(template, page)
template.link_to(page, template.posts_path(:tags => template.params[:tags], :page => page))
end
end
end

View File

@@ -1,18 +0,0 @@
module Paginators
class PostVersion < Base
attr_accessor :post_set
def initialize(post_set)
@post_set = post_set
end
def numbered_pagination_html(template)
raise NotImplementedError
end
protected
def sequential_link(template)
template.post_versions_path(:before_time => post_set.posts[-1].last_commented_at, :page => nil)
end
end
end

View File

@@ -1,29 +0,0 @@
module Paginators
class Sequential
attr_reader :template, :source
delegate :url, :to => :source
def initialize(template, source)
@template = template
@source = source
end
def pagination_html
html = "<menu>"
html << '<li>' + template.link_to("&laquo; Previous", prev_url) + '</li>'
if next_url
html << '<li>' + template.link_to("Next &raquo;", next_url) + '</li>'
end
html << "</menu>"
html.html_safe
end
def prev_url
template.request.env["HTTP_REFERER"]
end
def next_url
@next_url ||= url(template)
end
end
end

View File

@@ -38,14 +38,6 @@ class PostSetPresenter < Presenter
end end
end end
def pagination_html(template)
if post_set.use_sequential_paginator?
Paginators::Post.new(post_set).sequential_pagination_html(template)
else
Paginators::Post.new(post_set).numbered_pagination_html(template)
end
end
def post_previews_html def post_previews_html
html = "" html = ""

View File

@@ -7,7 +7,6 @@
class TagSetPresenter < Presenter class TagSetPresenter < Presenter
def initialize(tags) def initialize(tags)
@tags = tags @tags = tags
fetch_categories
end end
def tag_list_html(template, options = {}) def tag_list_html(template, options = {})
@@ -21,17 +20,13 @@ class TagSetPresenter < Presenter
end end
private private
def fetch_categories def categories
@category_cache ||= Tag.categories_for(@tags) @categories ||= Tag.categories_for(@tags)
end
def category_for(tag)
@category_cache[tag]
end end
def build_list_item(tag, template, options) def build_list_item(tag, template, options)
html = "" html = ""
html << %{<li data-tag-type="#{category_for(tag)}" data-tag-name="#{u(tag)}">} html << %{<li data-tag-type="#{categories[tag]}" data-tag-name="#{u(tag)}">}
if CurrentUser.user.is_privileged? if CurrentUser.user.is_privileged?
html << %{<a href="/wiki_pages?title=#{u(tag)}">?</a> } html << %{<a href="/wiki_pages?title=#{u(tag)}">?</a> }

View File

@@ -1,6 +1,6 @@
<div id="c-pools-posts"> <div id="c-pool-elements">
<div id="a-new"> <div id="a-new">
<%= form_tag(pool_post_path) do %> <%= form_tag(pool_element_path) do %>
<%= hidden_field_tag "post_id", @post.id %> <%= hidden_field_tag "post_id", @post.id %>
<%= text_field_tag "pool_name", "", :size => 20 %> <%= text_field_tag "pool_name", "", :size => 20 %>
<%= submit_tag "Select" %> <%= submit_tag "Select" %>

View File

@@ -0,0 +1,20 @@
<div id="c-pool-orders">
<div id="a-edit">
<h1>Order Pool: <%= @pool.name %></h1>
<p>Drag and drop the list below to determine ordering.</p>
<ul id="sortable">
<% @pool.posts(:limit => 1_000).each do |post| %>
<li class="ui-state-default" id="pool[post_id_array]_<%= post.id %>">
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
</li>
<% end %>
</ul>
<%= simple_form_for(@pool, :format => :js, :html => {:id => "ordering-form"}) do |f| %>
<%= submit_tag "Save" %>
<% end %>
</div>
</div>
<%= render :partial => "pools/secondary_links" %>

View File

@@ -1,6 +0,0 @@
<%= simple_form_for(@pool) do |f| %>
<h2>Edit Pool: <%= @pool.name %></h2>
<p>If you know the precise ordering of posts that you want, you can just enter them here instead of sorting each post manually. Enter a list of post ids separated by spaces.</p>
<%= f.input :post_ids, :label => "Posts" %>
<%= f.button :submit %>
<% end %>

View File

@@ -1,5 +0,0 @@
<%= simple_form_for(pool) do |f| %>
<%= f.input :name %>
<%= f.input :description %>
<%= f.button :submit %>
<% end %>

View File

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

View File

@@ -1,17 +0,0 @@
<h2>Edit Pool: <%= @pool.name %></h2>
<p>Drag and drop the list below to determine ordering.</p>
<ul id="sortable">
<% posts.each do |post| %>
<li class="ui-state-default" id="pool[post_id_array]_<%= post.id %>">
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
<span class="ui-icon ui-icon-closethick delete" title="Remove post"></span>
</li>
<% end %>
</ul>
<%= simple_form_for(@pool, :format => :js, :html => {:id => "ordering-form"}) do |f| %>
<%= f.input :name %>
<%= f.input :description %>
<%= submit_tag "Save" %>
<% end %>

View File

@@ -1,9 +1,11 @@
<div id="c-pools"> <div id="c-pools">
<div id="a-edit"> <div id="a-edit">
<% if params[:advanced] %> <%= simple_form_for(@pool) do |f| %>
<%= render "advanced_edit" %> <h1>Edit Pool: <%= @pool.name %></h1>
<% else %> <%= f.input :name %>
<%= render :partial => "simple_edit", :locals => {:posts => @pool.posts} %> <%= f.input :description %>
<%= f.input :post_ids, :label => "Posts" %>
<%= f.button :submit %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -1,9 +1,10 @@
<div id="c-pools"> <div id="c-pools">
<div id="a-show"> <div id="a-show">
<aside id="sidebar"> <h1>Pool: <%= @pool.name %></h1>
<h2>Pool: <%= @pool.name %></h2>
<p><%= format_text(@pool.description) %></p> <div id="description">
</aside> <%= format_text(@pool.description) %>
</div>
<section id="content"> <section id="content">
<%= @post_set.presenter.post_previews_html %> <%= @post_set.presenter.post_previews_html %>
@@ -11,7 +12,9 @@
<div class="clearfix"></div> <div class="clearfix"></div>
<div class="paginator"> <div class="paginator">
<%= @post_set.presenter.pagination_html(self) %> <%= numbered_paginator(@post_set) do |page| %>
<%= link_to(page, pool_path(@pool, :page => page)) %>
<% end %>
</div> </div>
</section> </section>
</div> </div>

View File

@@ -22,8 +22,6 @@
</ul> </ul>
</section> </section>
<%= render :partial => "posts/partials/index/explore", :locals => {:post_set => @post_set} %>
<section id="tag-box"> <section id="tag-box">
<h1>Tags</h1> <h1>Tags</h1>
<%= @post_set.presenter.tag_list_html(self) %> <%= @post_set.presenter.tag_list_html(self) %>

View File

@@ -7,7 +7,7 @@
<li>Subscriptions</li> <li>Subscriptions</li>
<li><%= link_to "Changes", post_versions_path %></li> <li><%= link_to "Changes", post_versions_path %></li>
<li>Approvals</li> <li>Approvals</li>
<li><%= link_to "Moderate", post_moderation_moderate_path %></li> <li><%= link_to "Moderate", moderation_post_dashboard_path %></li>
<li>Help</li> <li>Help</li>
</menu> </menu>
<% end %> <% end %>

View File

@@ -1,10 +0,0 @@
<% if post_set.date_tag %>
<section>
<h1>Explore</h1>
<ul>
<li>&laquo; Day &raquo;</li>
<li>&laquo; Week &raquo;</li>
<li>&laquo; Month &raquo;</li>
</ul>
</section>
<% end %>

View File

@@ -6,12 +6,12 @@
<li><%= link_to "Flag", new_post_flag_path(:post_id => post.id), :id => "flag" %></li> <li><%= link_to "Flag", new_post_flag_path(:post_id => post.id), :id => "flag" %></li>
<li><%= link_to "Appeal", new_post_appeal_path(:post_id => post.id), :id => "appeal" %></li> <li><%= link_to "Appeal", new_post_appeal_path(:post_id => post.id), :id => "appeal" %></li>
<% if CurrentUser.is_janitor? %> <% if CurrentUser.is_janitor? %>
<li><%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put, :id => "approve" %></li> <li><%= link_to "Approve", moderation_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :id => "approve" %></li>
<li><%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put, :id => "disapprove" %></li> <li><%= link_to "Disapprove", moderation_post_approval_path(:post_id => post.id), :remote => true, :method => :destroy, :id => "disapprove" %></li>
<% end %> <% end %>
<% if CurrentUser.is_moderator? %> <% if CurrentUser.is_moderator? %>
<li><%= link_to "Undelete", post_moderation_undelete_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %></li> <li><%= link_to "Undelete", moderation_post_deletion_path(:post_id => post.id), :remote => true, :method => :destroy, :id => "undelete" %></li>
<li><%= link_to "Delete", post_moderation_delete_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li> <li><%= link_to "Delete", moderation_post_deletion_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %></li>
<% end %> <% end %>
<li><%= link_to "Pool", "#", :id => "pool" %></li> <li><%= link_to "Pool", "#", :id => "pool" %></li>
</ul> </ul>

View File

@@ -1,13 +1,13 @@
<ul> <ul>
<% post.pools.each do |pool| %> <% post.pools.each do |pool| %>
<li> <li>
<% if pool.neighbor_posts(post)[:previous] %> <% if pool.neighbors(post).previous %>
<%= link_to "&laquo;".html_safe, post_path(pool.neighbor_posts(post)[:previous]) %> <%= link_to "&laquo;".html_safe, post_path(pool.neighbors(post).previous) %>
<% else %> <% else %>
&laquo; &laquo;
<% end %> <% end %>
<% if pool.neighbor_posts(post)[:next] %> <% if pool.neighbors(post).next %>
<%= link_to "&raquo;".html_safe, post_path(pool.neighbor_posts(post)[:next]) %> <%= link_to "&raquo;".html_safe, post_path(pool.neighbors(post).next) %>
<% else %> <% else %>
&raquo; &raquo;
<% end %> <% end %>

View File

@@ -57,6 +57,10 @@
</section> </section>
<section id="notes"> <section id="notes">
<% if @post.notes.active.empty? %>
<p>There are no notes.</p>
<% end %>
<%= render :partial => "notes/note", :collection => @post.notes.active %> <%= render :partial => "notes/note", :collection => @post.notes.active %>
</section> </section>
@@ -75,7 +79,7 @@
</div> </div>
<div id="add-to-pool-dialog" title="Add to Pool"> <div id="add-to-pool-dialog" title="Add to Pool">
<%= render :template => "pools_posts/new" %> <%= render :template => "pool_elements/new" %>
</div> </div>
</div> </div>

View File

@@ -20,18 +20,17 @@
</div> </div>
<% end %> <% end %>
</section> </section>
<aside>
<h1>Help</h1>
<ul>
<li><%= link_to "I don't have an account", new_user_path %></li>
<li><%= link_to "I forgot my password", reset_password_path %></li>
<li><%= link_to "I forgot my user name", login_reminder_path %></li>
</ul>
</aside>
</div> </div>
</div> </div>
<% content_for(:page_title) do %> <% content_for(:page_title) do %>
/login /login
<% end %> <% end %>
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Signup", new_user_path %></li>
<li><%= link_to "Reset Password", new_maintenance_user_password_reset_path %></li>
<li><%= link_to "Login Reminder", new_maintenance_user_login_reminder_path %></li>
</menu>
<% end %>

View File

@@ -1 +1,3 @@
<h1>Namasté <%= CurrentUser.pretty_name %>!</h1>
<%= render :partial => "secondary_links" %> <%= render :partial => "secondary_links" %>

View File

@@ -6,7 +6,7 @@ module Danbooru
end end
def posts_per_page def posts_per_page
20 1
end end
def is_user_restricted?(user) def is_user_restricted?(user)

View File

@@ -23,6 +23,7 @@ Danbooru::Application.routes.draw do
end end
end end
resources :dmails resources :dmails
resource :dtext_preview, :only => [:create]
resources :favorites resources :favorites
resources :forum_topics resources :forum_topics
resources :forum_posts do resources :forum_posts do
@@ -55,8 +56,9 @@ Danbooru::Application.routes.draw do
member do member do
put :revert put :revert
end end
resource :order, :only => [:edit, :update] resource :order, :only => [:edit, :update], :controller => "PoolOrders"
end end
resource :pool_element, :only => [:create, :destroy]
resources :pool_versions, :only => [:index] resources :pool_versions, :only => [:index]
resources :posts do resources :posts do
resources :votes, :controller => "post_votes", :only => [:create, :destroy] resources :votes, :controller => "post_votes", :only => [:create, :destroy]
@@ -68,16 +70,14 @@ Danbooru::Application.routes.draw do
resources :post_versions, :only => [:index] resources :post_versions, :only => [:index]
resources :post_flags, :only => [:new, :index, :create] resources :post_flags, :only => [:new, :index, :create]
resources :post_appeals, :only => [:new, :index, :create] resources :post_appeals, :only => [:new, :index, :create]
resource :session resource :session
resources :tags do resources :tags do
collection do collection do
get :search get :search
end end
end end
resources :tag_aliases do resources :tag_aliases do
member do resource :cache, :only => [:destroy]
delete :cache
end
end end
resources :tag_implications resources :tag_implications
resources :tag_subscriptions resources :tag_subscriptions
@@ -91,22 +91,23 @@ Danbooru::Application.routes.draw do
end end
resources :wiki_page_versions, :only => [:index, :show] resources :wiki_page_versions, :only => [:index, :show]
match '/favorites/:id' => 'favorites#create', :via => :post, :as => "favorite" namespace :maintenance do
match '/favorites/:id' => 'favorites#destroy', :via => :delete, :as => "favorite" namespace :user do
match '/favorites' => 'favorites#index', :via => :get, :as => "favorites" resource :password_reset, :only => [:new, :create, :edit, :update]
match '/pool_post' => 'pools_posts#create', :via => :post, :as => 'pool_post' resource :login_reminder, :only => [:new, :create]
match '/pool_post' => 'pools_posts#destroy', :via => :delete, :as => 'pool_post' end
match '/post_moderation/moderate' => 'post_moderation#moderate' end
match '/post_moderation/disapprove' => 'post_moderation#disapprove', :via => :put
match '/post_moderation/approve' => 'post_moderation#approve', :via => :put namespace :moderation do
match '/post_moderation/delete' => 'post_moderation#delete', :via => :post namespace :post do
match '/post_moderation/undelete' => 'post_moderation#undelete', :via => :post resource :dashboard, :only => [:show]
match '/dtext/preview' => 'dtext#preview', :via => :post resource :approval, :only => [:destroy, :create]
resource :deletion, :only => [:destroy, :create]
end
end
match "/site_map" => "static#site_map", :as => "site_map" match "/site_map" => "static#site_map", :as => "site_map"
match "/terms_of_service" => "static#terms_of_service", :as => "terms_of_service" match "/terms_of_service" => "static#terms_of_service", :as => "terms_of_service"
match "/user_maintenance/login_reminder" => "user_maintenance#login_reminder", :as => "login_reminder"
match "/user_maintenance/reset_password" => "user_maintenance#reset_password", :as => "reset_password"
match '/jquery_test' => 'static#jquery_test'
root :to => "posts#index" root :to => "posts#index"
end end

View File

@@ -1,6 +1,6 @@
require 'test_helper' require 'test_helper'
class PoolsPostsControllerTest < ActionController::TestCase class PoolElementsControllerTest < ActionController::TestCase
context "The pools posts controller" do context "The pools posts controller" do
setup do setup do
@user = Factory.create(:user) @user = Factory.create(:user)