kopia lustrzana https://github.com/snarfed/bridgy-fed
user page redesign: implement followers, following pages
includes subtabs on profile pages for #442pull/671/head
rodzic
c1e0a08f72
commit
11037d80df
27
pages.py
27
pages.py
|
@ -9,7 +9,7 @@ from flask import g, render_template, request
|
||||||
from google.cloud.ndb import tasklets
|
from google.cloud.ndb import tasklets
|
||||||
from google.cloud.ndb.query import AND, OR
|
from google.cloud.ndb.query import AND, OR
|
||||||
from google.cloud.ndb.stats import KindStat
|
from google.cloud.ndb.stats import KindStat
|
||||||
from granary import as1, atom, microformats2, rss
|
from granary import as1, as2, atom, microformats2, rss
|
||||||
import humanize
|
import humanize
|
||||||
from oauth_dropins.webutil import flask_util, logs, util
|
from oauth_dropins.webutil import flask_util, logs, util
|
||||||
from oauth_dropins.webutil.flask_util import error, flash, redirect
|
from oauth_dropins.webutil.flask_util import error, flash, redirect
|
||||||
|
@ -105,15 +105,7 @@ def profile(protocol, id):
|
||||||
Object.notify == g.user.key))
|
Object.notify == g.user.key))
|
||||||
objects, before, after = fetch_objects(query, by=Object.updated)
|
objects, before, after = fetch_objects(query, by=Object.updated)
|
||||||
|
|
||||||
followers = Follower.query(Follower.to == g.user.key,
|
num_followers, num_following = count_followers()
|
||||||
Follower.status == 'active')\
|
|
||||||
.count(limit=FOLLOWERS_UI_LIMIT)
|
|
||||||
followers = f'{followers}{"+" if followers == FOLLOWERS_UI_LIMIT else ""}'
|
|
||||||
|
|
||||||
following = Follower.query(Follower.from_ == g.user.key,
|
|
||||||
Follower.status == 'active')\
|
|
||||||
.count(limit=FOLLOWERS_UI_LIMIT)
|
|
||||||
following = f'{following}{"+" if following == FOLLOWERS_UI_LIMIT else ""}'
|
|
||||||
|
|
||||||
return render_template('profile.html', logs=logs, util=util, g=g, **locals())
|
return render_template('profile.html', logs=logs, util=util, g=g, **locals())
|
||||||
|
|
||||||
|
@ -143,9 +135,11 @@ def followers_or_following(protocol, id, collection):
|
||||||
load_user(protocol, id)
|
load_user(protocol, id)
|
||||||
|
|
||||||
followers, before, after = Follower.fetch_page(collection)
|
followers, before, after = Follower.fetch_page(collection)
|
||||||
|
num_followers, num_following = count_followers()
|
||||||
return render_template(
|
return render_template(
|
||||||
f'{collection}.html',
|
f'{collection}.html',
|
||||||
address=request.args.get('address'),
|
address=request.args.get('address'),
|
||||||
|
as2=as2,
|
||||||
follow_url=request.values.get('url'),
|
follow_url=request.values.get('url'),
|
||||||
g=g,
|
g=g,
|
||||||
util=util,
|
util=util,
|
||||||
|
@ -153,6 +147,19 @@ def followers_or_following(protocol, id, collection):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def count_followers():
|
||||||
|
followers = Follower.query(Follower.to == g.user.key,
|
||||||
|
Follower.status == 'active')\
|
||||||
|
.count(limit=FOLLOWERS_UI_LIMIT)
|
||||||
|
num_followers = f'{followers}{"+" if followers == FOLLOWERS_UI_LIMIT else ""}'
|
||||||
|
|
||||||
|
following = Follower.query(Follower.from_ == g.user.key,
|
||||||
|
Follower.status == 'active')\
|
||||||
|
.count(limit=FOLLOWERS_UI_LIMIT)
|
||||||
|
num_following = f'{following}{"+" if following == FOLLOWERS_UI_LIMIT else ""}'
|
||||||
|
|
||||||
|
return num_followers, num_following
|
||||||
|
|
||||||
@app.get(f'/<any({",".join(PROTOCOLS)}):protocol>/<id>/feed')
|
@app.get(f'/<any({",".join(PROTOCOLS)}):protocol>/<id>/feed')
|
||||||
def feed(protocol, id):
|
def feed(protocol, id):
|
||||||
format = request.args.get('format', 'html')
|
format = request.args.get('format', 'html')
|
||||||
|
|
|
@ -345,6 +345,7 @@ button[disabled]:hover {
|
||||||
border-left: 1px solid;
|
border-left: 1px solid;
|
||||||
border-right: 1px solid;
|
border-right: 1px solid;
|
||||||
background: inherit;
|
background: inherit;
|
||||||
|
color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
.disable-button, #bad-button {
|
.disable-button, #bad-button {
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% include "user_addresses.html" %}
|
|
||||||
|
|
||||||
<div class="row big">Feed</div>
|
<div class="row big">Feed</div>
|
||||||
|
|
||||||
<link rel="stylesheet" href="/static/feed.css" type="text/css" />
|
<link rel="stylesheet" href="/static/feed.css" type="text/css" />
|
||||||
|
|
|
@ -1,13 +1,8 @@
|
||||||
{% extends "base.html" %}
|
{% extends "profile.html" %}
|
||||||
|
{% set subtab = "followers" %}
|
||||||
{% block title %}{{ g.user.handle_or_id() }}'s followers - Bridgy Fed{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{% include "user_addresses.html" %}
|
|
||||||
|
|
||||||
<div class="row big">Followers</div>
|
|
||||||
|
|
||||||
|
{% block subsubtabs %}
|
||||||
|
{% if g.user.LABEL != 'activitypub' %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form method="post" action="/remote-follow">
|
<form method="post" action="/remote-follow">
|
||||||
<nobr>
|
<nobr>
|
||||||
|
@ -21,9 +16,11 @@
|
||||||
</nobr>
|
</nobr>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock subsubtabs %}
|
||||||
|
|
||||||
{% with page_name="followers" %}
|
{% block feed %}
|
||||||
{% include "_followers.html" %}
|
{% with page_name="followers" %}
|
||||||
{% endwith %}
|
{% include "_followers.html" %}
|
||||||
|
{% endwith %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,13 +1,7 @@
|
||||||
{% extends "base.html" %}
|
{% extends "profile.html" %}
|
||||||
|
{% set subtab = "following" %}
|
||||||
{% block title %}{{ g.user.handle_or_id() }}'s following - Bridgy Fed{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
|
||||||
|
|
||||||
{% include "user_addresses.html" %}
|
|
||||||
|
|
||||||
<div class="row big">Following</div>
|
|
||||||
|
|
||||||
|
{% block subsubtabs %}
|
||||||
{% if g.user.LABEL != 'activitypub' %}
|
{% if g.user.LABEL != 'activitypub' %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form method="post" action="/follow/start">
|
<form method="post" action="/follow/start">
|
||||||
|
@ -22,9 +16,10 @@
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endblock subsubtabs %}
|
||||||
|
|
||||||
{% with page_name="following" %}
|
{% block feed %}
|
||||||
{% include "_followers.html" %}
|
{% with page_name="following" %}
|
||||||
{% endwith %}
|
{% include "_followers.html" %}
|
||||||
|
{% endwith %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -2,25 +2,21 @@
|
||||||
{% set tab = "profile" %}
|
{% set tab = "profile" %}
|
||||||
|
|
||||||
{% block subtabs %}
|
{% block subtabs %}
|
||||||
<div class="row">
|
<div class="row tabs">
|
||||||
<a href="{{ g.user.user_page_path('followers') }}">{{ followers }} follower{% if followers != '1' %}s{% endif %}</a>
|
<a></a>
|
||||||
·
|
<a href="{{ g.user.user_page_path() }}"
|
||||||
<a href="{{ g.user.user_page_path('following') }}">following {{ following }}</a>
|
{% if not subtab %}class="active-tab"{% endif %}
|
||||||
·
|
>activity</a><a
|
||||||
|
href="{{ g.user.user_page_path('followers') }}"
|
||||||
{% if g.user.LABEL != 'activitypub' %}
|
{% if subtab == 'followers' %}class="active-tab"{% endif %}
|
||||||
bridged to
|
>{{ num_followers }} follower{% if followers != '1' %}s{% endif %}</a><a
|
||||||
<nobr title="Fediverse address">
|
href="{{ g.user.user_page_path('following') }}"
|
||||||
<img class="logo" src="/static/fediverse_logo.svg">
|
{% if subtab == 'following' %}class="active-tab"{% endif %}
|
||||||
{{ g.user.ap_address() }}
|
>following {{ num_following }}</a>
|
||||||
</nobr>
|
<a></a>
|
||||||
<form method="post" action="/webmention-interactive">
|
|
||||||
<input name="source" type="hidden" value="{{ g.user.web_url() }}" />
|
|
||||||
|
|
||||||
<button id="update-profile-button" type="submit"
|
|
||||||
title="Update profile from web site"
|
|
||||||
class="btn btn-default glyphicon glyphicon-refresh"></button>
|
|
||||||
</form>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% block subsubtabs %}
|
||||||
|
{% endblock subsubtabs %}
|
||||||
|
|
||||||
{% endblock subtabs %}
|
{% endblock subtabs %}
|
||||||
|
|
|
@ -35,8 +35,23 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="row big">
|
<div class="row">
|
||||||
{{ g.user.user_link()|safe }}
|
<span class="big">{{ g.user.user_link()|safe }}</span>
|
||||||
|
·
|
||||||
|
{% if g.user.LABEL != 'activitypub' %}
|
||||||
|
bridged to
|
||||||
|
<nobr title="Fediverse address">
|
||||||
|
<img class="logo" src="/static/fediverse_logo.svg">
|
||||||
|
{{ g.user.ap_address() }}
|
||||||
|
</nobr>
|
||||||
|
<form method="post" action="/webmention-interactive">
|
||||||
|
<input name="source" type="hidden" value="{{ g.user.web_url() }}" />
|
||||||
|
|
||||||
|
<button id="update-profile-button" type="submit"
|
||||||
|
title="Update profile from web site"
|
||||||
|
class="btn btn-default glyphicon glyphicon-refresh"></button>
|
||||||
|
</form>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- tabs -->
|
<!-- tabs -->
|
||||||
|
|
Ładowanie…
Reference in New Issue