From de8f5a3262234bdc05e5045ac56455b5eb1705d6 Mon Sep 17 00:00:00 2001 From: Morgan McMillian Date: Mon, 28 Dec 2020 11:22:54 -0800 Subject: [PATCH] adjust datetime field again and use timeago --- README.md | 5 +++-- dev.thrrgilag.squeak.json | 14 ++++++++++++++ src/main.py | 4 ---- src/widgets.py | 15 ++++++++++----- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 80fed8d..06ccacd 100644 --- a/README.md +++ b/README.md @@ -15,8 +15,9 @@ A nut obsessed saber-toothed client for pnut.io - [x] Keyboard shortcuts - [x] Avatars - [x] Post actions (reply, bookmark, repost, quote, copy) -- [ ] Load newer posts -- [ ] Load older posts +- [-] Load newer posts +- [x] Load older posts +- [ ] Thread view - [ ] Loading indicator - [ ] Render post media - [ ] Settings page diff --git a/dev.thrrgilag.squeak.json b/dev.thrrgilag.squeak.json index 7f2392a..0bde1f3 100644 --- a/dev.thrrgilag.squeak.json +++ b/dev.thrrgilag.squeak.json @@ -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", "buildsystem" : "meson", diff --git a/src/main.py b/src/main.py index 6c0b780..22c7e1c 100644 --- a/src/main.py +++ b/src/main.py @@ -128,10 +128,6 @@ class Application(Gtk.Application): self.win.add(vbox) self.win.show_all() - def blarp(self, args=None): - logging.debug("BLARP") - logging.debug(self.keyfile) - def handle_login(self, args, code): # TODO: should do some actual error handling here self.keyfile.set_string("GENERAL", "ACCESS_TOKEN", code) diff --git a/src/widgets.py b/src/widgets.py index bfd38f1..c6b2545 100644 --- a/src/widgets.py +++ b/src/widgets.py @@ -21,6 +21,8 @@ import os import pnutpy import logging import requests +import timeago +import datetime from dateutil.tz import tzlocal @@ -358,8 +360,11 @@ class PostItem(Gtk.ListBoxRow): self.name.set_markup(f"{post.user.name}") # datetime + now = datetime.datetime.now(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('' + timeago.format(post_date_local, now) + '') # post menu 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.name_box, False, False, 0) #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 self.c_box = Gtk.Box(orientation='vertical') @@ -412,9 +417,9 @@ class PostItem(Gtk.ListBoxRow): # footer container self.f_box = Gtk.Box(orientation='horizontal') - self.f_box.pack_end(self.menu_button, False, False, 10) - #self.f_box.pack_end(datetime_label, False, False, 10) - self.f_box.pack_end(self.source, False, False, 10) + self.f_box.pack_end(self.menu_button, False, False, 5) + self.f_box.pack_end(datetime_label, False, False, 5) + #self.f_box.pack_end(self.source, False, False, 5) pad = Gtk.Label(label="") self.f_box.pack_start(pad, False, False, 5)