Merge remote-tracking branch 'endorphant/master'

master
vilmibm 2019-07-01 17:06:30 +00:00
commit 720cb9af91
3 changed files with 53 additions and 29 deletions

View File

@ -258,3 +258,4 @@ thanks to:
* ~vilmibm, packaging help and gopher support * ~vilmibm, packaging help and gopher support
* ~sanqui, the bug swatter * ~sanqui, the bug swatter
* ~sinacutie, for css updates * ~sinacutie, for css updates
* ~epicmorphism, for fixing pagination scrolling

View File

@ -87,7 +87,7 @@ ___________________________________________________________
| ____ ____ ____ _ ____ ____ _ _ ____ _ _ _ ____ | | ____ ____ ____ _ ____ ____ _ _ ____ _ _ _ ____ |
| |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ | | |___ |___ |___ | [__ |___ |\ | | __ | |\ | |___ |
| | |___ |___ |___ ___] |___ | \| |__] | | \| |___ | | | |___ |___ |___ ___] |___ | \| |__] | | \| |___ |
| <gan jue; to feel> ver 0.12.1 | | <gan jue; to feel> ver 0.12.2 |
|__________________________________________________________| |__________________________________________________________|
'''.lstrip() '''.lstrip()
# ~ u n s t a b l e e x p e r i m e n t a l b r a n c h ~ # ~ u n s t a b l e e x p e r i m e n t a l b r a n c h ~
@ -309,5 +309,19 @@ version 0.9.3 features:
thanks for those of your who've written me with feedback! thanks for those of your who've written me with feedback!
keep feelin' together <3 keep feelin' together <3
""",
"0.12.2":"""
~[version 0.12.2 update]~
bug fix: ~epicmorphism helped out with fixing the pagination bug! now, when
you scroll through a list of entries, it'll correctly return you to the
page you were on if you open and close an item. thanks so much, friend <3
thanks to everyone writing me with feedback; i've been real busy lately,
and i might not get to making improvements or responding to mail for a
while :(
feel on!
~endo
""" """
} }

View File

@ -51,7 +51,7 @@ from . import chatter
from . import gopher from . import gopher
from . import util from . import util
__version__ = "0.12.1" __version__ = "0.12.2"
__author__ = "endorphant <endorphant@tilde.town)" __author__ = "endorphant <endorphant@tilde.town)"
p = inflect.engine() p = inflect.engine()
@ -89,7 +89,7 @@ SETTINGS = {
## ttbp specific utilities ## ttbp specific utilities
def menu_handler(options, prompt, pagify=10, rainbow=False, top=""): def menu_handler(options, prompt, pagify=10, page=0, rainbow=False, top=""):
''' '''
This menu handler takes an incoming list of options, pagifies to a This menu handler takes an incoming list of options, pagifies to a
pre-set value, and queries via the prompt. Calls print_menu() and pre-set value, and queries via the prompt. Calls print_menu() and
@ -99,7 +99,6 @@ def menu_handler(options, prompt, pagify=10, rainbow=False, top=""):
''' '''
optCount = len(options) optCount = len(options)
page = 0
total = optCount / pagify total = optCount / pagify
# don't display empty pages # don't display empty pages
@ -154,8 +153,9 @@ def page_helper(options, prompt, pagify, rainbow, page, total, top):
else: else:
# shift answer to refer to index from original list # shift answer to refer to index from original list
ans = ans + page * pagify ans = ans + page * pagify
# return the (shifted) answer and the current page
return ans # alternatively, we can recompute the current page at a call site
return (page, ans)
def redraw(leftover=""): def redraw(leftover=""):
''' '''
@ -745,7 +745,7 @@ def subscription_handler(intro=""):
redraw(top+intro) redraw(top+intro)
return subscription_handler(intro) return subscription_handler(intro)
def view_neighbors(users, prompt): def view_neighbors(users, prompt, page=0):
''' '''
generates list of all users on ttbp, sorted by most recent post generates list of all users on ttbp, sorted by most recent post
@ -804,12 +804,13 @@ def view_neighbors(users, prompt):
sortedUsers.append(user[0]) sortedUsers.append(user[0])
userIndex.append(user[2]) userIndex.append(user[2])
choice = menu_handler(sortedUsers, "pick a townie to browse their feels, or type 'q' to go home: ", 15, SETTINGS.get("rainbows", False), prompt) ans = menu_handler(sortedUsers, "pick a townie to browse their feels, or type 'q' to go home: ", 15, page, SETTINGS.get("rainbows", False), prompt)
if choice is not False: if ans is not False:
(page, choice) = ans
redraw("~{user}'s recorded feels, listed by date: \n".format(user=userIndex[choice])) redraw("~{user}'s recorded feels, listed by date: \n".format(user=userIndex[choice]))
view_feels(userIndex[choice]) view_feels(userIndex[choice])
view_neighbors(users, prompt) view_neighbors(users, prompt, page)
else: else:
redraw() redraw()
return return
@ -1079,9 +1080,10 @@ move it to {directory} and try running this tool again.\
""".format(directory=config.BACKUPS)) """.format(directory=config.BACKUPS))
else: else:
print("backup files found:\n") print("backup files found:\n")
choice = menu_handler(backups, "pick a backup file to load (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "backup files found:") ans = menu_handler(backups, "pick a backup file to load (or 'q' to cancel): ", 15, 0, SETTINGS.get("rainbows", False), "backup files found:")
if choice is not False: if ans is not False:
(page, choice) = ans
imports = core.process_backup(os.path.join(config.BACKUPS, backups[choice])) imports = core.process_backup(os.path.join(config.BACKUPS, backups[choice]))
for feel in imports: for feel in imports:
print("importing {entry}".format(entry="-".join(util.parse_date(feel)))) print("importing {entry}".format(entry="-".join(util.parse_date(feel))))
@ -1227,7 +1229,7 @@ def list_nopubs(user):
else: else:
redraw("no feels recorded by ~"+user) redraw("no feels recorded by ~"+user)
def set_nopubs(metas, user, prompt): def set_nopubs(metas, user, prompt, page=0):
"""displays a list of entries for pub/nopub toggling. """displays a list of entries for pub/nopub toggling.
""" """
@ -1246,9 +1248,10 @@ none of your feels will be viewable outside of this server)"""
pub = "(nopub)" pub = "(nopub)"
entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") "+"\t"+pub) entries.append(""+entry[4]+" ("+p.no("word", entry[2])+") "+"\t"+pub)
choice = menu_handler(entries, "pick an entry from the list to toggle nopub status, or type 'q' to go back: ", 10, SETTINGS.get("rainbows", False), prompt+"\n\n"+nopub_note) ans = menu_handler(entries, "pick an entry from the list to toggle nopub status, or type 'q' to go back: ", 10, page, SETTINGS.get("rainbows", False), prompt+"\n\n"+nopub_note)
if choice is not False: if ans is not False:
(page, choice) = ans
target = os.path.basename(metas[choice][0]) target = os.path.basename(metas[choice][0])
action = core.toggle_nopub(target) action = core.toggle_nopub(target)
redraw(prompt) redraw(prompt)
@ -1256,7 +1259,7 @@ none of your feels will be viewable outside of this server)"""
if SETTINGS["gopher"]: if SETTINGS["gopher"]:
gopher.publish_gopher('feels', core.get_files()) gopher.publish_gopher('feels', core.get_files())
return set_nopubs(metas, user, prompt) return set_nopubs(metas, user, prompt, page)
else: else:
redraw() redraw()
@ -1299,23 +1302,23 @@ running through the feedback option again!\
return exit return exit
def list_entries(metas, entries, prompt): def list_entries(metas, entries, prompt, page=0):
''' '''
displays a list of entries for reading selection, allowing user to select displays a list of entries for reading selection, allowing user to select
one for display. one for display.
''' '''
choice = menu_handler(entries, "pick an entry from the list, or type 'q' to go back: ", 10, SETTINGS.get("rainbows", False), prompt) ans = menu_handler(entries, "pick an entry from the list, or type 'q' to go back: ", 10, page, SETTINGS.get("rainbows", False), prompt)
if choice is not False:
if ans is not False:
(page, choice) = ans
redraw("now reading ~{user}'s feels on {date}\n> press <q> to return to feels list.\n\n".format(user=metas[choice][5], redraw("now reading ~{user}'s feels on {date}\n> press <q> to return to feels list.\n\n".format(user=metas[choice][5],
date=metas[choice][4])) date=metas[choice][4]))
show_entry(metas[choice][0]) show_entry(metas[choice][0])
redraw(prompt) redraw(prompt)
return list_entries(metas, entries, prompt) return list_entries(metas, entries, prompt, page)
else: else:
redraw() redraw()
@ -1434,26 +1437,27 @@ def subscription_manager(subs, intro=""):
redraw(top+intro) redraw(top+intro)
return subscription_manager(subs, intro) return subscription_manager(subs, intro)
def unsubscribe_handler(subs, prompt): def unsubscribe_handler(subs, prompt, page=0):
''' '''
displays a list of currently subscribed users and toggles deletion. displays a list of currently subscribed users and toggles deletion.
''' '''
subs.sort() subs.sort()
choice = menu_handler(subs, "pick a pal to unsubscribe (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "list of townies recording feels:") ans = menu_handler(subs, "pick a pal to unsubscribe (or 'q' to cancel): ", 15, page, SETTINGS.get("rainbows", False), "list of townies recording feels:")
if choice is not False: if ans is not False:
(page,choice) = ans
townie = subs[choice] townie = subs[choice]
subs.remove(townie) subs.remove(townie)
save_subs(subs) save_subs(subs)
redraw("{townie} removed! \n\n> {prompt}".format(townie=townie, prompt=prompt)) redraw("{townie} removed! \n\n> {prompt}".format(townie=townie, prompt=prompt))
return unsubscribe_handler(subs, prompt) return unsubscribe_handler(subs, prompt, page)
else: else:
redraw() redraw()
return subs return subs
def subscribe_handler(subs, prompt): def subscribe_handler(subs, prompt, page=0):
''' '''
displays a list of all users not subscribed to and toggles adding, displays a list of all users not subscribed to and toggles adding,
returning the subs list when finished. returning the subs list when finished.
@ -1467,14 +1471,15 @@ def subscribe_handler(subs, prompt):
candidates.sort() candidates.sort()
choice = menu_handler(candidates, "pick a townie to add to your subscriptions (or 'q' to cancel): ", 15, SETTINGS.get("rainbows", False), "list of townies recording feels:") ans = menu_handler(candidates, "pick a townie to add to your subscriptions (or 'q' to cancel): ", 15, page, SETTINGS.get("rainbows", False), "list of townies recording feels:")
if choice is not False: if ans is not False:
(page, choice) = ans
townie = candidates[choice] townie = candidates[choice]
subs.append(townie) subs.append(townie)
save_subs(subs) save_subs(subs)
redraw("{townie} added! \n\n> {prompt}".format(townie=townie, prompt=prompt)) redraw("{townie} added! \n\n> {prompt}".format(townie=townie, prompt=prompt))
return subscribe_handler(subs, prompt) return subscribe_handler(subs, prompt, page)
else: else:
redraw() redraw()
return subs return subs
@ -1902,6 +1907,10 @@ something strange happened to you during this update.
# version 0.12.1 patch notes # version 0.12.1 patch notes
print(config.UPDATES["0.12.1"]) print(config.UPDATES["0.12.1"])
if z < 2:
# version 0.12.2 patch notes
print(config.UPDATES["0.12.2"])
confirm = "" confirm = ""
while confirm not in ("x", "<x>", "X", "<X>"): while confirm not in ("x", "<x>", "X", "<X>"):