From 4d3cfdd379d5fe09e07e43f504332d2a16e995fd Mon Sep 17 00:00:00 2001 From: Dave Gaeddert Date: Sun, 23 Jun 2024 13:28:54 -0500 Subject: [PATCH] Tailwind and cache docs --- bolt-cache/README.md | 44 ++++++++++++++++++++++++--- bolt-cache/bolt/cache/README.md | 44 ++++++++++++++++++++++++--- bolt-tailwind/README.md | 32 ++++++------------- bolt-tailwind/bolt/tailwind/README.md | 32 ++++++------------- 4 files changed, 98 insertions(+), 54 deletions(-) diff --git a/bolt-cache/README.md b/bolt-cache/README.md index 469a28c350..489aa6dbf1 100644 --- a/bolt-cache/README.md +++ b/bolt-cache/README.md @@ -1,12 +1,48 @@ -# bolt-cache +# Cache -Caching API with several different backends. +A simple cache using the database. + +The Bolt Cache stores JSON-serializable values in a `CachedItem` model. +Cached data can be set to expire after a certain amount of time. + +Access to the cache is provided through the `Cached` class. + +```python +from bolt.cache import Cached + + +cached = Cached("my-cache-key") + +if cached.exists(): + print("Cache hit and not expired!") + print(cached.value) +else: + print("Cache miss!") + cached.set("a JSON-serializable value", expiration=60) + +# Delete the item if you need to +cached.delete() +``` + +Expired cache items can be cleared with `bolt cache clear-expired`. +You can run this on a schedule through various cron-like tools or [bolt-worker](../../../bolt-worker/bolt/worker/). ## Installation -- install pkg -- add to INSTALLED_APPS +Add `bolt.cache` to your `INSTALLED_PACKAGES`: + +```python +# app/settings.py +INSTALLED_PACKAGES = [ + # ... + "bolt.cache", +] +``` ## CLI + +- `bolt cache clear-expired` - Clear all expired cache items +- `bolt cache clear-all` - Clear all cache items +- `bolt cache stats` - Show cache statistics diff --git a/bolt-cache/bolt/cache/README.md b/bolt-cache/bolt/cache/README.md index 0299486416..40d18494dc 100644 --- a/bolt-cache/bolt/cache/README.md +++ b/bolt-cache/bolt/cache/README.md @@ -1,10 +1,46 @@ -# bolt-cache +# Cache -Caching API with several different backends. +A simple cache using the database. + +The Bolt Cache stores JSON-serializable values in a `CachedItem` model. +Cached data can be set to expire after a certain amount of time. + +Access to the cache is provided through the `Cached` class. + +```python +from bolt.cache import Cached + + +cached = Cached("my-cache-key") + +if cached.exists(): + print("Cache hit and not expired!") + print(cached.value) +else: + print("Cache miss!") + cached.set("a JSON-serializable value", expiration=60) + +# Delete the item if you need to +cached.delete() +``` + +Expired cache items can be cleared with `bolt cache clear-expired`. +You can run this on a schedule through various cron-like tools or [bolt-worker](../../../bolt-worker/bolt/worker/). ## Installation -- install pkg -- add to INSTALLED_APPS +Add `bolt.cache` to your `INSTALLED_PACKAGES`: + +```python +# app/settings.py +INSTALLED_PACKAGES = [ + # ... + "bolt.cache", +] +``` ## CLI + +- `bolt cache clear-expired` - Clear all expired cache items +- `bolt cache clear-all` - Clear all cache items +- `bolt cache stats` - Show cache statistics diff --git a/bolt-tailwind/README.md b/bolt-tailwind/README.md index 932b20d530..6fd6a1bddf 100644 --- a/bolt-tailwind/README.md +++ b/bolt-tailwind/README.md @@ -4,9 +4,8 @@ Integrate Tailwind CSS without JavaScript or npm. -Use [Tailwind CSS](https://tailwindcss.com/) with [Django](https://www.djangoproject.com/) *without* requiring JavaScript or npm. - -Made possible by the [Tailwind standalone CLI](https://tailwindcss.com/blog/standalone-cli). +Made possible by the [Tailwind standalone CLI](https://tailwindcss.com/blog/standalone-cli), +which is installed for you. ```console $ bolt tailwind @@ -25,13 +24,7 @@ Commands: ## Installation -First, install `bolt-tailwind` from [PyPI](https://pypi.org/project/bolt-tailwind/): - -```sh -pip install bolt-tailwind -``` - -Then add `bolt.tailwind` to your `INSTALLED_PACKAGES`: +Add `bolt.tailwind` to your `INSTALLED_PACKAGES`: ```python # settings.py @@ -74,19 +67,12 @@ You should add `.bolt` to your `.gitignore` file. ## Updating Tailwind -This package manages the Tailwind versioning by comparing `.bolt/tailwind.version` to the `FORGE_TAILWIND_VERSION` variable that is injected into your `tailwind.config.js` file. - -```js -const FORGE_TAILWIND_VERSION = "3.0.24" +This package manages the Tailwind versioning by comparing the value in your `pyproject.toml` to `.bolt/tailwind.version`. -module.exports = { - theme: { - extend: {}, - }, - plugins: [ - require("@tailwindcss/forms"), - ], -} +```toml +# pyproject.toml +[tool.bolt.tailwind] +version = "3.4.1" ``` When you run `tailwind compile`, @@ -95,7 +81,7 @@ it will automatically check whether your local installation needs to be updated You can use the `update` command to update your project to the latest version of Tailwind: ```sh -tailwind update +bolt tailwind update ``` ## Adding custom CSS diff --git a/bolt-tailwind/bolt/tailwind/README.md b/bolt-tailwind/bolt/tailwind/README.md index 413c6155eb..d718c3dccb 100644 --- a/bolt-tailwind/bolt/tailwind/README.md +++ b/bolt-tailwind/bolt/tailwind/README.md @@ -2,9 +2,8 @@ Integrate Tailwind CSS without JavaScript or npm. -Use [Tailwind CSS](https://tailwindcss.com/) with [Django](https://www.djangoproject.com/) *without* requiring JavaScript or npm. - -Made possible by the [Tailwind standalone CLI](https://tailwindcss.com/blog/standalone-cli). +Made possible by the [Tailwind standalone CLI](https://tailwindcss.com/blog/standalone-cli), +which is installed for you. ```console $ bolt tailwind @@ -23,13 +22,7 @@ Commands: ## Installation -First, install `bolt-tailwind` from [PyPI](https://pypi.org/project/bolt-tailwind/): - -```sh -pip install bolt-tailwind -``` - -Then add `bolt.tailwind` to your `INSTALLED_PACKAGES`: +Add `bolt.tailwind` to your `INSTALLED_PACKAGES`: ```python # settings.py @@ -72,19 +65,12 @@ You should add `.bolt` to your `.gitignore` file. ## Updating Tailwind -This package manages the Tailwind versioning by comparing `.bolt/tailwind.version` to the `FORGE_TAILWIND_VERSION` variable that is injected into your `tailwind.config.js` file. - -```js -const FORGE_TAILWIND_VERSION = "3.0.24" +This package manages the Tailwind versioning by comparing the value in your `pyproject.toml` to `.bolt/tailwind.version`. -module.exports = { - theme: { - extend: {}, - }, - plugins: [ - require("@tailwindcss/forms"), - ], -} +```toml +# pyproject.toml +[tool.bolt.tailwind] +version = "3.4.1" ``` When you run `tailwind compile`, @@ -93,7 +79,7 @@ it will automatically check whether your local installation needs to be updated You can use the `update` command to update your project to the latest version of Tailwind: ```sh -tailwind update +bolt tailwind update ``` ## Adding custom CSS