mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 09:12:35 +02:00
site change and file recording, better share support
This commit is contained in:
parent
9275b92d9f
commit
da9d1e4eb3
15 changed files with 125 additions and 65 deletions
2
Gemfile
2
Gemfile
|
@ -40,12 +40,12 @@ platform :jruby do
|
|||
|
||||
group :development do
|
||||
gem 'ruby-debug', require: nil
|
||||
gem 'sass', require: nil
|
||||
end
|
||||
end
|
||||
|
||||
group :development do
|
||||
gem 'shotgun', require: nil
|
||||
gem 'sass', require: nil
|
||||
end
|
||||
|
||||
group :test do
|
||||
|
|
8
app.rb
8
app.rb
|
@ -11,6 +11,14 @@ use Rack::Session::Cookie, key: 'neocities',
|
|||
use Rack::Recaptcha, public_key: $config['recaptcha_public_key'], private_key: $config['recaptcha_private_key']
|
||||
helpers Rack::Recaptcha::Helpers
|
||||
|
||||
helpers do
|
||||
def site_change_file_display_class(filename)
|
||||
return 'html' if filename.match(Site::HTML_REGEX)
|
||||
return 'image' if filename.match(Site::IMAGE_REGEX)
|
||||
'misc'
|
||||
end
|
||||
end
|
||||
|
||||
before do
|
||||
if request.path.match /^\/api\//i
|
||||
@api = true
|
||||
|
|
9
migrations/031_fix_event_site_update_id.rb
Normal file
9
migrations/031_fix_event_site_update_id.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.rename_column :events, :site_update_id, :site_change_id
|
||||
}
|
||||
|
||||
down {
|
||||
DB.rename_column :events, :site_change_id, :site_update_id
|
||||
}
|
||||
end
|
14
migrations/032_add_site_change_files.rb
Normal file
14
migrations/032_add_site_change_files.rb
Normal file
|
@ -0,0 +1,14 @@
|
|||
Sequel.migration do
|
||||
up {
|
||||
DB.create_table! :site_change_files do
|
||||
primary_key :id
|
||||
Integer :site_change_id
|
||||
String :filename
|
||||
DateTime :created_at
|
||||
end
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_table :site_change_files
|
||||
}
|
||||
end
|
|
@ -5,7 +5,7 @@ class Event < Sequel::Model
|
|||
many_to_one :follow
|
||||
one_to_one :tip
|
||||
one_to_one :tag
|
||||
one_to_one :site_change
|
||||
many_to_one :site_change
|
||||
many_to_one :profile_comment
|
||||
one_to_many :likes
|
||||
one_to_many :comments
|
||||
|
|
|
@ -56,7 +56,7 @@ class Site < Sequel::Model
|
|||
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']
|
||||
THUMBNAIL_RESOLUTIONS = ['105x63', '90x63']
|
||||
|
||||
many_to_one :server
|
||||
|
||||
|
@ -224,6 +224,8 @@ class Site < Sequel::Model
|
|||
ThumbnailWorker.perform_async values[:username], filename
|
||||
end
|
||||
|
||||
SiteChange.record self, filename
|
||||
|
||||
self.site_changed = true
|
||||
self.changed_count += 1
|
||||
save(validate: false)
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
class SiteChange < Sequel::Model
|
||||
NEW_CHANGE_TIMEOUT = 3600 * 4 # 4 hours
|
||||
many_to_one :site
|
||||
one_to_one :event
|
||||
end
|
||||
one_to_one :site_change
|
||||
one_to_many :site_change_files
|
||||
|
||||
def site_change_filenames(limit=4)
|
||||
site_change_files[0..limit-1].collect {|f| f.filename}
|
||||
end
|
||||
|
||||
def self.record(site, filename)
|
||||
site_change = filter(site_id: site.id).order(:created_at.desc).first
|
||||
|
||||
if site_change.nil? || site_change.created_at+NEW_CHANGE_TIMEOUT < Time.now
|
||||
site_change = create site: site
|
||||
Event.create site_id: site.id, site_change_id: site_change.id
|
||||
end
|
||||
|
||||
site_change_file = site_change.site_change_files_dataset.filter(filename: filename).first
|
||||
|
||||
if !site_change_file
|
||||
site_change.add_site_change_file filename: filename
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
3
models/site_change_file.rb
Normal file
3
models/site_change_file.rb
Normal file
|
@ -0,0 +1,3 @@
|
|||
class SiteChangeFile < Sequel::Model
|
||||
many_to_one :site_change
|
||||
end
|
|
@ -522,8 +522,8 @@ a.tag:hover {
|
|||
color: #000;
|
||||
}
|
||||
.news-item .comment {
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
color: #000;
|
||||
font-style: normal;
|
||||
font-size: .8em;
|
||||
}
|
||||
.news-item.for-me .comment {
|
||||
|
|
|
@ -1763,8 +1763,8 @@ a.tag:hover {
|
|||
color: #000; }
|
||||
|
||||
.news-item .comment {
|
||||
color: #999;
|
||||
font-style: italic;
|
||||
color: #000;
|
||||
font-style: normal;
|
||||
font-size: .8em; }
|
||||
|
||||
.news-item.for-me .comment {
|
||||
|
|
2
public/assets/css/neo.min.css
vendored
2
public/assets/css/neo.min.css
vendored
File diff suppressed because one or more lines are too long
|
@ -15,6 +15,51 @@
|
|||
<div class="icon"></div>
|
||||
<a href="/site/<%= event.actioning_site.username %>" class="user"><%= event.actioning_site.username %></a> followed <a href="/site/<%= event.site.username %>" class="user"><%= event.site.username %>'s</a> website<span class="date"><%= event.created_at.ago %></span>
|
||||
</div>
|
||||
<% elsif event.site_change_id %>
|
||||
<div class="news-item update">
|
||||
<div class="title">
|
||||
<div class="icon"></div>
|
||||
<a href="http://<%= site.username %>.neocities.org" class="user"><%= site.username %>.neocities.org</a> has been updated <span class="date"><%= event.created_at.ago %></span>
|
||||
</div>
|
||||
<div class="content">
|
||||
<div class="files">
|
||||
<% event.site_change.site_change_filenames.each do |f| %>
|
||||
<div class="file">
|
||||
<div class="html-thumbnail <%= site_change_file_display_class f %>">
|
||||
<a href="http://<%= site.username %>.neocities.org/<%= f %>">
|
||||
<% if site_change_file_display_class(f) == 'html' %>
|
||||
<img src="<%= site.screenshot_url(f, '90x63') %>">
|
||||
<% elsif site_change_file_display_class(f) == 'image' %>
|
||||
<img src="<%= site.thumbnail_url(f, '90x63') %>">
|
||||
<% elsif site_change_file_display_class(f) == 'misc' %>
|
||||
<span class="misc-icon">
|
||||
<%= File.extname(f).sub('.', '') %>
|
||||
</span>
|
||||
<% end %>
|
||||
<span class="title"><%= f %></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!--
|
||||
<div class="file">
|
||||
<div class="html-thumbnail misc"><a href=""><span class="misc-icon">css</span><span class="title">styles.css</span></a></div>
|
||||
</div>
|
||||
<div class="file">
|
||||
<div class="html-thumbnail html"><a href=""><img src="http://neocities.org/site_screenshots/codeventurer.jpg"><span class="title">styles.css</span></a></div>
|
||||
</div>
|
||||
<div class="file">
|
||||
<div class="html-thumbnail misc"><a href=""><span class="misc-icon">js</span><span class="title">styles.css</span></a></div>
|
||||
</div>
|
||||
<div class="file">
|
||||
<div class="html-thumbnail image"><a href=""><img src="/site_thumbnails/victoria/constructioncat2.png.105x63.png"><span class="title">cat.jpg</span></a></div>
|
||||
</div>
|
||||
<div class="file">
|
||||
<div class="html-thumbnail misc"><a href=""><span class="misc-icon">js</span><span class="title">styles.css</span></a></div>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%== erb :'_news_actions', layout: false, locals: {event: event} %>
|
||||
|
|
|
@ -67,17 +67,16 @@
|
|||
<p><%= @error %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% if flash.keys.length > 0 %>
|
||||
<div class="alert alert-block">
|
||||
<p>
|
||||
<% flash.keys.each do |key| %>
|
||||
<%= flash[key] %>
|
||||
<%== flash[key] %>
|
||||
<% end %>
|
||||
</p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
<div class="files">
|
||||
<div id="uploadingOverlay" class="uploading-overlay" style="display: none">
|
||||
|
@ -189,11 +188,11 @@
|
|||
function clickUploadFiles() {
|
||||
$("input[id='uploadFiles']").click()
|
||||
}
|
||||
|
||||
|
||||
function showUploadProgress() {
|
||||
$('#uploadingOverlay').css('display', 'block')
|
||||
}
|
||||
|
||||
|
||||
function hideUploadProgress() {
|
||||
$('#progressBar').css('display', 'none')
|
||||
$('#uploadingOverlay').css('display', 'none')
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
<script>
|
||||
$("a#like").tooltip({html: true})
|
||||
$("a.comment_like").tooltip({html: true})
|
||||
$('#shareButton').popover({html: true})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,14 +1,3 @@
|
|||
<div id="fb-root"></div>
|
||||
<script>
|
||||
(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) return;
|
||||
js = d.createElement(s); js.id = id;
|
||||
js.src = "//connect.facebook.net/en_US/sdk.js#xfbml=1&appId=1418659625072715&version=v2.0";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));
|
||||
</script>
|
||||
|
||||
<div class="header-Outro with-site-image">
|
||||
<div class="row content">
|
||||
<div class="col col-50 signup-Area large">
|
||||
|
@ -33,7 +22,14 @@
|
|||
</a>
|
||||
<a href="#" class="btn-Action tip"><span>Tip</span></a>
|
||||
<% end %>
|
||||
<!-- <a href="#" class="btn-Action share" onclick="$('#shareModal').modal(); return false"><span>Share</span></a> -->
|
||||
<a href="#" id="shareButton" class="btn-Action share" data-container="body" data-toggle="popover" data-placement="bottom" data-content='
|
||||
<a href="http://facebook.com/sharer.php?u=<%= Rack::Utils.build_query(u: "http://#{site.username}.neocities.org") %>" target="_blank">Facebook</a>
|
||||
<br>
|
||||
<a href="https://twitter.com/intent/tweet?<%= Rack::Utils.build_query(text: "This site is awesome: http://#{site.username}.neocities.org") %>">Twitter</a>
|
||||
<br>
|
||||
<a href="http://www.reddit.com/submit?<%= Rack::Utils.build_query(title: "#{site.username}.neocities.org", url: "http://#{site.username}.neocities.org" )%>" target="_blank">Reddit</a>
|
||||
'>
|
||||
<span>Share</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -81,26 +77,6 @@
|
|||
|
||||
<%== erb :'_follows', layout: false, locals: {site: site, is_current_site: site == current_site} %>
|
||||
|
||||
<h3><i class="fa fa-share-alt"></i> Share</h3>
|
||||
<div>
|
||||
<p>
|
||||
<a href="https://twitter.com/share" class="twitter-share-button" data-text="<%= site.username %>.neocities.org is awesome!" data-via="neocitiesweb" data-url="http://<%= site.username %>.neocities.org" data-count="none">Tweet</a>
|
||||
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<span id="tumblr_button_abc123"></span>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent('http://<%= site.username %>.neocities.org'); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<div class="fb-share-button" data-href="http://<%= site.username %>.neocities.org" data-width="100" data-type="button" style="height: 100px"></div>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!--
|
||||
<h3>Archives</h3>
|
||||
<div class="archives">
|
||||
|
@ -121,22 +97,6 @@
|
|||
</div></div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var tumblr_link_url = "http://<%= site.username %>.neocities.org"
|
||||
var tumblr_link_name = "<%= site.username %>.neocities.org"
|
||||
var tumblr_link_description = "<%= site.username %>.neocities.org"
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var tumblr_button = document.createElement("a");
|
||||
tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
|
||||
tumblr_button.setAttribute("title", "Share on Tumblr");
|
||||
tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:61px; height:20px; background:url('http://platform.tumblr.com/v1/share_2.png') top left no-repeat transparent;");
|
||||
tumblr_button.innerHTML = "Share on Tumblr";
|
||||
document.getElementById("tumblr_button_abc123").appendChild(tumblr_button);
|
||||
</script>
|
||||
|
||||
<!--
|
||||
<div class="modal hide fade" id="shareModal" tabindex="-1" role="dialog" aria-labelledby="shareModalLabel" aria-hidden="true">
|
||||
<div class="modal-header">
|
||||
<button class="close" type="button" data-dismiss="modal" aria-hidden="true">x</button>
|
||||
|
@ -155,13 +115,10 @@
|
|||
<p>
|
||||
<a href="http://www.reddit.com/submit" onclick="window.location = 'http://www.reddit.com/submit?url=' + encodeURIComponent(window.location); return false"> <img src="http://www.reddit.com/static/spreddit7.gif" alt="submit to reddit" border="0" /> </a>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<div class="fb-share-button" data-href="//neocities.org/site/<%= site.username %>" data-width="100" data-type="button" style="height: 100px"></div>
|
||||
</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn" data-dismiss="modal" aria-hidden="true">Done</button>
|
||||
</div>
|
||||
</div>
|
||||
-->
|
Loading…
Add table
Reference in a new issue