From a7ee94b0c7115ae098af03d4aa7d46ff6f6c7356 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Mon, 13 Jul 2015 16:28:15 -0700 Subject: [PATCH] a start on improving reporting --- Gemfile.lock | 2 +- app/admin.rb | 6 ++++++ app_helpers.rb | 16 +++------------ views/admin.erb | 6 ++++++ views/admin/reports.erb | 45 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 61 insertions(+), 14 deletions(-) create mode 100644 views/admin/reports.erb diff --git a/Gemfile.lock b/Gemfile.lock index 4d5aebb3..ee90e90c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -212,7 +212,7 @@ GEM sinatra (>= 1.0.0) sinatra-xsendfile (0.4.2) sinatra (>= 0.9.1) - slop (3.5.0) + slop (3.6.0) storable (0.8.9) stripe (1.15.0) json (~> 1.8.1) diff --git a/app/admin.rb b/app/admin.rb index 7500351c..5f2303af 100644 --- a/app/admin.rb +++ b/app/admin.rb @@ -5,6 +5,12 @@ get '/admin' do erb :'admin' end +get '/admin/reports' do + require_admin + @reports = Report.order(:created_at.desc).all + erb :'admin/reports' +end + get '/admin/email' do require_admin erb :'admin/email' diff --git a/app_helpers.rb b/app_helpers.rb index b05f49a7..27a0e116 100644 --- a/app_helpers.rb +++ b/app_helpers.rb @@ -53,26 +53,16 @@ def parent_site end def require_unbanned_ip - if session[:banned] || Site.banned_ip?(request.ip) + if session[:banned] || (is_banned_ip = Site.banned_ip?(request.ip)) signout session[:banned] = request.ip if !session[:banned] - send_banned_report - flash[:error] = 'Site creation has been banned due to a Terms of Service violation. '+ + + flash[:error] = 'Site creation has been banned due to a Terms of Service violation from your location. '+ 'If you believe this to be in error, contact the site admin.' return {result: 'error'}.to_json end end -def send_banned_report - EmailWorker.perform_async({ - from: 'web@neocities.org', - reply_to: 'contact@neocities.org', - to: 'errors@neocities.org', - subject: "[Neocities] Ban report", - body: "IP: #{request.ip}\n\nSession: #{session.inspect}\n\nParams:#{params}" - }) -end - def title out = "Neocities" return out if request.path == '/' diff --git a/views/admin.erb b/views/admin.erb index d3d3aa82..f2ac59b1 100644 --- a/views/admin.erb +++ b/views/admin.erb @@ -7,6 +7,12 @@
+
+ +
+ <% if flash.keys.length > 0 %>
<% flash.keys.each do |key| %> diff --git a/views/admin/reports.erb b/views/admin/reports.erb new file mode 100644 index 00000000..3b6c0801 --- /dev/null +++ b/views/admin/reports.erb @@ -0,0 +1,45 @@ +
+
+

Site Reports

+
+
+ +
+
+ + + + + + + + <% @reports.each do |report| %> + + + + + + + <% end %> +
SiteTypeCommentsActions
+ <%= report.site.title %> +
+ +
+ Reported <%= report.created_at.ago %> + <% if report.reporting_site %> + by <%= report.reporting_site.username %> + <% end %> +
<%= report.type %><%= report.comments[0...100] %> + +
+ + +
+ + +