improved config mechanism to include workskin

This commit is contained in:
niacdoial 2023-06-18 18:43:31 +02:00
parent e5cc1cccf2
commit 3ba2edef2d
No known key found for this signature in database
GPG key ID: D2B9B9FE6D7B1C8E
6 changed files with 16 additions and 4 deletions

View file

@ -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,

View file

@ -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"

View file

@ -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',

View file

@ -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,

View file

@ -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

View file

@ -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'