From f3af754c71302b607fbf2b695ef350c76f942c65 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 7 Oct 2015 11:17:43 -0500 Subject: [PATCH] Add capitalize_forumtags feature to base_xenforoforum and include forumtags by default. --- calibre-plugin/plugin-defaults.ini | 15 +++++++++++---- fanficfare/adapters/base_xenforoforum_adapter.py | 5 ++++- fanficfare/defaults.ini | 15 +++++++++++---- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index d12b0c4..9916fd7 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -406,19 +406,26 @@ add_to_replace_metadata: # change (spaces)slash(or semicolon)(spaces) to comma tagsfromtitle=> *[/;] *=>, tagsfromtitle=> [xX] =>, - + # remove [] or () blocks and leading/trailing spaces/dashes/colons title=>[-: ]*[\(\[]([^\]\)]+)[\)\]][-: ]*=> # remove 'Thread' and the next word, usually "Thread 2", "Thread # four", "Thread iv", "Story Thread", etc title,tagsfromtitle=>[-: ]*(Story *)?[Tt]hread [^ ]+[-: ]*=> +# Normalize 'fanfiction/fanfic/fan-fiction' a little. + forumtags=>[Ff]an-?[Ff]ic(tion)?=>FanFiction + add_to_extra_titlepage_entries:,tagsfromtitle,forumtags +## XenForo tags are all lowercase everywhere that I've seen. This +## makes the first letter of each word uppercase. Applied before +## replace_metadata. +capitalize_forumtags:true + +## Add both title tags and forumtags to standard (subject) tags. ## '.SPLIT' tells the system to split by ',' -add_to_include_subject_tags:,tagsfromtitle.SPLIT -## Or to also include forumtags add this to personal.ini: -#add_to_include_subject_tags:,forumtags +add_to_include_subject_tags:,tagsfromtitle.SPLIT,forumtags ## base_xenforoforum reads Published and Updated datetimes from ## Threadmarks if used, or from the posted & updated times of the diff --git a/fanficfare/adapters/base_xenforoforum_adapter.py b/fanficfare/adapters/base_xenforoforum_adapter.py index 39b12e5..b9bb571 100644 --- a/fanficfare/adapters/base_xenforoforum_adapter.py +++ b/fanficfare/adapters/base_xenforoforum_adapter.py @@ -177,7 +177,10 @@ class BaseXenForoForumAdapter(BaseSiteAdapter): ## only use tags if threadmarks for chapters. ## a bit arbitrary, but likely. for tag in soup.findAll('a',{'class':'tag'}): - self.story.addToList('forumtags',stripHTML(tag)) + tstr = stripHTML(tag) + if self.getConfig('capitalize_forumtags'): + tstr = tstr.title() + self.story.addToList('forumtags',tstr) soup = soup.find('li',{'class':'message'}) # limit first post for date stuff below. ('#' posts above) diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 6dd188c..30adb00 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -405,19 +405,26 @@ add_to_replace_metadata: # change (spaces)slash(or semicolon)(spaces) to comma tagsfromtitle=> *[/;] *=>, tagsfromtitle=> [xX] =>, - + # remove [] or () blocks and leading/trailing spaces/dashes/colons title=>[-: ]*[\(\[]([^\]\)]+)[\)\]][-: ]*=> # remove 'Thread' and the next word, usually "Thread 2", "Thread # four", "Thread iv", "Story Thread", etc title,tagsfromtitle=>[-: ]*(Story *)?[Tt]hread [^ ]+[-: ]*=> +# Normalize 'fanfiction/fanfic/fan-fiction' a little. + forumtags=>[Ff]an-?[Ff]ic(tion)?=>FanFiction + add_to_extra_titlepage_entries:,tagsfromtitle,forumtags +## XenForo tags are all lowercase everywhere that I've seen. This +## makes the first letter of each word uppercase. Applied before +## replace_metadata. +capitalize_forumtags:true + +## Add both title tags and forumtags to standard (subject) tags. ## '.SPLIT' tells the system to split by ',' -add_to_include_subject_tags:,tagsfromtitle.SPLIT -## Or to also include forumtags add this to personal.ini: -#add_to_include_subject_tags:,forumtags +add_to_include_subject_tags:,tagsfromtitle.SPLIT,forumtags ## base_xenforoforum reads Published and Updated datetimes from ## Threadmarks if used, or from the posted & updated times of the