From 45dc57b538bc51c781d06172c47cfe4ecf69b158 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 3 Jul 2022 22:01:47 +0200 Subject: [PATCH] Admin improvements and design tweaks --- app/admin.py | 23 +++++-- app/scss/main.scss | 94 +++++++++++++------------- app/templates/admin_inbox.html | 17 +++-- app/templates/admin_new.html | 8 +-- app/templates/admin_outbox.html | 1 - app/templates/lookup.html | 2 +- app/templates/remote_follow.html | 2 +- app/templates/utils.html | 110 ++++++++++++++++--------------- 8 files changed, 139 insertions(+), 118 deletions(-) diff --git a/app/admin.py b/app/admin.py index f8d8fa3..feb7007 100644 --- a/app/admin.py +++ b/app/admin.py @@ -158,15 +158,23 @@ async def admin_bookmarks( models.InboxObject.ap_type.in_( ["Note", "Article", "Video", "Announce"] ), - models.InboxObject.is_hidden_from_stream.is_(False), - models.InboxObject.undone_by_inbox_object_id.is_(None), models.InboxObject.is_bookmarked.is_(True), ) + .options( + joinedload(models.InboxObject.relates_to_inbox_object), + joinedload(models.InboxObject.relates_to_outbox_object).options( + joinedload( + models.OutboxObject.outbox_object_attachments + ).options(joinedload(models.OutboxObjectAttachment.upload)), + ), + joinedload(models.InboxObject.actor), + ) .order_by(models.InboxObject.ap_published_at.desc()) .limit(20) ) - ).all() - # TODO: joinedload + unique + ) + .unique() + .all() ) return await templates.render_template( db_session, @@ -185,7 +193,7 @@ async def admin_inbox( filter_by: str | None = None, cursor: str | None = None, ) -> templates.TemplateResponse: - where = [models.InboxObject.ap_type.not_in(["Accept"])] + where = [models.InboxObject.ap_type.not_in(["Accept", "Delete"])] if filter_by: where.append(models.InboxObject.ap_type == filter_by) if cursor: @@ -253,7 +261,10 @@ async def admin_outbox( filter_by: str | None = None, cursor: str | None = None, ) -> templates.TemplateResponse: - where = [models.OutboxObject.ap_type.not_in(["Accept"])] + where = [ + models.OutboxObject.ap_type.not_in(["Accept", "Delete"]), + models.OutboxObject.is_deleted.is_(False), + ] if filter_by: where.append(models.OutboxObject.ap_type == filter_by) if cursor: diff --git a/app/scss/main.scss b/app/scss/main.scss index dd60191..d856bd4 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -1,8 +1,12 @@ $font-stack: Helvetica, sans-serif; $background: #002B36; // solarized background color // font-family: Inconsolata, monospace; +$text-color: #ccc; $primary-color: #e14eea; $secondary-color: #32cd32; + +$form-background-color: #ccc; +$form-text-color: #222; $muted-color: #586e75; // solarized comment text // #93a1a1; solarized body text @@ -12,7 +16,7 @@ body { font-size: 20px; line-height: 32px; background: $background; - color: #ccc; + color: $text-color; margin: 0; padding: 0; display: flex; @@ -25,37 +29,52 @@ a { .activity-main { a { - color: #ddd; + color: $text-color; } } .activity-wrap { } code, pre { - color: #859900; // #cb4b16; // #268bd2; // #2aa198; + color: $secondary-color; // #cb4b16; // #268bd2; // #2aa198; font-family: 'Inconsolata, monospace'; } +.form { + input, select, textarea { + font-size: 20px; + border: 0; + padding: 5px; + background: $form-background-color; + color: $form-text-color; + &:focus { + outline: 1px solid $secondary-color; + } + } + input[type=submit] { + font-size: 20px; + outline: none; + background: $primary-color; + color: $form-text-color; + padding: 5px; + } +} header { .title { font-size: 1.3em; text-decoration: none; .handle { font-size: 0.85em; - color: #93a1a1; + color: $muted-color; } } .counter { - color: #93a1a1; + color: $muted-color; } } -.purple { - color: #e14eea; -} a { - color: #e14eea; -} - -.green, a:hover { - color: #32cd32; + color: $primary-color; + &:hover { + color: $secondary-color; + } } #main { flex: 1; @@ -69,7 +88,7 @@ footer { width: 100%; max-width: 960px; margin: 20px auto; - color: #93a1a1; + color: $muted-color; } .actor-box { display: flex; @@ -81,7 +100,7 @@ footer { .actor-handle { font-size: 0.85em; line-height: 1em; - color: #93a1a1; + color: $muted-color; } .actor-icon { margin-top: 5px; @@ -99,10 +118,6 @@ footer { } } -#admin { -} - -.activity-bar { input[type=submit], button { font-size: 20px; line-height: 32px; @@ -111,31 +126,13 @@ input[type=submit], button { border: none; padding: 0!important; cursor: pointer; - color: #e14eea; - } - input[type=submit]:hover, button:hover { - color: #32cd32; - - } + color: $muted-color; + &:hover { + color: $secondary-color; + } } nav.flexbox { - - input[type=submit] { - font-size: 20px; - line-height: 32px; - font-family: "Inconsolata, monospace"; - background: none!important; - border: none; - padding: 0!important; - cursor: pointer; - color: #e14eea; - } - input[type=submit]:hover { - color: #32cd32; - - } - ul { display: flex; flex-wrap: wrap; @@ -185,9 +182,10 @@ nav.flexbox { margin-left: 5px; } .actor-handle { - color: #93a1a1; + color: $muted-color; } .activity-date { float:right; } + .object-visibility { float:right;color: $muted-color;margin-right:10px; } } } .activity-attachment { @@ -199,22 +197,20 @@ nav.flexbox { } } .activity-bar { - display: flex; margin-left: 60px; margin-top: 10px; - .bar-item { - display: flex; - margin-right: 20px; - } } } .actor-action { - padding-left:70px; margin-top:20px; + margin-bottom:-10px; span { - float: right; + color: $muted-color; } } +.actor-metadata { + color: $muted-color; +} .emoji, .custom-emoji { max-width: 25px; } diff --git a/app/templates/admin_inbox.html b/app/templates/admin_inbox.html index 478e71a..a61ff5b 100644 --- a/app/templates/admin_inbox.html +++ b/app/templates/admin_inbox.html @@ -4,17 +4,26 @@ {{ utils.display_box_filters("admin_inbox") }} +{% macro actor_action(inbox_object, text) %} +
+ {{ inbox_object.actor.display_name }} {{ text }} + {{ inbox_object.ap_published_at | timeago }} +
+ +{% endmacro %} + {% for inbox_object in inbox %} {% if inbox_object.ap_type == "Announce" %} + {{ actor_action(inbox_object, "shared one of your post") }} {{ utils.display_object(inbox_object.relates_to_anybox_object) }} {% elif inbox_object.ap_type in ["Article", "Note", "Video"] %} {{ utils.display_object(inbox_object) }} {% elif inbox_object.ap_type == "Follow" %} -
- {{ inbox_object.actor.display_name }} followed you - {{ inbox_object.ap_published_at | timeago }} -
+ {{ actor_action(inbox_object, "followed you") }} {{ utils.display_actor(inbox_object.actor, actors_metadata) }} +{% elif inbox_object.ap_type == "Like" %} + {{ actor_action(inbox_object, "liked one of your post") }} + {{ utils.display_object(inbox_object.relates_to_anybox_object) }} {% else %}

Implement {{ inbox_object.ap_type }} diff --git a/app/templates/admin_new.html b/app/templates/admin_new.html index b1221bd..529e1aa 100644 --- a/app/templates/admin_new.html +++ b/app/templates/admin_new.html @@ -7,7 +7,7 @@ {{ utils.display_object(in_reply_to_object) }} {% endif %} -

+ {{ utils.embed_csrf_token() }} {{ utils.embed_redirect_url() }}

@@ -24,12 +24,12 @@ {{ emoji.name }} {% endfor %} - +

- +

- +

diff --git a/app/templates/admin_outbox.html b/app/templates/admin_outbox.html index fcdbc20..51f1078 100644 --- a/app/templates/admin_outbox.html +++ b/app/templates/admin_outbox.html @@ -16,7 +16,6 @@

You followed
{{ utils.display_actor(outbox_object.relates_to_actor, actors_metadata) }} {% elif outbox_object.ap_type in ["Article", "Note", "Video"] %} - {% if outbox_object.is_deleted %}Deleted{% endif %} {{ utils.display_object(outbox_object) }} {% else %} Implement {{ outbox_object.ap_type }} diff --git a/app/templates/lookup.html b/app/templates/lookup.html index 6ae5a16..5e46518 100644 --- a/app/templates/lookup.html +++ b/app/templates/lookup.html @@ -4,7 +4,7 @@

Interact with an ActivityPub object via its URL or look for a user using @user@domain.tld

- +
diff --git a/app/templates/remote_follow.html b/app/templates/remote_follow.html index 85e94e6..f525852 100644 --- a/app/templates/remote_follow.html +++ b/app/templates/remote_follow.html @@ -4,7 +4,7 @@ {% include "header.html" %}

Remotely follow {{ local_actor.display_name }}

-
+ diff --git a/app/templates/utils.html b/app/templates/utils.html index 6e15c8c..bfc2181 100644 --- a/app/templates/utils.html +++ b/app/templates/utils.html @@ -11,7 +11,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - +
{% endmacro %} @@ -20,7 +20,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -29,7 +29,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -38,7 +38,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -47,7 +47,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -56,7 +56,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -65,7 +65,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -74,7 +74,7 @@ {{ embed_csrf_token() }} {{ embed_redirect_url() }} - + {% endmacro %} @@ -111,36 +111,40 @@ {% macro admin_reply_button(ap_object_id) %}
- +
{% endmacro %} {% macro admin_profile_button(ap_actor_id) %}
- +
{% endmacro %} {% macro admin_expand_button(ap_object_id) %}
- +
{% endmacro %} {% macro display_box_filters(route) %} -

Filter by +

{% endmacro %} {% macro display_actor(actor, actors_metadata) %} @@ -156,11 +160,11 @@ {% if is_admin and metadata %}
-
-
+
+ + {% endif %} {% endmacro %}