Skip to main content

Display the date your data was updated

Project description

datasette-updated

PyPI Changelog Tests License

Display the date your data was updated

Installation

Install this plugin in the same environment as Datasette.

datasette install datasette-updated

Usage

You can have a different updated value per table, database or Datasette instance. If undefined at any level, updated will fall back in that order. If no value is set, updated will be unknown.

Base metadata configuration

If you have known updated values, you can define them in your base metadata.(json|yml):

{
  "plugins": {
    "datasette-updated": {
      "updated": "2023-12-14T23:04:42+00:00"
    }
  },
  "databases": {
    "my-database-name": {
      "plugins": {
        "datasette-updated": {
          "updated": "2023-01-01T00:00:00+00:00"
        }
      },
      "tables": {
        "my-table-name": {
          "plugins": {
            "datasette-updated": {
              "updated": "2020-01-01T00:00:00+00:00"
            }
          }
          ...

Plugin metadata configuration

If you want to define more dynamic updated value(s) on datasette package or datasette publish, put metadata for this plugin in YOUR_PLUGINS_DIR/datasette-updated/metadata.(json|yml). The following is an example that sets updated to the current date/time.

mkdir -p plugins/datasette-updated/ && \
echo '{
  "plugins": {
    "datasette-updated": {
      "updated": "'"$(date -Iseconds)"'"
    }
  }
}' > plugins/datasette-updated/metadata.json && \
datasette publish --plugins-dir=plugins --install=datasette-updated ...

Combined metadata configuration

You can combine base metadata and plugin metadata configuration, but be aware that the base metadata.(json|yml) will always win if there is a duplicate configuration value.

Extra configuration

The base / instance level metadata can accept the following extra configuration (that will apply to all levels):

Display

The plugin will try to load a footer template that is copied from the default Datasette footer template, but with the following addition:

{% if datasette_updated %}·
    Updated:
    <time
      data-local="{{ datasette_updated.time_type }}"
      datetime="{{ datasette_updated.updated }}">
        {{ datasette_updated.updated }}
    </time>
{% endif %}
  • If you have your own custom footer template, you will need to add the above code, as your base template will take precedence.
  • Look at local_time for extra configuration options (just ignore the Ruby parts).

Screenshot and Demo

screenshot

  • Example site: https://querydata.io/
  • The Javascript component converts time elements from UTC to the browser's local time.

Development

To set up this plugin locally, first checkout the code. Then create a new virtual environment:

cd datasette-updated
python3 -m venv venv
source venv/bin/activate

Now install the dependencies and test dependencies:

pip install -e '.[test]'

To run the tests:

pytest

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

datasette-updated-0.2.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

datasette_updated-0.2.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file datasette-updated-0.2.0.tar.gz.

File metadata

  • Download URL: datasette-updated-0.2.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.9

File hashes

Hashes for datasette-updated-0.2.0.tar.gz
Algorithm Hash digest
SHA256 80792d04fa453733365a2f7a67c5115d5c888912fbe9a179b98be4e8d9acb678
MD5 ab23e379c564946423ffbc8020dbe2cb
BLAKE2b-256 566a2bc3e60d2e9077d4838fee8e84f1121f66f76a30aadda3cb45beecb8c3ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for datasette_updated-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 66837418c82eaf92d0c9f951760adaa09ea1dd2b84b8021337d5b776d426f1ad
MD5 3ca571f93868a867fd10255fbd537eee
BLAKE2b-256 6555b4203969261cac5a23128342737e6b1a9504e31ab0e3f070637840b5c95b

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