tAdd support for basic profiles. - 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 e6df7f30af8a97a3cff1db7e10bde7e5af8e24b3|/git/diasporadiaries/commit/e6df7f30af8a97a3cff1db7e10bde7e5af8e24b3.gph|server|port] [1|parent ae2e0dec55f8372ad357e48d0ebfbf5b284f6379|/git/diasporadiaries/commit/ae2e0dec55f8372ad357e48d0ebfbf5b284f6379.gph|server|port] [h|Author: parazyd |URL:mailto:parazyd@dyne.org|server|port] Date: Wed, 16 Jan 2019 23:13:51 +0100 Add support for basic profiles. Diffstat: M diaspora.py | 32 +++++++++++++++++++++++++++---- M templates/country.html | 4 ++++ A templates/fail_profile.html | 17 +++++++++++++++++ A templates/profile.html | 55 +++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+), 4 deletions(-) --- [1|diff --git a/diaspora.py b/diaspora.py|/git/diasporadiaries/file/diaspora.py.gph|server|port] t@@ -136,14 +136,38 @@ def country(): ('embark', ccfrom)) stories = get_multiple_stories('disembark', cc) - clist = [] - for i in stories: - clist.append((i['embark'], i['embarkname'])) + + clist = [(i['embark'], i['embarkname']) for i in stories] clist = list(set(clist)) + profiles = {} + for i in stories: + if i['email']: + uid = sql_select_col_where('id', 'email', i['email'], + table='users') + profiles['email'] = uid[0][0] + return render_template('country.html', country=getcountryname(cc), cc=cc, stories=stories, filtered_stories=filtered, - clist=clist) + clist=clist, profiles=profiles) + + +@app.route('/profile') +def profile(): + """ + Route for viewing stories by a specific person. The persons + are differed by their emails. + """ + uid = request.args.get('id') + if uid: + email = sql_select_col_where('email', 'id', uid, table='users') + if email: + email = email[0][0] + stories = get_multiple_stories('email', email) + name = stories[0]['name'] + return render_template('profile.html', stories=stories, name=name) + + return render_template('fail_profile.html') @app.route('/dashboard') [1|diff --git a/templates/country.html b/templates/country.html|/git/diasporadiaries/file/templates/country.html.gph|server|port] t@@ -41,7 +41,11 @@ {{ i['embarkname'] }}{{ i['disembarkname'] }} + {% if i['email'] %} + {{ i['name'] }}
+ {% else %} {{ i['name'] }}
+ {% endif %} {{ i['date'] }}
{{ i['time'] }}
[1|diff --git a/templates/fail_profile.html b/templates/fail_profile.html|/git/diasporadiaries/file/templates/fail_profile.html.gph|server|port] t@@ -0,0 +1,17 @@ +{% include 'header.html' %} + + Error | Diaspora Diaries + +{% include 'nav.html' %} + +
+ +

Error!

+ +

No such profile.

+ +

You can return to the homepage now.

+ +
+ +{% include 'footer.html' %} [1|diff --git a/templates/profile.html b/templates/profile.html|/git/diasporadiaries/file/templates/profile.html.gph|server|port] t@@ -0,0 +1,55 @@ +{% include 'header.html' %} + + Diaries by {{ name }}| Diaspora Diaries + +{% include 'nav.html' %} + +
+ +

Diaries by {{ name }}

+ + +
+
+ + {% for i in stories %} + {% if loop.index % 3 == 1 %} +
+ {% endif %} + +
+
+

+ {{ i['abstract'] }} +

+ +
+
+ Read +
+ + {{ i['embarkname'] }}{{ i['disembarkname'] }} + + + {{ i['name'] }}
+ {{ i['date'] }}
+ {{ i['time'] }} +
+
+
+
+ + {% if loop.index % 3 == 0 or loop.last %} +
+ {% if not loop.last %} +
+ {% endif %} + {% endif %} + + {% endfor %} +
+
+ +
+ +{% include 'footer.html' %}