From aa8b19303c6ae1a2514ab57781b5983f1e80f235 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Sun, 7 Jul 2013 15:43:38 +0000 Subject: [PATCH] Rename template to pagetemplate. --- NEWS | 3 +++ config | 8 ++++---- rawdoglib/rawdog.py | 22 +++++++++++----------- test-rawdog | 13 +++++++++++-- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index d7aec4c..625747f 100644 --- a/NEWS +++ b/NEWS @@ -139,6 +139,9 @@ Move rawdog's feed quality heuristic into feedscanner. Provide templates for the feed list and each item in the feed list (based on patch from Arnout Engelen). +Rename the "template" option to "pagetemplate", for consistency. +("template" is still accepted for backwards compatibility.) + Rework the locking logic in persister so that it uses a separate lock file. This fixes a (mostly) harmless bug: previously if rawdog A was waiting for rawdog B to finish, then rawdog A wouldn't see the changes diff --git a/config b/config index 8fd40c0..cdf4c72 100644 --- a/config +++ b/config @@ -74,9 +74,9 @@ timeformat %H:%M # %Y-%m-%d %H:%M 2004-01-21 18:07 (ISO 8601 format) datetimeformat %H:%M, %A, %d %B -# The template file to use, or "default" to use the built-in template -# (which is probably sufficient for most users). Use "rawdog -t" to show -# the template currently in use as a starting-point for customisation. +# The page template file to use, or "default" to use the built-in template +# (which is probably sufficient for most users). Use "rawdog -t" to show the +# template currently in use as a starting-point for customisation. # The following strings will be replaced in the output: # __version__ The rawdog version in use # __refresh__ The HTML 4 header @@ -87,7 +87,7 @@ datetimeformat %H:%M, %A, %d %B # You can define additional strings using "define" in this config file; for # example, if you say "define myname Adam Sampson", then "__myname__" will be # replaced by "Adam Sampson" in the output. -template default +pagetemplate default # Similarly, the template used for each item shown. Use "rawdog -T" to # show the template currently in use as a starting-point for diff --git a/rawdoglib/rawdog.py b/rawdoglib/rawdog.py index af9d76d..912cd71 100644 --- a/rawdoglib/rawdog.py +++ b/rawdoglib/rawdog.py @@ -815,7 +815,7 @@ class Config: "userefresh" : False, "showfeeds" : True, "timeout" : 30, - "template" : "default", + "pagetemplate" : "default", "itemtemplate" : "default", "feedlisttemplate" : "default", "feeditemtemplate" : "default", @@ -922,8 +922,8 @@ class Config: self["showfeeds"] = parse_bool(l[1]) elif l[0] == "timeout": self["timeout"] = parse_time(l[1], "s") - elif l[0] == "template": - self["template"] = l[1] + elif l[0] in ("template", "pagetemplate"): + self["pagetemplate"] = l[1] elif l[0] == "itemtemplate": self["itemtemplate"] = l[1] elif l[0] == "feedlisttemplate": @@ -1374,10 +1374,10 @@ class Rawdog(Persistable): self.modified() config.log("Finished update") - def get_template(self, config): + def get_pagetemplate(self, config): """Get the main template.""" - if config["template"] != "default": - return load_file(config["template"]) + if config["pagetemplate"] != "default": + return load_file(config["pagetemplate"]) template = """ @@ -1462,9 +1462,9 @@ __feeditems__ """ - def show_template(self, config): - """Show the configured main template.""" - print self.get_template(config), + def show_pagetemplate(self, config): + """Show the configured page template.""" + print self.get_pagetemplate(config), def show_itemtemplate(self, config): """Show the configured item template.""" @@ -1671,7 +1671,7 @@ __feeditems__ f.close() bits["num_items"] = str(len(articles)) plugins.call_hook("output_bits", self, config, bits) - s = fill_template(self.get_template(config), bits) + s = fill_template(self.get_pagetemplate(config), bits) outputfile = config["outputfile"] if outputfile == "-": write_ascii(sys.stdout, s, config) @@ -1906,7 +1906,7 @@ def main(argv): config.reload() rawdog.sync_from_config(config) elif o in ("-t", "--show-template"): - rawdog.show_template(config) + rawdog.show_pagetemplate(config) elif o in ("-T", "--show-itemtemplate"): rawdog.show_itemtemplate(config) elif o in ("-u", "--update"): diff --git a/test-rawdog b/test-rawdog index bd8a970..e31f420 100644 --- a/test-rawdog +++ b/test-rawdog @@ -646,14 +646,14 @@ add "feed 0 $httpurl/simple.rss" runs -uw cp $statedir/output.html $statedir/output.html.orig run -t -cp $outfile $statedir/template +cp $outfile $statedir/page run -T cp $outfile $statedir/item run --show-feedlisttemplate cp $outfile $statedir/feedlist run --show-feeditemtemplate cp $outfile $statedir/feeditem -add "template template" +add "pagetemplate page" add "itemtemplate item" add "feedlisttemplate feedlist" add "feeditemtemplate feeditem" @@ -662,6 +662,15 @@ if ! cmp $statedir/output.html.orig $statedir/output.html; then die "output different from default templates" fi +begin "pre-2.15 template options" +run -t +echo hello world >$statedir/page +add "template page" +run -uw +if ! cmp $statedir/page $statedir/output.html; then + die "template not expanded" +fi + begin "item dates" # Debian bug 651080. run -T -- 2.35.1