improved pool simple edit interface
This commit is contained in:
29
app/logical/post_sets/wiki_page.rb
Normal file
29
app/logical/post_sets/wiki_page.rb
Normal 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
|
||||||
@@ -76,4 +76,12 @@ class WikiPage < ActiveRecord::Base
|
|||||||
def initialize_creator
|
def initialize_creator
|
||||||
self.creator_id = CurrentUser.user.id
|
self.creator_id = CurrentUser.user.id
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_set
|
||||||
|
@post_set ||= PostSets::WikiPage.new(title)
|
||||||
|
end
|
||||||
|
|
||||||
|
def presenter
|
||||||
|
@presenter ||= WikiPagePresenter.new(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class PostPresenter < Presenter
|
|||||||
flags << "flagged" if post.is_flagged?
|
flags << "flagged" if post.is_flagged?
|
||||||
flags << "deleted" if post.is_deleted?
|
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 << %{<a href="/posts/#{post.id}">}
|
||||||
html << %{<img src="#{post.preview_file_url}">}
|
html << %{<img src="#{post.preview_file_url}">}
|
||||||
html << %{</a>}
|
html << %{</a>}
|
||||||
|
|||||||
@@ -4,8 +4,8 @@
|
|||||||
<ul id="sortable">
|
<ul id="sortable">
|
||||||
<% posts.each do |post| %>
|
<% posts.each do |post| %>
|
||||||
<li class="ui-state-default" id="pool[post_id_array]_<%= post.id %>">
|
<li class="ui-state-default" id="pool[post_id_array]_<%= post.id %>">
|
||||||
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
<%= link_to(image_tag(post.preview_file_url), post_path(post)) %>
|
||||||
<span class="delete">Delete</span>
|
<span class="ui-icon ui-icon-closethick delete" title="Remove post"></span>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -14,4 +14,4 @@
|
|||||||
<%= f.input :name %>
|
<%= f.input :name %>
|
||||||
<%= f.input :description %>
|
<%= f.input :description %>
|
||||||
<%= submit_tag "Save" %>
|
<%= submit_tag "Save" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="pools">
|
<div id="c-pools">
|
||||||
<div class="edit">
|
<div id="a-edit">
|
||||||
<% if params[:advanced] %>
|
<% if params[:advanced] %>
|
||||||
<%= render "advanced_edit" %>
|
<%= render "advanced_edit" %>
|
||||||
<% else %>
|
<% else %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div id="pools">
|
<div id="c-pools">
|
||||||
<div id="index">
|
<div id="a-index">
|
||||||
<%= render "search" %>
|
<%= render "search" %>
|
||||||
|
|
||||||
<table class="highlightable" width="100%">
|
<table class="highlightable" width="100%">
|
||||||
|
|||||||
@@ -1,2 +1,6 @@
|
|||||||
<h1>New Pool</h1>
|
<div id="c-pools">
|
||||||
<%= render :partial => "form", :locals => {:pool => @pool} %>
|
<div id="c-new">
|
||||||
|
<h1>New Pool</h1>
|
||||||
|
<%= render :partial => "form", :locals => {:pool => @pool} %>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="pools">
|
<div id="c-pools">
|
||||||
<div class="show">
|
<div id="a-show">
|
||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<h2>Pool: <%= @pool.name %></h2>
|
<h2>Pool: <%= @pool.name %></h2>
|
||||||
<p><%= format_text(@pool.description) %></p>
|
<p><%= format_text(@pool.description) %></p>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="posts">
|
<div id="c-posts">
|
||||||
<div class="index">
|
<div id="a-index">
|
||||||
<% if @post_set.suggestions.any? %>
|
<% if @post_set.suggestions.any? %>
|
||||||
<div class="notice">
|
<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 ") %>
|
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 ") %>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div class="posts">
|
<div id="c-posts">
|
||||||
<div class="show">
|
<div id="a-show">
|
||||||
<aside id="sidebar">
|
<aside id="sidebar">
|
||||||
<section>
|
<section>
|
||||||
<h1>Search</h1>
|
<h1>Search</h1>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<%= f.input :title %>
|
<% if @wiki_page.new_record? || CurrentUser.is_moderator? %>
|
||||||
|
<%= f.input :title %>
|
||||||
|
<% end %>
|
||||||
<%= f.input :body %>
|
<%= f.input :body %>
|
||||||
<% if CurrentUser. %>
|
<% if CurrentUser.is_janitor? %>
|
||||||
<%= f.input :is_locked %>
|
<%= f.input :is_locked %>
|
||||||
|
<% end %>
|
||||||
<%= f.button :submit, "Save" %><%= f.button :submit, "Cancel" %><%= f.button :submit "Preview" %>
|
<%= f.button :submit, "Save" %><%= f.button :submit, "Cancel" %><%= f.button :submit "Preview" %>
|
||||||
|
|||||||
@@ -7,9 +7,11 @@
|
|||||||
<li>|</li>
|
<li>|</li>
|
||||||
<li><%= link_to "Posts (#{Post.fast_count(@wiki_page.title)})", posts_path(:tags => @wiki_page.title) %></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 "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>
|
<% unless @wiki_page.new_record? %>
|
||||||
<% if CurrentUser.is_moderator? %>
|
<li><%= link_to "Edit", edit_wiki_page_path(@wiki_page) %></li>
|
||||||
<li><%= link_to "Delete", wiki_page_path(@wiki_page), :remote => true, :method => :delete, :confirm => "Do you want to delete this 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 %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</menu>
|
</menu>
|
||||||
|
|||||||
@@ -10,48 +10,8 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wiki-page-posts">
|
<div id="wiki-page-posts">
|
||||||
<%= @wiki_page.presenter.posts %>
|
<%= @wiki_page.post_set.presenter.post_previews_html %>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
|
||||||
|
|||||||
@@ -1430,7 +1430,9 @@ $(document).ready(function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Pool.initialize_simple_edit = function() {
|
Danbooru.Pool.initialize_simple_edit = function() {
|
||||||
$("ul#sortable").sortable();
|
$("ul#sortable").sortable({
|
||||||
|
placeholder: "ui-state-placeholder"
|
||||||
|
});
|
||||||
$("ul#sortable").disableSelection();
|
$("ul#sortable").disableSelection();
|
||||||
$("ul#sortable span.delete").click(function(e) {
|
$("ul#sortable span.delete").click(function(e) {
|
||||||
$(e.target).parent().remove();
|
$(e.target).parent().remove();
|
||||||
|
|||||||
@@ -16,7 +16,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
Danbooru.Pool.initialize_simple_edit = function() {
|
Danbooru.Pool.initialize_simple_edit = function() {
|
||||||
$("ul#sortable").sortable();
|
$("ul#sortable").sortable({
|
||||||
|
placeholder: "ui-state-placeholder"
|
||||||
|
});
|
||||||
$("ul#sortable").disableSelection();
|
$("ul#sortable").disableSelection();
|
||||||
$("ul#sortable span.delete").click(function(e) {
|
$("ul#sortable span.delete").click(function(e) {
|
||||||
$(e.target).parent().remove();
|
$(e.target).parent().remove();
|
||||||
|
|||||||
@@ -218,9 +218,26 @@ div.dtext p {
|
|||||||
margin-bottom: 1em; }
|
margin-bottom: 1em; }
|
||||||
|
|
||||||
/*** Pools ***/
|
/*** Pools ***/
|
||||||
div.pools div.edit p {
|
div#c-pools div#a-edit p {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
width: 40em; }
|
width: 40em; }
|
||||||
|
div#c-pools div#a-edit ul.ui-sortable {
|
||||||
|
list-style-type: none; }
|
||||||
|
div#c-pools div#a-edit ul.ui-sortable span {
|
||||||
|
margin: 0;
|
||||||
|
float: right;
|
||||||
|
cursor: pointer; }
|
||||||
|
div#c-pools div#a-edit ul.ui-sortable li {
|
||||||
|
padding: 0.5em; }
|
||||||
|
div#c-pools div#a-edit ul.ui-sortable li.ui-state-default {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
width: 250px;
|
||||||
|
background: none; }
|
||||||
|
div#c-pools div#a-edit ul.ui-sortable li.ui-state-placeholder {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
width: 250px;
|
||||||
|
height: 150px;
|
||||||
|
background: none; }
|
||||||
|
|
||||||
/*** Comments ***/
|
/*** Comments ***/
|
||||||
div.comments-for-post div.list-of-comments article {
|
div.comments-for-post div.list-of-comments article {
|
||||||
@@ -254,38 +271,43 @@ div.favorites section#content > h1 {
|
|||||||
display: none; }
|
display: none; }
|
||||||
|
|
||||||
/*** Posts ***/
|
/*** Posts ***/
|
||||||
div.posts h1 {
|
article.post-preview {
|
||||||
|
margin-right: 4em;
|
||||||
|
margin-bottom: 4em;
|
||||||
|
float: left; }
|
||||||
|
|
||||||
|
div#c-posts h1 {
|
||||||
font-size: 1.2em; }
|
font-size: 1.2em; }
|
||||||
div.posts h2 {
|
div#c-posts h2 {
|
||||||
font-size: 1.1em; }
|
font-size: 1.1em; }
|
||||||
div.posts aside#sidebar > section > ul li {
|
div#c-posts aside#sidebar > section > ul li {
|
||||||
list-style-type: none; }
|
list-style-type: none; }
|
||||||
div.posts aside#sidebar > section > ul ul li {
|
div#c-posts aside#sidebar > section > ul ul li {
|
||||||
margin-left: 1em; }
|
margin-left: 1em; }
|
||||||
div.posts section#tag-and-wiki-box {
|
div#c-posts section#tag-and-wiki-box {
|
||||||
padding: 0; }
|
padding: 0; }
|
||||||
div.posts section#tag-and-wiki-box menu li {
|
div#c-posts section#tag-and-wiki-box menu li {
|
||||||
display: inline-block; }
|
display: inline-block; }
|
||||||
div.posts section#tag-and-wiki-box menu li.active a {
|
div#c-posts section#tag-and-wiki-box menu li.active a {
|
||||||
color: #000; }
|
color: #000; }
|
||||||
div.posts section#tag-and-wiki-box h1 {
|
div#c-posts section#tag-and-wiki-box h1 {
|
||||||
font-size: 1.2em; }
|
font-size: 1.2em; }
|
||||||
div.posts section#tag-and-wiki-box div#tag-box h2 {
|
div#c-posts section#tag-and-wiki-box div#tag-box h2 {
|
||||||
display: none; }
|
display: none; }
|
||||||
div.posts section#tag-and-wiki-box div#tag-box li {
|
div#c-posts section#tag-and-wiki-box div#tag-box li {
|
||||||
list-style-type: none; }
|
list-style-type: none; }
|
||||||
div.posts section#tag-and-wiki-box div#wiki-box h2 {
|
div#c-posts section#tag-and-wiki-box div#wiki-box h2 {
|
||||||
display: none; }
|
display: none; }
|
||||||
div.posts section#content > h1 {
|
div#c-posts section#content > h1 {
|
||||||
display: none; }
|
display: none; }
|
||||||
div.posts section#content section > h2 {
|
div#c-posts section#content section > h2 {
|
||||||
display: none; }
|
display: none; }
|
||||||
div.posts section#content menu#post-sections {
|
div#c-posts section#content menu#post-sections {
|
||||||
margin-bottom: 1em; }
|
margin-bottom: 1em; }
|
||||||
div.posts section#content menu#post-sections li {
|
div#c-posts section#content menu#post-sections li {
|
||||||
font-size: 1.1em;
|
font-size: 1.1em;
|
||||||
font-weight: bold; }
|
font-weight: bold; }
|
||||||
div.posts section#content menu#post-sections li.active a {
|
div#c-posts section#content menu#post-sections li.active a {
|
||||||
color: black; }
|
color: black; }
|
||||||
|
|
||||||
/*** Post Histories ***/
|
/*** Post Histories ***/
|
||||||
|
|||||||
@@ -311,12 +311,39 @@ div.dtext {
|
|||||||
|
|
||||||
/*** Pools ***/
|
/*** Pools ***/
|
||||||
|
|
||||||
div.pools {
|
div#c-pools {
|
||||||
div.edit {
|
div#a-edit {
|
||||||
p {
|
p {
|
||||||
margin-bottom: 1em;
|
margin-bottom: 1em;
|
||||||
width: 40em;
|
width: 40em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: 250px;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
li.ui-state-placeholder {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
width: 250px;
|
||||||
|
height: 150px;
|
||||||
|
background: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -386,7 +413,13 @@ div.favorites {
|
|||||||
|
|
||||||
/*** Posts ***/
|
/*** Posts ***/
|
||||||
|
|
||||||
div.posts {
|
article.post-preview {
|
||||||
|
margin-right: 4em;
|
||||||
|
margin-bottom: 4em;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#c-posts {
|
||||||
h1 {
|
h1 {
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user