entry saving respects nopub setting

master
Vincent Zeng 2018-02-28 13:16:51 -05:00
parent 222e6e9d59
commit 89a53336ac
2 changed files with 65 additions and 58 deletions

View File

@ -235,57 +235,60 @@ def write_global_feed(blogList):
prints to blog feed prints to blog feed
''' '''
outfile = open(FEED, "w") try:
outfile = open(FEED, "w")
## header ## header
outfile.write("""\ outfile.write("""\
<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\"> <!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 3.2//EN\">
<html> <html>
<head> <head>
<title>tilde.town feels engine</title> <title>tilde.town feels engine</title>
<link rel=\"stylesheet\" href=\"style.css\" /> <link rel=\"stylesheet\" href=\"style.css\" />
</head> </head>
<body> <body>
<div class="meta"> <div class="meta">
<h1>tilde.town feels engine</h1> <h1>tilde.town feels engine</h1>
<h2><a href="https://github.com/modgethanc/ttbp">github <h2><a href="https://github.com/modgethanc/ttbp">github
repo</a> | <a repo</a> | <a
href="http://tilde.town/~endorphant/blog/20160510.html">state href="http://tilde.town/~endorphant/blog/20160510.html">state
of the ttbp</a></h2> of the ttbp</a></h2>
<!--<p>curious? run <b>~endorphant/bin/ttbp</b> while logged in to tilde.town.</p> <!--<p>curious? run <b>~endorphant/bin/ttbp</b> while logged in to tilde.town.</p>
<p>it's still a little volatile. let me know if anything breaks.</p>---></div> <p>it's still a little volatile. let me know if anything breaks.</p>---></div>
<p>&nbsp;</p> <p>&nbsp;</p>
""") """)
## docs ## docs
outfile.write("""\ outfile.write("""\
<div class="docs">""") <div class="docs">""")
outfile.write(mistune.markdown(open(os.path.join(config.INSTALL_PATH, "..", "README.md"), "r").read())) outfile.write(mistune.markdown(open(os.path.join(config.INSTALL_PATH, "..", "README.md"), "r").read()))
outfile.write("""\ outfile.write("""\
</div>""") </div>""")
## feed ## feed
outfile.write("""\ outfile.write("""\
<p>&nbsp;</p> <p>&nbsp;</p>
<div class=\"feed\"> <div class=\"feed\">
<h3>live feels-sharing:</h3> <h3>live feels-sharing:</h3>
<ul>""") <ul>""")
for blog in blogList: for blog in blogList:
outfile.write("""
<li>"""+blog+"""</li>\
""")
## footer
outfile.write(""" outfile.write("""
<li>"""+blog+"""</li>\ </ul>
""") </div>
</body>
</html>
""")
## footer outfile.close()
outfile.write(""" #subprocess.call(['chmod', 'a+w', FEED])
</ul> except FileNotFoundError:
</div> pass
</body>
</html>
""")
outfile.close()
#subprocess.call(['chmod', 'a+w', FEED])
## misc helpers ## misc helpers
@ -309,7 +312,7 @@ def meta(entries = FILES):
for filename in entries: for filename in entries:
mtime = os.path.getmtime(filename) mtime = os.path.getmtime(filename)
try: try:
wc = subprocess.check_output(["wc","-w",filename], stderr=subprocess.STDOUT).split()[0] wc = int(subprocess.check_output(["wc","-w",filename], stderr=subprocess.STDOUT).split()[0])
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
wc = "???" wc = "???"
timestamp = time.strftime("%Y-%m-%d at %H:%M", time.localtime(mtime)) timestamp = time.strftime("%Y-%m-%d at %H:%M", time.localtime(mtime))

View File

@ -108,7 +108,7 @@ def menu_handler(options, prompt, pagify=10, rainbow=False, top=""):
return util.list_select(options, prompt) return util.list_select(options, prompt)
else: else:
return page_helper(options, prompt, pagify, rainbow, page, total, top) return page_helper(options, prompt, pagify, rainbow, page, int(total), top)
def page_helper(options, prompt, pagify, rainbow, page, total, top): def page_helper(options, prompt, pagify, rainbow, page, total, top):
''' '''
@ -126,7 +126,7 @@ def page_helper(options, prompt, pagify, rainbow, page, total, top):
optPage = options[x:y] optPage = options[x:y]
util.print_menu(optPage, SETTINGS.get("rainbows", False)) util.print_menu(optPage, SETTINGS.get("rainbows", False))
print("\n\t( page {page} of {total}; type 'u' or 'd' to scroll up and down )").format(page=page+1, total=total+1) print("\n\t( page {page} of {total}; type 'u' or 'd' to scroll up and down)".format(page=page+1, total=total+1))
ans = util.list_select(optPage, prompt) ans = util.list_select(optPage, prompt)
@ -794,17 +794,21 @@ editor.
left = "" left = ""
if core.publishing(): if SETTINGS.get("nopub"):
core.load_files() core.toggle_nopub(os.path.basename(entry))
core.write("index.html") else:
left = "posted to {url}/index.html\n\n>".format( if core.publishing():
url="/".join( core.write("index.html")
[config.LIVE+config.USER, left = "posted to {url}/index.html\n\n>".format(
str(SETTINGS.get("publish dir"))])) url="/".join(
[config.LIVE+config.USER,
str(SETTINGS.get("publish dir"))]))
if SETTINGS.get('gopher'): if SETTINGS.get('gopher'):
gopher.publish_gopher('feels', core.get_files()) gopher.publish_gopher('feels', core.get_files())
left += " also posted to your ~/public_gopher!\n" left += " also posted to your ~/public_gopher!\n"
core.load_files()
redraw(left + " thanks for sharing your feels!") redraw(left + " thanks for sharing your feels!")
return return