Skip to main content

django-sivuvahti

Django-laajennos avoinna olevien sivujen seuraamiseen

Asennus:

Asenna paketti:

pip install django-sivuvahti

Tee ASGI-määritys ja tarvittavat muutokset Django-asetuksiin django-pistoke- paketin asennusohjeiden mukaisesti.

Lisää sivuvahti asennettuihin sovelluksiin:

# projektin_asetukset.py

INSTALLED_APPS = [
  ...
  'sivuvahti',
]

Lisää sivuvahti URL-osoitteistoon:

# projektin_osoitteisto.py

from sivuvahti import Sivuvahti

urlpatterns = [
  ...
  path("sivuvahti", Sivuvahti.as_view(), name="sivuvahti")
]

Lisää Javascript-komentosarja:
```html
<!-- sivu.html -->

<head>
  ...
  <script
    type="text/javascript"
    src="{% static "sivuvahti/js/sivuvahti.js" %}"
    data-url="{{ request.websocket }}{% url "sivuvahti" %}"
    data-csrf="{{ csrf_token }}"
    ></script>
</head>

Käyttö:

Alusta sivuvahti sivun avaamisen yhteydessä:

let sivuvahti = new Sivuvahti(location.pathname);

Kuuntele saapuvia ja poistuvia käyttäjiä:

document.addEventListener(
  "sivuvahti.saapuvaKayttaja",
  function (e) {
    alert(`Saapuva käyttäjä: ${e.detail.nimi}`);
  }
);
document.addEventListener(
  "sivuvahti.poistuvaKayttaja",
  function (e) {
    alert(`Poistuva käyttäjä: ${e.detail.nimi}`);
  }
);

Reagoi tarvittaessa yhteyden avaamiseen tai katkaisuun:

document.addEventListener(
  "sivuvahti.yhteysAvattu",
  function (e) {
    console.log("Sivuvahti avattu");
  }
);
document.addEventListener(
  "sivuvahti.yhteysKatkaistu",
  function (e) {
    console.log("Sivuvahti suljettu");
  }
);

Sulje yhteys tarvittaessa:

sivuvahti.sulje();

Metadata

Release files for django-sivuvahti 0.4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-sivuvahti 0.4.1
File Size Uploaded Provenance Actions
django_sivuvahti-0.4.1.tar.gz 5.7 kB Without provenance Details for django_sivuvahti-0.4.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-sivuvahti 0.4.1
File Interpreter ABI Platform Actions
django_sivuvahti-0.4.1-py3-none-any.whl Python 3 none any Details for django_sivuvahti-0.4.1-py3-none-any.whl

Total release size: 12.6 kB

Release files / django_sivuvahti-0.4.1.tar.gz

Download URL django_sivuvahti-0.4.1.tar.gz
Size 5.7 kB
Tags Source
SHA-256 checksum
How to use checksums
55aec0e7ae82c2eb43b95dd6355678145233a48ea8212b252697e91647804078
BLAKE2b-256 checksum
How to use checksums
4e80998c1c5c4d0d4ca0215a9627f69565604f015c92590f6cc7aed0cfe4abdb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.0

Release files / django_sivuvahti-0.4.1-py3-none-any.whl

Download URL django_sivuvahti-0.4.1-py3-none-any.whl
Size 6.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
beb76632d2ff3b9828c03b875b7c5c2b20c12a2dfef766d3bd0c524b5d57c88d
BLAKE2b-256 checksum
How to use checksums
1ccfe31f3b56ed8906b3522ebdbf65281e1a8c5ed7921f8f3bee5f4083dbd497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.12.0

Security for django-sivuvahti 0.4.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page