cleaning up comments

This commit is contained in:
Vincent Zeng 2018-01-03 03:15:57 -05:00
parent 3bb5726e22
commit 17f69825f0
1 changed files with 31 additions and 47 deletions

View File

@ -51,9 +51,8 @@ FILES = []
NOPUBS = [] NOPUBS = []
def load(ttbprc={}): def load(ttbprc={}):
''' """Set up globals, including loading files and nopub list.
get all them globals set up!! """
'''
global HEADER global HEADER
global FOOTER global FOOTER
@ -67,20 +66,26 @@ def load(ttbprc={}):
load_files() load_files()
def reload_ttbprc(ttbprc={}): def reload_ttbprc(ttbprc={}):
''' """Loads a given ttbprc into session.
reloads new ttbprc into current session """
'''
global SETTINGS global SETTINGS
SETTINGS = ttbprc SETTINGS = ttbprc
def get_files(): def get_files():
"""Returns a list of user's feels.""" """Returns a list of user's feels, sorted in reverse chronological order.
As a secondary function, this checks if a file is listed as a nopub and
removes it from published directories, in case it wasn't caught in a
previous unpublishing pass.
"""
files = [] files = []
for filename in os.listdir(config.USER_DATA): for filename in os.listdir(config.USER_DATA):
if nopub(filename): if nopub(filename):
## TODO: include check for gopher unpublishin
link = os.path.join(config.WWW, link = os.path.join(config.WWW,
os.path.splitext( os.path.splitext(
os.path.basename(filename))[0]+".html") os.path.basename(filename))[0]+".html")
@ -96,14 +101,9 @@ def get_files():
return files return files
def load_files(): def load_files():
''' """Loads files into session.
file loader """
* reads user's nopub file
* loads all valid filenames that are not excluded in nopub to global files list
'''
global FILES global FILES
@ -111,7 +111,7 @@ def load_files():
FILES = get_files() FILES = get_files()
def load_nopubs(): def load_nopubs():
"""Load a list of the user's nopub entries. """Load a list of the user's nopub entries into session.
""" """
global NOPUBS global NOPUBS
@ -128,13 +128,12 @@ def load_nopubs():
## html outputting ## html outputting
def write(outurl="default.html"): def write(outurl="default.html"):
''' """Main page renderer
main page renderer
* takes everything currently in FILES and writes a single non-paginated html * takes everything currently in FILES and writes a single non-paginated html
file file
* calls write_page() on each file to make permalinks * calls write_page() on each file to make individual permalink files
''' """
outfile = open(os.path.join(config.WWW, outurl), "w") outfile = open(os.path.join(config.WWW, outurl), "w")
@ -160,12 +159,11 @@ def write(outurl="default.html"):
return os.path.join(config.LIVE+config.USER,os.path.basename(os.path.realpath(config.WWW)),outurl) return os.path.join(config.LIVE+config.USER,os.path.basename(os.path.realpath(config.WWW)),outurl)
def write_page(filename): def write_page(filename):
''' """Individual page generator.
permalink generator
* makes a page out of a single entry for permalinking, using filename/date as * makes a page out of a single entry for permalinking, using filename/date as
url url
''' """
outurl = os.path.join(config.WWW, "".join(parse_date(filename))+".html") outurl = os.path.join(config.WWW, "".join(parse_date(filename))+".html")
outfile = open(outurl, "w") outfile = open(outurl, "w")
@ -190,12 +188,8 @@ def write_page(filename):
return outurl return outurl
def write_entry(filename): def write_entry(filename):
''' """Returns a string list of the specified entry's htmlified text.
entry text generator """
* dump given file into entry format by parsing file as markdown
* return as list of strings
'''
date = parse_date(filename) date = parse_date(filename)
@ -215,25 +209,18 @@ def write_entry(filename):
entry.append("\t\t\t"+mistune.markdown("".join(raw), escape=False, hard_wrap=False)) entry.append("\t\t\t"+mistune.markdown("".join(raw), escape=False, hard_wrap=False))
#for line in raw:
#entry.append(line+"\t\t\t")
#if line == "\n":
# entry.append("</p>\n\t\t\t<p>")
#entry.append("</p>\n")
entry.append("\t\t\t<p style=\"font-size:.6em; font-color:#808080; text-align: right;\"><a href=\""+"".join(date)+".html\">permalink</a></p>\n") entry.append("\t\t\t<p style=\"font-size:.6em; font-color:#808080; text-align: right;\"><a href=\""+"".join(date)+".html\">permalink</a></p>\n")
entry.append("\n\t\t</div>\n") entry.append("\n\t\t</div>\n")
return entry return entry
def write_global_feed(blogList): def write_global_feed(blogList):
''' """Main ttbp index printer
main ttbp index printer
* sources README.md for documentation * sources README.md for documentation
* takes incoming list of formatted blog links for all publishing blogs and * takes incoming list of formatted blog links for all publishing blogs and
prints to blog feed prints to blog feed
''' """
outfile = open(FEED, "w") outfile = open(FEED, "w")
@ -285,13 +272,11 @@ def write_global_feed(blogList):
""") """)
outfile.close() outfile.close()
#subprocess.call(['chmod', 'a+w', FEED])
## misc helpers ## misc helpers
def meta(entries = FILES): def meta(entries = FILES):
''' """metadata generator
metadata generator
* takes a list of filenames and returns a 2d list: * takes a list of filenames and returns a 2d list:
[0] absolute path [0] absolute path
@ -302,7 +287,7 @@ def meta(entries = FILES):
[5] author [5] author
* sorted in reverse date order by [4] * sorted in reverse date order by [4]
''' """
meta = [] meta = []
@ -430,14 +415,13 @@ def www_neighbors():
write_global_feed(sortedUsers) write_global_feed(sortedUsers)
def nopub(filename): def nopub(filename):
''' """Checks to see if given filename is in user's NOPUB
checks to see if given filename is in user's NOPUB """
'''
return os.path.basename(filename) in NOPUBS return os.path.basename(filename) in NOPUBS
def toggle_nopub(filename): def toggle_nopub(filename):
"""toggles pub/nopub status for the given filename """Toggles pub/nopub status for the given filename
if the file is to be unpublished, delete it from published locations if the file is to be unpublished, delete it from published locations
""" """