From d6e4283cc7bafe4425695c659dd5b5948b698d16 Mon Sep 17 00:00:00 2001 From: albert Date: Sun, 12 Jun 2011 16:41:23 -0400 Subject: [PATCH] refactoring --- app/assets/javascripts/pools.js | 3 - app/assets/stylesheets/application.css.scss | 64 ++++++++------- app/controllers/application_controller.rb | 1 + ...troller.rb => pool_elements_controller.rb} | 6 +- app/controllers/pool_orders_controller.rb | 12 +++ app/controllers/pools_controller.rb | 4 +- app/controllers/posts_controller.rb | 21 ++++- app/helpers/pagination_helper.rb | 8 +- app/logical/post_sets/numbered.rb | 8 ++ app/logical/post_sets/post.rb | 4 + app/logical/post_sets/sequential.rb | 16 ++++ app/models/pool.rb | 2 + app/presenters/paginators/base.rb | 78 ------------------- app/presenters/paginators/forum_post.rb | 22 ------ app/presenters/paginators/forum_topic.rb | 23 ------ app/presenters/paginators/numbered.rb | 58 -------------- app/presenters/paginators/pool.rb | 22 ------ app/presenters/paginators/post.rb | 27 ------- app/presenters/paginators/post_version.rb | 18 ----- app/presenters/paginators/sequential.rb | 29 ------- app/presenters/post_set_presenter.rb | 8 -- app/presenters/tag_set_presenter.rb | 11 +-- .../new.html.erb | 4 +- app/views/pool_orders/edit.html.erb | 20 +++++ app/views/pools/_advanced_edit.html.erb | 6 -- app/views/pools/_form.html.erb | 5 -- app/views/pools/_secondary_links.html.erb | 4 +- app/views/pools/_simple_edit.html.erb | 17 ---- app/views/pools/edit.html.erb | 12 +-- app/views/pools/show.html.erb | 13 ++-- app/views/posts/index.html.erb | 2 - .../partials/common/_secondary_links.html.erb | 2 +- .../posts/partials/index/_explore.html.erb | 10 --- .../posts/partials/show/_options.html.erb | 8 +- app/views/posts/partials/show/_pools.html.erb | 8 +- app/views/posts/show.html.erb | 6 +- app/views/sessions/new.html.erb | 19 +++-- app/views/users/show.html.erb | 2 + config/danbooru_local_config.rb | 2 +- config/routes.rb | 39 +++++----- ...st.rb => pool_elements_controller_test.rb} | 2 +- 41 files changed, 197 insertions(+), 429 deletions(-) rename app/controllers/{pools_posts_controller.rb => pool_elements_controller.rb} (87%) create mode 100644 app/controllers/pool_orders_controller.rb delete mode 100644 app/presenters/paginators/base.rb delete mode 100644 app/presenters/paginators/forum_post.rb delete mode 100644 app/presenters/paginators/forum_topic.rb delete mode 100644 app/presenters/paginators/numbered.rb delete mode 100644 app/presenters/paginators/pool.rb delete mode 100644 app/presenters/paginators/post.rb delete mode 100644 app/presenters/paginators/post_version.rb delete mode 100644 app/presenters/paginators/sequential.rb rename app/views/{pools_posts => pool_elements}/new.html.erb (84%) create mode 100644 app/views/pool_orders/edit.html.erb delete mode 100644 app/views/pools/_advanced_edit.html.erb delete mode 100644 app/views/pools/_form.html.erb delete mode 100644 app/views/pools/_simple_edit.html.erb delete mode 100644 app/views/posts/partials/index/_explore.html.erb rename test/functional/{pools_posts_controller_test.rb => pool_elements_controller_test.rb} (96%) diff --git a/app/assets/javascripts/pools.js b/app/assets/javascripts/pools.js index 251b619c9..8172a9858 100644 --- a/app/assets/javascripts/pools.js +++ b/app/assets/javascripts/pools.js @@ -37,9 +37,6 @@ placeholder: "ui-state-placeholder" }); $("ul#sortable").disableSelection(); - $("ul#sortable span.delete").click(function(e) { - $(e.target).parent().remove(); - }); $("div.pools div.edit form#ordering-form").submit(function(e) { $.ajax({ diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 742d17f66..68c936d05 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -419,10 +419,12 @@ div.dtext { } -/*** Pools Posts ***/ +/*** Pool Elements ***/ -div#c-pools-posts { +div#c-pool-elements { div#a-new { + font-size: 0.8em; + form { margin-bottom: 1em; } @@ -431,6 +433,10 @@ div#c-pools-posts { margin-left: 1em; cursor: pointer; } + + h1 { + font-size: $h3_size; + } } } @@ -439,30 +445,41 @@ div#c-pools-posts { /*** Pools ***/ div#c-pools { + h1 { + font-size: $h2_size; + } + + p { + width: 30em; + } + + textarea { + height: 10em; + } +} + + +/*** Pool Orders ***/ + +div#c-pool-orders { + h1 { + font-size: $h2_size; + } + div#a-edit { - p { - width: 30em; - } - ul.ui-sortable { list-style-type: none; - span { - margin: 0; - float: right; - cursor: pointer; - } - li { padding: 0.5em; } - + li.ui-state-default { margin-bottom: 20px; width: 180px; background: none; } - + li.ui-state-placeholder { margin-bottom: 20px; width: 180px; @@ -473,7 +490,6 @@ div#c-pools { } } - /*** Comments ***/ div.comments-for-post { @@ -572,7 +588,7 @@ article.post-preview { div#c-posts { div.notice { - font-size: 80%; + font-size: 0.8em; padding: 1em; margin-bottom: 1em; @@ -687,18 +703,6 @@ div#sessions { width: 30em; float: left; } - - aside { - width: 20em; - float: left; - - li { - display: list-item; - margin-bottom: 0.5em; - list-style-type: square; - margin-left: 1em; - } - } h1 { font-size: $h2_size; @@ -752,7 +756,7 @@ div#c-users { } li { - font-size: 0.9em; + font-size: 0.8em; line-height: 1.5em; } @@ -940,7 +944,7 @@ div#note-container { } div.note-edit-dialog { - font-size: 70%; + font-size: 0.8em; } diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 46fec716a..acb4e489d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base protect_from_forgery + helper :pagination before_filter :set_current_user after_filter :reset_current_user before_filter :initialize_cookies diff --git a/app/controllers/pools_posts_controller.rb b/app/controllers/pool_elements_controller.rb similarity index 87% rename from app/controllers/pools_posts_controller.rb rename to app/controllers/pool_elements_controller.rb index d5c894460..dab27bed1 100644 --- a/app/controllers/pools_posts_controller.rb +++ b/app/controllers/pool_elements_controller.rb @@ -1,11 +1,11 @@ -class PoolsPostsController < ApplicationController +class PoolElementsController < ApplicationController respond_to :html, :xml, :json, :js before_filter :member_only def create @pool = Pool.find_by_name(params[:pool_name]) || Pool.find(params[:pool_id]) @post = Post.find(params[:post_id]) - @pool.add_post!(@post) + @pool.add!(@post) append_pool_to_session(@pool) respond_with(@pool, :location => pool_path(@pool)) end @@ -13,7 +13,7 @@ class PoolsPostsController < ApplicationController def destroy @pool = Pool.find(params[:pool_id]) @post = Post.find(params[:post_id]) - @pool.remove_post!(@post) + @pool.remove!(@post) respond_with(@pool, :location => pool_path(@pool)) end diff --git a/app/controllers/pool_orders_controller.rb b/app/controllers/pool_orders_controller.rb new file mode 100644 index 000000000..1e32d93f7 --- /dev/null +++ b/app/controllers/pool_orders_controller.rb @@ -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 diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index fd5ebbf3c..3d3e02781 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -25,7 +25,9 @@ class PoolsController < ApplicationController def show @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) end diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 3a13ddb2c..f8847b24c 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -4,7 +4,8 @@ class PostsController < ApplicationController respond_to :html, :xml, :json 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) end @@ -29,6 +30,24 @@ class PostsController < ApplicationController end 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 if params[:tags] || (params[:post] && params[:post][:tags]) tags = Tag.scan_tags(params[:tags] || params[:post][:tags]) diff --git a/app/helpers/pagination_helper.rb b/app/helpers/pagination_helper.rb index c7f2ede0a..fa5af5a4d 100644 --- a/app/helpers/pagination_helper.rb +++ b/app/helpers/pagination_helper.rb @@ -1,8 +1,10 @@ module PaginationHelper def smart_paginator(set, &block) - if set.page && set.page > 1000 + if params[:page] && set.page > 1000 + set.extend(PostSets::Sequential) sequential_paginator(set) else + set.extend(PostSets::Numbered) numbered_paginator(set, &block) end end @@ -10,11 +12,11 @@ module PaginationHelper def sequential_paginator(set) html = "" - unless set.first_page? + unless set.is_first_page? html << '
  • ' + link_to("« Previous", params.merge(:after_id => set.first_id)) + '
  • ' end - unless set.last_page? + unless set.is_last_page? html << '
  • ' + link_to("Next »", params.merge(:before_id => set.last_id)) + '
  • ' end diff --git a/app/logical/post_sets/numbered.rb b/app/logical/post_sets/numbered.rb index 22c1ab2f4..99398fab6 100644 --- a/app/logical/post_sets/numbered.rb +++ b/app/logical/post_sets/numbered.rb @@ -36,6 +36,14 @@ module PostSets @page ||= params[:page] ? params[:page].to_i : 1 end + def total_pages + (count / limit.to_f).ceil + end + + def current_page + page + end + def offset ((page < 1) ? 0 : (page - 1)) * limit end diff --git a/app/logical/post_sets/post.rb b/app/logical/post_sets/post.rb index 9c028a8f3..9b8ea25d8 100644 --- a/app/logical/post_sets/post.rb +++ b/app/logical/post_sets/post.rb @@ -41,6 +41,10 @@ module PostSets @tag_array ||= ::Tag.scan_query(tag_string) end + def tags + tag_array + end + def validate super validate_query_count diff --git a/app/logical/post_sets/sequential.rb b/app/logical/post_sets/sequential.rb index a566bb577..c4b41c74b 100644 --- a/app/logical/post_sets/sequential.rb +++ b/app/logical/post_sets/sequential.rb @@ -18,6 +18,22 @@ module PostSets 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 {:before_id => before_id, :after_id => after_id} end diff --git a/app/models/pool.rb b/app/models/pool.rb index 20a572502..d70ffbe50 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -1,3 +1,5 @@ +require 'ostruct' + class Pool < ActiveRecord::Base validates_uniqueness_of :name validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons" diff --git a/app/presenters/paginators/base.rb b/app/presenters/paginators/base.rb deleted file mode 100644 index 3751a5150..000000000 --- a/app/presenters/paginators/base.rb +++ /dev/null @@ -1,78 +0,0 @@ -module Paginators - class Base < Presenter - def sequential_pagination_html(template) - html = "" - prev_url = template.request.env["HTTP_REFERER"] - next_url = sequential_link(template) - html << %{
  • « Previous
  • } - if post_set.posts.any? - html << %{
  • Next »
  • } - end - html << "
    " - html.html_safe - end - - def numbered_pagination_html(template) - html = "" - 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 << "" - html.html_safe - end - - protected - def numbered_pagination_item(template, page, current_page) - html = "
  • " - if page == "..." - html << "..." - elsif page == current_page - html << page.to_s - else - html << paginated_link(template, page) - end - html << "
  • " - 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 diff --git a/app/presenters/paginators/forum_post.rb b/app/presenters/paginators/forum_post.rb deleted file mode 100644 index d5a9e1244..000000000 --- a/app/presenters/paginators/forum_post.rb +++ /dev/null @@ -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 diff --git a/app/presenters/paginators/forum_topic.rb b/app/presenters/paginators/forum_topic.rb deleted file mode 100644 index 317849bcd..000000000 --- a/app/presenters/paginators/forum_topic.rb +++ /dev/null @@ -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 diff --git a/app/presenters/paginators/numbered.rb b/app/presenters/paginators/numbered.rb deleted file mode 100644 index d848fe170..000000000 --- a/app/presenters/paginators/numbered.rb +++ /dev/null @@ -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 = "" - 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 << "" - html.html_safe - end - - protected - def pagination_item(page, current_page) - html = "
  • " - if page == "..." - html << "..." - elsif page == current_page - html << page.to_s - else - html << template.link_to(page, url(template, :page => page)) - end - html << "
  • " - html.html_safe - end - end -end diff --git a/app/presenters/paginators/pool.rb b/app/presenters/paginators/pool.rb deleted file mode 100644 index 0834c995a..000000000 --- a/app/presenters/paginators/pool.rb +++ /dev/null @@ -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 diff --git a/app/presenters/paginators/post.rb b/app/presenters/paginators/post.rb deleted file mode 100644 index a7d09f9e3..000000000 --- a/app/presenters/paginators/post.rb +++ /dev/null @@ -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 diff --git a/app/presenters/paginators/post_version.rb b/app/presenters/paginators/post_version.rb deleted file mode 100644 index c18a5177b..000000000 --- a/app/presenters/paginators/post_version.rb +++ /dev/null @@ -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 diff --git a/app/presenters/paginators/sequential.rb b/app/presenters/paginators/sequential.rb deleted file mode 100644 index 35d894f05..000000000 --- a/app/presenters/paginators/sequential.rb +++ /dev/null @@ -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 = "" - html << '
  • ' + template.link_to("« Previous", prev_url) + '
  • ' - if next_url - html << '
  • ' + template.link_to("Next »", next_url) + '
  • ' - end - html << "
    " - html.html_safe - end - - def prev_url - template.request.env["HTTP_REFERER"] - end - - def next_url - @next_url ||= url(template) - end - end -end diff --git a/app/presenters/post_set_presenter.rb b/app/presenters/post_set_presenter.rb index 706e6b689..f60629c4d 100644 --- a/app/presenters/post_set_presenter.rb +++ b/app/presenters/post_set_presenter.rb @@ -38,14 +38,6 @@ class PostSetPresenter < Presenter 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 html = "" diff --git a/app/presenters/tag_set_presenter.rb b/app/presenters/tag_set_presenter.rb index 227462075..e6fc2f74d 100644 --- a/app/presenters/tag_set_presenter.rb +++ b/app/presenters/tag_set_presenter.rb @@ -7,7 +7,6 @@ class TagSetPresenter < Presenter def initialize(tags) @tags = tags - fetch_categories end def tag_list_html(template, options = {}) @@ -21,17 +20,13 @@ class TagSetPresenter < Presenter end private - def fetch_categories - @category_cache ||= Tag.categories_for(@tags) - end - - def category_for(tag) - @category_cache[tag] + def categories + @categories ||= Tag.categories_for(@tags) end def build_list_item(tag, template, options) html = "" - html << %{
  • } + html << %{
  • } if CurrentUser.user.is_privileged? html << %{? } diff --git a/app/views/pools_posts/new.html.erb b/app/views/pool_elements/new.html.erb similarity index 84% rename from app/views/pools_posts/new.html.erb rename to app/views/pool_elements/new.html.erb index 7cb6a5bdb..42177cdc8 100644 --- a/app/views/pools_posts/new.html.erb +++ b/app/views/pool_elements/new.html.erb @@ -1,6 +1,6 @@ -
    +
    - <%= form_tag(pool_post_path) do %> + <%= form_tag(pool_element_path) do %> <%= hidden_field_tag "post_id", @post.id %> <%= text_field_tag "pool_name", "", :size => 20 %> <%= submit_tag "Select" %> diff --git a/app/views/pool_orders/edit.html.erb b/app/views/pool_orders/edit.html.erb new file mode 100644 index 000000000..0d2bb7a5b --- /dev/null +++ b/app/views/pool_orders/edit.html.erb @@ -0,0 +1,20 @@ +
    +
    +

    Order Pool: <%= @pool.name %>

    +

    Drag and drop the list below to determine ordering.

    + +
      + <% @pool.posts(:limit => 1_000).each do |post| %> +
    • + <%= link_to(image_tag(post.preview_file_url), post_path(post)) %> +
    • + <% end %> +
    + + <%= simple_form_for(@pool, :format => :js, :html => {:id => "ordering-form"}) do |f| %> + <%= submit_tag "Save" %> + <% end %> +
    +
    + +<%= render :partial => "pools/secondary_links" %> diff --git a/app/views/pools/_advanced_edit.html.erb b/app/views/pools/_advanced_edit.html.erb deleted file mode 100644 index 14b2485c3..000000000 --- a/app/views/pools/_advanced_edit.html.erb +++ /dev/null @@ -1,6 +0,0 @@ -<%= simple_form_for(@pool) do |f| %> -

    Edit Pool: <%= @pool.name %>

    -

    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.

    - <%= f.input :post_ids, :label => "Posts" %> - <%= f.button :submit %> -<% end %> diff --git a/app/views/pools/_form.html.erb b/app/views/pools/_form.html.erb deleted file mode 100644 index 78a20e8f1..000000000 --- a/app/views/pools/_form.html.erb +++ /dev/null @@ -1,5 +0,0 @@ -<%= simple_form_for(pool) do |f| %> - <%= f.input :name %> - <%= f.input :description %> - <%= f.button :submit %> -<% end %> diff --git a/app/views/pools/_secondary_links.html.erb b/app/views/pools/_secondary_links.html.erb index d3f491c96..c8320d96d 100644 --- a/app/views/pools/_secondary_links.html.erb +++ b/app/views/pools/_secondary_links.html.erb @@ -7,8 +7,8 @@
  • |
  • <%= link_to "Show", pool_path(@pool) %>
  • <%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %>
  • -
  • <%= link_to "Simple Edit", edit_pool_path(@pool) %>
  • -
  • <%= link_to "Advanced Edit", edit_pool_path(@pool, :advanced => true) %>
  • +
  • <%= link_to "Edit", edit_pool_path(@pool) %>
  • +
  • <%= link_to "Order", edit_pool_order_path(@pool) %>
  • <% end %>
    <% end %> diff --git a/app/views/pools/_simple_edit.html.erb b/app/views/pools/_simple_edit.html.erb deleted file mode 100644 index e073781e0..000000000 --- a/app/views/pools/_simple_edit.html.erb +++ /dev/null @@ -1,17 +0,0 @@ -

    Edit Pool: <%= @pool.name %>

    -

    Drag and drop the list below to determine ordering.

    - - - -<%= simple_form_for(@pool, :format => :js, :html => {:id => "ordering-form"}) do |f| %> - <%= f.input :name %> - <%= f.input :description %> - <%= submit_tag "Save" %> -<% end %> diff --git a/app/views/pools/edit.html.erb b/app/views/pools/edit.html.erb index 1bfdc04ec..497572ac9 100644 --- a/app/views/pools/edit.html.erb +++ b/app/views/pools/edit.html.erb @@ -1,10 +1,12 @@
    - <% if params[:advanced] %> - <%= render "advanced_edit" %> - <% else %> - <%= render :partial => "simple_edit", :locals => {:posts => @pool.posts} %> - <% end %> + <%= simple_form_for(@pool) do |f| %> +

    Edit Pool: <%= @pool.name %>

    + <%= f.input :name %> + <%= f.input :description %> + <%= f.input :post_ids, :label => "Posts" %> + <%= f.button :submit %> + <% end %>
    diff --git a/app/views/pools/show.html.erb b/app/views/pools/show.html.erb index c9a0fd3da..b4ab4be75 100644 --- a/app/views/pools/show.html.erb +++ b/app/views/pools/show.html.erb @@ -1,9 +1,10 @@
    - +

    Pool: <%= @pool.name %>

    + +
    + <%= format_text(@pool.description) %> +
    <%= @post_set.presenter.post_previews_html %> @@ -11,7 +12,9 @@
    - <%= @post_set.presenter.pagination_html(self) %> + <%= numbered_paginator(@post_set) do |page| %> + <%= link_to(page, pool_path(@pool, :page => page)) %> + <% end %>
    diff --git a/app/views/posts/index.html.erb b/app/views/posts/index.html.erb index 34afe46fd..aeaafb57d 100644 --- a/app/views/posts/index.html.erb +++ b/app/views/posts/index.html.erb @@ -22,8 +22,6 @@ - <%= render :partial => "posts/partials/index/explore", :locals => {:post_set => @post_set} %> -

    Tags

    <%= @post_set.presenter.tag_list_html(self) %> diff --git a/app/views/posts/partials/common/_secondary_links.html.erb b/app/views/posts/partials/common/_secondary_links.html.erb index e4ef90a7e..c71b4d581 100644 --- a/app/views/posts/partials/common/_secondary_links.html.erb +++ b/app/views/posts/partials/common/_secondary_links.html.erb @@ -7,7 +7,7 @@
  • Subscriptions
  • <%= link_to "Changes", post_versions_path %>
  • Approvals
  • -
  • <%= link_to "Moderate", post_moderation_moderate_path %>
  • +
  • <%= link_to "Moderate", moderation_post_dashboard_path %>
  • Help
  • <% end %> diff --git a/app/views/posts/partials/index/_explore.html.erb b/app/views/posts/partials/index/_explore.html.erb deleted file mode 100644 index 3069f216b..000000000 --- a/app/views/posts/partials/index/_explore.html.erb +++ /dev/null @@ -1,10 +0,0 @@ -<% if post_set.date_tag %> -
    -

    Explore

    -
      -
    • « Day »
    • -
    • « Week »
    • -
    • « Month »
    • -
    -
    -<% end %> diff --git a/app/views/posts/partials/show/_options.html.erb b/app/views/posts/partials/show/_options.html.erb index f3ce45832..85719c638 100644 --- a/app/views/posts/partials/show/_options.html.erb +++ b/app/views/posts/partials/show/_options.html.erb @@ -6,12 +6,12 @@
  • <%= link_to "Flag", new_post_flag_path(:post_id => post.id), :id => "flag" %>
  • <%= link_to "Appeal", new_post_appeal_path(:post_id => post.id), :id => "appeal" %>
  • <% if CurrentUser.is_janitor? %> -
  • <%= link_to "Approve", post_moderation_approve_path(:post_id => post.id), :remote => true, :method => :put, :id => "approve" %>
  • -
  • <%= link_to "Disapprove", post_moderation_disapprove_path(:post_id => post.id), :remote => true, :method => :put, :id => "disapprove" %>
  • +
  • <%= link_to "Approve", moderation_post_approval_path(:post_id => post.id), :remote => true, :method => :post, :id => "approve" %>
  • +
  • <%= link_to "Disapprove", moderation_post_approval_path(:post_id => post.id), :remote => true, :method => :destroy, :id => "disapprove" %>
  • <% end %> <% if CurrentUser.is_moderator? %> -
  • <%= link_to "Undelete", post_moderation_undelete_path(:post_id => post.id), :remote => true, :method => :post, :id => "undelete" %>
  • -
  • <%= link_to "Delete", post_moderation_delete_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %>
  • +
  • <%= link_to "Undelete", moderation_post_deletion_path(:post_id => post.id), :remote => true, :method => :destroy, :id => "undelete" %>
  • +
  • <%= link_to "Delete", moderation_post_deletion_path(:post_id => post.id), :remote => true, :method => :post, :id => "delete" %>
  • <% end %>
  • <%= link_to "Pool", "#", :id => "pool" %>
  • \ No newline at end of file diff --git a/app/views/posts/partials/show/_pools.html.erb b/app/views/posts/partials/show/_pools.html.erb index b734372ae..50c1217ba 100644 --- a/app/views/posts/partials/show/_pools.html.erb +++ b/app/views/posts/partials/show/_pools.html.erb @@ -1,13 +1,13 @@
      <% post.pools.each do |pool| %>
    • - <% if pool.neighbor_posts(post)[:previous] %> - <%= link_to "«".html_safe, post_path(pool.neighbor_posts(post)[:previous]) %> + <% if pool.neighbors(post).previous %> + <%= link_to "«".html_safe, post_path(pool.neighbors(post).previous) %> <% else %> « <% end %> - <% if pool.neighbor_posts(post)[:next] %> - <%= link_to "»".html_safe, post_path(pool.neighbor_posts(post)[:next]) %> + <% if pool.neighbors(post).next %> + <%= link_to "»".html_safe, post_path(pool.neighbors(post).next) %> <% else %> » <% end %> diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 01b52b794..8db130ead 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -57,6 +57,10 @@
    + <% if @post.notes.active.empty? %> +

    There are no notes.

    + <% end %> + <%= render :partial => "notes/note", :collection => @post.notes.active %>
    @@ -75,7 +79,7 @@
    - <%= render :template => "pools_posts/new" %> + <%= render :template => "pool_elements/new" %>
    diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb index 2b80cfb18..078a0a7e4 100644 --- a/app/views/sessions/new.html.erb +++ b/app/views/sessions/new.html.erb @@ -19,19 +19,18 @@ <%= submit_tag "Submit" %> <% end %> - - - + <% content_for(:page_title) do %> /login <% end %> + +<% content_for(:secondary_links) do %> + +
  • <%= link_to "Signup", new_user_path %>
  • +
  • <%= link_to "Reset Password", new_maintenance_user_password_reset_path %>
  • +
  • <%= link_to "Login Reminder", new_maintenance_user_login_reminder_path %>
  • +
    +<% end %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 14bf628e3..3ed9c19ea 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -1 +1,3 @@ +

    Namasté <%= CurrentUser.pretty_name %>!

    + <%= render :partial => "secondary_links" %> \ No newline at end of file diff --git a/config/danbooru_local_config.rb b/config/danbooru_local_config.rb index a9d5b9e24..e380ab2f2 100644 --- a/config/danbooru_local_config.rb +++ b/config/danbooru_local_config.rb @@ -6,7 +6,7 @@ module Danbooru end def posts_per_page - 20 + 1 end def is_user_restricted?(user) diff --git a/config/routes.rb b/config/routes.rb index 169246475..5cac83d82 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -23,6 +23,7 @@ Danbooru::Application.routes.draw do end end resources :dmails + resource :dtext_preview, :only => [:create] resources :favorites resources :forum_topics resources :forum_posts do @@ -55,8 +56,9 @@ Danbooru::Application.routes.draw do member do put :revert end - resource :order, :only => [:edit, :update] + resource :order, :only => [:edit, :update], :controller => "PoolOrders" end + resource :pool_element, :only => [:create, :destroy] resources :pool_versions, :only => [:index] resources :posts do resources :votes, :controller => "post_votes", :only => [:create, :destroy] @@ -68,16 +70,14 @@ Danbooru::Application.routes.draw do resources :post_versions, :only => [:index] resources :post_flags, :only => [:new, :index, :create] resources :post_appeals, :only => [:new, :index, :create] - resource :session + resource :session resources :tags do collection do get :search end end resources :tag_aliases do - member do - delete :cache - end + resource :cache, :only => [:destroy] end resources :tag_implications resources :tag_subscriptions @@ -91,22 +91,23 @@ Danbooru::Application.routes.draw do end resources :wiki_page_versions, :only => [:index, :show] - match '/favorites/:id' => 'favorites#create', :via => :post, :as => "favorite" - match '/favorites/:id' => 'favorites#destroy', :via => :delete, :as => "favorite" - match '/favorites' => 'favorites#index', :via => :get, :as => "favorites" - match '/pool_post' => 'pools_posts#create', :via => :post, :as => 'pool_post' - match '/pool_post' => 'pools_posts#destroy', :via => :delete, :as => 'pool_post' - match '/post_moderation/moderate' => 'post_moderation#moderate' - match '/post_moderation/disapprove' => 'post_moderation#disapprove', :via => :put - match '/post_moderation/approve' => 'post_moderation#approve', :via => :put - match '/post_moderation/delete' => 'post_moderation#delete', :via => :post - match '/post_moderation/undelete' => 'post_moderation#undelete', :via => :post - match '/dtext/preview' => 'dtext#preview', :via => :post + namespace :maintenance do + namespace :user do + resource :password_reset, :only => [:new, :create, :edit, :update] + resource :login_reminder, :only => [:new, :create] + end + end + + namespace :moderation do + namespace :post do + resource :dashboard, :only => [:show] + resource :approval, :only => [:destroy, :create] + resource :deletion, :only => [:destroy, :create] + end + end + match "/site_map" => "static#site_map", :as => "site_map" 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" end diff --git a/test/functional/pools_posts_controller_test.rb b/test/functional/pool_elements_controller_test.rb similarity index 96% rename from test/functional/pools_posts_controller_test.rb rename to test/functional/pool_elements_controller_test.rb index cff7a7a0f..d779fda52 100644 --- a/test/functional/pools_posts_controller_test.rb +++ b/test/functional/pool_elements_controller_test.rb @@ -1,6 +1,6 @@ require 'test_helper' -class PoolsPostsControllerTest < ActionController::TestCase +class PoolElementsControllerTest < ActionController::TestCase context "The pools posts controller" do setup do @user = Factory.create(:user)