enable reportbooru integration for upload reports
This commit is contained in:
@@ -10,4 +10,8 @@ class ReportsController < ApplicationController
|
||||
def contributors
|
||||
@report = Reports::Contributors.new
|
||||
end
|
||||
|
||||
def uploads
|
||||
@report = Reports::Uploads.new(params[:min_date], params[:max_date], params[:queries])
|
||||
end
|
||||
end
|
||||
|
||||
26
app/logical/reports/uploads.rb
Normal file
26
app/logical/reports/uploads.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module Reports
|
||||
class Uploads
|
||||
attr_reader :min_date, :max_date, :queries
|
||||
|
||||
def initialize(min_date, max_date, queries)
|
||||
if min_date.present?
|
||||
@min_date = min_date
|
||||
else
|
||||
@min_date = 30.days.ago.to_date
|
||||
end
|
||||
|
||||
if max_date.present?
|
||||
@max_date = max_date
|
||||
else
|
||||
@max_date = Date.today
|
||||
end
|
||||
|
||||
@queries = queries.to_s.split(/,\s*/).join(",")
|
||||
end
|
||||
|
||||
def generate_sig
|
||||
digest = OpenSSL::Digest.new("sha256")
|
||||
OpenSSL::HMAC.hexdigest(digest, Danbooru.config.shared_remote_key, "#{min_date},#{max_date},#{queries}")
|
||||
end
|
||||
end
|
||||
end
|
||||
33
app/views/reports/uploads.html.erb
Normal file
33
app/views/reports/uploads.html.erb
Normal file
@@ -0,0 +1,33 @@
|
||||
<div id="c-reports">
|
||||
<div id="a-uploads">
|
||||
<h1>Upload Report</h1>
|
||||
|
||||
<%= form_tag(reports_uploads_path, :method => :get, :class => "simple_form") do %>
|
||||
|
||||
<div class="input">
|
||||
<label for="queries">Tags</label>
|
||||
<%= text_field_tag "queries", params[:queries], :placeholder => "Separate with commas" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="min_date">Start Date</label>
|
||||
<%= text_field_tag "min_date", params[:min_date], :placeholder => "YYYY-MM-DD" %>
|
||||
</div>
|
||||
|
||||
<div class="input">
|
||||
<label for="max_date">End Date</label>
|
||||
<%= text_field_tag "max_date", params[:max_date], :placeholder => "YYYY-MM-DD" %>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "Search" %>
|
||||
<% end %>
|
||||
|
||||
<% if params[:queries] %>
|
||||
<%= content_tag("iframe", "Loading...", :src => "#{Danbooru.config.report_server}/reports/uploads?min=#{@report.min_date}&max=#{@report.max_date}&tags=#{u(@report.queries)}&sig=#{@report.generate_sig}", :height => "700", :width => "1200", :style => "border: none;") %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% content_for(:page_title) do %>
|
||||
Upload Report - <%= Danbooru.config.app_name %>
|
||||
<% end %>
|
||||
@@ -222,6 +222,7 @@ Rails.application.routes.draw do
|
||||
get "reports/user_promotions" => "reports#user_promotions"
|
||||
get "reports/janitor_trials" => "reports#janitor_trials"
|
||||
get "reports/contributors" => "reports#contributors"
|
||||
get "reports/uploads" => "reports#uploads"
|
||||
resources :saved_searches, :except => [:show] do
|
||||
collection do
|
||||
get :categories
|
||||
|
||||
Reference in New Issue
Block a user