improved pool simple edit interface

This commit is contained in:
albert
2011-03-03 18:26:50 -05:00
parent 9e7efbd295
commit e431452a11
17 changed files with 150 additions and 85 deletions

View File

@@ -0,0 +1,29 @@
module PostSets
class WikiPage < Base
attr_reader :tag_name
def initialize(tag_name)
@tag_name = tag_name
end
def load_posts
@posts = ::Post.tag_match(tag_name).all(:order => "posts.id desc", :limit => limit, :offset => offset)
end
def limit
8
end
def offset
0
end
def use_sequential_paginator?
false
end
def use_numbered_paginator?
false
end
end
end

View File

@@ -76,4 +76,12 @@ class WikiPage < ActiveRecord::Base
def initialize_creator
self.creator_id = CurrentUser.user.id
end
def post_set
@post_set ||= PostSets::WikiPage.new(title)
end
def presenter
@presenter ||= WikiPagePresenter.new(self)
end
end

View File

@@ -5,7 +5,7 @@ class PostPresenter < Presenter
flags << "flagged" if post.is_flagged?
flags << "deleted" if post.is_deleted?
html = %{<article id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{flags.join(' ')}">}
html = %{<article class="post-preview" id="post_#{post.id}" data-id="#{post.id}" data-tags="#{h(post.tag_string)}" data-uploader="#{h(post.uploader_name)}" data-rating="#{post.rating}" data-width="#{post.image_width}" data-height="#{post.image_height}" data-flags="#{flags.join(' ')}">}
html << %{<a href="/posts/#{post.id}">}
html << %{<img src="#{post.preview_file_url}">}
html << %{</a>}

View File

@@ -4,8 +4,8 @@
<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="delete">Delete</span>
<%= 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>
@@ -14,4 +14,4 @@
<%= f.input :name %>
<%= f.input :description %>
<%= submit_tag "Save" %>
<% end %>
<% end %>

View File

@@ -1,5 +1,5 @@
<div class="pools">
<div class="edit">
<div id="c-pools">
<div id="a-edit">
<% if params[:advanced] %>
<%= render "advanced_edit" %>
<% else %>

View File

@@ -1,5 +1,5 @@
<div id="pools">
<div id="index">
<div id="c-pools">
<div id="a-index">
<%= render "search" %>
<table class="highlightable" width="100%">

View File

@@ -1,2 +1,6 @@
<h1>New Pool</h1>
<%= render :partial => "form", :locals => {:pool => @pool} %>
<div id="c-pools">
<div id="c-new">
<h1>New Pool</h1>
<%= render :partial => "form", :locals => {:pool => @pool} %>
</div>
</div>

View File

@@ -1,5 +1,5 @@
<div class="pools">
<div class="show">
<div id="c-pools">
<div id="a-show">
<aside id="sidebar">
<h2>Pool: <%= @pool.name %></h2>
<p><%= format_text(@pool.description) %></p>

View File

@@ -1,5 +1,5 @@
<div class="posts">
<div class="index">
<div id="c-posts">
<div id="a-index">
<% if @post_set.suggestions.any? %>
<div class="notice">
Maybe you meant: <%= @post_set.suggestions.map {|x| link_to(x, posts_path(:tags => x), :class => "tag-type-#{Tag.type_name(x)}" )}.to_sentence(:last_word_connector => ", or ", :two_words_connector => " or ") %>

View File

@@ -1,5 +1,5 @@
<div class="posts">
<div class="show">
<div id="c-posts">
<div id="a-show">
<aside id="sidebar">
<section>
<h1>Search</h1>

View File

@@ -1,5 +1,8 @@
<%= f.input :title %>
<% if @wiki_page.new_record? || CurrentUser.is_moderator? %>
<%= f.input :title %>
<% end %>
<%= f.input :body %>
<% if CurrentUser. %>
<%= f.input :is_locked %>
<% if CurrentUser.is_janitor? %>
<%= f.input :is_locked %>
<% end %>
<%= f.button :submit, "Save" %><%= f.button :submit, "Cancel" %><%= f.button :submit "Preview" %>

View File

@@ -7,9 +7,11 @@
<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>
<% unless @wiki_page.new_record? %>
<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 %>
<% end %>
</menu>

View File

@@ -10,48 +10,8 @@
</div>
<div id="wiki-page-posts">
<%= @wiki_page.presenter.posts %>
<%= @wiki_page.post_set.presenter.post_previews_html %>
</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>