Merge pull request 'minor cleaning in rss_1' (#3) from eloitor/microblog.py:rss_1 into rss_1
Reviewed-on: #3
This commit is contained in:
commit
5044b2b0e9
@ -1,4 +1,3 @@
|
||||
|
||||
import os, argparse
|
||||
from tomlkit import loads
|
||||
from tomlkit import dump
|
||||
@ -34,7 +33,7 @@ class MicroblogConfig:
|
||||
|
||||
def check(self, r, u): # (reference, user)
|
||||
for key in r:
|
||||
if key == "latestpages": continue;
|
||||
if key == "latestpages": continue
|
||||
# post and webring have subtables
|
||||
# webring.profile
|
||||
# webring.following
|
||||
|
@ -550,6 +550,9 @@ if __name__ == "__main__":
|
||||
updated += writepage(tpl, tl, tc, cfg["page"],
|
||||
paginate=True if new_posts is None else False)
|
||||
if cfg["rss"]["enabled"]:
|
||||
# ensure output directory for feeds exists
|
||||
if not os.path.exists("feeds"):
|
||||
os.mkdir("feeds")
|
||||
feed_filename = "feeds/__index__.xml"
|
||||
rss.write_feed(
|
||||
p[:cfg["rss"]["limit"]], \
|
||||
|
13
src/rss.py
13
src/rss.py
@ -1,4 +1,3 @@
|
||||
|
||||
from microblog import My_Html_Parser
|
||||
# from html.parser import HTMLParser
|
||||
from html import escape
|
||||
@ -7,7 +6,7 @@ try:
|
||||
import feedgenerator
|
||||
except ImportError:
|
||||
traceback.print_exc()
|
||||
def write_feed(posts, filename, params):
|
||||
def write_feed(posts, filename, params, tagname=None):
|
||||
pass
|
||||
print("\trss disabled - missing dependency", file=sys.stderr)
|
||||
print("\tYour microblog still may have been generated.", file=sys.stderr)
|
||||
@ -22,7 +21,7 @@ def line2words(lines, limit):
|
||||
l = len(word)
|
||||
if limit > 0 and (l + char_count > limit):
|
||||
break_outer_loop = True
|
||||
break;
|
||||
break
|
||||
output.append(word)
|
||||
char_count += l
|
||||
if break_outer_loop:
|
||||
@ -35,10 +34,10 @@ def line2words(lines, limit):
|
||||
output.append("...")
|
||||
return output
|
||||
|
||||
# this is similar tot he markup function in microblog
|
||||
# this is similar to the markup function in microblog
|
||||
def enrich_msg(lines, is_atom=True):
|
||||
if not is_atom:
|
||||
return string
|
||||
return lines
|
||||
content = []
|
||||
parser = My_Html_Parser([])
|
||||
for line in lines:
|
||||
@ -66,9 +65,9 @@ def enrich_msg(lines, is_atom=True):
|
||||
content.append(line)
|
||||
return content
|
||||
|
||||
def write_feed(posts, filename, params, tagname=str()):
|
||||
def write_feed(posts, filename, params, tagname=None):
|
||||
feed = None
|
||||
if tagname != str():
|
||||
if tagname:
|
||||
t = params["title_tagged"].format(
|
||||
__tagname__ = tagname,
|
||||
__title__ = params["title"])
|
||||
|
Loading…
x
Reference in New Issue
Block a user