add screenshot
This commit is contained in:
parent
6d0fafdd00
commit
24f3289224
@ -1,6 +1,8 @@
|
||||
# bink
|
||||
|
||||
serverless microblogging for tilde.town
|
||||
serverless microblogging for tilde.town!
|
||||
|
||||

|
||||
|
||||
## command usage
|
||||
|
||||
|
23
bink.py
23
bink.py
@ -3,7 +3,7 @@ from glob import glob
|
||||
from time import time_ns
|
||||
import datetime
|
||||
import os
|
||||
from sys import argv
|
||||
import sys
|
||||
from subprocess import run
|
||||
import tempfile
|
||||
from math import floor
|
||||
@ -11,6 +11,11 @@ from math import floor
|
||||
home = os.path.expanduser("~/.bink")
|
||||
max_body_length = 64_000
|
||||
|
||||
helptext = """see https://git.tilde.town/nebula/bink for details
|
||||
--help: show this message
|
||||
--pipe: user stdin as post content. ex `echo "hello!" | bink.py --pipe`
|
||||
--dump: print all posts in a json object"""
|
||||
|
||||
try:
|
||||
os.mkdir(home)
|
||||
except FileExistsError:
|
||||
@ -50,14 +55,14 @@ def generate_feed(before=None, count=200):
|
||||
blogs.append(obj)
|
||||
return blogs
|
||||
|
||||
if len(argv) > 1:
|
||||
if argv[1] == "--help":
|
||||
exit("see https://git.tilde.town/nebula/bink for usage instructions")
|
||||
elif argv[1] == "--dump":
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] == "--help":
|
||||
exit(helptext)
|
||||
elif sys.argv[1] == "--dump":
|
||||
with open("/dev/stdout", "w") as f:
|
||||
json.dump(generate_feed(), f)
|
||||
exit()
|
||||
elif argv[1] == "--pipe":
|
||||
elif sys.argv[1] == "--pipe":
|
||||
try:
|
||||
with open("/dev/stdin", "r", encoding="UTF-8") as f:
|
||||
body = f.read().strip()
|
||||
@ -67,7 +72,7 @@ if len(argv) > 1:
|
||||
except KeyboardInterrupt:
|
||||
exit()
|
||||
else:
|
||||
create_post(" ".join(argv[1:]))
|
||||
create_post(" ".join(sys.argv[1:]))
|
||||
exit()
|
||||
|
||||
import urwid
|
||||
@ -99,8 +104,8 @@ class App():
|
||||
self.walker.append(self.post_to_widget(post))
|
||||
|
||||
def post_to_widget(self, post):
|
||||
time = post["time"] / 1_000_000_000
|
||||
stamp = datetime.datetime.fromtimestamp(time)
|
||||
time_seconds = post["time"] / 1_000_000_000
|
||||
stamp = datetime.datetime.fromtimestamp(time_seconds)
|
||||
pile = urwid.Pile([
|
||||
urwid.Text([("bold", f"~{post['user']}"), " @ ", stamp.strftime("%H:%M (%A, %B %d, %Y)")]),
|
||||
urwid.Text(post['body']),
|
||||
|
BIN
screenshot.png
Normal file
BIN
screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
Loading…
x
Reference in New Issue
Block a user