tImplement read/unread messages. - diasporadiaries - a platform for writing stories with personal accounts and messages [h|git clone git://parazyd.org/diasporadiaries.git|URL:git://parazyd.org/diasporadiaries.git|server|port] [1|Log|/git/diasporadiaries/log.gph|server|port] [1|Files|/git/diasporadiaries/files.gph|server|port] [1|Refs|/git/diasporadiaries/refs.gph|server|port] [1|Submodules|/git/diasporadiaries/file/.gitmodules.gph|server|port] [1|README|/git/diasporadiaries/file/README.md.gph|server|port] [1|LICENSE|/git/diasporadiaries/file/LICENSE.gph|server|port] --- [1|commit bf634ca22fb5cdc964af23b14323acd8e4bcff0c|/git/diasporadiaries/commit/bf634ca22fb5cdc964af23b14323acd8e4bcff0c.gph|server|port] [1|parent 2a4b2ba7f5b822b1556bb247a2b9ef2d9330722b|/git/diasporadiaries/commit/2a4b2ba7f5b822b1556bb247a2b9ef2d9330722b.gph|server|port] [h|Author: parazyd |URL:mailto:parazyd@dyne.org|server|port] Date: Wed, 23 Jan 2019 14:30:49 +0100 Implement read/unread messages. Diffstat: M templates/index.html | 2 +- M templates/messages.html | 8 +++++++- M utils.py | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 5 deletions(-) --- [1|diff --git a/templates/index.html b/templates/index.html|/git/diasporadiaries/file/templates/index.html.gph|server|port] t@@ -22,7 +22,7 @@ others of their kind. Make them feel less scared and lonely.

- GO AND WRITE DOWN YOUR + GO AND WRITE DOWN YOUR STORY!

[1|diff --git a/templates/messages.html b/templates/messages.html|/git/diasporadiaries/file/templates/messages.html.gph|server|port] t@@ -18,8 +18,9 @@ - + + t@@ -28,6 +29,11 @@ + {% if i[2]['unread'] == 1 %} + + {% else %} + + {% endif %} {% endfor %} [1|diff --git a/utils.py b/utils.py|/git/diasporadiaries/file/utils.py.gph|server|port] t@@ -311,10 +311,18 @@ def get_messages(user_id, id_from): json.dump(data, msgfile) return [] - messages = [] + marked = [] for i in data: - i['time'] = strftime('%d.%m.%Y. %H:%M UTC', gmtime(i['time'])) - messages.append(i) + i['unread'] = 0 + marked.append(i) + + with open(msgpath, 'w') as msgfile: + json.dump(marked, msgfile) + + messages = [] + for j in marked: + j['time'] = strftime('%d.%m.%Y. %H:%M UTC', gmtime(j['time'])) + messages.append(j) return messages t@@ -339,6 +347,7 @@ def send_message(id_to, msg, id_us): 'from': ours['name'], 'message': Markup(msg).striptags(), 'time': int(time()), + 'unread': 1, } ourdata = []
FromWith LatestStatus At
{{ i[0] }} {{ i[2]['message'] }}{{ i[2]['time'] }}