diff --git a/app/logical/sources/site.rb b/app/logical/sources/site.rb index b4fd61e88..364c39380 100644 --- a/app/logical/sources/site.rb +++ b/app/logical/sources/site.rb @@ -7,6 +7,7 @@ module Sources :profile_url, :image_url, :tags, :artist_record, :unique_id, :page_count, :file_url, :ugoira_frame_data, :ugoira_content_type, :image_urls, :artist_commentary_title, :artist_commentary_desc, + :dtext_artist_commentary_title, :dtext_artist_commentary_desc, :rewrite_thumbnails, :illust_id_from_url, :to => :strategy def self.strategies @@ -70,6 +71,8 @@ module Sources :artist_commentary => { :title => artist_commentary_title, :description => artist_commentary_desc, + :dtext_title => dtext_artist_commentary_title, + :dtext_description => dtext_artist_commentary_desc, } } end diff --git a/app/logical/sources/strategies/base.rb b/app/logical/sources/strategies/base.rb index 65b408a07..25e25ab48 100644 --- a/app/logical/sources/strategies/base.rb +++ b/app/logical/sources/strategies/base.rb @@ -86,10 +86,25 @@ module Sources nil end + def dtext_artist_commentary_title + self.class.to_dtext(artist_commentary_title) + end + + def dtext_artist_commentary_desc + self.class.to_dtext(artist_commentary_desc) + end + protected def agent raise NotImplementedError end + + # Convert commentary to dtext by stripping html tags. Sites can override + # this to customize how their markup is translated to dtext. + def self.to_dtext(text) + text = Rails::Html::FullSanitizer.new.sanitize(text, encode_special_chars: false) + text + end end end end