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