Yet another bookmarking library (yabl) for Django. Bookmark and tag arbitrary models.
Project description
django-yabl
Yet another bookmarking library (yabl) for Django. Bookmark and tag arbitrary models.
AbstractBookmarkable
contains bookmarks
field. This enables arbitrary child models, e.g. Movies, Books, Laws, Clothes, etc., to inherit uniform properties for bookmarking and tagging.
The bookmarks
field is mapped to a generic Bookmark
model containing:
- the authenticated user adding the bookmark, i.e. the
bookmarker
; - the concrete model instance referenced, i.e. the bookmarked;[^1] and
- a ManyToMany
tags
field which maps to aTagItem
model.
[^1]: The model is referenced via a content_type
and an object_id
AbstractBookmarkable
The abstraction makes each inheriting instance bookmarkable and taggable by authenticated users.
Attributes | Purpose |
---|---|
is_bookmarked (user) |
Check whether object instance is bookmarked or not |
get_bookmarked (user) |
Get instances of model that user has bookmarked |
get_user_tags (user) |
If user bookmarked, get user-made tags on instance |
toggle_bookmark (user) |
Toggle bookmark status as bookmarked or not |
add_tags (user, tags: list[str]) |
Add unique tags, accepts a list of names |
remove_tag (user, tag: str) |
Delete an existing tag name from tags previously added |
set_bookmarked_context (user) |
Combines relevant urls and attributes for template output |
@modal |
Custom modal enables: toggle, add tags, remove tag |
@launch_modal_url |
URL to launch custom modal |
@add_tags_url |
URL to POST tags added |
@del_tag_url |
URL to DELETE tag added |
@toggle_status_url |
URL to toggle bookmark status of an object instance added |
@object_content_for_panel |
Content when custom modal is loaded; must be overriden |
Modal-based UX
What is the concept?
The modal is where the user interacts – i.e. toggle bookmark status, add tags, remove tag (see table above) – with the data.
How is the modal styled?
See the htmx/hyperscript example modal.css.
How is the modal constructed during run-time?
See app-level modal.html which shows a modal via htmx click on the @launch_modal_url
property.
What are the pre-made contents of the modal?
The app-level panel.html, contained within the modal, shows an actionable form for saving the bookmarable object and associating said object with tags:
- The submission of tags is POST'ed through the
add_tags_url
. - The deletion of tags is DELETE'ed through the
del_tag_url
. - The bookmark toggle is PUT'ed through the
toggle_status_url
.
Setup
- Download and install.
- See configuration of models to be bookmarked and tagged.
- Examine frontend setup using
htmx/hyperscript
.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for django_yabl-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93af4261a8d5b1a443b561353e5d8bea7be91a5191b28fd9b8b4dbb3be0d3705 |
|
MD5 | 8bbb6a473f56648d1407e42805d7e5fe |
|
BLAKE2b-256 | 66704a81ae2d4265f654afbcaa672a4e27ca711bdd24ab46bea658b0e42b7473 |