adjust datetime field again and use timeago
This commit is contained in:
parent
b0515a5e4a
commit
de8f5a3262
4 changed files with 27 additions and 11 deletions
|
@ -15,8 +15,9 @@ A nut obsessed saber-toothed client for pnut.io
|
||||||
- [x] Keyboard shortcuts
|
- [x] Keyboard shortcuts
|
||||||
- [x] Avatars
|
- [x] Avatars
|
||||||
- [x] Post actions (reply, bookmark, repost, quote, copy)
|
- [x] Post actions (reply, bookmark, repost, quote, copy)
|
||||||
- [ ] Load newer posts
|
- [-] Load newer posts
|
||||||
- [ ] Load older posts
|
- [x] Load older posts
|
||||||
|
- [ ] Thread view
|
||||||
- [ ] Loading indicator
|
- [ ] Loading indicator
|
||||||
- [ ] Render post media
|
- [ ] Render post media
|
||||||
- [ ] Settings page
|
- [ ] Settings page
|
||||||
|
|
|
@ -71,6 +71,20 @@
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "python3-timeago",
|
||||||
|
"buildsystem": "simple",
|
||||||
|
"build-commands": [
|
||||||
|
"pip3 install --exists-action=i --no-index --find-links=\"file://${PWD}\" --prefix=${FLATPAK_DEST} \"timeago\""
|
||||||
|
],
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"type": "file",
|
||||||
|
"url": "https://files.pythonhosted.org/packages/8c/d3/2d4152ea477223a1d10be0f33551341f5e3758a67f8bf831835c3722c350/timeago-1.0.15.tar.gz",
|
||||||
|
"sha256": "cfce420d82892af6b2439d0f69eeb3e876bbeddab6670c3c88ebf7676407bf4c"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name" : "libhandy",
|
"name" : "libhandy",
|
||||||
"buildsystem" : "meson",
|
"buildsystem" : "meson",
|
||||||
|
|
|
@ -128,10 +128,6 @@ class Application(Gtk.Application):
|
||||||
self.win.add(vbox)
|
self.win.add(vbox)
|
||||||
self.win.show_all()
|
self.win.show_all()
|
||||||
|
|
||||||
def blarp(self, args=None):
|
|
||||||
logging.debug("BLARP")
|
|
||||||
logging.debug(self.keyfile)
|
|
||||||
|
|
||||||
def handle_login(self, args, code):
|
def handle_login(self, args, code):
|
||||||
# TODO: should do some actual error handling here
|
# TODO: should do some actual error handling here
|
||||||
self.keyfile.set_string("GENERAL", "ACCESS_TOKEN", code)
|
self.keyfile.set_string("GENERAL", "ACCESS_TOKEN", code)
|
||||||
|
|
|
@ -21,6 +21,8 @@ import os
|
||||||
import pnutpy
|
import pnutpy
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
import timeago
|
||||||
|
import datetime
|
||||||
|
|
||||||
from dateutil.tz import tzlocal
|
from dateutil.tz import tzlocal
|
||||||
|
|
||||||
|
@ -358,8 +360,11 @@ class PostItem(Gtk.ListBoxRow):
|
||||||
self.name.set_markup(f"<b>{post.user.name}</b>")
|
self.name.set_markup(f"<b>{post.user.name}</b>")
|
||||||
|
|
||||||
# datetime
|
# datetime
|
||||||
|
now = datetime.datetime.now(tzlocal())
|
||||||
post_date_local = post.created_at.astimezone(tzlocal())
|
post_date_local = post.created_at.astimezone(tzlocal())
|
||||||
datetime_label = Gtk.Label(label=post_date_local.strftime("%Y-%m-%d %H:%M"), xalign=1, yalign=0)
|
#datetime_label = Gtk.Label(label=post_date_local.strftime("%Y-%m-%d %H:%M"), xalign=1)
|
||||||
|
datetime_label = Gtk.Label(xalign=1)
|
||||||
|
datetime_label.set_markup('<span size="small">' + timeago.format(post_date_local, now) + '</span>')
|
||||||
|
|
||||||
# post menu
|
# post menu
|
||||||
self.menu_button = Gtk.Button.new_from_icon_name('view-more-symbolic', 1)
|
self.menu_button = Gtk.Button.new_from_icon_name('view-more-symbolic', 1)
|
||||||
|
@ -378,7 +383,7 @@ class PostItem(Gtk.ListBoxRow):
|
||||||
self.h_box.pack_start(self.avatar, False, False, 10)
|
self.h_box.pack_start(self.avatar, False, False, 10)
|
||||||
self.h_box.pack_start(self.name_box, False, False, 0)
|
self.h_box.pack_start(self.name_box, False, False, 0)
|
||||||
#self.h_box.pack_end(self.source, False, False, 10)
|
#self.h_box.pack_end(self.source, False, False, 10)
|
||||||
self.h_box.pack_end(datetime_label, False, False, 10)
|
#self.h_box.pack_end(datetime_label, False, False, 10)
|
||||||
|
|
||||||
# content container
|
# content container
|
||||||
self.c_box = Gtk.Box(orientation='vertical')
|
self.c_box = Gtk.Box(orientation='vertical')
|
||||||
|
@ -412,9 +417,9 @@ class PostItem(Gtk.ListBoxRow):
|
||||||
|
|
||||||
# footer container
|
# footer container
|
||||||
self.f_box = Gtk.Box(orientation='horizontal')
|
self.f_box = Gtk.Box(orientation='horizontal')
|
||||||
self.f_box.pack_end(self.menu_button, False, False, 10)
|
self.f_box.pack_end(self.menu_button, False, False, 5)
|
||||||
#self.f_box.pack_end(datetime_label, False, False, 10)
|
self.f_box.pack_end(datetime_label, False, False, 5)
|
||||||
self.f_box.pack_end(self.source, False, False, 10)
|
#self.f_box.pack_end(self.source, False, False, 5)
|
||||||
|
|
||||||
pad = Gtk.Label(label="")
|
pad = Gtk.Label(label="")
|
||||||
self.f_box.pack_start(pad, False, False, 5)
|
self.f_box.pack_start(pad, False, False, 5)
|
||||||
|
|
Loading…
Reference in a new issue