views: factor out sidebar layout template.

* Factor out common sidebar layout template.
* Convert wiki pages and posts to use this template.
* Add data-layout attribute to <body> element indicating the current layout.
This commit is contained in:
evazion
2019-09-28 17:05:18 -05:00
parent f7d7ed4b23
commit 960e5d4ae0
16 changed files with 316 additions and 339 deletions

View File

@@ -1,58 +1,53 @@
<div id="c-posts">
<div id="a-index">
<aside id="sidebar">
<%= render "posts/partials/common/search", :path => posts_path, :tags => params[:tags], :tags_dom_id => "tags" %>
<% content_for(:sidebar) do %>
<%= render "posts/partials/common/search", :path => posts_path, :tags => params[:tags], :tags_dom_id => "tags" %>
<%= render "posts/partials/index/mode_menu" %>
<%= render "posts/partials/index/mode_menu" %>
<%= render "posts/partials/index/blacklist" %>
<%= render "posts/partials/index/blacklist" %>
<section id="tag-box">
<h1>Tags</h1>
<%= @post_set.presenter.tag_list_html(current_query: params[:tags], show_extra_links: CurrentUser.user.is_gold?) %>
</section>
<section id="tag-box">
<h1>Tags</h1>
<%= @post_set.presenter.tag_list_html(current_query: params[:tags], show_extra_links: CurrentUser.user.is_gold?) %>
</section>
<section id="tag-box">
<h1>Share</h1>
<%= render "posts/partials/index/share" %>
</section>
<section id="tag-box">
<h1>Share</h1>
<%= render "posts/partials/index/share" %>
</section>
<%= render "posts/partials/index/options" %>
<%= render "posts/partials/index/options" %>
<%= render "posts/partials/index/related" %>
</aside>
<%= render "posts/partials/index/related" %>
<% end %>
<section id="content">
<menu id="post-sections">
<li class="active"><a href="#" id="show-posts-link">Posts</a></li>
<% content_for(:content) do %>
<menu id="post-sections">
<li class="active"><a href="#" id="show-posts-link">Posts</a></li>
<% if @post_set.artist.present? %>
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
<% elsif @post_set.wiki_page.present? %>
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_pool? %>
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_favgroup? %>
<li><%= link_to "Favorite Group", favorite_group_path(@post_set.favgroup), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_blank_wiki? %>
<li><%= link_to "Wiki", new_wiki_page_path(wiki_page: { title: @post_set.tag_string }), id: "show-excerpt-link" %></li>
<% end %>
<% if @post_set.artist.present? %>
<li><%= link_to "Artist", artist_path(@post_set.artist), :id => "show-excerpt-link" %></li>
<% elsif @post_set.wiki_page.present? %>
<li><%= link_to "Wiki", wiki_page_path(@post_set.wiki_page), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_pool? %>
<li><%= link_to "Pool", pool_path(@post_set.pool), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_favgroup? %>
<li><%= link_to "Favorite Group", favorite_group_path(@post_set.favgroup), :id => "show-excerpt-link" %></li>
<% elsif @post_set.has_blank_wiki? %>
<li><%= link_to "Wiki", new_wiki_page_path(wiki_page: { title: @post_set.tag_string }), id: "show-excerpt-link" %></li>
<% end %>
<li id="searchbox-redirect-link"><a href="#search-box">Search &raquo;</a></li>
</menu>
<li id="searchbox-redirect-link"><a href="#search-box">Search &raquo;</a></li>
</menu>
<%= render "posts/partials/index/edit" %>
<%= render "posts/partials/index/excerpt", :post_set => @post_set %>
<%= render "posts/partials/index/posts", :post_set => @post_set %>
</section>
<%= render "posts/partials/index/edit" %>
<%= render "posts/partials/index/excerpt", :post_set => @post_set %>
<%= render "posts/partials/index/posts", :post_set => @post_set %>
<% end %>
<%= post_search_count_js %>
<%= post_search_count_js %>
<div id="saved-searches-nav">
<%= render "saved_searches/interface" %>
</div>
</div>
<div id="saved-searches-nav">
<%= render "saved_searches/interface" %>
</div>
<% if params[:tags] =~ /search:/ %>

View File

@@ -1,155 +1,151 @@
<div id="c-posts">
<div id="a-show">
<aside id="sidebar">
<%= render "posts/partials/common/search", :path => posts_path, :tags => params[:q], :tags_dom_id => "tags" %>
<% content_for(:sidebar) do %>
<%= render "posts/partials/common/search", :path => posts_path, :tags => params[:q], :tags_dom_id => "tags" %>
<%= render "posts/partials/index/blacklist" %>
<%= render "posts/partials/index/blacklist" %>
<section id="tag-list">
<%= @post.presenter.split_tag_list_html(current_query: params[:q], show_extra_links: CurrentUser.user.is_gold?) %>
</section>
<section id="tag-list">
<%= @post.presenter.split_tag_list_html(current_query: params[:q], show_extra_links: CurrentUser.user.is_gold?) %>
</section>
<section id="post-information">
<h1>Information</h1>
<%= render "posts/partials/show/information", :post => @post %>
</section>
<section id="post-information">
<h1>Information</h1>
<%= render "posts/partials/show/information", :post => @post %>
</section>
<section id="post-share">
<h1>Share</h1>
<%= render "posts/partials/show/share", :post => @post %>
</section>
<section id="post-share">
<h1>Share</h1>
<%= render "posts/partials/show/share", :post => @post %>
</section>
<section id="post-options">
<h1>Options</h1>
<%= render "posts/partials/show/options", :post => @post %>
</section>
<section id="post-options">
<h1>Options</h1>
<%= render "posts/partials/show/options", :post => @post %>
</section>
<section id="post-history">
<h1>History</h1>
<ul>
<li id="post-history-tags"><%= link_to "Tags", post_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-pools"><%= link_to "Pools", pool_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-notes"><%= link_to "Notes", note_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-moderation"><%= link_to "Moderation", post_events_path(@post.id) %></li>
<li id="post-history-commentary"><%= link_to "Commentary", artist_commentary_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-replacements"><%= link_to "Replacements", post_replacements_path(search: {post_id: @post.id }) %></li>
</ul>
</section>
</aside>
<section id="post-history">
<h1>History</h1>
<ul>
<li id="post-history-tags"><%= link_to "Tags", post_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-pools"><%= link_to "Pools", pool_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-notes"><%= link_to "Notes", note_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-moderation"><%= link_to "Moderation", post_events_path(@post.id) %></li>
<li id="post-history-commentary"><%= link_to "Commentary", artist_commentary_versions_path(search: { post_id: @post.id }) %></li>
<li id="post-history-replacements"><%= link_to "Replacements", post_replacements_path(search: {post_id: @post.id }) %></li>
</ul>
</section>
<% end %>
<section id="content">
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "top" %>
<% end %>
<% content_for(:content) do %>
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "top" %>
<% end %>
<%= render "posts/partials/show/notices", :post => @post %>
<%= render "posts/partials/show/notices", :post => @post %>
<%= content_tag(:section, { id: "image-container" }.merge(PostPresenter.data_attributes(@post))) do -%>
<div id="note-container"></div>
<div id="note-preview"></div>
<%= render "posts/partials/show/embedded", post: @post %>
<% end -%>
<% if CurrentUser.is_member? %>
<%= content_tag(:div, class: "fav-buttons fav-buttons-#{@post.is_favorited?}") do %>
<%= form_tag(favorites_path(post_id: @post.id), method: "post", id: "add-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<% end %>
<%= form_tag(favorite_path(@post.id), method: "delete", id: "remove-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<% end %>
<% end %>
<% end %>
<section id="mark-as-translated-section" style="display: none;">
<%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>
<%= hidden_field_tag :tags_query, params[:q] %>
<%= hidden_field_tag :pool_id, params[:pool_id] %>
<fieldset>
<label for="post_check_translation">
<%= check_box "post", "check_translation", :checked => @post.has_tag?("check_translation") %>
Check translation
</label>
<label for="post_partially_translated">
<%= check_box "post", "partially_translated", :checked => @post.has_tag?("partially_translated") %>
Partially translated
</label>
</fieldset>
<div class="input">
<%= submit_tag "Mark as translated" %>
</div>
<% end %>
</section>
<% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
<div id="artist-commentary">
<%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>
</div>
<% end %>
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
<% end %>
<menu id="post-sections">
<li class="active"><a href="#comments">Comments</a></li>
<% if RecommenderService.available_for_post?(@post) %>
<li><a href="#recommended">Recommended</a></li>
<% end %>
<% if CurrentUser.is_member? && @post.visible? %>
<li><a href="#edit" id="post-edit-link" data-shortcut="e">Edit</a></li>
<% end %>
</menu>
<% if RecommenderService.available_for_post?(@post) %>
<section id="recommended" style="display: none;">
<p><em>Loading...</em></p>
</section>
<% end %>
<section id="comments">
<% if !CurrentUser.user.is_builder? %>
<h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
<% end %>
<%= render "comments/partials/index/list", comments: @comments, post: @post, page: :post %>
</section>
<section id="notes" style="display: none;">
<% if @post.has_notes? %>
<% cache("p/#{@post.id}/n/#{@post.last_noted_at.to_i}") do %>
<%= render :partial => "notes/note", :collection => @post.notes.active %>
<% end %>
<% end %>
</section>
<% if CurrentUser.is_member? && @post.visible? %>
<section id="edit" style="display: none;">
<%= render "posts/partials/show/edit", :post => @post %>
</section>
<% end %>
</section>
</div>
<%= content_tag(:section, { id: "image-container" }.merge(PostPresenter.data_attributes(@post))) do -%>
<div id="note-container"></div>
<div id="note-preview"></div>
<%= render "posts/partials/show/embedded", post: @post %>
<% end -%>
<% if CurrentUser.is_member? %>
<div id="add-to-pool-dialog" title="Add to pool" style="display: none;">
<%= render "pool_elements/new" %>
</div>
<%= content_tag(:div, class: "fav-buttons fav-buttons-#{@post.is_favorited?}") do %>
<%= form_tag(favorites_path(post_id: @post.id), method: "post", id: "add-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<% end %>
<div id="add-commentary-dialog" title="Add artist commentary" style="display: none;">
<%= render "artist_commentaries/form", :post => @post %>
</div>
<%= form_tag(favorite_path(@post.id), method: "delete", id: "remove-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<% end %>
<% end %>
<% end %>
<div id="add-to-favgroup-dialog" title="Add to favorite group" style="display: none;">
<%= render "favorite_groups/add_to_favgroup_dialog", :post => @post %>
<section id="mark-as-translated-section" style="display: none;">
<%= form_tag(mark_as_translated_post_path(@post), :class => "simple_form", :method => :put) do |f| %>
<%= hidden_field_tag :tags_query, params[:q] %>
<%= hidden_field_tag :pool_id, params[:pool_id] %>
<fieldset>
<label for="post_check_translation">
<%= check_box "post", "check_translation", :checked => @post.has_tag?("check_translation") %>
Check translation
</label>
<label for="post_partially_translated">
<%= check_box "post", "partially_translated", :checked => @post.has_tag?("partially_translated") %>
Partially translated
</label>
</fieldset>
<div class="input">
<%= submit_tag "Mark as translated" %>
</div>
<% end %>
</section>
<% if @post.artist_commentary && @post.artist_commentary.any_field_present? %>
<div id="artist-commentary">
<%= render "artist_commentaries/show", :artist_commentary => @post.artist_commentary %>
</div>
<% end %>
</div>
<% if @post.presenter.has_nav_links?(self) %>
<%= render "posts/partials/show/nav_links", :post => @post, :position => "bottom" %>
<% end %>
<menu id="post-sections">
<li class="active"><a href="#comments">Comments</a></li>
<% if RecommenderService.available_for_post?(@post) %>
<li><a href="#recommended">Recommended</a></li>
<% end %>
<% if CurrentUser.is_member? && @post.visible? %>
<li><a href="#edit" id="post-edit-link" data-shortcut="e">Edit</a></li>
<% end %>
</menu>
<% if RecommenderService.available_for_post?(@post) %>
<section id="recommended" style="display: none;">
<p><em>Loading...</em></p>
</section>
<% end %>
<section id="comments">
<% if !CurrentUser.user.is_builder? %>
<h2>Before commenting, read the <%= link_to "how to comment guide", wiki_pages_path(:search => {:title => "howto:comment"}) %>.</h2>
<% end %>
<%= render "comments/partials/index/list", comments: @comments, post: @post, page: :post %>
</section>
<section id="notes" style="display: none;">
<% if @post.has_notes? %>
<% cache("p/#{@post.id}/n/#{@post.last_noted_at.to_i}") do %>
<%= render :partial => "notes/note", :collection => @post.notes.active %>
<% end %>
<% end %>
</section>
<% if CurrentUser.is_member? && @post.visible? %>
<section id="edit" style="display: none;">
<%= render "posts/partials/show/edit", :post => @post %>
</section>
<% end %>
<% end %>
<% if CurrentUser.is_member? %>
<div id="add-to-pool-dialog" title="Add to pool" style="display: none;">
<%= render "pool_elements/new" %>
</div>
<div id="add-commentary-dialog" title="Add artist commentary" style="display: none;">
<%= render "artist_commentaries/form", :post => @post %>
</div>
<div id="add-to-favgroup-dialog" title="Add to favorite group" style="display: none;">
<%= render "favorite_groups/add_to_favgroup_dialog", :post => @post %>
</div>
<% end %>
<%= post_view_count_js %>