--- /home/paladox/rawdog/rawdog-2.22/rawdoglib/rawdog.py.orig 2018-05-29 20:37:03.608320054 +0000 +++ /home/paladox/rawdog/rawdog-2.22/rawdoglib/rawdog.py 2018-05-29 20:52:58.830966189 +0000 @@ -16,7 +16,7 @@ # Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA, or see http://www.gnu.org/. -VERSION = "2.22" +VERSION = "2.22-wmf1" HTTP_AGENT = "rawdog/" + VERSION STATE_VERSION = 2 @@ -898,6 +898,7 @@ "feeddefaults" : {}, "defines" : {}, "outputfile" : "output.html", + "oldpages" : 7, "maxarticles" : 200, "maxage" : 0, "expireage" : 24 * 60 * 60, @@ -1011,6 +1012,8 @@ load_plugins(dir, self) elif l[0] == "outputfile": self["outputfile"] = l[1] + elif l[0] == "oldpages": + self["oldpages"] = l[1] elif l[0] == "maxarticles": self["maxarticles"] = int(l[1]) elif l[0] == "maxage": @@ -1736,7 +1739,7 @@ return bits - def write_output_file(self, articles, article_dates, config): + def write_output_file(self, articles, article_dates, config, oldpage=0): """Write a regular rawdog HTML output file.""" f = StringIO() dw = DayWriter(f, config) @@ -1751,13 +1754,24 @@ dw.close() call_hook("output_items_end", self, config, f) + if oldpage != config["oldpages"]: + filename = config["outputfile"].split("/")[-1:][0] # get the filename only + filename = filename.split(".html") + outputfile = filename[0] + str(oldpage+1) + ".html" + f.write('

Older blog entries

') + + bits = self.get_main_template_bits(config) bits["items"] = f.getvalue() f.close() bits["num_items"] = str(len(articles)) call_hook("output_bits", self, config, bits) s = fill_template(self.get_template(config, "page"), bits) - outputfile = config["outputfile"] + if oldpage > 0: + filename = config["outputfile"].split(".html") + outputfile = filename[0] + str(oldpage) + ".html" + else: + outputfile = config["outputfile"] if outputfile == "-": write_ascii(sys.stdout, s, config) else: @@ -1787,8 +1801,8 @@ if not call_hook("output_sort_articles", self, config, article_list): article_list.sort() - if config["maxarticles"] != 0: - article_list = article_list[:config["maxarticles"]] + # if config["maxarticles"] != 0: + # article_list = article_list[:config["maxarticles"]] if config["splitstate"]: wanted = {} @@ -1828,8 +1842,13 @@ config.log("Selected ", len(articles), " of ", numarticles, " articles to write; ignored ", dup_count, " duplicates") - if not call_hook("output_write_files", self, config, articles, article_dates): - self.write_output_file(articles, article_dates, config) + for page in range(0, config["oldpages"]+1): + print "on page: " + str(page) + if config["maxarticles"] != 0: + pageArticles = articles[config["maxarticles"]*page:config["maxarticles"]*(page+1)] + + if not call_hook("output_write_files", self, config, pageArticles, article_dates): + self.write_output_file(pageArticles, article_dates, config, page) config.log("Finished write")