diff --git a/.gitignore b/.gitignore index a655e4e..c040887 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,4 @@ __pycache__/ .pytest_cache/ docs/dist/ requirements.txt -app/scss/vars.scss +app/scss/_vars.scss diff --git a/app/ap_object.py b/app/ap_object.py index df3f698..5e226e5 100644 --- a/app/ap_object.py +++ b/app/ap_object.py @@ -1,5 +1,6 @@ import hashlib from datetime import datetime +from functools import cached_property from typing import Any import pydantic @@ -26,7 +27,7 @@ class Object: def is_from_inbox(self) -> bool: return False - @property + @cached_property def ap_type(self) -> str: return self.ap_object["type"] @@ -42,7 +43,7 @@ class Object: def ap_actor_id(self) -> str: return ap.get_actor_id(self.ap_object) - @property + @cached_property def ap_published_at(self) -> datetime | None: # TODO: default to None? or now()? if "published" in self.ap_object: @@ -55,7 +56,7 @@ class Object: def actor(self) -> Actor: raise NotImplementedError() - @property + @cached_property def visibility(self) -> ap.VisibilityEnum: return ap.object_visibility(self.ap_object, self.actor) @@ -71,7 +72,7 @@ class Object: def tags(self) -> list[ap.RawObject]: return ap.as_list(self.ap_object.get("tag", [])) - @property + @cached_property def attachments(self) -> list["Attachment"]: attachments = [] for obj in ap.as_list(self.ap_object.get("attachment", [])): @@ -130,7 +131,7 @@ class Object: return None - @property + @cached_property def content(self) -> str | None: content = self.ap_object.get("content") if not content: @@ -146,7 +147,7 @@ class Object: def summary(self) -> str | None: return self.ap_object.get("summary") - @property + @cached_property def permalink_id(self) -> str: return ( "permalink-" diff --git a/app/main.py b/app/main.py index b3b2fb2..5157ed7 100644 --- a/app/main.py +++ b/app/main.py @@ -75,6 +75,7 @@ _RESIZED_CACHE: MutableMapping[tuple[str, int], tuple[bytes, str, Any]] = LFUCac # # Next: # - fix stream (only content from follows + mention, and dedup shares) +# - custom emoji in data/ # - handle remove activity # - retries httpx? # - DB models for webmentions diff --git a/app/scss/_theme.scss b/app/scss/_theme.scss new file mode 120000 index 0000000..4036f4c --- /dev/null +++ b/app/scss/_theme.scss @@ -0,0 +1 @@ +../../data/_theme.scss \ No newline at end of file diff --git a/app/scss/main.scss b/app/scss/main.scss index fb2e359..ec2096e 100644 --- a/app/scss/main.scss +++ b/app/scss/main.scss @@ -10,7 +10,7 @@ $form-text-color: #333; $muted-color: #555; // solarized comment text // Load custom theme -// @import "vars.scss"; +// @import "theme.scss"; .light-background { @@ -142,22 +142,31 @@ footer { } } +@mixin admin-button() { + font-size: 20px; + line-height: 32px; + font-family: $font-stack; + background: $form-background-color; + color: $form-text-color; + border: 1px solid $background; + padding: 8px 10px 5px 10px; + cursor: pointer; + &:hover { + border: 1px solid $form-text-color; + } +} + +.show-sensitive-btn, .show-more-btn { + @include admin-button; + margin: 20px 0; +} + nav { form { margin: 15px 0; } input[type=submit], button { - font-size: 20px; - line-height: 32px; - font-family: $font-stack; - background: $form-background-color; - color: $form-text-color; - border: 1px solid $background; - padding: 8px 10px 5px 10px; - cursor: pointer; - &:hover { - border: 1px solid $form-text-color; - } + @include admin-button; } } diff --git a/app/templates/admin_new.html b/app/templates/admin_new.html index a3bded1..af0c8b5 100644 --- a/app/templates/admin_new.html +++ b/app/templates/admin_new.html @@ -1,5 +1,10 @@ {%- import "utils.html" as utils with context -%} {% extends "layout.html" %} + +{% block head %} +