switch post previews to use flexbox, add better styling for cropped thumbnails
This commit is contained in:
@@ -38,12 +38,16 @@ div#page {
|
|||||||
}
|
}
|
||||||
|
|
||||||
input[type=text] {
|
input[type=text] {
|
||||||
width: 10em;
|
|
||||||
|
|
||||||
/* ensure expanded search box renders above post thumbnails. */
|
/* ensure expanded search box renders above post thumbnails. */
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button[type=submit] {
|
||||||
|
padding: 2px 6px;
|
||||||
|
background: #EEE;
|
||||||
|
border-left: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
aside#sidebar > section {
|
aside#sidebar > section {
|
||||||
|
|||||||
@@ -10,11 +10,10 @@ div.paginator {
|
|||||||
a {
|
a {
|
||||||
margin: 0 0.25em;
|
margin: 0 0.25em;
|
||||||
padding: 0.25em 0.75em;
|
padding: 0.25em 0.75em;
|
||||||
border: 1px solid #EAEAEA;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
a.arrow {
|
&.more {
|
||||||
border: none;
|
color: grey;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.arrow:hover {
|
a.arrow:hover {
|
||||||
@@ -22,10 +21,6 @@ div.paginator {
|
|||||||
color: $link_color;
|
color: $link_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.current {
|
|
||||||
border: 1px solid #AAA;
|
|
||||||
}
|
|
||||||
|
|
||||||
a:hover {
|
a:hover {
|
||||||
background: $link_color;
|
background: $link_color;
|
||||||
color: white;
|
color: white;
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ article.post-preview {
|
|||||||
height: 154px;
|
height: 154px;
|
||||||
width: 154px;
|
width: 154px;
|
||||||
margin: 0 10px 10px 0;
|
margin: 0 10px 10px 0;
|
||||||
float: left;
|
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
@include inline-block;
|
@include inline-block;
|
||||||
@@ -26,13 +25,6 @@ article.post-preview {
|
|||||||
margin: auto;
|
margin: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.large-cropped {
|
|
||||||
height: auto;
|
|
||||||
weidth: auto;
|
|
||||||
float: none;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
||||||
@include animated-icon;
|
@include animated-icon;
|
||||||
}
|
}
|
||||||
@@ -171,7 +163,6 @@ body[data-user-can-approve-posts="true"] .post-preview {
|
|||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
article.post-preview {
|
article.post-preview {
|
||||||
float: none;
|
|
||||||
width: auto;
|
width: auto;
|
||||||
border: none;
|
border: none;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
@@ -314,13 +305,6 @@ div#c-posts {
|
|||||||
}
|
}
|
||||||
|
|
||||||
div#a-index {
|
div#a-index {
|
||||||
div#jlist-rss-ads-for-show {
|
|
||||||
float: right;
|
|
||||||
position: absolute;
|
|
||||||
top: 0;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
menu#post-sections {
|
menu#post-sections {
|
||||||
margin-bottom: 0.5em;
|
margin-bottom: 0.5em;
|
||||||
font-size: $h3_size;
|
font-size: $h3_size;
|
||||||
|
|||||||
@@ -22,12 +22,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
div#page aside#sidebar {
|
div#page aside#sidebar {
|
||||||
|
padding: 5px;
|
||||||
|
|
||||||
input#tags {
|
input#tags {
|
||||||
width: 75%;
|
width: 80%;
|
||||||
}
|
}
|
||||||
|
|
||||||
input[type=submit] {
|
button[type=submit] {
|
||||||
width: 20%;
|
font-size: 1.4em;
|
||||||
|
background-color: #EEE;
|
||||||
|
height: 42px;
|
||||||
|
padding: 2px 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -136,34 +141,26 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#posts #posts-container {
|
||||||
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
article.post-preview {
|
article.post-preview {
|
||||||
margin: 0.5vw;
|
float: none;
|
||||||
width: 48vw;
|
margin: 0;
|
||||||
height: 48vw;
|
|
||||||
text-align: center;
|
text-align: center;
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
|
|
||||||
&.cropped {
|
|
||||||
width: 32vw;
|
|
||||||
height: 32vw;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
a {
|
||||||
//width: 48.5vw;
|
|
||||||
//display: block;
|
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
img {
|
img {
|
||||||
//object-fit: contain;
|
|
||||||
margin: 0 auto;
|
|
||||||
border: none !important;
|
border: none !important;
|
||||||
|
|
||||||
&.cropped {
|
|
||||||
width: 32vw;
|
|
||||||
height: 32vw;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
&[data-tags~=animated]:before, &[data-file-ext=swf]:before, &[data-file-ext=webm]:before, &[data-file-ext=mp4]:before, &[data-file-ext=zip]:before {
|
||||||
@@ -175,6 +172,19 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.user-disable-cropped-false {
|
||||||
|
article {
|
||||||
|
width: 32vw;
|
||||||
|
height: 32vw;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 32vw;
|
||||||
|
height: 32vw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
img#image {
|
img#image {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,9 +29,9 @@ module PaginationHelper
|
|||||||
window = 4
|
window = 4
|
||||||
|
|
||||||
if records.current_page >= 2
|
if records.current_page >= 2
|
||||||
html << "<li class='arrow'>" + link_to("<<", nav_params_for(records.current_page - 1), :rel => "prev") + "</li>"
|
html << "<li class='arrow'>" + link_to(content_tag(:i, nil, class: "fas fa-chevron-left"), nav_params_for(records.current_page - 1), :rel => "prev") + "</li>"
|
||||||
else
|
else
|
||||||
html << "<li class='arrow'><span>" + "<<" + "</span></li>"
|
html << "<li class='arrow'><span>" + content_tag(:i, nil, class: "fas fa-chevron-left") + "</span></li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
if records.total_pages <= (window * 2) + 5
|
if records.total_pages <= (window * 2) + 5
|
||||||
@@ -69,9 +69,9 @@ module PaginationHelper
|
|||||||
end
|
end
|
||||||
|
|
||||||
if records.current_page < records.total_pages && records.size > 0
|
if records.current_page < records.total_pages && records.size > 0
|
||||||
html << "<li class='arrow'>" + link_to(">>", nav_params_for(records.current_page + 1), :rel => "next") + "</li>"
|
html << "<li class='arrow'>" + link_to(content_tag(:i, nil, class: "fas fa-chevron-right"), nav_params_for(records.current_page + 1), :rel => "next") + "</li>"
|
||||||
else
|
else
|
||||||
html << "<li class='arrow'><span>" + ">>" + "</span></li>"
|
html << "<li class='arrow'><span>" + content_tag(:i, nil, class: "fas fa-chevron-right") + "</span></li>"
|
||||||
end
|
end
|
||||||
|
|
||||||
html << "</menu></div>"
|
html << "</menu></div>"
|
||||||
@@ -92,7 +92,7 @@ module PaginationHelper
|
|||||||
html = []
|
html = []
|
||||||
if page == "..."
|
if page == "..."
|
||||||
html << "<li class='more'>"
|
html << "<li class='more'>"
|
||||||
html << "..."
|
html << content_tag(:i, nil, class: "fas fa-ellipsis-h")
|
||||||
html << "</li>"
|
html << "</li>"
|
||||||
elsif page == current_page
|
elsif page == current_page
|
||||||
html << "<li class='current-page'>"
|
html << "<li class='current-page'>"
|
||||||
|
|||||||
@@ -21,15 +21,13 @@ class PostPresenter < Presenter
|
|||||||
end
|
end
|
||||||
|
|
||||||
path = options[:path_prefix] || "/posts"
|
path = options[:path_prefix] || "/posts"
|
||||||
if Danbooru.config.enable_image_cropping && CurrentUser.id == 1 && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails?
|
if Danbooru.config.enable_image_cropping && options[:show_cropped] && post.has_cropped? && !CurrentUser.user.disable_cropped_thumbnails?
|
||||||
src = post.crop_file_url
|
cropped_src = post.crop_file_url
|
||||||
imgClass = "cropped"
|
|
||||||
else
|
else
|
||||||
src = post.preview_file_url
|
cropped_src = post.preview_file_url
|
||||||
imgClass = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
html = %{<article itemscope itemtype="http://schema.org/ImageObject" id="post_#{post.id}" class="#{imgClass} #{preview_class(post, options[:pool], options)}" #{data_attributes(post)}>}
|
html = %{<article itemscope itemtype="http://schema.org/ImageObject" id="post_#{post.id}" class="#{preview_class(post, options[:pool], options)}" #{data_attributes(post)}>}
|
||||||
if options[:tags].present? && !CurrentUser.is_anonymous?
|
if options[:tags].present? && !CurrentUser.is_anonymous?
|
||||||
tag_param = "?tags=#{CGI::escape(options[:tags])}"
|
tag_param = "?tags=#{CGI::escape(options[:tags])}"
|
||||||
elsif options[:pool_id] || options[:pool]
|
elsif options[:pool_id] || options[:pool]
|
||||||
@@ -42,7 +40,11 @@ class PostPresenter < Presenter
|
|||||||
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
|
html << %{<a href="#{path}/#{post.id}#{tag_param}">}
|
||||||
|
|
||||||
tooltip = "#{post.tag_string} rating:#{post.rating} score:#{post.score}"
|
tooltip = "#{post.tag_string} rating:#{post.rating} score:#{post.score}"
|
||||||
html << %{<img class="#{imgClass}" itemprop="thumbnailUrl" src="#{src}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
|
html << %{<picture>}
|
||||||
|
html << %{<source media="(max-width: 660px)" srcset="#{cropped_src}">}
|
||||||
|
html << %{<source media="(min-width: 660px)" srcset="#{post.preview_file_url}">}
|
||||||
|
html << %{<img itemprop="thumbnailUrl" src="#{post.preview_file_url}" title="#{h(tooltip)}" alt="#{h(post.tag_string)}">}
|
||||||
|
html << %{</picture>}
|
||||||
html << %{</a>}
|
html << %{</a>}
|
||||||
|
|
||||||
if options[:pool]
|
if options[:pool]
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ module PostSetPresenters
|
|||||||
end
|
end
|
||||||
|
|
||||||
posts.each do |post|
|
posts.each do |post|
|
||||||
html << PostPresenter.preview(post, options.merge(:show_cropped => true, :tags => @post_set.tag_string, :raw => @post_set.raw))
|
html << PostPresenter.preview(post, options.merge(:tags => @post_set.tag_string, :raw => @post_set.raw))
|
||||||
html << "\n"
|
html << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ module PostSetPresenters
|
|||||||
@tag_set_presenter ||= TagSetPresenter.new(related_tags)
|
@tag_set_presenter ||= TagSetPresenter.new(related_tags)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def post_previews_html(template, options = {})
|
||||||
|
super(template, options.merge(show_cropped: true))
|
||||||
|
end
|
||||||
|
|
||||||
def related_tags
|
def related_tags
|
||||||
if post_set.is_pattern_search?
|
if post_set.is_pattern_search?
|
||||||
pattern_tags
|
pattern_tags
|
||||||
|
|||||||
@@ -6,14 +6,13 @@
|
|||||||
<section id="search-box">
|
<section id="search-box">
|
||||||
<h1>Search</h1>
|
<h1>Search</h1>
|
||||||
<%= form_tag(path, :method => "get") do %>
|
<%= form_tag(path, :method => "get") do %>
|
||||||
<%= text_field_tag("tags", tags, :size => 30, :id => tags_dom_id, :data => { :autocomplete => "tag-query" }) %>
|
|
||||||
<% if params[:raw] %>
|
<% if params[:raw] %>
|
||||||
<%= hidden_field_tag :raw, params[:raw] %>
|
<%= hidden_field_tag :raw, params[:raw] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if params[:random] %>
|
<% if params[:random] %>
|
||||||
<%= hidden_field_tag :random, params[:random] %>
|
<%= hidden_field_tag :random, params[:random] %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= submit_tag "Go", :name => nil, :class => "ui-button ui-widget ui-corner-all tiny gradient" %>
|
<%= text_field_tag("tags", tags, :id => tags_dom_id, :data => { :autocomplete => "tag-query" }) %><%= content_tag "button", content_tag("i", nil, class: "fas fa-search"), type: "submit" %>
|
||||||
<%= hidden_field_tag "ms", "1" %>
|
<%= hidden_field_tag "ms", "1" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
<div id="posts">
|
<div id="posts" class="user-disable-cropped-<%= CurrentUser.user.disable_cropped_thumbnails? %>">
|
||||||
<div style="overflow: hidden;">
|
<div id="posts-container">
|
||||||
<%= post_set.presenter.post_previews_html(self) %>
|
<%= post_set.presenter.post_previews_html(self) %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ end
|
|||||||
if Comment.count == 0
|
if Comment.count == 0
|
||||||
puts "Creating comments"
|
puts "Creating comments"
|
||||||
Post.all.each do |post|
|
Post.all.each do |post|
|
||||||
rand(10).times do
|
rand(100).times do
|
||||||
Comment.create(:post_id => post.id, :body => rand_paragraph(6))
|
Comment.create(:post_id => post.id, :body => rand_paragraph(6))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -141,7 +141,7 @@ if Note.count == 0
|
|||||||
rand(5).times do
|
rand(5).times do
|
||||||
note = Note.create(:post_id => post.id, :x => rand(post.image_width), :y => rand(post.image_height), :width => 100, :height => 100, :body => Time.now.to_f.to_s)
|
note = Note.create(:post_id => post.id, :x => rand(post.image_width), :y => rand(post.image_height), :width => 100, :height => 100, :body => Time.now.to_f.to_s)
|
||||||
|
|
||||||
rand(10).times do |i|
|
rand(20).times do |i|
|
||||||
note.update_attributes(:body => rand_sentence(6))
|
note.update_attributes(:body => rand_sentence(6))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user