|
|
|
@ -3,6 +3,7 @@
|
|
|
|
|
# https://git.rawtext.club/samhunter/edlogxx
|
|
|
|
|
|
|
|
|
|
with_markdown = True
|
|
|
|
|
wrapwidth = 80
|
|
|
|
|
|
|
|
|
|
import glob
|
|
|
|
|
import os
|
|
|
|
@ -48,6 +49,8 @@ def display_help():
|
|
|
|
|
G - go to last post
|
|
|
|
|
/ - search in the titles
|
|
|
|
|
q - quit
|
|
|
|
|
> - increases text width by 4 characters (in `wrap` mode)
|
|
|
|
|
< - decreases text width by 4 characters (in `wrap` mode)
|
|
|
|
|
!command - execute `command`. Accepts optional parameters:
|
|
|
|
|
- {f} - shlog file
|
|
|
|
|
- {t} - shlog title
|
|
|
|
@ -164,19 +167,26 @@ def cat(shlog, wrap=False, internal_pager=True, md_format=False):
|
|
|
|
|
author = shlog[1][1]
|
|
|
|
|
if wrap == True:
|
|
|
|
|
margin = 4
|
|
|
|
|
textwidth=min(80, cols) - margin * 2
|
|
|
|
|
textwidth=min(wrapwidth, cols) - margin * 2
|
|
|
|
|
filler=" " * margin
|
|
|
|
|
else:
|
|
|
|
|
filler = ""
|
|
|
|
|
textwidth = cols
|
|
|
|
|
if os.access(file, os.R_OK):
|
|
|
|
|
if md_format == True:
|
|
|
|
|
lines = [];
|
|
|
|
|
lines = []
|
|
|
|
|
#XXX
|
|
|
|
|
link_re = r'(?:https?|gemini|spartan|file|ftp|gopher)://[^ \])]+'
|
|
|
|
|
links = []
|
|
|
|
|
lines += ["-" * 6 ] # post separator
|
|
|
|
|
lines += [f'**Title: {title}** \n**Author: {author}** \n**Date: {date}** \n']
|
|
|
|
|
with open(shlog[1][0]) as f:
|
|
|
|
|
for line in f.readlines():
|
|
|
|
|
links += re.findall(link_re, line.rstrip())
|
|
|
|
|
lines += [line.rstrip()]
|
|
|
|
|
if len(links) > 0:
|
|
|
|
|
lines += [f' \n**Links**:\n']
|
|
|
|
|
lines += map( lambda x: "- " + x, links)
|
|
|
|
|
lines += [f' \n**Source**: *{file}*']
|
|
|
|
|
console.print(Markdown("\n".join(lines)))
|
|
|
|
|
else:
|
|
|
|
@ -386,6 +396,10 @@ try:
|
|
|
|
|
wrapped = True
|
|
|
|
|
elif cmd == ':nowrap':
|
|
|
|
|
wrapped = False
|
|
|
|
|
elif cmd == '>':
|
|
|
|
|
wrapwidth += 4
|
|
|
|
|
elif cmd == '<':
|
|
|
|
|
wrapwidth -= 4
|
|
|
|
|
elif cmd == ':pager':
|
|
|
|
|
internal = False
|
|
|
|
|
elif cmd == ':nopager':
|
|
|
|
|