diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 80fef4f7..e18f44b7 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1522,6 +1522,10 @@ use_basic_cache:true ## True by built-in default. #use_view_full_work:true +## Some works on AO3 ship with an author-defined CSS sheet. +## By default, do not include it. +#use_workskin:false + ## archiveofourown.org stories allow chapters to be added out of ## order. So the newest chapter may not be the last one. FanFicFare update ## doesn't like that. If do_update_hook is uncommented and set true, diff --git a/fanficfare/adapters/adapter_archiveofourownorg.py b/fanficfare/adapters/adapter_archiveofourownorg.py index 96f23d68..dac57f01 100644 --- a/fanficfare/adapters/adapter_archiveofourownorg.py +++ b/fanficfare/adapters/adapter_archiveofourownorg.py @@ -21,6 +21,7 @@ logger = logging.getLogger(__name__) import re import json +from ..six import text_type as unicode from ..htmlcleanup import stripHTML from .. import exceptions as exceptions @@ -398,13 +399,13 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter): self.story.setMetadata('seriesUrl',series_url) - if 'style' in self.getConfigList('keep_html_attrs',[]): + if self.getConfig('use_workskin',False): divmain = metasoup.find('div',{'id':'main'}) if divmain: # we sort of assume ddmain exists because otherwise, there would be no fic workskin = divmain.style if workskin: - workskin = str(workskin.contents[0]) # 'contents' returns a list with (here) a single element + workskin = unicode(workskin.contents[0]) # 'contents' returns a list with (here) a single element # some transformation to adjust which classes are affected workskin = workskin.replace('#workskin', '.userstuff') self.story.extra_css = "/*start of AO3 workskin*/\n" + workskin + "\n/* end of AO3 workskin*/\n" diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 94a89ca4..4d3ccab9 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -223,7 +223,8 @@ def get_valid_set_options(): 'archiveofourown.org'],None,boollist), 'always_login':(['archiveofourown.org']+base_xenforo_list,None,boollist), 'use_archived_author':(['archiveofourown.org'],None,boollist), - 'use_view_full_work':(['archiveofourown.org'],None,boollist), + 'use_view_full_work':(['archiveofourown.org','fanfics.me'],None,boollist), + 'use_workskin':(['archiveofourown.org'],None,boollist), 'remove_authorfootnotes_on_update':(['archiveofourown.org'],None,boollist), 'non_breaking_spaces':(['fictionmania.tv'],None,boollist), @@ -382,6 +383,7 @@ def get_valid_keywords(): 'do_update_hook', 'use_archived_author', 'use_view_full_work', + 'use_workskin', 'always_login', 'exclude_notes', 'remove_authorfootnotes_on_update', diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 8dc9c20f..15b37472 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -1526,6 +1526,10 @@ use_basic_cache:true ## True by built-in default. #use_view_full_work:true +## Some works on AO3 ship with an author-defined CSS sheet. +## By default, do not include it. +#use_workskin:false + ## archiveofourown.org stories allow chapters to be added out of ## order. So the newest chapter may not be the last one. FanFicFare update ## doesn't like that. If do_update_hook is uncommented and set true, diff --git a/fanficfare/story.py b/fanficfare/story.py index a0353a92..d3db36e6 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -700,7 +700,7 @@ class Story(Requestable): self.chapter_text_replacements = [] self.in_ex_cludes = {} self.chapters = [] # chapters will be dict containing(url,title,html,etc) - self.extra_css = "" + self.extra_css = "" # story-wide author-defined CSS, like AO3's workskins self.chapter_first = None self.chapter_last = None diff --git a/fanficfare/writers/base_writer.py b/fanficfare/writers/base_writer.py index 9f3fa88d..67b8912f 100644 --- a/fanficfare/writers/base_writer.py +++ b/fanficfare/writers/base_writer.py @@ -175,6 +175,7 @@ class BaseStoryWriter(Requestable): temp_css = self.getConfig("output_css") else: temp_css = '' + # if the story has author-defined CSS that we want to include, append it to FFF's existing CSS. if self.story.extra_css != '': if temp_css != '': temp_css += '\n'