richer news feed, change screenshots/thumbnails to use retina quality

This commit is contained in:
Kyle Drake 2014-09-17 20:13:14 -07:00
parent 45168341de
commit 1d200a886e
11 changed files with 69 additions and 36 deletions

View file

@ -168,4 +168,11 @@ task :cleantags => [:environment] do
matching_tag.delete
end
end
end
desc 'update screenshots'
task :updatescreenshots => [:environment] do
Site.select(:username).where(site_changed: true, is_banned: false, is_crashing: false).all.each do |site|
ScreenshotWorker.new.perform site.username, 'index.html'
end
end

View file

@ -59,8 +59,8 @@ class Site < Sequel::Model
HTML_REGEX = /htm|html/
MAX_COMMENT_SIZE = 420 # Used to be the limit for Facebook.. no comment (PUN NOT INTENDED).
SCREENSHOT_RESOLUTIONS = ['235x141', '105x63', '270x162', '37x37', '146x88', '302x182', '90x63', '82x62', '348x205']
THUMBNAIL_RESOLUTIONS = ['105x63', '90x63']
SCREENSHOT_RESOLUTIONS = ['540x405', '210x158', '100x100', '50x50']
THUMBNAIL_RESOLUTIONS = ['210x158']
CLAMAV_THREAT_MATCHES = [
/^VBS/,
@ -779,7 +779,6 @@ class Site < Sequel::Model
following_ids = self.followings_dataset.select(:site_id).all.collect {|f| f.site_id}
Event.filter(site_id: following_ids+[self.id]).
order(:created_at.desc).
exclude(actioning_site_id: self.id).
paginate(current_page, limit)
end

View file

@ -6,7 +6,7 @@
<p>You are not following any sites yet. Add some by <a href="/browse">browsing sites</a> or looking at your tags.
<% else %>
<% site.followings_dataset.select(:site_id).all.each do |following| %>
<a href="/site/<%= following.site_dataset.select(:username).first.username %>"><img src="<%= site.screenshot_path 'index.html', '37x37' %>" class="avatar"></a>
<a href="/site/<%= following.site_dataset.select(:username).first.username %>"><img src="<%= site.screenshot_path 'index.html', '50x50' %>" class="avatar"></a>
<% end %>
<% end %>
</div>
@ -21,7 +21,7 @@
<% else %>
<% site.follows_dataset.select(:actioning_site_id).all.each do |follow| %>
<% follow_actioning_site = follow.actioning_site_dataset.select(:username).first %>
<a href="/site/<%= follow_actioning_site.username %>"><img src="<%= follow_actioning_site.screenshot_path 'index.html', '37x37' %>" class="avatar"></a>
<a href="/site/<%= follow_actioning_site.username %>"><img src="<%= follow_actioning_site.screenshot_path 'index.html', '50x50' %>" class="avatar"></a>
<% end %>
<% end %>
</div>

View file

@ -18,15 +18,23 @@
<div class="news-item follow">
<div class="title">
<div class="icon"></div>
<% actioning_site = event.actioning_site_dataset.select(:username, :title, :domain).first %>
<% actioning_site = event.actioning_site_dataset.select(:id, :username, :title, :domain).first %>
<% event_site = event.site_dataset.select(:id, :username, :title, :domain).first %>
<a href="/site/<%= actioning_site.username %>" class="user" title="<%= actioning_site.title %>"><%= actioning_site.title.shorten(40) %></a>
is following
<% if current_site && current_site.id == actioning_site.id %>
You
<% else %>
<a href="/site/<%= actioning_site.username %>" class="user" title="<%= actioning_site.title %>"><%= actioning_site.username %></a>
<% end %>
started following
<% if current_site && event_site.id == current_site.id %>
your site!
<% else %>
<a href="/site/<%= event_site.username %>" class="user" title="<%= event_site.title %>"><%= event_site.title.shorten(40) %></a>
<a href="/site/<%= event_site.username %>" class="user" title="<%= event_site.title %>"><%= event_site.username %></a>
<% end %>
<span class="date">
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
</span>
@ -39,7 +47,7 @@
<% if current_site && event_site.id == current_site.id %>
Your site was updated.
<% else %>
<a href="/site/<%= event_site.username %>" class="user"><%= event_site.title %></a> has been updated.
<a href="/site/<%= event_site.username %>" class="user" title="<%= event_site.title %>"><%= event_site.title.shorten(45) %></a> has been updated.
<% end %>
<span class="date">
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
@ -54,9 +62,9 @@
<div class="html-thumbnail <%= site_change_file_display_class f %>">
<a href="//<%= event_site.host %>/<%= f %>">
<% if site_change_file_display_class(f) == 'html' %>
<img src="<%= event_site.screenshot_url(f, '90x63') %>">
<img src="<%= event_site.screenshot_url(f, '210x158') %>">
<% elsif site_change_file_display_class(f) == 'image' %>
<img src="<%= event_site.thumbnail_url(f, '90x63') %>">
<img src="<%= event_site.thumbnail_url(f, '210x158') %>">
<% elsif site_change_file_display_class(f) == 'misc' %>
<span class="misc-icon">
<%= File.extname(f).sub('.', '') %>

View file

@ -1,11 +1,22 @@
<% actioning_site = profile_comment.actioning_site_dataset.select(:username, :title, :domain).first %>
<% actioning_site = profile_comment.actioning_site_dataset.select(:id, :username).first %>
<% site = profile_comment.site_dataset.select(:id, :username).first %>
<div class="title">
<div class="icon" style="background-image:url(<%= actioning_site.screenshot_url('index.html', '82x62') %>);"></div>
<a href="/site/<%= actioning_site.username %>" class="user"><%= actioning_site.title %></a>
<% if request.path == '/' %>
posted on your site profile:
<div class="icon" style="background-image:url(<%= actioning_site.screenshot_url('index.html', '100x100') %>);"></div>
<% if current_site && current_site.id == actioning_site.id && request.path == '/' %>
You
<% else %>
<a href="/site/<%= actioning_site.username %>" class="user"><%= actioning_site.username %></a>
<% end %>
<% if request.path == '/' %>
<% if current_site && current_site.id == profile_comment.site_id %>
left a comment on <a href="/site/<%= current_site.username %>">your profile</a>:
<% else %>
left a comment on <a href="/site/<%= profile_comment.site.username %>" class="user"><%= profile_comment.site.username %></a><%= site.username[site.username.length-1] == 's' ? "'" : "'s" %> site profile:
<% end %>
<% end %>
<span class="date">
<a href="?event_id=<%= profile_comment.event.id %>"><%= profile_comment.created_at.ago %></a>
</span>

View file

@ -65,7 +65,7 @@
<% @sites.each do |site| %>
<li>
<a href="//<%= site.host %>" class="neo-Screen-Shot" target="_blank" title="<%= site.title %>">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '270x162') %>) no-repeat;">
<span class="img-Holder" style="background:url(<%= site.screenshot_url('index.html', '540x405') %>) no-repeat;">
<img src="/img/placeholder.png" alt="<%= site.title %>" />
</span>
</a>

View file

@ -22,7 +22,7 @@
<div class="col col-50 signup-Area" style="width: 289px;">
<div class="signup-Form">
<fieldset class="content">
<img class="screenshot" src="<%= current_site.screenshot_url('index.html', '270x162') %>">
<img class="screenshot" src="<%= current_site.screenshot_url('index.html', '540x405') %>">
</fieldset>
</div>
</div>
@ -112,14 +112,14 @@
<div class="upload-Boundary <%= @file_list.length <= 5 ? 'with-instruction' : '' %>">
<% @file_list.each do |file| %>
<div class="file filehover">
<% if file[:is_html] && current_site.screenshot_exists?(file[:path], '105x63') %>
<% if file[:is_html] && current_site.screenshot_exists?(file[:path], '210x158') %>
<div class="html-thumbnail html fileimagehover">
<img src="<%= current_site.screenshot_url(file[:path], '105x63') %>">
<img src="<%= current_site.screenshot_url(file[:path], '210x158') %>">
<div class="overlay"></div>
</div>
<% elsif file[:is_image] && current_site.thumbnail_exists?(file[:path], '105x63') %>
<% elsif file[:is_image] && current_site.thumbnail_exists?(file[:path], '210x158') %>
<div class="html-thumbnail image fileimagehover">
<img src="<%= current_site.thumbnail_url(file[:path], '105x63') %>" style="">
<img src="<%= current_site.thumbnail_url(file[:path], '210x158') %>">
<div class="overlay"></div>
</div>
<% elsif file[:is_directory] %>

View file

@ -39,7 +39,7 @@
<div class="site-suggestion">
<div class="site-portrait">
<a href="//<%= suggested_site.host %>">
<img src="<%= suggested_site.screenshot_url('index.html', '270x162') %>">
<img src="<%= suggested_site.screenshot_url('index.html', '540x405') %>">
</a>
<span class="caption">
<a href="/site/<%= suggested_site.username %>"><%= suggested_site.title %></a>
@ -71,7 +71,7 @@
</div>
</div>
<a href="//<%= site.host %>"><img src="<%= site.screenshot_url('index.html', '348x205') %>" style="width:340px" class="large-portrait"></a>
<a href="//<%= site.host %>"><img src="<%= site.screenshot_url('index.html', '540x405') %>" class="large-portrait"></a>
<div style="margin-top: 20px; margin-bottom: 20px" class="txt-Center">
<a href="/site/<%= site.username %>" class="btn-Action">View Site Profile</a>

View file

@ -184,42 +184,42 @@
<ul class="row website-Gallery hp-Gallery">
<li>
<a href="http://dragonquest.neocities.org/" title="The Quest of Dragons" target="_blank">
<img src="//neocities.org/site_screenshots/dragonquest/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of The Quest of Dragons" />
<img src="//neocities.org/site_screenshots/dragonquest/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of The Quest of Dragons" />
</a>
</li>
<li>
<a href="http://codeventurer.neocities.org/" title="codeventurer" target="_blank">
<img src="//neocities.org/site_screenshots/codeventurer/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of codeventurer" />
<img src="//neocities.org/site_screenshots/codeventurer/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of codeventurer" />
</a>
</li>
<li>
<a href="http://clouds.neocities.org/" title="Cloud Quotes" target="_blank">
<img src="//neocities.org/site_screenshots/clouds/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of Cloud Quotes" />
<img src="//neocities.org/site_screenshots/clouds/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of Cloud Quotes" />
</a>
</li>
<li>
<a href="http://manatee.neocities.org/" title="Title of Website" target="_blank">
<img src="//neocities.org/site_screenshots/manatee/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of TITLE OF WEBSITE" />
<img src="//neocities.org/site_screenshots/manatee/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of TITLE OF WEBSITE" />
</a>
</li>
<li>
<a href="http://suppilulemur.neocities.org/" title="Sokoban" target="_blank">
<img src="//neocities.org/site_screenshots/suppilulemur/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of Sokoban" />
<img src="//neocities.org/site_screenshots/suppilulemur/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of Sokoban" />
</a>
</li>
<li>
<a href="http://drawinglair.neocities.org/" title="Tomasz Zawadzki" target="_blank">
<img src="//neocities.org/site_screenshots/drawinglair/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of Tomasz Zawadzki" />
<img src="//neocities.org/site_screenshots/drawinglair/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of Tomasz Zawadzki" />
</a>
</li>
<li>
<a href="http://rik.neocities.org/" title="Rock Im Kaff" target="_blank">
<img src="//neocities.org/site_screenshots/rik/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of Eleanor Holroyd's Website" />
<img src="//neocities.org/site_screenshots/rik/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of Eleanor Holroyd's Website" />
</a>
</li>
<li>
<a href="http://cute-animation.neocities.org/" title="Cute Animation" target="_blank">
<img src="//neocities.org/site_screenshots/cute-animation/index.html.270x162.jpg" class="neo-SS" alt="Thumbnail of Cute Animation" />
<img src="//neocities.org/site_screenshots/cute-animation/index.html.540x405.jpg" class="neo-SS" alt="Thumbnail of Cute Animation" />
</a>
</li>
</ul>

View file

@ -14,7 +14,7 @@
<div class="col col-50 signup-Area large">
<div class="signup-Form">
<fieldset class="content">
<a href="//<%= site.host %>"><img class="screenshot" src="<%= site.screenshot_url('index.html', '348x205') %>" style="width: 358px;height: 215px;"></a>
<a href="//<%= site.host %>"><img class="screenshot" src="<%= site.screenshot_url('index.html', '540x405') %>"></a>
</fieldset>
</div>
</div>

View file

@ -44,7 +44,7 @@ class ScreenshotWorker
f.fetch(
output: screenshot_output_path,
width: 1280,
height: 720
height: 960
)
rescue Timeout::Error
# :nocov:
@ -89,7 +89,15 @@ class ScreenshotWorker
FileUtils.mkdir_p screenshot_path unless Dir.exists?(screenshot_path)
Site::SCREENSHOT_RESOLUTIONS.each do |res|
img.scale(*res.split('x').collect {|r| r.to_i}).write(File.join(user_screenshots_path, "#{path}.#{res}.jpg")) {
width, height = res.split('x').collect {|r| r.to_i}
if width == height
new_img = img.crop_resized width, height, Magick::NorthGravity
else
new_img = img.scale width, height
end
new_img.write(File.join(user_screenshots_path, "#{path}.#{res}.jpg")) {
self.quality = 90
}
end