Skip to main content

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:

  1. the authenticated user adding the bookmark, i.e. the bookmarker;
  2. the concrete model instance referenced, i.e. the bookmarked;[^1] and
  3. a ManyToMany tags field which maps to a TagItem 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
@get_item_url URL to load the panel containde within 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:

  1. The submission of tags is POST'ed through the add_tags_url.
  2. The deletion of tags is DELETE'ed through the del_tag_url.
  3. The bookmark toggle is PUT'ed through the toggle_status_url.

Setup

  1. Download and install.
  2. See configuration of models to be bookmarked and tagged.
  3. Examine frontend setup using htmx/hyperscript.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-yabl-0.2.0.tar.gz (56.5 kB view details)

Uploaded Source

Built Distribution

django_yabl-0.2.0-py3-none-any.whl (64.4 kB view details)

Uploaded Python 3

File details

Details for the file django-yabl-0.2.0.tar.gz.

File metadata

  • Download URL: django-yabl-0.2.0.tar.gz
  • Upload date:
  • Size: 56.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.10.2 Darwin/21.3.0

File hashes

Hashes for django-yabl-0.2.0.tar.gz
Algorithm Hash digest
SHA256 4798646ad851c611a82633a9e401e7074070fd9f89bc8b932e53d1b7ba34ee33
MD5 6e0b82dd3d7002b6ec625e3b3f5ec8a6
BLAKE2b-256 638acbb428fc8f504d98259b6eab15786fbda95fd07d476d5705ea64d6e04d41

See more details on using hashes here.

File details

Details for the file django_yabl-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: django_yabl-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 64.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.2.0a2 CPython/3.10.2 Darwin/21.3.0

File hashes

Hashes for django_yabl-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c5c47434cbdad3d02b78245f399719a22c1e2994ae57c7c54c963dea5854a9ee
MD5 f6f57753ddc85cc45137df738fe0e014
BLAKE2b-256 0d58f9a494d23f357360dae392c6c2bfb3ffbc7ab4698575a5f6b96d22ffd37d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page