1
0
mirror of https://codeberg.org/diginaut/digimarks.git synced 2026-02-04 12:40:27 +01:00

4 Commits

Author SHA1 Message Date
971ede6067 Dependency declarations; moved project to Codeberg 2025-12-11 17:58:21 +01:00
96a8946a9a Small fixes 2025-12-11 17:57:59 +01:00
14f09a2dfb Small fixes 2025-12-11 17:45:25 +01:00
9d813b7ea6 Added type checker 2025-12-11 17:27:31 +01:00
5 changed files with 22 additions and 16 deletions

View File

@@ -32,9 +32,9 @@ dependencies = [
[dependency-groups] [dependency-groups]
dev = [ dev = [
{include-group = "lint"}, { include-group = "lint" },
{include-group = "pub"}, { include-group = "pub" },
{include-group = "test"} { include-group = "test" }
] ]
test = [ test = [
"pytest>=7.0.0", "pytest>=7.0.0",
@@ -42,7 +42,7 @@ test = [
] ]
lint = [ lint = [
"ruff>=0.1.0", "ruff>=0.1.0",
"mypy>=1.0.0", "pyrefly",
] ]
# Publishing on PyPI # Publishing on PyPI
pub = [ pub = [
@@ -50,7 +50,7 @@ pub = [
"twine" "twine"
] ]
server = [ server = [
"gunicorn>=23.0.0", "uvicorn",
] ]
# dynamic = ["version"] # dynamic = ["version"]
@@ -58,8 +58,8 @@ server = [
my-script = "digimarks:app" my-script = "digimarks:app"
[project.urls] [project.urls]
"Homepage" = "https://github.com/aquatix/digimarks" "Homepage" = "https://codeberg.org/diginaut/digimarks"
"Bug Tracker" = "https://github.com/aquatix/digimarks/issues" "Bug Tracker" = "https://codeberg.org/diginaut/digimarks/issues"
[tool.black] [tool.black]
line-length = 120 line-length = 120

View File

@@ -2,9 +2,12 @@
# Linting and fixing, including isort # Linting and fixing, including isort
ruff ruff
# Typing
pyrefly
# Test suite # Test suite
pytest pytest
pytest-cov
# Publishing on PyPI # Publishing on PyPI
build build

View File

@@ -92,7 +92,10 @@ async def list_bookmarks_for_user(
offset: int = 0, offset: int = 0,
limit: Annotated[int, Query(le=10000)] = 100, limit: Annotated[int, Query(le=10000)] = 100,
) -> Sequence[Bookmark]: ) -> Sequence[Bookmark]:
"""List all bookmarks in the database. By default, 100 items are returned.""" """List all bookmarks in the database. By default, 100 items are returned.
There is a limit of 10000 items.
"""
result = await session.exec( result = await session.exec(
select(Bookmark) select(Bookmark)
.where(Bookmark.user_key == user_key, Bookmark.status != Visibility.DELETED) .where(Bookmark.user_key == user_key, Bookmark.status != Visibility.DELETED)
@@ -121,7 +124,7 @@ async def autocomplete_bookmark(
user_key: str, user_key: str,
bookmark: Bookmark, bookmark: Bookmark,
strip_params: bool = False, strip_params: bool = False,
): ) -> Bookmark:
"""Autofill some fields for this (new) bookmark for user `user_key`.""" """Autofill some fields for this (new) bookmark for user `user_key`."""
bookmark.user_key = user_key bookmark.user_key = user_key
@@ -149,7 +152,7 @@ async def add_bookmark(
user_key: str, user_key: str,
bookmark: Bookmark, bookmark: Bookmark,
strip_params: bool = False, strip_params: bool = False,
): ) -> Bookmark:
"""Add new bookmark for user `user_key`.""" """Add new bookmark for user `user_key`."""
bookmark.user_key = user_key bookmark.user_key = user_key
@@ -171,7 +174,7 @@ async def update_bookmark(
bookmark: Bookmark, bookmark: Bookmark,
url_hash: str, url_hash: str,
strip_params: bool = False, strip_params: bool = False,
): ) -> Bookmark:
"""Update existing bookmark `bookmark_key` for user `user_key`.""" """Update existing bookmark `bookmark_key` for user `user_key`."""
result = await session.exec( result = await session.exec(
select(Bookmark).where( select(Bookmark).where(
@@ -202,7 +205,7 @@ async def delete_bookmark(
session, session,
user_key: str, user_key: str,
url_hash: str, url_hash: str,
): ) -> None:
"""(Soft)Delete bookmark `bookmark_key` for user `user_key`.""" """(Soft)Delete bookmark `bookmark_key` for user `user_key`."""
result = await session.get(Bookmark, {'url_hash': url_hash, 'user_key': user_key}) result = await session.get(Bookmark, {'url_hash': url_hash, 'user_key': user_key})
bookmark = result bookmark = result

View File

@@ -202,7 +202,7 @@ async def autocomplete_bookmark(
user_key: str, user_key: str,
bookmark: Bookmark, bookmark: Bookmark,
strip_params: bool = False, strip_params: bool = False,
): ) -> Bookmark:
"""Autofill some fields for this (new) bookmark for user `user_key`.""" """Autofill some fields for this (new) bookmark for user `user_key`."""
logger.info('Autocompleting bookmark %s for user %s', bookmark.url_hash, user_key) logger.info('Autocompleting bookmark %s for user %s', bookmark.url_hash, user_key)
return await bookmarks_service.autocomplete_bookmark(session, request, user_key, bookmark, strip_params) return await bookmarks_service.autocomplete_bookmark(session, request, user_key, bookmark, strip_params)
@@ -248,7 +248,7 @@ async def delete_bookmark(
"""(Soft)Delete bookmark `bookmark_key` for user `user_key`.""" """(Soft)Delete bookmark `bookmark_key` for user `user_key`."""
logger.info('Deleting bookmark %s for user %s', url_hash, user_key) logger.info('Deleting bookmark %s for user %s', url_hash, user_key)
try: try:
result = await bookmarks_service.delete_bookmark(session, user_key, url_hash) _ = await bookmarks_service.delete_bookmark(session, user_key, url_hash)
return {'ok': True} return {'ok': True}
except Exception: except Exception:
logger.exception('Failed to delete bookmark %s', url_hash) logger.exception('Failed to delete bookmark %s', url_hash)
@@ -310,7 +310,7 @@ async def page_user_landing(
session: SessionDep, session: SessionDep,
request: Request, request: Request,
user_key: str, user_key: str,
): ) -> HTMLResponse:
"""HTML page with the main view for the user.""" """HTML page with the main view for the user."""
result = await session.exec(select(User).where(User.key == user_key)) result = await session.exec(select(User).where(User.key == user_key))
user = result.first() user = result.first()

View File

@@ -16,7 +16,7 @@
.thumbnail { .thumbnail {
/*width: 80px;*/ /*width: 80px;*/
width: 66; width: 66px;
} }
.thumbnail img { .thumbnail img {