diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index ccc79f869..986359335 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -21,10 +21,7 @@ class CommentsController < ApplicationController end def create - @comment = Comment.new(params[:comment]) - @comment.post_id = params[:comment][:post_id] - @comment.score = 0 - @comment.save + @comment = Comment.create(params[:comment]) respond_with(@comment) do |format| format.html do redirect_to post_path(@comment.post), :notice => "Comment posted" diff --git a/app/controllers/pools_controller.rb b/app/controllers/pools_controller.rb index 3d3e02781..b0705ef6b 100644 --- a/app/controllers/pools_controller.rb +++ b/app/controllers/pools_controller.rb @@ -15,7 +15,7 @@ class PoolsController < ApplicationController def index @search = Pool.search(params[:search]) - @pools = @search.paginate(:page => params[:page]) + @pools = @search.paginate(params[:page]) respond_with(@pools) end @@ -25,9 +25,7 @@ class PoolsController < ApplicationController def show @pool = Pool.find(params[:id]) - @post_set = PostSets::Base.new(:id => @pool, :page => params[:page]) - @post_set.extend(PostSets::Numbered) - @post_set.extend(PostSets::Pool) + @post_set = PostSets::Pool.new(@pool, params[:page]) respond_with(@pool) end diff --git a/app/logical/post_sets/pool.rb b/app/logical/post_sets/pool.rb new file mode 100644 index 000000000..a091b99d7 --- /dev/null +++ b/app/logical/post_sets/pool.rb @@ -0,0 +1,31 @@ +module PostSets + class Pool < Base + attr_reader :pool, :page, :posts + + def initailize(pool, page) + @pool = pool + @page = page + @posts = pool.posts(:offset => offset, :limit => limit) + end + + def offset + ([page.to_i, 1].max - 1) * limit + end + + def limit + Danbooru.config.posts_per_page + end + + def tag_array + ["pool:#{pool.id}"] + end + + def tag_string + tag_array.join("") + end + + def presenter + @presenter ||= PostSetPresenters::Pool.new(self) + end + end +end diff --git a/app/models/comment.rb b/app/models/comment.rb index dca3e5af1..ef2bafdd5 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -6,7 +6,7 @@ class Comment < ActiveRecord::Base has_many :votes, :class_name => "CommentVote", :dependent => :destroy before_validation :initialize_creator, :on => :create after_save :update_last_commented_at - attr_accessible :body + attr_accessible :body, :post_id attr_accessor :do_not_bump_post scope :recent, :order => "comments.id desc", :limit => 6 diff --git a/app/presenters/post_set_presenters/pool.rb b/app/presenters/post_set_presenters/pool.rb new file mode 100644 index 000000000..002be2862 --- /dev/null +++ b/app/presenters/post_set_presenters/pool.rb @@ -0,0 +1,32 @@ +module PostSetPresenters + class Pool + attr_accessor :tag_set_presenter + + def initialize(pool_set) + @pool_set = pool_set + @tag_set_presenter = TagSetPresenter.new( + RelatedTagCalculator.calculate_from_sample_to_array( + pool_set.tag_string + ).map {|x| x[0]} + ) + end + + def tag_list_html(template) + tag_set_presenter.tag_list_html(template) + end + + def post_previews_html(template) + html = "" + + if pool_set.posts.empty? + return template.render(:partial => "post_sets/blank") + end + + pool_set.posts.each do |post| + html << PostPresenter.preview(post) + end + + html.html_safe + end + end +end diff --git a/app/views/notes/index_by_note.html.erb b/app/views/notes/index_by_note.html.erb index 8e9c749a9..e606e94b9 100644 --- a/app/views/notes/index_by_note.html.erb +++ b/app/views/notes/index_by_note.html.erb @@ -1,6 +1,6 @@
- +
diff --git a/app/views/pools/_secondary_links.html.erb b/app/views/pools/_secondary_links.html.erb index c8320d96d..fd1957600 100644 --- a/app/views/pools/_secondary_links.html.erb +++ b/app/views/pools/_secondary_links.html.erb @@ -3,7 +3,7 @@
  • <%= link_to "Listing", pools_path %>
  • <%= link_to "Search", search_pools_path %>
  • <%= link_to "New", new_pool_path %>
  • - <% if @pool %> + <% if @pool && !@pool.new_record? %>
  • |
  • <%= link_to "Show", pool_path(@pool) %>
  • <%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %>
  • diff --git a/app/views/pools/new.html.erb b/app/views/pools/new.html.erb index b04f0a6d6..2d81a62d0 100644 --- a/app/views/pools/new.html.erb +++ b/app/views/pools/new.html.erb @@ -1,6 +1,12 @@
    -

    New Pool

    - <%= render :partial => "form", :locals => {:pool => @pool} %> + <%= simple_form_for(@pool) do |f| %> +

    New Pool

    + <%= f.input :name %> + <%= f.input :description %> + <%= f.button :submit %> + <% end %>
    + +<%= render "secondary_links" %> diff --git a/app/views/tag_aliases/_secondary_links.html.erb b/app/views/tag_aliases/_secondary_links.html.erb index f2adbcffc..f46665a77 100644 --- a/app/views/tag_aliases/_secondary_links.html.erb +++ b/app/views/tag_aliases/_secondary_links.html.erb @@ -1,7 +1,7 @@ <% content_for(:secondary_links) do %>
  • <%= link_to "Listing", tag_aliases_path %>
  • -
  • <%= link_to "Add", new_tag_alias_path %>
  • +
  • <%= link_to "New", new_tag_alias_path %>
  • <%= link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %>
  • <% end %> diff --git a/app/views/tag_implications/_secondary_links.html.erb b/app/views/tag_implications/_secondary_links.html.erb index cc6425c7b..33d8432c8 100644 --- a/app/views/tag_implications/_secondary_links.html.erb +++ b/app/views/tag_implications/_secondary_links.html.erb @@ -1,7 +1,7 @@ <% content_for(:secondary_links) do %>
  • <%= link_to "Listing", tag_implications_path %>
  • -
  • <%= link_to "Add", new_tag_implication_path %>
  • +
  • <%= link_to "New", new_tag_implication_path %>
  • <%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %>
  • <% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 7799e3021..fa09e077d 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -1,77 +1,31 @@ -<%= form_for @user do |f| %> +<%= simple_form_for @user do |f| %>

    Hover over the labels to see a brief explanation of the setting. Required fields are marked in red.

    Basic -

    - <%= f.label :email %> - <% if Danbooru.config.enable_email_verification? %> - <%= f.text_field :email %> - <% else %> - <%= f.text_field :email, :class => "required" %> - <% end %> -

    - -

    - <%= f.label :time_zone %> - <%= f.time_zone_select :time_zone %> -

    - -

    - <%= f.label :receive_email_notifications, "Email notifications", :title => "Enable to receive email notification when you receive a DMail" %> - <%= f.check_box :receive_email_notifications %> -

    - -

    - <%= f.label :comment_threshold, nil, :title => "Comments below this score will be hidden by default" %> - <%= f.text_field :comment_threshold, :size => 2 %> -

    - -

    - <%= f.label :always_resize_images, nil, :title => "Enable to automatically resize images to fit your browser window" %> - <%= f.check_box :always_resize_images %> -

    - -

    - <%= f.label :default_image_size, nil, :title => "Medium shows images resized to #{Danbooru.config.medium_image_width} pixels wide, large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is" %> - <%= f.select :default_image_size, %w(Medium Large Original) %> -

    - -

    - <%= f.label :favorite_tags, nil, :title => "A list of whitespace delimited tags that show up in your profile" %> - <%= f.text_area :favorite_tags, :rows => 5 %> -

    - -

    - <%= f.label :blacklisted_tags, nil, :title => "A list of newline delimited tags that you never want to see" %> - <%= f.text_area :blacklisted_tags, :rows => 5 %> -

    + <%= f.input :email, :required => Danbooru.config.enable_email_verification? %> + <%= f.input :time_zone %> + <%= f.input :receive_email_notifications, :title => "Enable to receive email notification when you receive a DMail" %> + <%= f.input :comment_threshold, :title => "Comments below this score will be hidden by default" %> + <%= f.input :always_resize_images, :title => "Enable to automatically resize images to fit your browser window" %> + <%= f.input :default_image_size, :title => "Medium shows images resized to #{Danbooru.config.medium_image_width} pixels wide, large is #{Danbooru.config.large_image_width} pixels wide, and original is whatever the original image is", :collection => %w(Medium Large Original) %> + <%= f.input :favorite_tags, :title => "A list of whitespace delimited tags that show up in your profile" %> + <%= f.input :blacklisted_tags, :title => "A list of newline delimited tags that you never want to see" %>
    SpecialFor security purposes, changing the following settings requires you to re-enter your password. You can leave the new password field blank to keep your current one.

    -

    - <%= f.label :name, nil, :title => "Your login name" %> - <%= f.text_field :name %> -

    - -

    - <%= f.label :password, "New password", :title => "What you want your new password to be (leave blank if you don't want to change your password)" %> - <%= f.text_field :password %> -

    - -

    - <%= f.label :old_password, nil, :title => "Your old password (you must enter your password if updating your name or password)" %> - <%= f.text_field :old_password %> -

    + <%= f.input :name %> + <%= f.input :password, :title => "What you want your new password to be (leave blank if you don't want to change your password)", :label => "New password" %> + <%= f.input :old_password, :title => "Your old password (you must enter your password if updating your name or password)", :as => :password %>
    - <%= submit_tag "Submit" %> + <%= f.button :submit %> <% end %> <% content_for(:page_title) do %> - / Users / <%= @user.name %> / Settings + /Users/<%= @user.name %>/Settings <% end %> diff --git a/app/views/wiki_pages/edit.html.erb b/app/views/wiki_pages/edit.html.erb index e6a30a2a5..f7a57d560 100644 --- a/app/views/wiki_pages/edit.html.erb +++ b/app/views/wiki_pages/edit.html.erb @@ -3,6 +3,7 @@ <%= render "sidebar" %>
    +

    Edit Wiki Page: <%= @wiki_page.title %>

    <%= render "form" %>
    diff --git a/app/views/wiki_pages/index.html.erb b/app/views/wiki_pages/index.html.erb index c23d3d107..2a6676940 100644 --- a/app/views/wiki_pages/index.html.erb +++ b/app/views/wiki_pages/index.html.erb @@ -17,7 +17,7 @@
    Post
    - <%= smart_paginator(@wiki_pages) do |page| %> + <%= numbered_paginator(@wiki_pages) do |page| %> <%= link_to(page, wiki_pages_path(:page => page, :search => params[:search])) %> <% end %>
    diff --git a/app/views/wiki_pages/new.html.erb b/app/views/wiki_pages/new.html.erb index bc6c9c53b..0a96c4dab 100644 --- a/app/views/wiki_pages/new.html.erb +++ b/app/views/wiki_pages/new.html.erb @@ -3,6 +3,7 @@ <%= render "sidebar" %>
    +

    New Wiki Page

    <%= render "form" %>