This commit is contained in:
albert
2011-06-29 12:47:40 -04:00
parent 4e19d98047
commit 5cf122c2e0
14 changed files with 96 additions and 76 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,6 +1,6 @@
<div id="c-notes">
<div id="a-index">
<table>
<table width="100%">
<thead>
<tr>
<th>Post</th>

View File

@@ -3,7 +3,7 @@
<li><%= link_to "Listing", pools_path %></li>
<li><%= link_to "Search", search_pools_path %></li>
<li><%= link_to "New", new_pool_path %></li>
<% if @pool %>
<% if @pool && !@pool.new_record? %>
<li>|</li>
<li><%= link_to "Show", pool_path(@pool) %></li>
<li><%= link_to "Posts", posts_path(:tags => "pool:#{@pool.id}") %></li>

View File

@@ -1,6 +1,12 @@
<div id="c-pools">
<div id="c-new">
<h1>New Pool</h1>
<%= render :partial => "form", :locals => {:pool => @pool} %>
<%= simple_form_for(@pool) do |f| %>
<h1>New Pool</h1>
<%= f.input :name %>
<%= f.input :description %>
<%= f.button :submit %>
<% end %>
</div>
</div>
<%= render "secondary_links" %>

View File

@@ -1,7 +1,7 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", tag_aliases_path %></li>
<li><%= link_to "Add", new_tag_alias_path %></li>
<li><%= link_to "New", new_tag_alias_path %></li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_aliases") %></li>
</menu>
<% end %>

View File

@@ -1,7 +1,7 @@
<% content_for(:secondary_links) do %>
<menu>
<li><%= link_to "Listing", tag_implications_path %></li>
<li><%= link_to "Add", new_tag_implication_path %></li>
<li><%= link_to "New", new_tag_implication_path %></li>
<li><%= link_to "Help", wiki_pages_path(:title => "help:tag_implications") %></li>
</menu>
<% end %>

View File

@@ -1,77 +1,31 @@
<%= form_for @user do |f| %>
<%= simple_form_for @user do |f| %>
<p>Hover over the labels to see a brief explanation of the setting. Required fields are marked in red.</p>
<fieldset>
<legend>Basic</legend>
<p>
<%= f.label :email %>
<% if Danbooru.config.enable_email_verification? %>
<%= f.text_field :email %>
<% else %>
<%= f.text_field :email, :class => "required" %>
<% end %>
</p>
<p>
<%= f.label :time_zone %>
<%= f.time_zone_select :time_zone %>
</p>
<p>
<%= f.label :receive_email_notifications, "Email notifications", :title => "Enable to receive email notification when you receive a DMail" %>
<%= f.check_box :receive_email_notifications %>
</p>
<p>
<%= f.label :comment_threshold, nil, :title => "Comments below this score will be hidden by default" %>
<%= f.text_field :comment_threshold, :size => 2 %>
</p>
<p>
<%= f.label :always_resize_images, nil, :title => "Enable to automatically resize images to fit your browser window" %>
<%= f.check_box :always_resize_images %>
</p>
<p>
<%= 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) %>
</p>
<p>
<%= 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 %>
</p>
<p>
<%= 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 %>
</p>
<%= 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" %>
</fieldset>
<fieldset>
<legend>Special</legend
<p>For 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.</p>
<p>
<%= f.label :name, nil, :title => "Your login name" %>
<%= f.text_field :name %>
</p>
<p>
<%= 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 %>
</p>
<p>
<%= 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 %>
</p>
<%= 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 %>
</fieldset>
<%= submit_tag "Submit" %>
<%= f.button :submit %>
<% end %>
<% content_for(:page_title) do %>
/ Users / <%= @user.name %> / Settings
/Users/<%= @user.name %>/Settings
<% end %>

View File

@@ -3,6 +3,7 @@
<%= render "sidebar" %>
<section id="content">
<h1>Edit Wiki Page: <%= @wiki_page.title %></h1>
<%= render "form" %>
</section>
</div>

View File

@@ -17,7 +17,7 @@
</table>
<div id="paginator">
<%= smart_paginator(@wiki_pages) do |page| %>
<%= numbered_paginator(@wiki_pages) do |page| %>
<%= link_to(page, wiki_pages_path(:page => page, :search => params[:search])) %>
<% end %>
</div>

View File

@@ -3,6 +3,7 @@
<%= render "sidebar" %>
<section id="content">
<h1>New Wiki Page</h1>
<%= render "form" %>
</section>
</div>