- Python 84.4%
- JavaScript 9%
- HTML 5.6%
- Mako 1%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| frontend | ||
| src | ||
| .gitignore | ||
| COPYING | ||
| COPYING.LESSER | ||
| MANIFEST.in | ||
| pyproject.toml | ||
| README.md | ||
splent_feature_rating
The rating feature of a SPLENT product line.
A SPLENT feature is a Python package that a product composes with others:
its models, routes, services, templates and hooks are registered when the
product starts. What this feature provides and requires is listed in the
[tool.splent.contract] section of pyproject.toml, which
splent feature:contract --write keeps in sync with the source.
Use it in a product
splent feature:add splent_feature_rating
The best rated first on the home page
dataset's home section puts first the datasets DATASET_HOME_ORDER says,
and rating, the best rated, is this feature's: it registers that order
(dataset's register_home_order, dataset 0.6.0 and later), the public
datasets with the best net score among those with a vote. The SPL's model
asks home_most_rated => rating, so a product that chooses it has this
feature.
Dislikes, owners and the panels
A reader likes or dislikes a published dataset, and the vote counts for
every version of its lineage. Its owner sees the counts and cannot vote
(DC-9). RATING_ALLOW_DISLIKE = false takes dislikes away: the widget has
no dislike and the API answers one with a 400.
When the product has statistics, rating fills two of its panels: the best
rated datasets, and the worst rated when RATING_WORST_RATED_PANEL = true
(D17: off by default, and never without dislikes). A dataset stands in them
with RATING_PANEL_MIN_VOTES votes or more (3), the best above zero and the
worst below it.
When the product has explore (0.5.0 or later), the votes are facets of its
documents (likes, dislikes, net_likes), which its result cards read,
and the most liked first is one of its orders. Neither feature names
rating: both read what rating registers.
Frontend
The widget's script is assets/js/scripts.js, an ES module the SPLENT
toolchain builds into assets/dist/rating.bundle.js (entry rating, type
module), which rating/_rating_widget.html loads with
<script type="module">. It ships no library of its own: Bootstrap's
Tooltip is the shell's, imported from bootstrap, which is a
peerDependency in frontend/package.json (^5.2.0) and becomes
window.bootstrap in the bundle. The template uses the shell's CSS and its
feather icons too, declared in splent.shell, so product:validate checks
that the product's shell provides all three. What the page knows (the
dataset, the caller, the CSRF token) reaches the script in data-*
attributes of the widget, and the template has no inline script.
splent feature:compile rating # build it once, in development mode
splent feature:compile rating --watch # again on every change
splent feature:compile rating --verify # the files match assets/meta/manifest.json
Develop
splent feature:test splent_feature_rating
splent feature:contract splent_feature_rating
Release
splent feature:release splent_feature_rating --dry-run --bump patch
splent feature:release splent_feature_rating
The first command rehearses the release and changes nothing. The second publishes it to the git forge and to PyPI, and a PyPI version is permanent.