mirror of
https://github.com/neocities/neocities.git
synced 2025-04-25 09:42:36 +02:00
Merge branch 'v2' of github.com:neocities/neocities into v2
This commit is contained in:
commit
7afc07ecff
4 changed files with 26 additions and 9 deletions
|
@ -51,7 +51,9 @@ Sidekiq.configure_client do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
if $config['pubsub_url']
|
if $config['pubsub_url']
|
||||||
$pubsub = Redis.new url: $config['pubsub_url']
|
$pubsub_pool = ConnectionPool.new(size: 10, timeout: 5) {
|
||||||
|
Redis.new url: $config['pubsub_url']
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if $config['pubsub_url'].nil? && ENV['RACK_ENV'] == 'production'
|
if $config['pubsub_url'].nil? && ENV['RACK_ENV'] == 'production'
|
||||||
|
|
|
@ -243,6 +243,8 @@ class Site < Sequel::Model
|
||||||
raise 'username is missing'
|
raise 'username is missing'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return if is_banned == true
|
||||||
|
|
||||||
DB.transaction {
|
DB.transaction {
|
||||||
self.is_banned = true
|
self.is_banned = true
|
||||||
self.updated_at = Time.now
|
self.updated_at = Time.now
|
||||||
|
@ -629,12 +631,15 @@ class Site < Sequel::Model
|
||||||
end
|
end
|
||||||
|
|
||||||
def latest_events(current_page=1, limit=10)
|
def latest_events(current_page=1, limit=10)
|
||||||
events_dataset.exclude(site_id: self.id).order(:created_at.desc).paginate(current_page, limit)
|
events_dataset.order(:created_at.desc).paginate(current_page, limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def news_feed(current_page=1, limit=10)
|
def news_feed(current_page=1, limit=10)
|
||||||
following_ids = self.followings_dataset.select(:site_id).all.collect {|f| f.site_id}
|
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).paginate(current_page, limit)
|
Event.filter(site_id: following_ids+[self.id]).
|
||||||
|
order(:created_at.desc).
|
||||||
|
exclude(actioning_site_id: self.id).
|
||||||
|
paginate(current_page, limit)
|
||||||
end
|
end
|
||||||
|
|
||||||
def host
|
def host
|
||||||
|
|
|
@ -19,10 +19,14 @@
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
<% actioning_site = event.actioning_site_dataset.select(:username, :title, :domain).first %>
|
<% actioning_site = event.actioning_site_dataset.select(:username, :title, :domain).first %>
|
||||||
<% event_site = event.site_dataset.select(: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>
|
<a href="/site/<%= actioning_site.username %>" class="user" title="<%= actioning_site.title %>"><%= actioning_site.title.shorten(40) %></a>
|
||||||
is following
|
is following
|
||||||
|
<% if 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.title.shorten(40) %></a>
|
||||||
|
<% end %>
|
||||||
<span class="date">
|
<span class="date">
|
||||||
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
|
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -31,8 +35,12 @@
|
||||||
<div class="news-item update">
|
<div class="news-item update">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<div class="icon"></div>
|
<div class="icon"></div>
|
||||||
<% event_site = event.site_dataset.select(:username, :title, :domain).first %>
|
<% event_site = event.site_dataset.select(:id, :username, :title, :domain).first %>
|
||||||
|
<% if 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"><%= event_site.title %></a> has been updated.
|
||||||
|
<% end %>
|
||||||
<span class="date">
|
<span class="date">
|
||||||
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
|
<a href="?event_id=<%= event.id %>"><%= event.created_at.ago %></a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -70,7 +78,7 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="comments">
|
<div class="comments">
|
||||||
<% event.comments.each do |comment| %>
|
<% event.comments.each do |comment| %>
|
||||||
<% comment_actioning_site = comment.actioning_site_dataset.select(:title, :domain, :username).first %>
|
<% comment_actioning_site = comment.actioning_site_dataset.select(:id, :title, :domain, :username).first %>
|
||||||
<div class="comment" id="comment_<%= comment.id %>">
|
<div class="comment" id="comment_<%= comment.id %>">
|
||||||
<img class="avatar" src="<%= comment_actioning_site.screenshot_url('index.html', '82x62') %>">
|
<img class="avatar" src="<%= comment_actioning_site.screenshot_url('index.html', '82x62') %>">
|
||||||
<a href="/site/<%= comment_actioning_site.username %>" class="user"><%= comment_actioning_site.title %></a>
|
<a href="/site/<%= comment_actioning_site.username %>" class="user"><%= comment_actioning_site.title %></a>
|
||||||
|
|
|
@ -6,7 +6,9 @@ class PurgeCacheWorker
|
||||||
attempt = 0
|
attempt = 0
|
||||||
begin
|
begin
|
||||||
attempt += 1
|
attempt += 1
|
||||||
$pubsub.publish 'purgecache', payload.to_json
|
$pubsub_pool.with do |redis|
|
||||||
|
redis.publish 'purgecache', payload.to_json
|
||||||
|
end
|
||||||
rescue Redis::BaseConnectionError => error
|
rescue Redis::BaseConnectionError => error
|
||||||
raise if attempt > 3
|
raise if attempt > 3
|
||||||
puts "pubsub error: #{error}, retrying in 1s"
|
puts "pubsub error: #{error}, retrying in 1s"
|
||||||
|
|
Loading…
Add table
Reference in a new issue