Cleanup utils
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import typing
|
||||
from dataclasses import dataclass
|
||||
from typing import Union
|
||||
from urllib.parse import urlparse
|
||||
|
||||
from sqlalchemy.orm import Session
|
||||
@@ -148,7 +149,7 @@ ActorsMetadata = dict[str, ActorMetadata]
|
||||
|
||||
def get_actors_metadata(
|
||||
db: Session,
|
||||
actors: list["ActorModel"],
|
||||
actors: list[Union["ActorModel", "RemoteActor"]],
|
||||
) -> ActorsMetadata:
|
||||
from app import models
|
||||
|
||||
@@ -179,6 +180,8 @@ def get_actors_metadata(
|
||||
}
|
||||
idx: ActorsMetadata = {}
|
||||
for actor in actors:
|
||||
if not actor.ap_id:
|
||||
raise ValueError("Should never happen")
|
||||
idx[actor.ap_id] = ActorMetadata(
|
||||
ap_actor_id=actor.ap_id,
|
||||
is_following=actor.ap_id in following,
|
||||
|
@@ -72,9 +72,9 @@ def get_lookup(
|
||||
if query:
|
||||
ap_object = lookup(db, query)
|
||||
if ap_object.ap_type in ap.ACTOR_TYPES:
|
||||
actors_metadata = get_actors_metadata(db, [ap_object])
|
||||
actors_metadata = get_actors_metadata(db, [ap_object]) # type: ignore
|
||||
else:
|
||||
actors_metadata = get_actors_metadata(db, [ap_object.actor])
|
||||
actors_metadata = get_actors_metadata(db, [ap_object.actor]) # type: ignore
|
||||
print(ap_object)
|
||||
return templates.render_template(
|
||||
db,
|
||||
|
@@ -7,10 +7,10 @@ from dateutil.parser import isoparse
|
||||
from markdown import markdown
|
||||
|
||||
from app import activitypub as ap
|
||||
from app import opengraph
|
||||
from app.actor import LOCAL_ACTOR
|
||||
from app.actor import Actor
|
||||
from app.actor import RemoteActor
|
||||
from app.utils import opengraph
|
||||
|
||||
|
||||
class Object:
|
||||
|
135
app/scss/main.scss
Normal file
135
app/scss/main.scss
Normal file
@@ -0,0 +1,135 @@
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: flex;
|
||||
min-height: 100vh;
|
||||
flex-direction: column;
|
||||
}
|
||||
#main {
|
||||
flex: 1;
|
||||
}
|
||||
main {
|
||||
max-width: 800px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
footer {
|
||||
max-width: 800px;
|
||||
margin: 20px auto;
|
||||
}
|
||||
#notifications, #followers, #following {
|
||||
ul {
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
li {
|
||||
display: inline-block;
|
||||
}
|
||||
}
|
||||
.actor-box {
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
#admin {
|
||||
.navbar {
|
||||
display: grid;
|
||||
grid-template-rows: auto;
|
||||
grid-template-columns: 1fr;
|
||||
grid-auto-flow: dense;
|
||||
justify-items: stretch;
|
||||
align-items: stretch;
|
||||
column-gap: 20px;
|
||||
}
|
||||
|
||||
.logo {
|
||||
grid-column:-3;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.menus {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
justify-content: start;
|
||||
grid-column: 1;
|
||||
}
|
||||
|
||||
.menus * {
|
||||
padding: 5px;
|
||||
}
|
||||
}
|
||||
|
||||
nav.flexbox {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
|
||||
ul {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
list-style-type: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
}
|
||||
|
||||
ul li {
|
||||
margin-right: 20px;
|
||||
|
||||
&:last-child {
|
||||
margin-right: 0px;
|
||||
}
|
||||
}
|
||||
}
|
||||
#admin {
|
||||
a.active {
|
||||
font-weight: bold;
|
||||
text-decoration: none;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.activity-wrap {
|
||||
margin: 0 auto;
|
||||
padding: 30px 0;
|
||||
.actor-icon {
|
||||
width:48px;
|
||||
margin-right: 15px;
|
||||
img {
|
||||
max-width: 48px;
|
||||
}
|
||||
}
|
||||
.activity-content {
|
||||
display: flex;
|
||||
align-items:flex-start;
|
||||
.activity-header {
|
||||
width: 100%;
|
||||
strong {
|
||||
font-weight:bold;
|
||||
}
|
||||
span {
|
||||
font-weight:normal;
|
||||
margin-left: 5px;
|
||||
}
|
||||
.activity-date { float:right; }
|
||||
}
|
||||
}
|
||||
.activity-attachment {
|
||||
padding-left: 60px;
|
||||
img, audio, video {
|
||||
width: 100%;
|
||||
max-width: 740px;
|
||||
margin: 30px 0;
|
||||
}
|
||||
}
|
||||
.activity-bar {
|
||||
display: flex;
|
||||
margin-left: 60px;
|
||||
margin-top: 10px;
|
||||
.bar-item {
|
||||
display: flex;
|
||||
margin-right: 20px;
|
||||
}
|
||||
}
|
||||
}
|
@@ -23,8 +23,8 @@ from app.config import VERSION
|
||||
from app.config import generate_csrf_token
|
||||
from app.config import session_serializer
|
||||
from app.database import now
|
||||
from app.highlight import HIGHLIGHT_CSS
|
||||
from app.highlight import highlight
|
||||
from app.utils.highlight import HIGHLIGHT_CSS
|
||||
from app.utils.highlight import highlight
|
||||
|
||||
_templates = Jinja2Templates(directory="app/templates")
|
||||
|
||||
|
0
app/utils/__init__.py
Normal file
0
app/utils/__init__.py
Normal file
@@ -8,7 +8,7 @@ from pydantic import BaseModel
|
||||
|
||||
from app import activitypub as ap
|
||||
from app import config
|
||||
from app.urlutils import is_url_valid
|
||||
from app.utils.url import is_url_valid
|
||||
|
||||
|
||||
class OpenGraphMeta(BaseModel):
|
Reference in New Issue
Block a user