mirror of
https://github.com/neocities/neocities.git
synced 2026-05-26 05:34:53 +00:00
needs_moderation flag
This commit is contained in:
@@ -338,6 +338,24 @@ post '/admin/unmark_nsfw' do
|
||||
redirect request.referrer
|
||||
end
|
||||
|
||||
post '/admin/mark_moderated' do
|
||||
require_admin
|
||||
|
||||
not_found if params[:site_id].blank?
|
||||
site = Site[params[:site_id]]
|
||||
not_found if site.nil?
|
||||
|
||||
site_ids = Site.select(:id).where(needs_moderation: true, site_changed: true).exclude(is_deleted: true).where{created_at >= site.created_at}.all.collect {|s| s.id}
|
||||
|
||||
DB[:sites].where(id: site_ids).update(needs_moderation: false)
|
||||
|
||||
uri = Addressable::URI.parse request.referer
|
||||
query = Rack::Utils.parse_query uri.query
|
||||
query.delete 'page'
|
||||
uri.query = query.empty? ? nil : Rack::Utils.build_query(query)
|
||||
redirect uri.to_s
|
||||
end
|
||||
|
||||
post '/admin/feature' do
|
||||
require_admin
|
||||
site = Site[username: params[:username]]
|
||||
|
||||
@@ -80,6 +80,10 @@ def browse_sites_dataset
|
||||
ds = ds.where{views > Site::BROWSE_MINIMUM_VIEWS} unless current_site && current_site.is_admin
|
||||
ds = ds.exclude site_updated_at: nil
|
||||
ds = ds.order :created_at.desc, :views.desc
|
||||
when 'moderation'
|
||||
not_found unless current_site && current_site.is_admin
|
||||
ds = ds.where(needs_moderation: true, site_changed: true)
|
||||
ds = ds.order :created_at.desc
|
||||
when 'oldest'
|
||||
ds = ds.where{score > 0.4} unless params[:tag]
|
||||
ds = ds.exclude site_updated_at: nil
|
||||
@@ -105,6 +109,8 @@ def browse_sites_dataset
|
||||
ds = ds.inner_join :blocks, :site_id => :id
|
||||
ds = ds.group :sites__id
|
||||
ds = ds.order :total.desc
|
||||
else
|
||||
not_found
|
||||
end
|
||||
|
||||
ds = ds.where ['sites.is_nsfw = ?', (params[:is_nsfw] == 'true' ? true : false)]
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
Sequel.migration do
|
||||
up {
|
||||
DB.add_column :sites, :needs_moderation, :boolean, default: true
|
||||
}
|
||||
|
||||
down {
|
||||
DB.drop_column :sites, :needs_moderation
|
||||
}
|
||||
end
|
||||
@@ -26,6 +26,9 @@
|
||||
<option value="newest" <%= params[:sort_by] == 'newest' ? 'selected' : '' %>>Newest</option>
|
||||
<% end %>
|
||||
<option value="oldest" <%= params[:sort_by] == 'oldest' ? 'selected' : '' %>>Oldest</option>
|
||||
<% if current_site && current_site.is_admin %>
|
||||
<option value="moderation" <%= params[:sort_by] == 'moderation' ? 'selected' : '' %>>Moderation</option>
|
||||
<% end %>
|
||||
<!-- <option value="robots" <%= params[:sort_by] == 'robots' ? 'selected' : '' %>>Robots</option> -->
|
||||
</select>
|
||||
</div>
|
||||
@@ -117,6 +120,14 @@
|
||||
<input type="hidden" name="username" value="<%= site.username %>">
|
||||
<button>NSFW</button>
|
||||
</form>
|
||||
|
||||
<% if params[:sort_by] == 'moderation' %>
|
||||
<form action="/admin/mark_moderated" method="POST" onsubmit="return confirm('Confirm moderation until <%= site.username %>');">
|
||||
<%== csrf_token_input_html %>
|
||||
<input type="hidden" name="site_id" value="<%= site.id %>">
|
||||
<button>Moderated</button>
|
||||
</form>
|
||||
<% end %>
|
||||
|
||||
<% if params[:sort_by] == 'blocks' %>
|
||||
<p>
|
||||
|
||||
Reference in New Issue
Block a user