Fix for fallback metadata labels, plus allow other text in titlepage_entries.

This commit is contained in:
Jim Miller 2012-07-01 13:12:48 -05:00
parent b8bc2cecb6
commit 57dc8eb12e
4 changed files with 23 additions and 4 deletions

View file

@ -66,7 +66,9 @@ extratags_label:Extra Tags
version_label:FFDL Version
## items to include in the title page
## Empty entries will *not* appear, even if in the list.
## Empty metadata entries will *not* appear, even if in the list.
## You can include extra text or HTML that will be included as-is in
## the title page. Eg: titlepage_entries: ...,<br />,summary,<br />,...
## All current formats already include title and author.
titlepage_entries: series,category,genre,language,characters,status,datePublished,dateUpdated,dateCreated,rating,warnings,numChapters,numWords,site,description

View file

@ -54,6 +54,17 @@ class Configurable(object):
def addConfigSection(self,section):
self.sectionslist.insert(0,section)
def hasConfig(self, key):
for section in self.sectionslist:
try:
self.config.get(section,key)
print("found %s in section [%s]"%(key,section))
return True
except:
pass
return False
def getConfig(self, key):
val = ""
for section in self.sectionslist:

View file

@ -149,18 +149,22 @@ class BaseStoryWriter(Configurable):
TEMPLATE=WIDE_ENTRY
else:
TEMPLATE=ENTRY
if self.getConfigList(entry):
if self.hasConfig(entry+"_label"):
label=self.getConfig(entry+"_label")
else:
print("Using fallback label for %s_label"%entry)
label=self.titleLabels[entry]
# If the label for the title entry is empty, use the
# 'no title' option if there is one.
# 'no title' option if there is one.
if label == "" and NO_TITLE_ENTRY:
TEMPLATE= NO_TITLE_ENTRY
self._write(out,TEMPLATE.substitute({'label':label,
'value':self.story.getMetadata(entry)}))
else:
self._write(out, entry)
self._write(out,END.substitute(self.story.metadata))

View file

@ -71,7 +71,9 @@ extratags_label:Extra Tags
version_label:FFDL Version
## items to include in the title page
## Empty entries will *not* appear, even if in the list.
## Empty metadata entries will *not* appear, even if in the list.
## You can include extra text or HTML that will be included as-is in
## the title page. Eg: titlepage_entries: ...,<br />,summary,<br />,...
## All current formats already include title and author.
titlepage_entries: series,category,genre,language,characters,status,datePublished,dateUpdated,dateCreated,rating,warnings,numChapters,numWords,site,description