mirror of
https://github.com/neocities/neocities.git
synced 2025-04-24 17:22:35 +02:00
bugfixes and reforms to block filters
This commit is contained in:
parent
687a134207
commit
6f7a6098a4
5 changed files with 38 additions and 3 deletions
19
Rakefile
19
Rakefile
|
@ -443,3 +443,22 @@ task :prime_redis_proxy_ssl => [:environment] do
|
|||
Site[site_id].store_ssl_in_redis_proxy
|
||||
end
|
||||
end
|
||||
|
||||
desc 'dedupe_site_blocks'
|
||||
task :dedupe_site_blocks => [:environment] do
|
||||
duped_blocks = []
|
||||
block_ids = Block.select(:id).all.collect {|b| b.id}
|
||||
block_ids.each do |block_id|
|
||||
next unless duped_blocks.select {|db| db.id == block_id}.empty?
|
||||
block = Block[block_id]
|
||||
if block
|
||||
blocks = Block.exclude(id: block.id).where(site_id: block.site_id).where(actioning_site_id: block.actioning_site_id).all
|
||||
duped_blocks << blocks
|
||||
duped_blocks.flatten!
|
||||
end
|
||||
end
|
||||
|
||||
duped_blocks.each do |duped_block|
|
||||
duped_block.destroy
|
||||
end
|
||||
end
|
||||
|
|
|
@ -93,6 +93,12 @@ def browse_sites_dataset
|
|||
ds = ds.where{views > 10_000}
|
||||
ds = ds.group :sites__id
|
||||
ds = ds.order :follow_count.desc, :views.desc, :updated_at.desc
|
||||
when 'blocks'
|
||||
require_admin
|
||||
ds = ds.select{[sites.*, Sequel[count(site_id)].as(:total)]}
|
||||
ds = ds.inner_join :blocks, :site_id => :id
|
||||
ds = ds.group :sites__id
|
||||
ds = ds.order :total.desc
|
||||
else
|
||||
params[:sort_by] = 'followers'
|
||||
ds = ds.where{views > 10_000}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Block < Sequel::Model
|
||||
many_to_one :site
|
||||
many_to_one :actioning_site, class: :Block
|
||||
many_to_one :actioning_site, class: :Site
|
||||
end
|
|
@ -130,7 +130,7 @@ class Site < Sequel::Model
|
|||
DISPOSABLE_EMAIL_BLACKLIST_PATH = File.join(DIR_ROOT, 'files', 'disposable_email_blacklist.conf')
|
||||
BANNED_EMAIL_BLACKLIST_PATH = File.join(DIR_ROOT, 'files', 'banned_email_blacklist.conf')
|
||||
|
||||
BLOCK_JERK_THRESHOLD = 2
|
||||
BLOCK_JERK_THRESHOLD = 4
|
||||
MAXIMUM_TAGS = 5
|
||||
MAX_USERNAME_LENGTH = 32.freeze
|
||||
|
||||
|
@ -572,6 +572,7 @@ class Site < Sequel::Model
|
|||
|
||||
def block!(site)
|
||||
block = blockings_dataset.filter(site_id: site.id).first
|
||||
return true if block
|
||||
add_blocking site: site
|
||||
end
|
||||
|
||||
|
|
|
@ -153,6 +153,15 @@
|
|||
<input type="hidden" name="username" value="<%= site.username %>">
|
||||
<button>Mark NSFW</button>
|
||||
</form>
|
||||
|
||||
<% if params[:sort_by] == 'blocks' %>
|
||||
<p>
|
||||
Blocks:<br>
|
||||
<% site.blocks.each do |block| %>
|
||||
<a href="/site/<%= block.actioning_site.username %>"><%= block.actioning_site.username %></a><br>
|
||||
<% end %>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue