diff --git a/models.py b/models.py index f40c58b..c90bf61 100644 --- a/models.py +++ b/models.py @@ -472,10 +472,7 @@ class User(StringIdModel, metaclass=ProtocolUserMeta): return f"""\ - - {self.name()} - -""" + {self.name()}""" class Object(StringIdModel): diff --git a/pages.py b/pages.py index b1cafe0..b0c92bf 100644 --- a/pages.py +++ b/pages.py @@ -30,6 +30,16 @@ with app.test_request_context('/'): logger = logging.getLogger(__name__) +TEMPLATE_VARS = { + 'as2': as2, + 'g': g, + 'isinstance': isinstance, + 'logs': logs, + 'PROTOCOLS': PROTOCOLS, + 'set': set, + 'util': util, +} + def load_user(protocol, id): """Loads the current request's user into `g.user`. @@ -101,13 +111,10 @@ def web_user_redirects(**kwargs): def profile(protocol, id): load_user(protocol, id) - query = Object.query(OR(Object.users == g.user.key, - Object.notify == g.user.key)) + query = Object.query(Object.users == g.user.key) objects, before, after = fetch_objects(query, by=Object.updated) - num_followers, num_following = count_followers() - - return render_template('profile.html', logs=logs, util=util, g=g, **locals()) + return render_template('profile.html', **TEMPLATE_VARS, **locals()) @app.get(f'///home') @@ -116,8 +123,7 @@ def home(protocol, id): query = Object.query(Object.feed == g.user.key) objects, before, after = fetch_objects(query, by=Object.created) - - return render_template('home.html', logs=logs, util=util, g=g, **locals()) + return render_template('home.html', **TEMPLATE_VARS, **locals()) @app.get(f'///notifications') @@ -126,8 +132,7 @@ def notifications(protocol, id): query = Object.query(Object.notify == g.user.key) objects, before, after = fetch_objects(query, by=Object.updated) - - return render_template('notifications.html', logs=logs, util=util, g=g, **locals()) + return render_template('notifications.html', **TEMPLATE_VARS, **locals()) @app.get(f'///') @@ -139,10 +144,8 @@ def followers_or_following(protocol, id, collection): return render_template( f'{collection}.html', address=request.args.get('address'), - as2=as2, follow_url=request.values.get('url'), - g=g, - util=util, + **TEMPLATE_VARS, **locals(), ) @@ -202,7 +205,7 @@ def feed(protocol, id): # syntax. maybe a fediverse kwarg down through the call chain? if format == 'html': entries = [microformats2.object_to_html(a) for a in activities] - return render_template('feed.html', util=util, g=g, **locals()) + return render_template('feed.html', **TEMPLATE_VARS, **locals()) elif format == 'atom': body = atom.activities_to_atom(activities, actor=actor, title=title, request_url=request.url) diff --git a/static/style.css b/static/style.css index 5f97af0..8eea65e 100644 --- a/static/style.css +++ b/static/style.css @@ -304,7 +304,7 @@ button[disabled]:hover { border-radius: 1em; } -.btn-home img, .logo { +.btn-home img, .logo, .logo img { height: 1.1em; margin-top: -.2em; } @@ -328,7 +328,7 @@ button[disabled]:hover { } .tabs a { - border-bottom: 1px solid; + border-bottom: 1px solid lightgray; background: linear-gradient(white, #e8e8e8); padding-left: .5em; padding-right: .5em; @@ -340,14 +340,23 @@ button[disabled]:hover { text-decoration: none; } -.tabs a.active-tab { +a.active-tab { border-bottom: none; - border-left: 1px solid; - border-right: 1px solid; + border-left: 1px solid lightgray; background: inherit; color: inherit; } +/* TODO: drop border-left above and switch to this once Firefix supports :has() + * https://caniuse.com/css-has +a:has(+ a.active-tab) { + border-right: 1px solid lightgray; +} */ + +a.active-tab + a { + border-left: 1px solid lightgray; +} + .disable-button, #bad-button { border-color: red; color: red; diff --git a/templates/_followers.html b/templates/_followers.html index f1e37ac..d7d77d0 100644 --- a/templates/_followers.html +++ b/templates/_followers.html @@ -25,7 +25,7 @@ {% endif %} {% else %} - None yet. Check back soon! + None yet. Check back soon! {% endfor %} diff --git a/templates/activities.html b/templates/activities.html index ae07b31..f6480cf 100644 --- a/templates/activities.html +++ b/templates/activities.html @@ -56,7 +56,7 @@ {% else %} -
  • Nothing yet!
  • + None yet. Check back soon! {% endfor %} diff --git a/templates/user_base.html b/templates/user_base.html index c4d1d36..b4f9f24 100644 --- a/templates/user_base.html +++ b/templates/user_base.html @@ -36,27 +36,38 @@ {% endif %}
    - {{ g.user.user_link()|safe }} - · - {% if g.user.LABEL != 'activitypub' %} - bridged to - - - {{ g.user.ap_address() }} - -
    - -   - -
    - {% endif %} + + {{ g.user.user_link()|safe }} + · + + + + {{ g.user.handle_or_id() }} + + +
    + + +
    +
    + · +
    + + {% for proto in set(PROTOCOLS.values()) %} + {% if proto and not isinstance(g.user, proto) + and proto.LABEL not in ('atproto', 'ui') %} + + + {{ g.user.ap_address() }} + + {% endif %} + {% endfor %}
    {% block subtabs %} diff --git a/tests/test_common.py b/tests/test_common.py index 8160cda..7f91b00 100644 --- a/tests/test_common.py +++ b/tests/test_common.py @@ -34,9 +34,7 @@ class CommonTest(TestCase): self.assert_multiline_equals("""\ - - user.com -""", common.pretty_link('https://user.com/')) + user.com""", common.pretty_link('https://user.com/')) def test_redirect_wrap_empty(self): self.assertIsNone(common.redirect_wrap(None)) diff --git a/tests/test_models.py b/tests/test_models.py index a1dac4b..89be661 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -139,17 +139,13 @@ class UserTest(TestCase): self.assert_multiline_equals("""\ - - y.z -""", g.user.user_link()) + y.z""", g.user.user_link()) g.user.obj = Object(id='a', as2=ACTOR) self.assert_multiline_equals("""\ - - - Mrs. β˜• Foo -""", g.user.user_link()) + + Mrs. β˜• Foo""", g.user.user_link()) def test_is_web_url(self): for url in 'y.z', '//y.z', 'http://y.z', 'https://y.z':