enhance show or new wpages; move wpage preview code to helper
This commit is contained in:
@@ -69,6 +69,9 @@ class WikiPagesController < ApplicationController
|
|||||||
@wiki_page = WikiPage.find_by_title(params[:title])
|
@wiki_page = WikiPage.find_by_title(params[:title])
|
||||||
if @wiki_page
|
if @wiki_page
|
||||||
redirect_to wiki_page_path(@wiki_page)
|
redirect_to wiki_page_path(@wiki_page)
|
||||||
|
else
|
||||||
|
@wiki_page = WikiPage.new(params[:wiki_page])
|
||||||
|
respond_with(@wiki_page)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -33,4 +33,17 @@ module WikiPagesHelper
|
|||||||
|
|
||||||
html.html_safe
|
html.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def wiki_page_post_previews(wiki_page)
|
||||||
|
html = '<div id="wiki-page-posts">'
|
||||||
|
|
||||||
|
if Post.fast_count(wiki_page.title) > 0
|
||||||
|
html << "<h2>Posts</h2>"
|
||||||
|
html << wiki_page.post_set.presenter.post_previews_html(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
html << "</div>"
|
||||||
|
|
||||||
|
html.html_safe
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,12 +15,7 @@
|
|||||||
|
|
||||||
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
|
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
|
||||||
|
|
||||||
<div id="wiki-page-posts">
|
<%= wiki_page_post_previews(@wiki_page) %>
|
||||||
<% if Post.fast_count(@wiki_page.title) > 0 %>
|
|
||||||
<h2>Posts</h2>
|
|
||||||
<% end %>
|
|
||||||
<%= @wiki_page.post_set.presenter.post_previews_html(self) %>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -18,12 +18,7 @@
|
|||||||
<%= wiki_page_alias_and_implication_list(@wiki_page) %>
|
<%= wiki_page_alias_and_implication_list(@wiki_page) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="wiki-page-posts">
|
<%= wiki_page_post_previews(@wiki_page) %>
|
||||||
<% if Post.fast_count(@wiki_page.title) > 0 %>
|
|
||||||
<h2>Posts</h2>
|
|
||||||
<% end %>
|
|
||||||
<%= @wiki_page.post_set.presenter.post_previews_html(self) %>
|
|
||||||
</div>
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -7,12 +7,17 @@
|
|||||||
<div id="wiki-page-body" class="prose">
|
<div id="wiki-page-body" class="prose">
|
||||||
<p>This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.</p>
|
<p>This wiki page does not exist. <%= link_to "Create new wiki page", new_wiki_page_path(:wiki_page => {:title => params[:title]}) %>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= wiki_page_alias_and_implication_list(@wiki_page)%>
|
||||||
|
|
||||||
|
<%= wiki_page_post_previews(@wiki_page) %>
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<%= render "secondary_links" %>
|
||||||
|
|
||||||
<% content_for(:page_title) do %>
|
<% content_for(:page_title) do %>
|
||||||
Wiki - <%= params[:title] %> - <%= Danbooru.config.app_name %>
|
Wiki - <%= params[:title] %> - <%= Danbooru.config.app_name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<%= render "secondary_links" %>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user