From c505ed39cf9b0d59dfe5adbe7dc31dfb42ab7b87 Mon Sep 17 00:00:00 2001 From: Earlopain <14981592+Earlopain@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:35:20 +0200 Subject: [PATCH] Move submission_url into the simple definition Allows you to view files of scrapers that were removed --- app/logical/sites/scraper_definition.rb | 12 ------------ app/logical/sites/simple_definition.rb | 12 ++++++++++-- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/app/logical/sites/scraper_definition.rb b/app/logical/sites/scraper_definition.rb index df924acc..82836188 100644 --- a/app/logical/sites/scraper_definition.rb +++ b/app/logical/sites/scraper_definition.rb @@ -2,23 +2,11 @@ module Sites class ScraperDefinition < SimpleDefinition - attr_reader :submission_template - def initialize(definition_data) super - @submission_template = Addressable::Template.new(definition_data["submission_template"]) - @image_domains = definition_data["image_domains"] || [] - @download_headers = definition_data["download_headers"] || {} @scraper = "Scraper::#{site_type.camelize}".constantize end - def submission_url(submission) - submission_template.expand( - site_artist_identifier: submission.artist_url.url_identifier, - site_submission_identifier: submission.identifier_on_site, - ).to_s - end - def missing_config_keys @scraper.required_config_keys.select { |key| Config.send(key).blank? } end diff --git a/app/logical/sites/simple_definition.rb b/app/logical/sites/simple_definition.rb index 5ad23ce1..6c9544bf 100644 --- a/app/logical/sites/simple_definition.rb +++ b/app/logical/sites/simple_definition.rb @@ -10,8 +10,9 @@ def initialize(definition_data) @homepage = definition_data["homepage"] @gallery_templates = definition_data["gallery_templates"].map { |t| Addressable::Template.new("{prefix}#{t}{/remaining}{?remaining}{#remaining}") } @username_identifier_regex = Regexp.new("^#{definition_data['username_identifier_regex']}$") - @image_domains = [] - @download_headers = {} + @submission_template = Addressable::Template.new(definition_data["submission_template"]) if definition_data["submission_template"] + @image_domains = definition_data["image_domains"] || [] + @download_headers = definition_data["download_headers"] || {} end def match_for_gallery(uri) @@ -35,6 +36,13 @@ def gallery_url(identifier) "https://#{gallery_templates.first.expand(site_artist_identifier: identifier)}" end + def submission_url(submission) + @submission_template.expand( + site_artist_identifier: submission.artist_url.url_identifier, + site_submission_identifier: submission.identifier_on_site, + ).to_s + end + def missing_config_keys [] end