Compare commits

..

5 Commits

Author SHA1 Message Date
R. Miles McCain
17bb5cda0d Improve litepicker box shadow 2021-05-14 15:32:16 +00:00
R. Miles McCain
84c647ad43 Update packages 2021-05-14 15:32:08 +00:00
Paweł Jastrzębski
0e37e7f042 Update litepicker and add ranges plugin
Fix litepicker colors

Fix litepicker event

Add custom ranges to litepicker

Fix code style

Remove some date ranges

Fix date ranges

Replace yesterday date range with last 3 days
2021-05-14 15:09:14 +00:00
CasperVerswijvelt
a76e0feaf3 Add custom location url from environment variable
Remove trailing dollar in long and lat placeholder
2021-05-14 15:07:49 +00:00
CasperVerswijvelt
109d977932 Make favicon not squish and add ellipsis overflow
General styling improvements

Many UI Improvements

- Consistent spacing between titles and content
- Removed many ugly text squishing by hiding overflowing text with ellipsis
- Fixed Service favicon being squisched by long service name
- Hide scrollbar in 'more session' screen when content isn't scrollable
- Fix apexcharts tooltips and labels being cut off by card class

Disable wrapping in table cells, prefer ellipsis

Ellipsis overflow for long url on hit page

Fix flex grow in header not working as intended

Remove forgotten truncatechars

Fix code checks, add button role and tabindex
2021-05-14 15:04:30 +00:00
92 changed files with 1077 additions and 6578 deletions

View File

@ -1,15 +0,0 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.11-bullseye
ENV PYTHONUNBUFFERED 1
# [Optional] If your requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
# RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements.txt \
# && rm -rf /tmp/pip-tmp
# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

View File

@ -1,29 +0,0 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/postgres
{
"name": "Python 3 & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {},
"ghcr.io/devcontainers/features/node:1": {},
"ghcr.io/devcontainers-contrib/features/poetry:2": {}
}
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// This can be used to network with other containers or the host.
// "forwardPorts": [5000, 5432],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip install --user -r requirements.txt",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View File

@ -1,35 +0,0 @@
version: '3.8'
services:
app:
build:
context: ..
dockerfile: .devcontainer/Dockerfile
volumes:
- ../..:/workspaces:cached
# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
network_mode: service:db
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
db:
image: postgres:latest
restart: unless-stopped
volumes:
- postgres-data:/var/lib/postgresql/data
environment:
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_PASSWORD: postgres
# Add "forwardPorts": ["5432"] to **devcontainer.json** to forward PostgreSQL locally.
# (Adding the "ports" property to this file will not forward from a Codespace.)
volumes:
postgres-data:

View File

@ -1,2 +0,0 @@
[flake8]
max-line-length = 88

View File

@ -1,58 +0,0 @@
name: Build edge Docker images
on:
push:
branches:
- master
jobs:
publish_to_docker_hub:
runs-on: ubuntu-latest
steps:
- name: Create Docker Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
milesmcc/shynet
ghcr.io/milesmcc/shynet
tags:
type=edge
- name: Set swap space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 5
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push advanced image
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

View File

@ -1,58 +0,0 @@
name: Build manual Docker images
on:
workflow_dispatch:
inputs:
tag:
description: 'Docker image tag'
jobs:
publish_to_docker_hub:
runs-on: ubuntu-latest
steps:
- name: Create Docker Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
milesmcc/shynet
ghcr.io/milesmcc/shynet
tags:
type=raw,value=${{ github.event.inputs.tag }}
- name: Set swap space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 5
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push advanced image
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

View File

@ -1,60 +0,0 @@
name: Build release Docker images
on:
push:
tags:
- "*"
jobs:
publish_to_docker_hub:
runs-on: ubuntu-latest
steps:
# https://github.com/docker/metadata-action/tree/v4/#typeref
- name: Create Docker Metadata
id: metadata
uses: docker/metadata-action@v5
with:
images: |
milesmcc/shynet
ghcr.io/milesmcc/shynet
tags:
type=raw,value=latest
type=ref,event=tag
- name: Set swap space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 5
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push advanced image
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}

View File

@ -1,38 +0,0 @@
name: Run tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
services:
db:
image: postgres:12.3-alpine
env:
POSTGRES_USER: shynet_db_user
POSTGRES_PASSWORD: shynet_db_user_password
POSTGRES_DB: shynet_db
ports:
- 5432:5432
strategy:
max-parallel: 4
matrix:
python-version: [3.9]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Run image
uses: abatilo/actions-poetry@v2.0.0
with:
poetry-version: 1.2.2
- name: Preinstall dependencies (temporary)
run: poetry run pip install "Cython<3.0" "pyyaml==5.4.1" --no-build-isolation
- name: Install dependencies
run: poetry install
- name: Django Testing project
run: |
cp TEMPLATE.env .env
poetry run ./shynet/manage.py test

View File

@ -1,16 +0,0 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
#- repo: https://github.com/pre-commit/pre-commit-hooks
#rev: v3.2.0
#hooks:
#- id: trailing-whitespace
#- id: end-of-file-fixer
#- id: check-yaml
#- id: check-added-large-files
- repo: https://github.com/psf/black
rev: 22.8.0
hooks:
- id: black
exclude: 'migrations|^shynet/shynet/settings.py'

View File

@ -1,15 +0,0 @@
# Contributing
This document provides an overview of how to contribute to Shynet. Currently, it focuses on the more technical elements of contributing --- for example, setting up your development environment. Eventually, we will expand this guide to cover the social and governance oriented side of contributing as well.
## Setting up your development environment
To contribute to Shynet, you must have a reliable development environment. Because Shynet is intended to be run inside containers, we strongly encourage you to run Shynet in a container in development as well. The development setup described in this guide will use Docker and Docker Compose.
To begin, clone the Shynet repository to your computer, and ensure that you have Docker and Docker Compose installed.
Copy `TEMPLATE.env` to a new file called `.env`. This `.env` file will be used in your development environment. Paste `DEBUG=True` into the end of your new `.env` file so that Shynet will know to run in development mode.
Finally, follow the steps in [GUIDE.md](GUIDE.md) on setting up a Shynet instance with Docker Compose. This is where you'll setup an admin user.
_Did you have to perform additional steps to setup your environment? Document them here and submit a pull request!_

View File

@ -1,43 +1,30 @@
FROM python:alpine3.14
FROM python:3-alpine
# Getting things ready
WORKDIR /usr/src/shynet
COPY Pipfile.lock Pipfile ./
COPY package.json package-lock.json ../
# Django expects node_modules to be in its parent directory.
# Install dependencies & configure machine
ARG GF_UID="500"
ARG GF_GID="500"
RUN apk update && \
apk add --no-cache gettext bash npm postgresql-libs && \
test "$(arch)" != "x86_64" && apk add libffi-dev rust cargo || echo "amd64 build, skipping Rust installation"
# libffi-dev and rust are used for the cryptography package,
# which we indirectly rely on. Necessary for aarch64 support.
# Collect GeoIP Database
RUN apk add --no-cache curl && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=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&suffix=tar.gz" | tar -xvz -C /tmp && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=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&suffix=tar.gz" | tar -xvz -C /tmp && \
apk add gettext curl bash npm && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN&license_key=kKG1ebhL3iWVd0iv&suffix=tar.gz" | tar -xvz -C /tmp && \
curl -m 180 "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-City&license_key=kKG1ebhL3iWVd0iv&suffix=tar.gz" | tar -xvz -C /tmp && \
mv /tmp/GeoLite2*/*.mmdb /etc && \
apk --purge del curl
# Move dependency files
COPY poetry.lock pyproject.toml ./
COPY package.json package-lock.json ../
# Django expects node_modules to be in its parent directory.
# Install more dependencies and cleanup build dependencies afterwards
RUN apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev libressl-dev libffi-dev && \
apk del curl && \
apk add --no-cache postgresql-libs && \
apk add --no-cache --virtual .build-deps gcc musl-dev postgresql-dev && \
npm i -P --prefix .. && \
pip install poetry==1.2.2 && \
poetry config virtualenvs.create false && \
poetry run pip install "Cython<3.0" "pyyaml==5.4.1" --no-build-isolation && \
poetry install --no-dev --no-interaction --no-ansi && \
apk --purge del .build-deps
# Setup user group
RUN addgroup --system -g $GF_GID appgroup && \
adduser appuser --system --uid $GF_UID -G appgroup && \
mkdir -p /var/local/shynet/db/ && \
chown -R appuser:appgroup /var/local/shynet
pip install pipenv~=2020.6.2 && \
pipenv install --system --deploy && \
apk --purge del .build-deps && \
rm -rf /var/lib/apt/lists/* && \
rm /var/cache/apk/* && \
addgroup --system -g $GF_GID appgroup && \
adduser appuser --system --uid $GF_UID -G appgroup
# Install Shynet
COPY shynet .
@ -47,5 +34,4 @@ RUN python manage.py collectstatic --noinput && \
# Launch
USER appuser
EXPOSE 8080
HEALTHCHECK CMD bash -c 'wget -o /dev/null -O /dev/null --header "Host: ${ALLOWED_HOSTS%%,*}" "http://127.0.0.1:${PORT:-8080}/healthz/?format=json"'
CMD [ "./entrypoint.sh" ]

View File

@ -7,6 +7,7 @@
- [Render](#render)
- [Updating Your Configuration](#updating-your-configuration)
- [Advanced Usage](#advanced-usage)
* [Installation with SSL](#installation-with-ssl)
* [Configuring a Reverse Proxy](#configuring-a-reverse-proxy)
+ [Cloudflare](#cloudflare)
+ [Nginx](#nginx)
@ -20,11 +21,9 @@
**If you install Shynet, you should strongly consider enabling notifications when new versions are released.** You can do this under the "Watch" tab on GitHub (above). This will ensure that you are notified when new versions are available, some of which may be security updates. (Shynet will never automatically update itself.)
> **When you do update, read the release notes!** These will tell you if you need to make changes to your deployment. (E.g., Shynet 0.13.1 requires additional configuration.)
## Installation
Installation of Shynet is easy! Follow the [Basic Installation](#basic-installation) guide or the [Basic Installation with Docker Compose](#basic-installation-with-docker-compose) below for a minimal installation, or if you are going to be running Shynet over HTTPS through a reverse proxy.
Installation of Shynet is easy! Follow the [Basic Installation](#basic-installation) guide or the [Basic Installation with Docker Compose](#basic-installation-with-docker-compose) below for a minimal installation, or if you are going to be running Shynet over HTTPS through a reverse proxy. If you'd like to run Shynet over HTTPS without a reverse proxy, skip ahead to [Installation with SSL](#installation-with-ssl) instead.
> **These commands assume Ubuntu.** If you're installing Shynet on a different platform, the process will be different.
@ -34,25 +33,23 @@ Before continuing, please be sure to have the latest version of Docker installed
1. Pull the latest version of Shynet using `docker pull milesmcc/shynet:latest`. If you don't have Docker installed, [install it](https://docs.docker.com/get-docker/).
2. For database you can use either PostgreSQL or SQLite:
2. Have a PostgreSQL server ready to go. This can be on the same machine as the deployment, or elsewhere. You'll just need a username, password, host, and port. (For info on how to setup a PostgreSQL server on Ubuntu, follow [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)).
2.1 To use PostgreSQL you need a server ready to go. This can be on the same machine as the deployment, or elsewhere. You'll need a username, password, host, and port, set in the appropriate `DB_` environment variables (see next). (For info on how to setup a PostgreSQL server on Ubuntu, follow [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)).
2.2 SQLite doesn't need a server, just a file. Set `SQLITE=True` in the environment file and create a Docker volume to hold the persistent DB with `docker volume create shynet_db`. Then whenever you run the container include `-v shynet_db:/var/local/shynet/db:rw` to mount the volume into the container. See the [Docker documentation on volumes](https://docs.docker.com/storage/volumes/).
3. Configure an environment file for Shynet, using [this file](/TEMPLATE.env) as a template. (This file is typically named `.env`.) Make sure you set the database settings, or Shynet won't be able to run. Also consider setting `ALLOWED_HOSTS` inside the environment file to your deployment's domain for better security.
3. Configure an environment file for Shynet, using [this file](/TEMPLATE.env) as a template. (This file is typically named `.env`.) Make sure you set the database settings, or Shynet won't be able to run.
4. Launch the Shynet server for the first time by running `docker run --env-file=<your env file> milesmcc/shynet:latest`. Provided you're using the default environment information (i.e., `PERFORM_CHECKS_AND_SETUP` is `True`), you'll see a few warnings about not having an admin user or host setup; these are normal. Don't worry — we'll do this in the next step. You only need to stop if you see a stacktrace about being unable to connect to the database.
5. Create an admin user by running `docker run --env-file=<your env file> milesmcc/shynet:latest ./manage.py registeradmin <your email>`. A temporary password will be printed to the console.
6. Set the whitelabel of your Shynet instance by running `docker run --env-file=<your env file> milesmcc/shynet:latest ./manage.py whitelabel <whitelabel>`. While this setting doesn't affect any core operations of Shynet, it lets you rename Shynet to whatever you want. (Example whitelabels: `"My Shynet Instance"` or `"Acme Analytics"`.)
6. Set the hostname of your Shynet instance by running `docker run --env-file=<your env file> milesmcc/shynet:latest ./manage.py hostname <your public hostname>`, where `<your public hostname>` is the _publicly accessible hostname_ of your instance, including port. This setting affects the URL that the tracking script sends its results to, so make sure it's correct. (Example hostnames: `shynet.example.com` or `example.com:8000`.)
7. Launch your webserver by running `docker run --env-file=<your env file> milesmcc/shynet:latest`. You may need to bind Docker's port 8080 (where Shynet runs) to your local port 80 (http); this can be done using the flag `-p 80:8080` after `run`. Visit your service's homepage, and verify everything looks right! You should see a login prompt. Log in with the credentials from step 5. You'll probably be prompted to "confirm your email"—if you haven't set up an email server, the confirmation email will be printed to the console instead.
7. Set the whitelabel of your Shynet instance by running `docker run --env-file=<your env file> milesmcc/shynet:latest ./manage.py whitelabel <whitelabel>`. While this setting doesn't affect any core operations of Shynet, it lets you rename Shynet to whatever you want. (Example whitelabels: `"My Shynet Instance"` or `"Acme Analytics"`.)
8. Create a service by clicking "+ Create Service" in the top right hand corner. Fill out the options as appropriate. Once you're done, press "create" and you'll be redirected to your new service's analytics page.
8. Launch your webserver by running `docker run --env-file=<your env file> milesmcc/shynet:latest`. You may need to bind Docker's port 8080 (where Shynet runs) to your local port 80 (http); this can be done using the flag `-p 80:8080` after `run`. Visit your service's homepage, and verify everything looks right! You should see a login prompt. Log in with the credentials from step 5. You'll probably be prompted to "confirm your email"—if you haven't set up an email server, the confirmation email will be printed to the console instead.
9. Finally, click on "Manage" in the top right of the service's page to get the tracking script code. Inject this script on all pages you'd like the service to track.
9. Create a service by clicking "+ Create Service" in the top right hand corner. Fill out the options as appropriate. Once you're done, press "create" and you'll be redirected to your new service's analytics page.
10. Finally, click on "Manage" in the top right of the service's page to get the tracking script code. Inject this script on all pages you'd like the service to track.
### Basic Installation with Docker Compose
@ -61,7 +58,7 @@ Before continuing, please be sure to have the latest version of Docker installed
1. Clone the repository.
2. Using [TEMPLATE.env](/TEMPLATE.env) as a template, configure the environment for your Shynet instance and place the modified config in a file called `.env` in the root of the repository. Do _not_ change the port number at the end; you can set the public facing port in the next step.
2. Using [TEMPLATE.env](/TEMPLATE.env) as a template, confiure the environment for your Shynet instance and place the modified config in a file called `.env` in the root of the repository. Do _not_ change the port number at the end; you can set the public facing port in the next step.
3. On line 2 of the `nginx.conf` file located in the root of the repository, replace `example.com` with your hostname. Then, in the `docker-compose.yml` file, set the port number by replacing `8080` in line 38 ( `- 8080:80` ) with whatever local port you want to bind it to. For example, set the port number to `- 80:80` if you want your site will be available via HTTP (port 80) at `http://<your hostname>`.
@ -69,7 +66,9 @@ Before continuing, please be sure to have the latest version of Docker installed
5. Create an admin user by running `docker exec -it shynet_main ./manage.py registeradmin <your email>`. A temporary password will be printed to the console.
6. Set the whitelabel of your Shynet instance by running `docker exec -it shynet_main ./manage.py whitelabel <whitelabel>`. While this setting doesn't affect any core operations of Shynet, it lets you rename Shynet to whatever you want. (Example whitelabels: "My Shynet Instance" or "Acme Analytics".)
6. Set the hostname of your Shynet instance by running `docker exec -it shynet_main ./manage.py hostname <your public hostname>`, where `<your public hostname>` is the same as the hostname you set in step 3. This setting affects the URL that the tracking script sends its results to, so make sure it's correct. (Example hostnames: shynet.example.com or example.com:8000.)
7. Set the whitelabel of your Shynet instance by running `docker exec -it shynet_main ./manage.py whitelabel <whitelabel>`. While this setting doesn't affect any core operations of Shynet, it lets you rename Shynet to whatever you want. (Example whitelabels: "My Shynet Instance" or "Acme Analytics".)
Your site should now be accessible at `http://hostname:port`. Now you can follow steps 9-10 of the [Basic Installation](#basic-installation) guide above to get Shynet integrated on your sites.
@ -79,10 +78,11 @@ You may wish to deploy Shynet on Heroku. Note that Heroku's free offerings (name
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/milesmcc/shynet/tree/master)
Once you deploy, you'll need to setup an admin user and whitelabel before you can use Shynet. Do that with the following commands:
Once you deploy, you'll need to setup an admin user, whitelabel, and hostname before you can use Shynet. Do that with the following commands:
1. `heroku run --app=<your app> ./manage.py registeradmin <your email>`
2. `heroku run --app=<your app> ./manage.py whitelabel "<your Shynet instance's name>"`
2. `heroku run --app=<your app> ./manage.py hostname <the hostname where you will run Shynet>`
3. `heroku run --app=<your app> ./manage.py whitelabel "<your Shynet instance's name>"`
## Render
@ -93,7 +93,8 @@ Once you deploy, you'll need to setup an admin user and whitelabel before you ca
Once your deploy has completed, use the **Render Shell** to configure your app:
1. Set your email: `./manage.py registeradmin your-email@example.com`
2. Set your whitelabel: `./manage.py whitelabel "Your Shynet Instance Name"`
1. Add your onrender.com domain: `./manage.py hostname your-shynet-domain.onrender.com`
1. Set your whitelabel: `./manage.py whitelabel "Your Shynet Instance Name"`
See the [Render docs](https://render.com/docs/deploy-shynet) for more information on deploying your application on Render.
@ -101,6 +102,40 @@ See the [Render docs](https://render.com/docs/deploy-shynet) for more informatio
## Advanced Usage
### Installation with SSL
If you are going to be running Shynet through a reverse proxy, please see [Configuring a Reverse Proxy](#configuring-a-reverse-proxy) instead.
0. We'll be cloning this into the home directory to make this installation easier, so run `cd ~/` if you need to.
1. Instead of pulling from Docker, we will be pulling from GitHub and building using Docker in order to easily add SSL certificates. You will want to run `git clone https://github.com/milesmcc/shynet.git` to clone the GitHub repo to your current working directory.
2. To install `certbot` follow [the guide here](https://certbot.eff.org/instructions) or follow along below
* Ubuntu 18.04
* `sudo apt-get update`
* `sudo apt-get install software-properties-common`
* `sudo add-apt-repository universe`
* `sudo add-apt-repository ppa:certbot/certbot`
* `sudo apt-get update`
* `sudo apt-get install certbot`
3. Run `sudo certbot certonly --standalone` and follow the instructions to generate your SSL certificate.
* If you registering the certificate to a domain name like `example.com`, please be sure to point your DNS records to your current server before running `certbot`.
4. We are going to move the SSL certificates to the Shynet repo with with command below. Replace `<domain>` with the domain name you used in step 3.
* `cp /etc/letsencrypt/live/<domain>/{cert,privkey}.pem ~/shynet/shynet/`
5. With that, we are going to replace the `webserver.sh` with `ssl.webserver.sh` to enable the use of SSL certificates. The original `webserver.sh` will be backed up to `backup.webserver.sh`
* `mv ~/shynet/shynet/webserver.sh ~/shynet/shynet/backup.webserver.sh`
* `mv ~/shynet/shynet/ssl.webserver.sh ~/shynet/shynet/webserver.sh`
6. Now we build the image!
* `docker image build shynet -t shynet-ssl:latest`
7. Have a PostgreSQL server ready to go. This can be on the same machine as the deployment, or elsewhere. You'll just need a username, password, host, and port (default is `5432`). (For info on how to setup a PostgreSQL server on Ubuntu, follow [this guide](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04)).
8. Follow the [Basic Installation](#basic-installation) guide with just one modification: in step #4, change the local bind port from `80` to `443`, and use `shynet-ssl:latest` as your Docker image instead of `milesmcc/shynet:latest`.
### Configuring a Reverse Proxy
A reverse proxy has many benefits. It can be used for DDoS protection, caching files to reduce server load, routing HTTPS and/or HTTP connections, hosting multiple services on a single server, [and more](https://www.cloudflare.com/learning/cdn/glossary/reverse-proxy/)!
@ -214,22 +249,6 @@ In a single-page application, the page never reloads. (That's the entire point o
Fortunately, Shynet offers a simple method you can call from anywhere within your JavaScript to indicate that a new page has been loaded: `Shynet.newPageLoad()`. Add this method call to the code that handles routing in your app, and you'll be ready to go.
### API
All the information displayed on the dashboard can be obtained via API on url ```//shynet.example.com/api/v1/dashboard/```. By default this endpoint will return the full data from all services over the last last 30 days. The `Authentication` header should be set to use user's personal API token (```'Authorization: Token <user API token>'```).
There are 3 optional query parameters:
* `uuid` - to get data only from one service
* `startDate` - to set start date in format YYYY-MM-DD
* `endDate` - to set end date in format YYYY-MM-DD
Example in HTTPie:
```http get '//shynet.example.com/api/v1/dashboard/?uuid={{service_uuid}}&startDate=2021-01-01&endDate=2050-01-01' 'Authorization:Token {{user_api_token}}'```
Example in cURL:
```curl -H 'Authorization:Token {{user_api_token}}' '//shynet.example.com/api/v1/dashboard/?uuid={{service_uuid}}&startDate=2021-01-01&endDate=2050-01-01'```
---
## Troubleshooting
@ -253,4 +272,4 @@ Here are solutions for some common issues. If your situation isn't described her
#### Shynet can't connect to my database running on `localhost`/`127.0.0.1`
* The problem is likely that to Shynet, `localhost` points to the local network in the container itself, not on the host machine. Try adding the `--network='host'` option when you run Docker.
* The problem is likely that to Shynet, `localhost` points to the local network in the container itself, not on the host machine. Try adding the `--network='host'` option when you run Docker.

25
Pipfile Normal file
View File

@ -0,0 +1,25 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[packages]
django = "~=3.1"
django-allauth = "~=0.42.0"
geoip2 = "~=3.0.0"
whitenoise = "~=5.1.0"
celery = "~=4.4.6"
django-ipware = "~=2.1.0"
pyyaml = "~=5.4"
ua-parser = "~=0.10.0"
user-agents = "~=2.1"
rules = "~=2.2"
gunicorn = "~=20.0.4"
psycopg2-binary = "~=2.8.5"
redis = "~=3.5.3"
django-redis-cache = "~=3.0.0"
pycountry = "~=19.8.18"
html2text = "~=2020.1.16"
django-health-check = "~=3.12.1"
django-npm = "~=1.0.0"
django-debug-toolbar = "*"

343
Pipfile.lock generated Normal file
View File

@ -0,0 +1,343 @@
{
"_meta": {
"hash": {
"sha256": "c51ea0205c9ffe753b9ef5249cd49c2338bb50768ae104113bfb7b97b5f9d70c"
},
"pipfile-spec": 6,
"requires": {},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"amqp": {
"hashes": [
"sha256:70cdb10628468ff14e57ec2f751c7aa9e48e7e3651cfd62d431213c0c4e58f21",
"sha256:aa7f313fb887c91f15474c1229907a04dac0b8135822d6603437803424c0aa59"
],
"version": "==2.6.1"
},
"asgiref": {
"hashes": [
"sha256:92906c611ce6c967347bbfea733f13d6313901d54dcca88195eaeb52b2a8e8ee",
"sha256:d1216dfbdfb63826470995d31caed36225dcaf34f182e0fa257a4dd9e86f1b78"
],
"version": "==3.3.4"
},
"billiard": {
"hashes": [
"sha256:299de5a8da28a783d51b197d496bef4f1595dd023a93a4f59dde1886ae905547",
"sha256:87103ea78fa6ab4d5c751c4909bcff74617d985de7fa8b672cf8618afd5a875b"
],
"version": "==3.6.4.0"
},
"celery": {
"hashes": [
"sha256:a92e1d56e650781fb747032a3997d16236d037c8199eacd5217d1a72893bca45",
"sha256:d220b13a8ed57c78149acf82c006785356071844afe0b27012a4991d44026f9f"
],
"index": "pypi",
"version": "==4.4.7"
},
"certifi": {
"hashes": [
"sha256:1a4995114262bffbc2413b159f2a1a480c969de6e6eb13ee966d470af86af59c",
"sha256:719a74fb9e33b9bd44cc7f3a8d94bc35e4049deebe19ba7d8e108280cfd59830"
],
"version": "==2020.12.5"
},
"chardet": {
"hashes": [
"sha256:0d6f53a15db4120f2b08c94f11e7d93d2c911ee118b6b30a04ec3ee8310179fa",
"sha256:f864054d66fd9118f2e67044ac8981a54775ec5b67aed0441892edb553d21da5"
],
"version": "==4.0.0"
},
"defusedxml": {
"hashes": [
"sha256:1bb3032db185915b62d7c6209c5a8792be6a32ab2fedacc84e01b52c51aa3e69",
"sha256:a352e7e428770286cc899e2542b6cdaedb2b4953ff269a210103ec58f6198a61"
],
"version": "==0.7.1"
},
"django": {
"hashes": [
"sha256:c348b3ddc452bf4b62361f0752f71a339140c777ebea3cdaaaa8fdb7f417a862",
"sha256:f8393103e15ec2d2d313ccbb95a3f1da092f9f58d74ac1c61ca2ac0436ae1eac"
],
"index": "pypi",
"version": "==3.1.8"
},
"django-allauth": {
"hashes": [
"sha256:f17209410b7f87da0a84639fd79d3771b596a6d3fc1a8e48ce50dabc7f441d30"
],
"index": "pypi",
"version": "==0.42.0"
},
"django-debug-toolbar": {
"hashes": [
"sha256:a5ff2a54f24bf88286f9872836081078f4baa843dc3735ee88524e89f8821e33",
"sha256:e759e63e3fe2d3110e0e519639c166816368701eab4a47fed75d7de7018467b9"
],
"index": "pypi",
"version": "==3.2.1"
},
"django-health-check": {
"hashes": [
"sha256:2667b89b8f85ad9b2a24c90581b376016d22ea912fedf37f9866413a3c2e0a5d",
"sha256:894738bd7e461b2405c005927403ad5ee8048bbaf5934cf30b2c81a4e047d4b0"
],
"index": "pypi",
"version": "==3.12.3"
},
"django-ipware": {
"hashes": [
"sha256:a7c7a8fd019dbdc9c357e6e582f65034e897572fc79a7e467674efa8aef9d00b"
],
"index": "pypi",
"version": "==2.1.0"
},
"django-npm": {
"hashes": [
"sha256:2e6bba65e728fa18b9db3c8dc0d4490b70cb7f43bacf60eb3654d7dcb6424272"
],
"index": "pypi",
"version": "==1.0.0"
},
"django-redis-cache": {
"hashes": [
"sha256:9a2eebef421d996a82098a19d17ff6b321265cd73178fa398913019764e8394a"
],
"index": "pypi",
"version": "==3.0.0"
},
"geoip2": {
"hashes": [
"sha256:5869e987bc54c0d707264fec4710661332cc38d2dca5a7f9bb5362d0308e2ce0",
"sha256:99ec12d2f1271a73a0a4a2b663fe6ce25fd02289c0a6bef05c0a1c3b30ee95a4"
],
"index": "pypi",
"version": "==3.0.0"
},
"gunicorn": {
"hashes": [
"sha256:1904bb2b8a43658807108d59c3f3d56c2b6121a701161de0ddf9ad140073c626",
"sha256:cd4a810dd51bf497552cf3f863b575dabd73d6ad6a91075b65936b151cbf4f9c"
],
"index": "pypi",
"version": "==20.0.4"
},
"html2text": {
"hashes": [
"sha256:c7c629882da0cf377d66f073329ccf34a12ed2adf0169b9285ae4e63ef54c82b",
"sha256:e296318e16b059ddb97f7a8a1d6a5c1d7af4544049a01e261731d2d5cc277bbb"
],
"index": "pypi",
"version": "==2020.1.16"
},
"idna": {
"hashes": [
"sha256:b307872f855b18632ce0c21c5e45be78c0ea7ae4c15c828c20788b26921eb3f6",
"sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0"
],
"version": "==2.10"
},
"kombu": {
"hashes": [
"sha256:be48cdffb54a2194d93ad6533d73f69408486483d189fe9f5990ee24255b0e0a",
"sha256:ca1b45faac8c0b18493d02a8571792f3c40291cf2bcf1f55afed3d8f3aa7ba74"
],
"version": "==4.6.11"
},
"maxminddb": {
"hashes": [
"sha256:47e86a084dd814fac88c99ea34ba3278a74bc9de5a25f4b815b608798747c7dc"
],
"version": "==2.0.3"
},
"oauthlib": {
"hashes": [
"sha256:bee41cc35fcca6e988463cacc3bcb8a96224f470ca547e697b604cc697b2f889",
"sha256:df884cd6cbe20e32633f1db1072e9356f53638e4361bef4e8b03c9127c9328ea"
],
"version": "==3.1.0"
},
"psycopg2-binary": {
"hashes": [
"sha256:0deac2af1a587ae12836aa07970f5cb91964f05a7c6cdb69d8425ff4c15d4e2c",
"sha256:0e4dc3d5996760104746e6cfcdb519d9d2cd27c738296525d5867ea695774e67",
"sha256:11b9c0ebce097180129e422379b824ae21c8f2a6596b159c7659e2e5a00e1aa0",
"sha256:15978a1fbd225583dd8cdaf37e67ccc278b5abecb4caf6b2d6b8e2b948e953f6",
"sha256:1fabed9ea2acc4efe4671b92c669a213db744d2af8a9fc5d69a8e9bc14b7a9db",
"sha256:2dac98e85565d5688e8ab7bdea5446674a83a3945a8f416ad0110018d1501b94",
"sha256:42ec1035841b389e8cc3692277a0bd81cdfe0b65d575a2c8862cec7a80e62e52",
"sha256:6422f2ff0919fd720195f64ffd8f924c1395d30f9a495f31e2392c2efafb5056",
"sha256:6a32f3a4cb2f6e1a0b15215f448e8ce2da192fd4ff35084d80d5e39da683e79b",
"sha256:7312e931b90fe14f925729cde58022f5d034241918a5c4f9797cac62f6b3a9dd",
"sha256:7d92a09b788cbb1aec325af5fcba9fed7203897bbd9269d5691bb1e3bce29550",
"sha256:833709a5c66ca52f1d21d41865a637223b368c0ee76ea54ca5bad6f2526c7679",
"sha256:89705f45ce07b2dfa806ee84439ec67c5d9a0ef20154e0e475e2b2ed392a5b83",
"sha256:8cd0fb36c7412996859cb4606a35969dd01f4ea34d9812a141cd920c3b18be77",
"sha256:950bc22bb56ee6ff142a2cb9ee980b571dd0912b0334aa3fe0fe3788d860bea2",
"sha256:a0c50db33c32594305b0ef9abc0cb7db13de7621d2cadf8392a1d9b3c437ef77",
"sha256:a0eb43a07386c3f1f1ebb4dc7aafb13f67188eab896e7397aa1ee95a9c884eb2",
"sha256:aaa4213c862f0ef00022751161df35804127b78adf4a2755b9f991a507e425fd",
"sha256:ac0c682111fbf404525dfc0f18a8b5f11be52657d4f96e9fcb75daf4f3984859",
"sha256:ad20d2eb875aaa1ea6d0f2916949f5c08a19c74d05b16ce6ebf6d24f2c9f75d1",
"sha256:b4afc542c0ac0db720cf516dd20c0846f71c248d2b3d21013aa0d4ef9c71ca25",
"sha256:b8a3715b3c4e604bcc94c90a825cd7f5635417453b253499664f784fc4da0152",
"sha256:ba28584e6bca48c59eecbf7efb1576ca214b47f05194646b081717fa628dfddf",
"sha256:ba381aec3a5dc29634f20692349d73f2d21f17653bda1decf0b52b11d694541f",
"sha256:bd1be66dde2b82f80afb9459fc618216753f67109b859a361cf7def5c7968729",
"sha256:c2507d796fca339c8fb03216364cca68d87e037c1f774977c8fc377627d01c71",
"sha256:cec7e622ebc545dbb4564e483dd20e4e404da17ae07e06f3e780b2dacd5cee66",
"sha256:d14b140a4439d816e3b1229a4a525df917d6ea22a0771a2a78332273fd9528a4",
"sha256:d1b4ab59e02d9008efe10ceabd0b31e79519da6fb67f7d8e8977118832d0f449",
"sha256:d5227b229005a696cc67676e24c214740efd90b148de5733419ac9aaba3773da",
"sha256:e1f57aa70d3f7cc6947fd88636a481638263ba04a742b4a37dd25c373e41491a",
"sha256:e74a55f6bad0e7d3968399deb50f61f4db1926acf4a6d83beaaa7df986f48b1c",
"sha256:e82aba2188b9ba309fd8e271702bd0d0fc9148ae3150532bbb474f4590039ffb",
"sha256:ee69dad2c7155756ad114c02db06002f4cded41132cc51378e57aad79cc8e4f4",
"sha256:f5ab93a2cb2d8338b1674be43b442a7f544a0971da062a5da774ed40587f18f5"
],
"index": "pypi",
"version": "==2.8.6"
},
"pycountry": {
"hashes": [
"sha256:3c57aa40adcf293d59bebaffbe60d8c39976fba78d846a018dc0c2ec9c6cb3cb"
],
"index": "pypi",
"version": "==19.8.18"
},
"python3-openid": {
"hashes": [
"sha256:33fbf6928f401e0b790151ed2b5290b02545e8775f982485205a066f874aaeaf",
"sha256:6626f771e0417486701e0b4daff762e7212e820ca5b29fcc0d05f6f8736dfa6b"
],
"version": "==3.2.0"
},
"pytz": {
"hashes": [
"sha256:83a4a90894bf38e243cf052c8b58f381bfe9a7a483f6a9cab140bc7f702ac4da",
"sha256:eb10ce3e7736052ed3623d49975ce333bcd712c7bb19a58b9e2089d4057d0798"
],
"version": "==2021.1"
},
"pyyaml": {
"hashes": [
"sha256:08682f6b72c722394747bddaf0aa62277e02557c0fd1c42cb853016a38f8dedf",
"sha256:0f5f5786c0e09baddcd8b4b45f20a7b5d61a7e7e99846e3c799b05c7c53fa696",
"sha256:129def1b7c1bf22faffd67b8f3724645203b79d8f4cc81f674654d9902cb4393",
"sha256:294db365efa064d00b8d1ef65d8ea2c3426ac366c0c4368d930bf1c5fb497f77",
"sha256:3b2b1824fe7112845700f815ff6a489360226a5609b96ec2190a45e62a9fc922",
"sha256:3bd0e463264cf257d1ffd2e40223b197271046d09dadf73a0fe82b9c1fc385a5",
"sha256:4465124ef1b18d9ace298060f4eccc64b0850899ac4ac53294547536533800c8",
"sha256:49d4cdd9065b9b6e206d0595fee27a96b5dd22618e7520c33204a4a3239d5b10",
"sha256:4e0583d24c881e14342eaf4ec5fbc97f934b999a6828693a99157fde912540cc",
"sha256:5accb17103e43963b80e6f837831f38d314a0495500067cb25afab2e8d7a4018",
"sha256:607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e",
"sha256:6c78645d400265a062508ae399b60b8c167bf003db364ecb26dcab2bda048253",
"sha256:72a01f726a9c7851ca9bfad6fd09ca4e090a023c00945ea05ba1638c09dc3347",
"sha256:74c1485f7707cf707a7aef42ef6322b8f97921bd89be2ab6317fd782c2d53183",
"sha256:895f61ef02e8fed38159bb70f7e100e00f471eae2bc838cd0f4ebb21e28f8541",
"sha256:8c1be557ee92a20f184922c7b6424e8ab6691788e6d86137c5d93c1a6ec1b8fb",
"sha256:bb4191dfc9306777bc594117aee052446b3fa88737cd13b7188d0e7aa8162185",
"sha256:bfb51918d4ff3d77c1c856a9699f8492c612cde32fd3bcd344af9be34999bfdc",
"sha256:c20cfa2d49991c8b4147af39859b167664f2ad4561704ee74c1de03318e898db",
"sha256:cb333c16912324fd5f769fff6bc5de372e9e7a202247b48870bc251ed40239aa",
"sha256:d2d9808ea7b4af864f35ea216be506ecec180628aced0704e34aca0b040ffe46",
"sha256:d483ad4e639292c90170eb6f7783ad19490e7a8defb3e46f97dfe4bacae89122",
"sha256:dd5de0646207f053eb0d6c74ae45ba98c3395a571a2891858e87df7c9b9bd51b",
"sha256:e1d4970ea66be07ae37a3c2e48b5ec63f7ba6804bdddfdbd3cfd954d25a82e63",
"sha256:e4fac90784481d221a8e4b1162afa7c47ed953be40d31ab4629ae917510051df",
"sha256:fa5ae20527d8e831e8230cbffd9f8fe952815b2b7dae6ffec25318803a7528fc",
"sha256:fd7f6999a8070df521b6384004ef42833b9bd62cfee11a09bda1079b4b704247",
"sha256:fdc842473cd33f45ff6bce46aea678a54e3d21f1b61a7750ce3c498eedfe25d6",
"sha256:fe69978f3f768926cfa37b867e3843918e012cf83f680806599ddce33c2c68b0"
],
"index": "pypi",
"version": "==5.4.1"
},
"redis": {
"hashes": [
"sha256:0e7e0cfca8660dea8b7d5cd8c4f6c5e29e11f31158c0b0ae91a397f00e5a05a2",
"sha256:432b788c4530cfe16d8d943a09d40ca6c16149727e4afe8c2c9d5580c59d9f24"
],
"index": "pypi",
"version": "==3.5.3"
},
"requests": {
"hashes": [
"sha256:27973dd4a904a4f13b263a19c866c13b92a39ed1c964655f025f3f8d3d75b804",
"sha256:c210084e36a42ae6b9219e00e48287def368a26d03a048ddad7bfee44f75871e"
],
"version": "==2.25.1"
},
"requests-oauthlib": {
"hashes": [
"sha256:7f71572defaecd16372f9006f33c2ec8c077c3cfa6f5911a9a90202beb513f3d",
"sha256:b4261601a71fd721a8bd6d7aa1cc1d6a8a93b4a9f5e96626f8e4d91e8beeaa6a"
],
"version": "==1.3.0"
},
"rules": {
"hashes": [
"sha256:9bae429f9d4f91a375402990da1541f9e093b0ac077221d57124d06eeeca4405"
],
"index": "pypi",
"version": "==2.2"
},
"sqlparse": {
"hashes": [
"sha256:017cde379adbd6a1f15a61873f43e8274179378e95ef3fede90b5aa64d304ed0",
"sha256:0f91fd2e829c44362cbcfab3e9ae12e22badaa8a29ad5ff599f9ec109f0454e8"
],
"version": "==0.4.1"
},
"ua-parser": {
"hashes": [
"sha256:46ab2e383c01dbd2ab284991b87d624a26a08f72da4d7d413f5bfab8b9036f8a",
"sha256:47b1782ed130d890018d983fac37c2a80799d9e0b9c532e734c67cf70f185033"
],
"index": "pypi",
"version": "==0.10.0"
},
"urllib3": {
"hashes": [
"sha256:2f4da4594db7e1e110a944bb1b551fdf4e6c136ad42e4234131391e21eb5b0df",
"sha256:e7b021f7241115872f92f43c6508082facffbd1c048e3c6e2bb9c2a157e28937"
],
"version": "==1.26.4"
},
"user-agents": {
"hashes": [
"sha256:a98c4dc72ecbc64812c4534108806fb0a0b3a11ec3fd1eafe807cee5b0a942e7",
"sha256:d36d25178db65308d1458c5fa4ab39c9b2619377010130329f3955e7626ead26"
],
"index": "pypi",
"version": "==2.2.0"
},
"vine": {
"hashes": [
"sha256:133ee6d7a9016f177ddeaf191c1f58421a1dcc6ee9a42c58b34bed40e1d2cd87",
"sha256:ea4947cc56d1fd6f2095c8d543ee25dad966f78692528e68b4fada11ba3f98af"
],
"version": "==1.3.0"
},
"whitenoise": {
"hashes": [
"sha256:60154b976a13901414a25b0273a841145f77eb34a141f9ae032a0ace3e4d5b27",
"sha256:6dd26bfda3af29177d8ab7333a0c7b7642eb615ce83764f4d15a9aecda3201c4"
],
"index": "pypi",
"version": "==5.1.0"
}
},
"develop": {}
}

View File

@ -8,7 +8,7 @@
<br>
<strong><a href="#installation">Getting started »</a></strong>
</p>
<p align="center"><a href="#screenshots">Screenshots</a> &bull; <a href="#features">Features</a> &bull; <a href="https://miles.land/officehours/">Office Hours</a></p>
<p align="center"><a href="#screenshots">Screenshots</a> &bull; <a href="#features">Features</a> &bull; <a href="https://github.com/milesmcc/a17t">Design</a></p>
</p>
<br>
@ -93,7 +93,7 @@ Shynet is pretty simple, but there are a few key terms you need to know in order
## Installation
You can find instructions on getting started and usage in the [Usage Guide](GUIDE.md#installation). Out of the box, we support deploying via a simple Docker container, docker-compose, Heroku, or Kubernetes (see [kubernetes](/kubernetes)).
You can find intructions on getting started and usage in the [Usage Guide](GUIDE.md#installation). Out of the box, we support deploying via a simple Docker container, docker-compose, Heroku, or Kubernetes (see [kubernetes](/kubernetes)).
## FAQ

View File

@ -9,10 +9,6 @@ DB_PASSWORD=shynet_db_user_password
DB_HOST=db
DB_PORT=5432
# Database settings (SQLite) - comment PostgreSQL settings
# SQLITE=True
# DB_NAME=/var/local/shynet/db/db.sqlite3
# Email settings (optional)
EMAIL_HOST_USER=example
EMAIL_HOST_PASSWORD=example_password
@ -23,16 +19,11 @@ EMAIL_USE_SSL=True
# EMAIL_USE_TLS=True
SERVER_EMAIL=Shynet <noreply@shynet.example.com>
# General Django settings - to generate run: python3 -c "import secrets; print(secrets.token_urlsafe())"
# General Django settings
DJANGO_SECRET_KEY=random_string
# Set these to your deployment's domain. Both are comma separated, but CSRF_TRUSTED_ORIGINS also requires a scheme (e.g., `https://`).
ALLOWED_HOSTS=example.com
CSRF_TRUSTED_ORIGINS=https://example.com
# Localization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE=en-us
# For better security, set this to your deployment's domain. Comma separated.
ALLOWED_HOSTS=*
# Set to True (capitalized) if you want people to be able to sign up for your Shynet instance (not recommended)
ACCOUNT_SIGNUPS_ENABLED=False
@ -42,8 +33,6 @@ ACCOUNT_SIGNUPS_ENABLED=False
ACCOUNT_EMAIL_VERIFICATION=none
# The timezone of the admin panel. Affects how dates are displayed.
# This must match a value from the IANA's tz database.
# Wikipedia has a list of valid strings: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIME_ZONE=America/New_York
# Set to "False" if you will not be serving content over HTTPS
@ -102,11 +91,4 @@ AGGRESSIVE_HASH_SALTING=True
# - https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE (default)
# - https://www.google.com/maps/search/?api=1&query=$LATITUDE,$LONGITUDE
# - https://www.mapquest.com/near-$LATITUDE,$LONGITUDE
LOCATION_URL=https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE
# How many services should be displayed on dashboard page?
# Set to big number if you don't want pagination at all.
DASHBOARD_PAGE_SIZE=5
# Should background bars be scaled to full width?
USE_RELATIVE_MAX_IN_BAR_VISUALIZATION=True
LOCATION_URL=https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE

View File

@ -127,16 +127,6 @@
"description": "Custom location url to link to in frontend.",
"value": "https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE",
"required": false
},
"DASHBOARD_PAGE_SIZE": {
"description": "How many services should be displayed on dashboard page?",
"value": "5",
"required": false
},
"USE_RELATIVE_MAX_IN_BAR_VISUALIZATION": {
"description": "Should background bars be scaled to full width?",
"value": "True",
"required": false
}
}
}

View File

@ -17,7 +17,7 @@ spec:
spec:
containers:
- name: "shynet-webserver"
image: "milesmcc/shynet:edge" # Change to the version appropriate for you (e.g., :latest)
image: "milesmcc/shynet:dev"
imagePullPolicy: Always
envFrom:
- secretRef:
@ -42,7 +42,7 @@ spec:
spec:
containers:
- name: "shynet-celeryworker"
image: "milesmcc/shynet:edge" # Change to the version appropriate for you (e.g., :latest)
image: "milesmcc/shynet:dev"
command: ["./celeryworker.sh"]
imagePullPolicy: Always
envFrom:
@ -95,7 +95,7 @@ spec:
selector:
app: shynet-webserver
---
apiVersion: networking.k8s.io/v1
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
name: shynet-webserver-ingress

1017
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -20,7 +20,6 @@
"@fortawesome/fontawesome-free": "^5.15.1",
"a17t": "^0.5.1",
"apexcharts": "^3.24.0",
"datamaps": "^0.5.9",
"flag-icon-css": "^3.5.0",
"inter-ui": "^3.15.0",
"litepicker": "^2.0.11"

1752
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,44 +0,0 @@
[tool.poetry]
name = "shynet"
version = "0.13.1"
description = "Modern, privacy-friendly, and cookie-free web analytics."
authors = ["R. Miles McCain <github@sendmiles.email>"]
license = "Apache-2.0"
[tool.poetry.dependencies]
python = "^3.8"
Django = "^4"
django-allauth = "^0.45.0"
geoip2 = "^4.2.0"
whitenoise = "^5.3.0"
celery = "^5.2.2"
django-ipware = "^4.0.2"
PyYAML = "^5.4.1"
user-agents = "^2.2.0"
rules = "^3.0"
gunicorn = "^20.1.0"
psycopg2-binary = "^2.9.2"
redis = "^3.5.3"
django-redis-cache = "^3.0.0"
pycountry = "^20.7.3"
html2text = "^2020.1.16"
django-health-check = "^3.16.4"
django-npm = "^1.0.0"
python-dotenv = "^0.18.0"
django-debug-toolbar = "^3.2.1"
django-cors-headers = "^3.11.0"
[tool.poetry.dev-dependencies]
pytest-sugar = "^0.9.4"
factory-boy = "^3.2.0"
pytest-django = "^4.4.0"
django-coverage-plugin = "^2.0.0"
django-stubs = "^1.8.0"
mypy = "^0.910"
[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.black]
line-length = 88

View File

@ -1,29 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: a17t/templates/a17t/includes/pagination.html:5
#: a17t/templates/a17t/includes/pagination.html:7
msgid "Previous"
msgstr "Zurück"
#: a17t/templates/a17t/includes/pagination.html:10
#: a17t/templates/a17t/includes/pagination.html:12
msgid "Next"
msgstr "Vor"

View File

@ -1,29 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: a17t/templates/a17t/includes/pagination.html:5
#: a17t/templates/a17t/includes/pagination.html:7
msgid "Previous"
msgstr "上一頁"
#: a17t/templates/a17t/includes/pagination.html:10
#: a17t/templates/a17t/includes/pagination.html:12
msgid "Next"
msgstr "下一頁"

View File

@ -1,2 +1 @@
{% load i18n %}
<label class="label" for="{{field.auto_id}}">{% trans field.label %} {% if not field.field.required %}<span class="badge ~neutral">Optional</span>{% endif %}</label>
<label class="label" for="{{field.auto_id}}">{{ field.label }} {% if not field.field.required %}<span class="badge ~neutral">Optional</span>{% endif %}</label>

View File

@ -1,46 +1,45 @@
{% load i18n %}
<nav class="flex w-full flex-wrap items-center justify-between" role="navigation" aria-label="pagination">
<div class="w-full md:w-auto mb-2">
{% if page.has_previous %}
<a href="?page={{ page.previous_page_number }}&{{url_parameters}}" class="button field !low bg-neutral-000 w-auto mr-1">{% trans 'Previous' %}</a>
<a href="?page={{ page.previous_page_number }}&{{url_parameters}}" class="button field bg-neutral-000 w-auto mr-1">Previous</a>
{% else %}
<a class="button field !low bg-neutral-000 w-auto mr-1" disabled>{% trans 'Previous' %}</a>
<a class="button field bg-neutral-000 w-auto mr-1" disabled>Previous</a>
{% endif %}
{% if page.has_next %}
<a href="?page={{ page.next_page_number }}&{{url_parameters}}" class="button field !low bg-neutral-000 w-auto">{% trans 'Next' %}</a>
<a href="?page={{ page.next_page_number }}&{{url_parameters}}" class="button field bg-neutral-000 w-auto">Next</a>
{% else %}
<a class="button field !low bg-neutral-000 w-auto" disabled>{% trans 'Next' %}</a>
<a class="button field bg-neutral-000 w-auto" disabled>Next</a>
{% endif %}
</div>
<ul class="pagination-list w-full md:w-auto mb-2 flex">
{% for pnum in begin %}
{% if page.number == pnum %}
<li><a class="button field !low w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% ifequal page.number pnum %}
<li><a class="button field w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% else %}
<li><a class="button field !low bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endif %}
<li><a class="button field bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endifequal %}
{% endfor %}
{% if middle %}
<li><span class="pagination-ellipsis">&hellip;</span></li>
{% for pnum in middle %}
{% if page.number == pnum %}
<li><a class="button field !low w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% ifequal page.number pnum %}
<li><a class="button field w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% else %}
<li><a class="button field !low bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endif %}
<li><a class="button field bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endifequal %}
{% endfor %}
{% endif %}
{% if end %}
<li><span class="pagination-ellipsis">&hellip;</span></li>
{% for pnum in end %}
{% if page.number == pnum %}
<li><a class="button field !low w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% ifequal page.number pnum %}
<li><a class="button field w-auto mx-1 text-white bg-neutral-700">{{ pnum }}</a></li>
{% else %}
<li><a class="button field !low bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endif %}
<li><a class="button field bg-neutral-000 w-auto mx-1" href="?page={{ pnum }}&{{url_parameters}}">{{ pnum }}</a></li>
{% endifequal %}
{% endfor %}
{% endif %}
</ul>

View File

@ -1,118 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: analytics/models.py:18
msgid "Service"
msgstr "Dienst"
#: analytics/models.py:24
msgid "Identifier"
msgstr "Kennung"
#: analytics/models.py:29
msgid "Start time"
msgstr "Startzeit"
#: analytics/models.py:32
msgid "Last seen"
msgstr "Zuletzt gesehen"
#: analytics/models.py:36
msgid "User agent"
msgstr ""
#: analytics/models.py:37
msgid "Browser"
msgstr ""
#: analytics/models.py:38
msgid "Device"
msgstr "Gerät"
#: analytics/models.py:42
msgid "Phone"
msgstr ""
#: analytics/models.py:43
msgid "Tablet"
msgstr ""
#: analytics/models.py:44
msgid "Desktop"
msgstr ""
#: analytics/models.py:45
msgid "Robot"
msgstr ""
#: analytics/models.py:46
msgid "Other"
msgstr "Andere"
#: analytics/models.py:49
msgid "Device type"
msgstr "Gerätetyp"
#: analytics/models.py:51
msgid "OS"
msgstr "Betriessystem"
#: analytics/models.py:52
msgid "IP"
msgstr ""
#: analytics/models.py:55
msgid "Asn"
msgstr ""
#: analytics/models.py:56
msgid "Country"
msgstr "Land"
#: analytics/models.py:57
msgid "Longitude"
msgstr "Längengrad"
#: analytics/models.py:58
msgid "Latitude"
msgstr "Breitengrad"
#: analytics/models.py:59
msgid "Time zone"
msgstr "Zeitzone"
#: analytics/models.py:61
msgid "Is bounce"
msgstr "Absprung"
#: analytics/models.py:64 analytics/models.py:100
msgid "Session"
msgstr "Sitzung"
#: analytics/models.py:65
msgid "Sessions"
msgstr "Sitzungen"
#: analytics/models.py:122
msgid "Hit"
msgstr "Besuch"
#: analytics/models.py:123
msgid "Hits"
msgstr "Besuche"

View File

@ -1,118 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: analytics/models.py:18
msgid "Service"
msgstr "服務"
#: analytics/models.py:24
msgid "Identifier"
msgstr "識別碼"
#: analytics/models.py:29
msgid "Start time"
msgstr "開始時間"
#: analytics/models.py:32
msgid "Last seen"
msgstr "最後瀏覽"
#: analytics/models.py:36
msgid "User agent"
msgstr "使用者代理程式"
#: analytics/models.py:37
msgid "Browser"
msgstr "瀏覽器"
#: analytics/models.py:38
msgid "Device"
msgstr "裝置"
#: analytics/models.py:42
msgid "Phone"
msgstr "手機"
#: analytics/models.py:43
msgid "Tablet"
msgstr "平板"
#: analytics/models.py:44
msgid "Desktop"
msgstr "桌上型電腦"
#: analytics/models.py:45
msgid "Robot"
msgstr "機器人"
#: analytics/models.py:46
msgid "Other"
msgstr "其他"
#: analytics/models.py:49
msgid "Device type"
msgstr "裝置類型"
#: analytics/models.py:51
msgid "OS"
msgstr "作業系統"
#: analytics/models.py:52
msgid "IP"
msgstr "IP"
#: analytics/models.py:55
msgid "Asn"
msgstr "ASN"
#: analytics/models.py:56
msgid "Country"
msgstr "國家"
#: analytics/models.py:57
msgid "Longitude"
msgstr "經度"
#: analytics/models.py:58
msgid "Latitude"
msgstr "緯度"
#: analytics/models.py:59
msgid "Time zone"
msgstr "時區"
#: analytics/models.py:61
msgid "Is bounce"
msgstr "是否為跳出"
#: analytics/models.py:64 analytics/models.py:100
msgid "Session"
msgstr "工作階段"
#: analytics/models.py:65
msgid "Sessions"
msgstr "工作階段次數"
#: analytics/models.py:122
msgid "Hit"
msgstr "點選"
#: analytics/models.py:123
msgid "Hits"
msgstr "點選次數"

View File

@ -1,114 +0,0 @@
# Generated by Django 3.2.12 on 2022-06-24 11:44
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('core', '0009_auto_20211117_0217'),
('analytics', '0009_auto_20210329_1100'),
]
operations = [
migrations.AlterModelOptions(
name='hit',
options={'ordering': ['-start_time'], 'verbose_name': 'Hit', 'verbose_name_plural': 'Hits'},
),
migrations.AlterModelOptions(
name='session',
options={'ordering': ['-start_time'], 'verbose_name': 'Session', 'verbose_name_plural': 'Sessions'},
),
migrations.AlterField(
model_name='hit',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='hit',
name='session',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='analytics.session', verbose_name='Session'),
),
migrations.AlterField(
model_name='session',
name='asn',
field=models.TextField(blank=True, verbose_name='Asn'),
),
migrations.AlterField(
model_name='session',
name='browser',
field=models.TextField(verbose_name='Browser'),
),
migrations.AlterField(
model_name='session',
name='country',
field=models.TextField(blank=True, verbose_name='Country'),
),
migrations.AlterField(
model_name='session',
name='device',
field=models.TextField(verbose_name='Device'),
),
migrations.AlterField(
model_name='session',
name='device_type',
field=models.CharField(choices=[('PHONE', 'Phone'), ('TABLET', 'Tablet'), ('DESKTOP', 'Desktop'), ('ROBOT', 'Robot'), ('OTHER', 'Other')], default='OTHER', max_length=7, verbose_name='Device type'),
),
migrations.AlterField(
model_name='session',
name='identifier',
field=models.TextField(blank=True, db_index=True, verbose_name='Identifier'),
),
migrations.AlterField(
model_name='session',
name='ip',
field=models.GenericIPAddressField(db_index=True, null=True, verbose_name='IP'),
),
migrations.AlterField(
model_name='session',
name='is_bounce',
field=models.BooleanField(db_index=True, default=True, verbose_name='Is bounce'),
),
migrations.AlterField(
model_name='session',
name='last_seen',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now, verbose_name='Last seen'),
),
migrations.AlterField(
model_name='session',
name='latitude',
field=models.FloatField(null=True, verbose_name='Latitude'),
),
migrations.AlterField(
model_name='session',
name='longitude',
field=models.FloatField(null=True, verbose_name='Longitude'),
),
migrations.AlterField(
model_name='session',
name='os',
field=models.TextField(verbose_name='OS'),
),
migrations.AlterField(
model_name='session',
name='service',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.service', verbose_name='Service'),
),
migrations.AlterField(
model_name='session',
name='start_time',
field=models.DateTimeField(db_index=True, default=django.utils.timezone.now, verbose_name='Start time'),
),
migrations.AlterField(
model_name='session',
name='time_zone',
field=models.TextField(blank=True, verbose_name='Time zone'),
),
migrations.AlterField(
model_name='session',
name='user_agent',
field=models.TextField(verbose_name='User agent'),
),
]

View File

@ -3,7 +3,6 @@ import uuid
from django.db import models
from django.shortcuts import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from core.models import Service, ACTIVE_USER_TIMEDELTA
@ -14,56 +13,43 @@ def _default_uuid():
class Session(models.Model):
uuid = models.UUIDField(default=_default_uuid, primary_key=True)
service = models.ForeignKey(
Service, verbose_name=_("Service"), on_delete=models.CASCADE, db_index=True
)
service = models.ForeignKey(Service, on_delete=models.CASCADE, db_index=True)
# Cross-session identification; optional, and provided by the service
identifier = models.TextField(
blank=True, db_index=True, verbose_name=_("Identifier")
)
identifier = models.TextField(blank=True, db_index=True)
# Time
start_time = models.DateTimeField(
default=timezone.now, db_index=True, verbose_name=_("Start time")
)
last_seen = models.DateTimeField(
default=timezone.now, db_index=True, verbose_name=_("Last seen")
)
start_time = models.DateTimeField(default=timezone.now, db_index=True)
last_seen = models.DateTimeField(default=timezone.now, db_index=True)
# Core request information
user_agent = models.TextField(verbose_name=_("User agent"))
browser = models.TextField(verbose_name=_("Browser"))
device = models.TextField(verbose_name=_("Device"))
user_agent = models.TextField()
browser = models.TextField()
device = models.TextField()
device_type = models.CharField(
max_length=7,
choices=[
("PHONE", _("Phone")),
("TABLET", _("Tablet")),
("DESKTOP", _("Desktop")),
("ROBOT", _("Robot")),
("OTHER", _("Other")),
("PHONE", "Phone"),
("TABLET", "Tablet"),
("DESKTOP", "Desktop"),
("ROBOT", "Robot"),
("OTHER", "Other"),
],
default="OTHER",
verbose_name=_("Device type"),
)
os = models.TextField(verbose_name=_("OS"))
ip = models.GenericIPAddressField(db_index=True, null=True, verbose_name=_("IP"))
os = models.TextField()
ip = models.GenericIPAddressField(db_index=True, null=True)
# GeoIP data
asn = models.TextField(blank=True, verbose_name=_("Asn"))
country = models.TextField(blank=True, verbose_name=_("Country"))
longitude = models.FloatField(null=True, verbose_name=_("Longitude"))
latitude = models.FloatField(null=True, verbose_name=_("Latitude"))
time_zone = models.TextField(blank=True, verbose_name=_("Time zone"))
asn = models.TextField(blank=True)
country = models.TextField(blank=True)
longitude = models.FloatField(null=True)
latitude = models.FloatField(null=True)
time_zone = models.TextField(blank=True)
is_bounce = models.BooleanField(
default=True, db_index=True, verbose_name=_("Is bounce")
)
is_bounce = models.BooleanField(default=True, db_index=True)
class Meta:
verbose_name = _("Session")
verbose_name_plural = _("Sessions")
ordering = ["-start_time"]
indexes = [
models.Index(fields=["service", "-start_time"]),
@ -96,9 +82,7 @@ class Session(models.Model):
class Hit(models.Model):
session = models.ForeignKey(
Session, on_delete=models.CASCADE, db_index=True, verbose_name=_("Session")
)
session = models.ForeignKey(Session, on_delete=models.CASCADE, db_index=True)
initial = models.BooleanField(default=True, db_index=True)
# Base request information
@ -119,8 +103,6 @@ class Hit(models.Model):
service = models.ForeignKey(Service, on_delete=models.CASCADE, db_index=True)
class Meta:
verbose_name = _("Hit")
verbose_name_plural = _("Hits")
ordering = ["-start_time"]
indexes = [
models.Index(fields=["session", "-start_time"]),

View File

@ -61,7 +61,7 @@ def ingress_request(
log.debug(f"Linked to service {service}")
if dnt and service.respect_dnt:
log.debug("Ignoring because of DNT or GPC")
log.debug("Ignoring because of DNT")
return
try:

View File

@ -5,36 +5,21 @@
//
// This script only sends the current URL, the referrer URL, and the page load time. That's it!
{% if dnt %}
var Shynet = {
dnt: true
};
{% else %}
var Shynet = {
dnt: false,
idempotency: null,
heartbeatTaskId: null,
skipHeartbeat: false,
sendHeartbeat: function () {
try {
if (document.hidden || Shynet.skipHeartbeat) {
if (document.hidden) {
return;
}
Shynet.skipHeartbeat = true;
var xhr = new XMLHttpRequest();
xhr.open(
"POST",
"{{protocol}}://{{request.get_host}}{{endpoint}}",
"{{protocol}}://{{request.site.domain|default:request.META.HTTP_HOST}}{{endpoint}}",
true
);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.onload = function () {
Shynet.skipHeartbeat = false;
};
xhr.onerror = function () {
Shynet.skipHeartbeat = false;
};
xhr.send(
JSON.stringify({
idempotency: Shynet.idempotency,
@ -45,22 +30,19 @@ var Shynet = {
window.performance.timing.navigationStart,
})
);
} catch (e) {}
} catch (e) { }
},
newPageLoad: function () {
if (Shynet.heartbeatTaskId != null) {
clearInterval(Shynet.heartbeatTaskId);
}
Shynet.idempotency = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15);
Shynet.skipHeartbeat = false;
Shynet.heartbeatTaskId = setInterval(Shynet.sendHeartbeat, parseInt("{{heartbeat_frequency}}"));
Shynet.sendHeartbeat();
}
};
window.addEventListener("load", Shynet.newPageLoad);
{% endif %}
{% if script_inject %}
// The following is script is not part of Shynet, and was instead
@ -69,4 +51,4 @@ window.addEventListener("load", Shynet.newPageLoad);
// -- START --
{{script_inject|safe}}
// -- END --
{% endif %}
{% endif %}

View File

@ -15,7 +15,7 @@ from django.shortcuts import render, reverse
from django.utils import timezone
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt
from django.views.generic import View
from django.views.generic import TemplateView, View
from ipware import get_client_ip
from core.models import Service
@ -29,9 +29,6 @@ def ingress(request, service_uuid, identifier, tracker, payload):
location = request.META.get("HTTP_REFERER", "").strip()
user_agent = request.META.get("HTTP_USER_AGENT", "").strip()
dnt = request.META.get("HTTP_DNT", "0").strip() == "1"
gpc = request.META.get("HTTP_SEC_GPC", "0").strip() == "1"
if gpc or dnt:
dnt = True
ingress_request.delay(
service_uuid,
@ -119,7 +116,7 @@ class ScriptView(ValidateServiceOriginsMixin, View):
"service_uuid": self.kwargs.get("service_uuid"),
},
)
if self.kwargs.get("identifier") is None
if self.kwargs.get("identifier") == None
else reverse(
"ingress:endpoint_script_id",
kwargs={
@ -129,9 +126,6 @@ class ScriptView(ValidateServiceOriginsMixin, View):
)
)
heartbeat_frequency = settings.SCRIPT_HEARTBEAT_FREQUENCY
dnt = self.request.META.get("HTTP_DNT", "0").strip() == "1"
service_uuid = self.kwargs.get("service_uuid")
service = Service.objects.get(pk=service_uuid, status=Service.ACTIVE)
return render(
self.request,
"analytics/scripts/page.js",
@ -141,7 +135,6 @@ class ScriptView(ValidateServiceOriginsMixin, View):
"protocol": protocol,
"heartbeat_frequency": heartbeat_frequency,
"script_inject": self.get_script_inject(),
"dnt": dnt and service.respect_dnt,
}
),
content_type="application/javascript",
@ -163,7 +156,7 @@ class ScriptView(ValidateServiceOriginsMixin, View):
def get_script_inject(self):
service_uuid = self.kwargs.get("service_uuid")
script_inject = cache.get(f"script_inject_{service_uuid}")
if script_inject is None:
if script_inject == None:
service = Service.objects.get(uuid=service_uuid)
script_inject = service.script_inject
cache.set(f"script_inject_{service_uuid}", script_inject, timeout=3600)

View File

@ -1 +0,0 @@
# from django.contrib import admin

View File

@ -1,6 +0,0 @@
from django.apps import AppConfig
class ApiConfig(AppConfig):
default_auto_field = "django.db.models.BigAutoField"
name = "api"

View File

@ -1,26 +0,0 @@
from http import HTTPStatus
from django.contrib.auth import get_user_model
from django.contrib.auth.models import AnonymousUser
from django.http import JsonResponse
User = get_user_model()
class ApiTokenRequiredMixin:
def _get_user_by_token(self, request):
token = request.headers.get("Authorization")
if not token or not token.startswith("Token "):
return AnonymousUser()
token = token.split(" ")[1]
user: User = User.objects.filter(api_token=token).first()
return user or AnonymousUser()
def dispatch(self, request, *args, **kwargs):
request.user = self._get_user_by_token(request)
return (
super().dispatch(request, *args, **kwargs)
if request.user.is_authenticated
else JsonResponse(data={}, status=HTTPStatus.FORBIDDEN)
)

View File

@ -1 +0,0 @@
# from django.db import models

View File

@ -1,77 +0,0 @@
from http import HTTPStatus
from django.test import TestCase, RequestFactory
from django.views import View
from api.mixins import ApiTokenRequiredMixin
from core.factories import UserFactory
from core.models import _default_api_token, Service
class TestApiTokenRequiredMixin(TestCase):
class DummyView(ApiTokenRequiredMixin, View):
model = Service
template_name = "dashboard/pages/service.html"
def setUp(self):
super().setUp()
self.user = UserFactory()
self.request = RequestFactory().get("/fake-path")
# Setup request and view.
self.factory = RequestFactory()
self.view = self.DummyView()
def test_get_user_by_token_without_authorization_token(self):
"""
GIVEN: A request without Authorization header
WHEN: get_user_by_token is called
THEN: It should return AnonymousUser
"""
user = self.view._get_user_by_token(self.request)
self.assertEqual(user.is_anonymous, True)
def test_get_user_by_token_with_invalid_authorization_token(self):
"""
GIVEN: A request with invalid Authorization header
WHEN: get_user_by_token is called
THEN: It should return AnonymousUser
"""
self.request.META["HTTP_AUTHORIZATION"] = "Bearer invalid-token"
user = self.view._get_user_by_token(self.request)
self.assertEqual(user.is_anonymous, True)
def test_get_user_by_token_with_invalid_token(self):
"""
GIVEN: A request with invalid token
WHEN: get_user_by_token is called
THEN: It should return AnonymousUser
"""
self.request.META["HTTP_AUTHORIZATION"] = f"Token {_default_api_token()}"
user = self.view._get_user_by_token(self.request)
self.assertEqual(user.is_anonymous, True)
def test_get_user_by_token_with_valid_token(self):
"""
GIVEN: A request with valid token
WHEN: get_user_by_token is called
THEN: It should return the user
"""
self.request.META["HTTP_AUTHORIZATION"] = f"Token {self.user.api_token}"
user = self.view._get_user_by_token(self.request)
self.assertEqual(user, self.user)
def test_dispatch_with_unauthenticated_user(self):
"""
GIVEN: A request with unauthenticated user
WHEN: dispatch is called
THEN: It should return 403
"""
self.request.META["HTTP_AUTHORIZATION"] = f"Token {_default_api_token()}"
response = self.view.dispatch(self.request)
self.assertEqual(response.status_code, HTTPStatus.FORBIDDEN)

View File

@ -1,79 +0,0 @@
import json
from http import HTTPStatus
from django.contrib.auth import get_user_model
from django.test import TestCase, RequestFactory
from django.urls import reverse
from api.views import DashboardApiView
from core.factories import UserFactory, ServiceFactory
from core.models import Service
User = get_user_model()
class TestDashboardApiView(TestCase):
def setUp(self) -> None:
super().setUp()
self.user: User = UserFactory()
self.service_1: Service = ServiceFactory(owner=self.user)
self.service_2: Service = ServiceFactory(owner=self.user)
self.url = reverse("api:services")
self.factory = RequestFactory()
def test_get_with_unauthenticated_user(self):
"""
GIVEN: An unauthenticated user
WHEN: The user makes a GET request to the dashboard API view
THEN: It should return 403
"""
response = self.client.get(self.url)
self.assertEqual(response.status_code, HTTPStatus.FORBIDDEN)
def test_get_returns_400(self):
"""
GIVEN: An authenticated user
WHEN: The user makes a GET request to the dashboard API view with an invalid date format
THEN: It should return 400
"""
request = self.factory.get(self.url, {"startDate": "01/01/2000"})
request.META["HTTP_AUTHORIZATION"] = f"Token {self.user.api_token}"
response = DashboardApiView.as_view()(request)
self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST)
data = json.loads(response.content)
self.assertEqual(data["error"], "Invalid date format. Use YYYY-MM-DD.")
def test_get_with_authenticated_user(self):
"""
GIVEN: An authenticated user
WHEN: The user makes a GET request to the dashboard API view
THEN: It should return 200
"""
request = self.factory.get(self.url)
request.META["HTTP_AUTHORIZATION"] = f"Token {self.user.api_token}"
response = DashboardApiView.as_view()(request)
self.assertEqual(response.status_code, HTTPStatus.OK)
data = json.loads(response.content)
self.assertEqual(len(data["services"]), 2)
def test_get_with_service_uuid(self):
"""
GIVEN: An authenticated user
WHEN: The user makes a GET request to the dashboard API view with a service UUID
THEN: It should return 200 and a single service
"""
request = self.factory.get(self.url, {"uuid": str(self.service_1.uuid)})
request.META["HTTP_AUTHORIZATION"] = f"Token {self.user.api_token}"
response = DashboardApiView.as_view()(request)
self.assertEqual(response.status_code, HTTPStatus.OK)
data = json.loads(response.content)
self.assertEqual(len(data["services"]), 1)
self.assertEqual(data["services"][0]["uuid"], str(self.service_1.uuid))
self.assertEqual(data["services"][0]["name"], str(self.service_1.name))

View File

@ -1,7 +0,0 @@
from django.urls import path
from . import views
urlpatterns = [
path("dashboard/", views.DashboardApiView.as_view(), name="services"),
]

View File

@ -1,52 +0,0 @@
from http import HTTPStatus
from django.db.models import Q
from django.db.models.query import QuerySet
from django.http import JsonResponse
from django.views.generic import View
from core.models import Service
from core.utils import is_valid_uuid
from dashboard.mixins import DateRangeMixin
from .mixins import ApiTokenRequiredMixin
class DashboardApiView(ApiTokenRequiredMixin, DateRangeMixin, View):
def get(self, request, *args, **kwargs):
services = Service.objects.filter(Q(owner=request.user) | Q(collaborators__in=[request.user])).distinct()
uuid_ = request.GET.get("uuid")
if uuid_ and is_valid_uuid(uuid_):
services = services.filter(uuid=uuid_)
try:
start = self.get_start_date()
end = self.get_end_date()
except ValueError:
return JsonResponse(status=HTTPStatus.BAD_REQUEST, data={"error": "Invalid date format. Use YYYY-MM-DD."})
service: Service
services_data = [
{
"name": service.name,
"uuid": service.uuid,
"link": service.link,
"stats": service.get_core_stats(start, end),
}
for service in services
]
services_data = self._convert_querysets_to_lists(services_data)
return JsonResponse(data={"services": services_data})
def _convert_querysets_to_lists(self, services_data: list[dict]) -> list[dict]:
for service_data in services_data:
for key, value in service_data["stats"].items():
if isinstance(value, QuerySet):
service_data["stats"][key] = list(value)
for key, value in service_data["stats"]["compare"].items():
if isinstance(value, QuerySet):
service_data["stats"]["compare"][key] = list(value)
return services_data

View File

@ -1,15 +1,8 @@
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
from django.contrib.auth.admin import UserAdmin
from .models import Service, User
class UserAdmin(BaseUserAdmin):
fieldsets = BaseUserAdmin.fieldsets + (
("Extra fields", {"fields": ("api_token",)}),
)
admin.site.register(User, UserAdmin)

View File

@ -1,39 +0,0 @@
import factory
from django.contrib.auth import get_user_model
from factory import post_generation
from factory.django import DjangoModelFactory
from .models import Service
class UserFactory(DjangoModelFactory):
username = factory.Faker("user_name")
email = factory.Faker("email")
first_name = factory.Faker("name")
@post_generation
def password(self, create, extracted, **kwargs):
password = (
extracted
or factory.Faker(
"password",
length=42,
special_chars=True,
digits=True,
upper_case=True,
lower_case=True,
).evaluate(None, None, extra={"locale": None})
)
self.set_password(password)
class Meta:
model = get_user_model()
django_get_or_create = ["username"]
class ServiceFactory(DjangoModelFactory):
class Meta:
model = Service
name = factory.Faker("company")

View File

@ -1,87 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: core/models.py:58
msgid "Active"
msgstr "Aktiv"
#: core/models.py:58
msgid "Archived"
msgstr "Archiviert"
#: core/models.py:61
msgid "Name"
msgstr "Name"
#: core/models.py:63
msgid "Owner"
msgstr "Eigentümer"
#: core/models.py:67
msgid "Collaborators"
msgstr "Mitarbeiter"
#: core/models.py:70
msgid "created"
msgstr "Erstellt"
#: core/models.py:71
msgid "link"
msgstr "Verweis"
#: core/models.py:72
msgid "origins"
msgstr ""
#: core/models.py:75
msgid "status"
msgstr "Status"
#: core/models.py:77
msgid "Respect dnt"
msgstr "DNT beachten"
#: core/models.py:78
msgid "Ignore robots"
msgstr "Robots ignorieren"
#: core/models.py:79
msgid "Collect ips"
msgstr "IPs erfassen"
#: core/models.py:82
msgid "Igored ips"
msgstr "IPs ignorieren"
#: core/models.py:86
msgid "Hide referrer regex"
msgstr "Referrer Regex ausblenden"
#: core/models.py:88
msgid "Script inject"
msgstr ""
#: core/models.py:91
msgid "Service"
msgstr "Dienst"
#: core/models.py:92
msgid "Services"
msgstr "Dienste"

View File

@ -0,0 +1,247 @@
#: account/adapter.py:51
msgid "A user is already registered with this e-mail address."
msgstr "A user is already registered with this email address."
#: account/adapter.py:294
#, python-brace-format
msgid "Password must be a minimum of {0} characters."
msgstr ""
#: account/forms.py:92
msgid "Remember Me"
msgstr "Remember me"
#: account/forms.py:101
msgid "The e-mail address and/or password you specified are not correct."
msgstr "The email address and/or password are not correct."
#: account/forms.py:113 account/forms.py:268 account/forms.py:426
#: account/forms.py:495
msgid "E-mail address"
msgstr "Email address"
#: account/forms.py:115 account/forms.py:301 account/forms.py:421
#: account/forms.py:490
msgid "E-mail"
msgstr "Email"
#: account/forms.py:130
msgid "Username or e-mail"
msgstr "Username or email"
#: account/forms.py:292
msgid "E-mail (again)"
msgstr "Email (again)"
#: account/forms.py:296
msgid "E-mail address confirmation"
msgstr "Email address confirmation"
#: account/forms.py:304
msgid "E-mail (optional)"
msgstr "Email (optional)"
#: account/forms.py:432
msgid "This e-mail address is already associated with this account."
msgstr "This email address is already associated with this account."
#: account/forms.py:434
msgid "This e-mail address is already associated with another account."
msgstr "This email address is already associated with another account."
#: account/forms.py:504
msgid "The e-mail address is not assigned to any user account"
msgstr "The email address is not assigned to any user account."
#: account/models.py:25 account/models.py:78
msgid "e-mail address"
msgstr "email address"
#: socialaccount/adapter.py:26
#, python-format
msgid ""
"An account already exists with this e-mail address. Please sign in to that "
"account first, then connect your %s account."
msgstr ""
"An account already exists with this email address. Please sign in to that "
"account first, then connect your %s account."
#: socialaccount/adapter.py:138
msgid "Your account has no verified e-mail address."
msgstr "Your account has no verified email address."
#: templates/account/email.html:8
msgid "E-mail Addresses"
msgstr "Email Addresses"
#: templates/account/email.html:10
msgid "The following e-mail addresses are associated with your account:"
msgstr "The following email addresses are associated with your account:"
#: templates/account/email.html:43
msgid ""
"You currently do not have any e-mail address set up. You should really add "
"an e-mail address so you can receive notifications, reset your password, etc."
msgstr ""
"You currently do not have any email address set up. You should really add "
"an email address so you can receive notifications, reset your password, etc."
#: templates/account/email.html:48
msgid "Add E-mail Address"
msgstr "Add Email Address"
#: templates/account/email.html:53
msgid "Add E-mail"
msgstr "Add Email"
#: templates/account/email.html:62
msgid "Do you really want to remove the selected e-mail address?"
msgstr "Do you really want to remove the selected email address?"
#: templates/account/email/email_confirmation_message.txt:1
#, python-format
msgid ""
"Hello from %(site_name)s!\n"
"\n"
"You're receiving this e-mail because user %(user_display)s has given yours "
"as an e-mail address to connect their account.\n"
"\n"
"To confirm this is correct, go to %(activate_url)s\n"
msgstr ""
"Hello from %(site_name)s!\n"
"\n"
"You're receiving this email because user %(user_display)s has given yours "
"as an email address to connect their account.\n"
"\n"
"To confirm this is correct, go to %(activate_url)s\n"
#: templates/account/email/email_confirmation_message.txt:7
#, python-format
msgid ""
"Thank you from %(site_name)s!\n"
"%(site_domain)s"
msgstr ""
#: templates/account/email/email_confirmation_subject.txt:3
msgid "Please Confirm Your E-mail Address"
msgstr "Please Confirm Your Email Address"
#: templates/account/email/password_reset_key_message.txt:1
#, python-format
msgid ""
"Hello from %(site_name)s!\n"
"\n"
"You're receiving this e-mail because you or someone else has requested a "
"password for your user account.\n"
"It can be safely ignored if you did not request a password reset. Click the "
"link below to reset your password."
msgstr ""
"Hello from %(site_name)s!\n"
"\n"
"You're receiving this email because you or someone else has requested a "
"password for your user account.\n"
"It can be safely ignored if you did not request a password reset. Click the "
"link below to reset your password."
#: templates/account/email/password_reset_key_subject.txt:3
msgid "Password Reset E-mail"
msgstr "Password Reset Email"
#: templates/account/email_confirm.html:6
#: templates/account/email_confirm.html:10
msgid "Confirm E-mail Address"
msgstr "Confirm Email Address"
#: templates/account/email_confirm.html:16
#, python-format
msgid ""
"Please confirm that <a href=\"mailto:%(email)s\">%(email)s</a> is an e-mail "
"address for user %(user_display)s."
msgstr ""
"Please confirm that <a href=\"mailto:%(email)s\">%(email)s</a> is an email "
"address for user %(user_display)s."
#: templates/account/email_confirm.html:27
#, python-format
msgid ""
"This e-mail confirmation link expired or is invalid. Please <a href="
"\"%(email_url)s\">issue a new e-mail confirmation request</a>."
msgstr ""
"This email confirmation link expired or is invalid. Please <a href="
"\"%(email_url)s\">issue a new email confirmation request</a>."
#: templates/account/messages/cannot_delete_primary_email.txt:2
#, python-format
msgid "You cannot remove your primary e-mail address (%(email)s)."
msgstr "You cannot remove your primary email address (%(email)s)."
#: templates/account/messages/email_confirmation_sent.txt:2
#, python-format
msgid "Confirmation e-mail sent to %(email)s."
msgstr "Confirmation email sent to %(email)s."
#: templates/account/messages/email_deleted.txt:2
#, python-format
msgid "Removed e-mail address %(email)s."
msgstr "Removed email address %(email)s."
#: templates/account/messages/primary_email_set.txt:2
msgid "Primary e-mail address set."
msgstr "Primary email address set."
#: templates/account/messages/unverified_primary_email.txt:2
msgid "Your primary e-mail address must be verified."
msgstr "Your primary email address must be verified."
#: templates/account/password_reset.html:15
msgid ""
"Forgotten your password? Enter your e-mail address below, and we'll send you "
"an e-mail allowing you to reset it."
msgstr ""
"Forgotten your password? Enter your email address below, and we'll send you "
"an email allowing you to reset it."
#: templates/account/password_reset_done.html:15
msgid ""
"We have sent you an e-mail. Please contact us if you do not receive it "
"within a few minutes."
msgstr ""
"We have sent you an email. Please contact us if you do not receive it "
"within a few minutes."
#: templates/account/verification_sent.html:5
#: templates/account/verification_sent.html:8
#: templates/account/verified_email_required.html:5
#: templates/account/verified_email_required.html:8
msgid "Verify Your E-mail Address"
msgstr "Verify Your Email Address"
#: templates/account/verification_sent.html:10
msgid ""
"We have sent an e-mail to you for verification. Follow the link provided to "
"finalize the signup process. Please contact us if you do not receive it "
"within a few minutes."
msgstr ""
"We have sent an email to you for verification. Follow the link provided to "
"finalize the signup process. Please contact us if you do not receive it "
"within a few minutes."
#: templates/account/verified_email_required.html:12
msgid ""
"This part of the site requires us to verify that\n"
"you are who you claim to be. For this purpose, we require that you\n"
"verify ownership of your e-mail address. "
msgstr ""
"This part of the site requires us to verify that\n"
"you are who you claim to be. For this purpose, we require that you\n"
"verify ownership of your email address. "
#: templates/account/verified_email_required.html:16
msgid ""
"We have sent an e-mail to you for\n"
"verification. Please click on the link inside this e-mail. Please\n"
"contact us if you do not receive it within a few minutes."
msgstr ""
"We have sent an email to you for\n"
"verification. Please click on the link inside this email. Please\n"
"contact us if you do not receive it within a few minutes."

View File

@ -1,87 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:20+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: core/models.py:58
msgid "Active"
msgstr "啟用"
#: core/models.py:58
msgid "Archived"
msgstr "已封存"
#: core/models.py:61
msgid "Name"
msgstr "名稱"
#: core/models.py:63
msgid "Owner"
msgstr "擁有者"
#: core/models.py:67
msgid "Collaborators"
msgstr "協作者"
#: core/models.py:70
msgid "created"
msgstr "已建立"
#: core/models.py:71
msgid "link"
msgstr "連結"
#: core/models.py:72
msgid "origins"
msgstr "來源"
#: core/models.py:75
msgid "status"
msgstr "狀態"
#: core/models.py:77
msgid "Respect dnt"
msgstr "尊重停止追蹤 (Do Not Track) 設定"
#: core/models.py:78
msgid "Ignore robots"
msgstr "忽略機器人"
#: core/models.py:79
msgid "Collect ips"
msgstr "收集 IP"
#: core/models.py:82
msgid "Igored ips"
msgstr "忽略的 IP"
#: core/models.py:86
msgid "Hide referrer regex"
msgstr "隱藏來源參照正規表達式"
#: core/models.py:88
msgid "Script inject"
msgstr "插入指令碼"
#: core/models.py:91
msgid "Service"
msgstr "服務"
#: core/models.py:92
msgid "Services"
msgstr "服務"

View File

@ -0,0 +1,35 @@
import traceback
import uuid
from django.conf import settings
from django.contrib.sites.models import Site
from django.core.management.base import BaseCommand, CommandError
from django.utils.crypto import get_random_string
from core.models import User
class Command(BaseCommand):
help = "Configures the Shynet hostname"
def add_arguments(self, parser):
parser.add_argument(
"hostname",
type=str,
)
def handle(self, *args, **options):
site = Site.objects.get(pk=settings.SITE_ID)
site.domain = options.get("hostname")
if options.get("hostname").lower().startswith("http"):
self.stdout.write(
self.style.WARNING(
f"Warning: the hostname '{options.get('hostname')}' starts with `http`. You almost certainly don't want this. The hostname is supposed to be the raw domain name of your Shynet instance, without `http://` or `https://`. For example, if your Shynet instance will eventually be hosted at `https://analytics.example.com`, the hostname should be `analytics.example.com`."
)
)
site.save()
self.stdout.write(
self.style.SUCCESS(
f"Successfully set the hostname to '{options.get('hostname')}'"
)
)

View File

@ -20,7 +20,7 @@ class Command(BaseCommand):
def handle(self, *args, **options):
email = options.get("email")
password = get_random_string(10)
password = get_random_string()
User.objects.create_superuser(str(uuid.uuid4()), email=email, password=password)
self.stdout.write(self.style.SUCCESS("Successfully created a Shynet superuser"))
self.stdout.write(f"Email address: {email}")

View File

@ -35,9 +35,15 @@ class Command(BaseCommand):
def handle(self, *args, **options):
migration = self.check_migrations()
admin, whitelabel = [True] * 2
admin, hostname, whitelabel = [True] * 3
if not migration:
admin = not User.objects.all().exists()
hostname = (
not Site.objects.filter(domain__isnull=False)
.exclude(domain__exact="")
.exclude(domain__exact="example.com")
.exists()
)
whitelabel = (
not Site.objects.filter(name__isnull=False)
.exclude(name__exact="")
@ -45,4 +51,6 @@ class Command(BaseCommand):
.exists()
)
self.stdout.write(self.style.SUCCESS(f"{migration} {admin} {whitelabel}"))
self.stdout.write(
self.style.SUCCESS(f"{migration} {admin} {hostname} {whitelabel}")
)

View File

@ -1,24 +0,0 @@
# Generated by Django 3.2.5 on 2021-11-17 07:17
import core.models
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('core', '0008_auto_20200628_1403'),
]
operations = [
migrations.AddField(
model_name='user',
name='api_token',
field=models.TextField(null=True, unique=True),
),
migrations.AlterField(
model_name='user',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]

View File

@ -1,89 +0,0 @@
# Generated by Django 3.2.12 on 2022-06-24 11:44
import core.models
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('core', '0009_auto_20211117_0217'),
]
operations = [
migrations.AlterModelOptions(
name='service',
options={'ordering': ['name', 'uuid'], 'verbose_name': 'Service', 'verbose_name_plural': 'Services'},
),
migrations.AlterField(
model_name='service',
name='collaborators',
field=models.ManyToManyField(blank=True, related_name='collaborating_services', to=settings.AUTH_USER_MODEL, verbose_name='Collaborators'),
),
migrations.AlterField(
model_name='service',
name='collect_ips',
field=models.BooleanField(default=True, verbose_name='Collect ips'),
),
migrations.AlterField(
model_name='service',
name='created',
field=models.DateTimeField(auto_now_add=True, verbose_name='created'),
),
migrations.AlterField(
model_name='service',
name='hide_referrer_regex',
field=models.TextField(blank=True, default='', validators=[core.models._validate_regex], verbose_name='Hide referrer regex'),
),
migrations.AlterField(
model_name='service',
name='ignore_robots',
field=models.BooleanField(default=False, verbose_name='Ignore robots'),
),
migrations.AlterField(
model_name='service',
name='ignored_ips',
field=models.TextField(blank=True, default='', validators=[core.models._validate_network_list], verbose_name='Igored ips'),
),
migrations.AlterField(
model_name='service',
name='link',
field=models.URLField(blank=True, verbose_name='link'),
),
migrations.AlterField(
model_name='service',
name='name',
field=models.TextField(max_length=64, verbose_name='Name'),
),
migrations.AlterField(
model_name='service',
name='origins',
field=models.TextField(default='*', verbose_name='origins'),
),
migrations.AlterField(
model_name='service',
name='owner',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='owning_services', to=settings.AUTH_USER_MODEL, verbose_name='Owner'),
),
migrations.AlterField(
model_name='service',
name='respect_dnt',
field=models.BooleanField(default=True, verbose_name='Respect dnt'),
),
migrations.AlterField(
model_name='service',
name='script_inject',
field=models.TextField(blank=True, default='', verbose_name='Script inject'),
),
migrations.AlterField(
model_name='service',
name='status',
field=models.CharField(choices=[('AC', 'Active'), ('AR', 'Archived')], db_index=True, default='AC', max_length=2, verbose_name='status'),
),
migrations.AlterField(
model_name='user',
name='id',
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID'),
),
]

View File

@ -1,25 +1,22 @@
import ipaddress
import json
import re
import uuid
from secrets import token_urlsafe
from django.apps import apps
from django.conf import settings
from django.contrib.auth.models import AbstractUser
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.functions import TruncDate, TruncHour
from django.db.models.functions import TruncDate
from django.db.utils import NotSupportedError
from django.shortcuts import reverse
from django.utils import timezone
from django.utils.translation import gettext_lazy as _
# How long a session a needs to go without an update to no longer be considered 'active' (i.e., currently online)
ACTIVE_USER_TIMEDELTA = timezone.timedelta(
milliseconds=settings.SCRIPT_HEARTBEAT_FREQUENCY * 2
)
RESULTS_LIMIT = 300
def _default_uuid():
@ -46,14 +43,9 @@ def _parse_network_list(networks: str):
return [ipaddress.ip_network(network.strip()) for network in networks.split(",")]
def _default_api_token():
return token_urlsafe(32)
class User(AbstractUser):
username = models.TextField(default=_default_uuid, unique=True)
email = models.EmailField(unique=True)
api_token = models.TextField(default=_default_api_token, unique=True)
def __str__(self):
return self.email
@ -62,54 +54,34 @@ class User(AbstractUser):
class Service(models.Model):
ACTIVE = "AC"
ARCHIVED = "AR"
SERVICE_STATUSES = [(ACTIVE, _("Active")), (ARCHIVED, _("Archived"))]
SERVICE_STATUSES = [(ACTIVE, "Active"), (ARCHIVED, "Archived")]
uuid = models.UUIDField(default=_default_uuid, primary_key=True)
name = models.TextField(max_length=64, verbose_name=_("Name"))
name = models.TextField(max_length=64)
owner = models.ForeignKey(
User,
verbose_name=_("Owner"),
on_delete=models.CASCADE,
related_name="owning_services",
User, on_delete=models.CASCADE, related_name="owning_services"
)
collaborators = models.ManyToManyField(
User,
verbose_name=_("Collaborators"),
related_name="collaborating_services",
blank=True,
User, related_name="collaborating_services", blank=True
)
created = models.DateTimeField(auto_now_add=True, verbose_name=_("created"))
link = models.URLField(blank=True, verbose_name=_("link"))
origins = models.TextField(default="*", verbose_name=_("origins"))
created = models.DateTimeField(auto_now_add=True)
link = models.URLField(blank=True)
origins = models.TextField(default="*")
status = models.CharField(
max_length=2,
choices=SERVICE_STATUSES,
default=ACTIVE,
db_index=True,
verbose_name=_("status"),
max_length=2, choices=SERVICE_STATUSES, default=ACTIVE, db_index=True
)
respect_dnt = models.BooleanField(default=True, verbose_name=_("Respect dnt"))
ignore_robots = models.BooleanField(default=False, verbose_name=_("Ignore robots"))
collect_ips = models.BooleanField(default=True, verbose_name=_("Collect ips"))
respect_dnt = models.BooleanField(default=True)
ignore_robots = models.BooleanField(default=False)
collect_ips = models.BooleanField(default=True)
ignored_ips = models.TextField(
default="",
blank=True,
validators=[_validate_network_list],
verbose_name=_("Igored ips"),
default="", blank=True, validators=[_validate_network_list]
)
hide_referrer_regex = models.TextField(
default="",
blank=True,
validators=[_validate_regex],
verbose_name=_("Hide referrer regex"),
)
script_inject = models.TextField(
default="", blank=True, verbose_name=_("Script inject")
default="", blank=True, validators=[_validate_regex]
)
script_inject = models.TextField(default="", blank=True)
class Meta:
verbose_name = _("Service")
verbose_name_plural = _("Services")
ordering = ["name", "uuid"]
def __str__(self):
@ -153,10 +125,8 @@ class Service(models.Model):
Session = apps.get_model("analytics", "Session")
Hit = apps.get_model("analytics", "Hit")
tz_now = timezone.now()
currently_online = Session.objects.filter(
service=self, last_seen__gt=tz_now - ACTIVE_USER_TIMEDELTA
service=self, last_seen__gt=timezone.now() - ACTIVE_USER_TIMEDELTA
).count()
sessions = Session.objects.filter(
@ -177,7 +147,7 @@ class Service(models.Model):
locations = (
hits.values("location")
.annotate(count=models.Count("location"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
referrer_ignore = self.get_ignored_referrer_regex()
@ -187,7 +157,7 @@ class Service(models.Model):
hits.filter(initial=True)
.values("referrer")
.annotate(count=models.Count("referrer"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
if not referrer_ignore.match(referrer["referrer"])
]
@ -195,31 +165,29 @@ class Service(models.Model):
countries = (
sessions.values("country")
.annotate(count=models.Count("country"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
operating_systems = (
sessions.values("os")
.annotate(count=models.Count("os"))
.order_by("-count")[:RESULTS_LIMIT]
sessions.values("os").annotate(count=models.Count("os")).order_by("-count")
)
browsers = (
sessions.values("browser")
.annotate(count=models.Count("browser"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
device_types = (
sessions.values("device_type")
.annotate(count=models.Count("device_type"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
devices = (
sessions.values("device")
.annotate(count=models.Count("device"))
.order_by("-count")[:RESULTS_LIMIT]
.order_by("-count")
)
avg_load_time = hits.aggregate(load_time__avg=models.Avg("load_time"))[
@ -228,37 +196,6 @@ class Service(models.Model):
avg_hits_per_session = hit_count / session_count if session_count > 0 else None
avg_session_duration = self._get_avg_session_duration(sessions, session_count)
chart_data, chart_tooltip_format, chart_granularity = self._get_chart_data(
sessions, hits, start_time, end_time, tz_now
)
return {
"currently_online": currently_online,
"session_count": session_count,
"hit_count": hit_count,
"has_hits": has_hits,
"bounce_rate_pct": bounce_count * 100 / session_count
if session_count > 0
else None,
"avg_session_duration": avg_session_duration,
"avg_load_time": avg_load_time,
"avg_hits_per_session": avg_hits_per_session,
"locations": locations,
"referrers": referrers,
"countries": countries,
"operating_systems": operating_systems,
"browsers": browsers,
"devices": devices,
"device_types": device_types,
"chart_data": chart_data,
"chart_tooltip_format": chart_tooltip_format,
"chart_granularity": chart_granularity,
"online": True,
}
def _get_avg_session_duration(self, sessions, session_count):
try:
avg_session_duration = sessions.annotate(
duration=models.F("last_seen") - models.F("start_time")
@ -273,77 +210,47 @@ class Service(models.Model):
if session_count == 0:
avg_session_duration = None
return avg_session_duration
def _get_chart_data(self, sessions, hits, start_time, end_time, tz_now):
# Show hourly chart for date ranges of 3 days or less, otherwise daily chart
if (end_time - start_time).days < 3:
chart_tooltip_format = "MM/dd HH:mm"
chart_granularity = "hourly"
sessions_per_hour = (
sessions.annotate(hour=TruncHour("start_time"))
.values("hour")
.annotate(count=models.Count("uuid"))
.order_by("hour")
)
chart_data = {
k["hour"]: {"sessions": k["count"], "hits": 0}
for k in sessions_per_hour
}
hits_per_hour = (
hits.annotate(hour=TruncHour("start_time"))
.values("hour")
.annotate(count=models.Count("id"))
.order_by("hour")
)
for k in hits_per_hour:
if k["hour"] not in chart_data:
chart_data[k["hour"]] = {"hits": k["count"], "sessions": 0}
else:
chart_data[k["hour"]]["hits"] = k["count"]
hours_range = range(int((end_time - start_time).total_seconds() / 3600) + 1)
for hour_offset in hours_range:
hour = start_time + timezone.timedelta(hours=hour_offset)
if hour not in chart_data and hour <= tz_now:
chart_data[hour] = {"sessions": 0, "hits": 0}
else:
chart_tooltip_format = "MMM d"
chart_granularity = "daily"
sessions_per_day = (
sessions.annotate(date=TruncDate("start_time"))
.values("date")
.annotate(count=models.Count("uuid"))
.order_by("date")
)
chart_data = {
k["date"]: {"sessions": k["count"], "hits": 0} for k in sessions_per_day
}
hits_per_day = (
hits.annotate(date=TruncDate("start_time"))
.values("date")
.annotate(count=models.Count("id"))
.order_by("date")
)
for k in hits_per_day:
if k["date"] not in chart_data:
chart_data[k["date"]] = {"hits": k["count"], "sessions": 0}
else:
chart_data[k["date"]]["hits"] = k["count"]
for day_offset in range((end_time - start_time).days + 1):
day = (start_time + timezone.timedelta(days=day_offset)).date()
if day not in chart_data and day <= tz_now.date():
chart_data[day] = {"sessions": 0, "hits": 0}
chart_data = sorted(chart_data.items(), key=lambda k: k[0])
chart_data = {
"sessions": [v["sessions"] for k, v in chart_data],
"hits": [v["hits"] for k, v in chart_data],
"labels": [str(k) for k, v in chart_data],
session_chart_data = {
k["date"]: k["count"]
for k in sessions.annotate(date=TruncDate("start_time"))
.values("date")
.annotate(count=models.Count("uuid"))
.order_by("date")
}
for day_offset in range((end_time - start_time).days + 1):
day = (start_time + timezone.timedelta(days=day_offset)).date()
if day not in session_chart_data:
session_chart_data[day] = 0
return chart_data, chart_tooltip_format, chart_granularity
return {
"currently_online": currently_online,
"session_count": session_count,
"hit_count": hit_count,
"has_hits": has_hits,
"avg_hits_per_session": hit_count / (max(session_count, 1)),
"bounce_rate_pct": bounce_count * 100 / session_count
if session_count > 0
else None,
"avg_session_duration": avg_session_duration,
"avg_load_time": avg_load_time,
"avg_hits_per_session": avg_hits_per_session,
"locations": locations,
"referrers": referrers,
"countries": countries,
"operating_systems": operating_systems,
"browsers": browsers,
"devices": devices,
"device_types": device_types,
"session_chart_data": json.dumps(
[
{"x": str(key), "y": value}
for key, value in sorted(
session_chart_data.items(), key=lambda k: k[0]
)
]
),
"online": True,
}
def get_absolute_url(self):
return reverse(

View File

@ -1 +0,0 @@

View File

@ -1,10 +0,0 @@
import uuid
def is_valid_uuid(value: str) -> bool:
"""Check if a string is a valid UUID."""
try:
uuid.UUID(value)
return True
except ValueError:
return False

View File

@ -25,25 +25,19 @@ class ServiceForm(forms.ModelForm):
"name": forms.TextInput(),
"origins": forms.TextInput(),
"ignored_ips": forms.TextInput(),
"respect_dnt": forms.RadioSelect(
choices=[(True, _("Yes")), (False, _("No"))]
),
"collect_ips": forms.RadioSelect(
choices=[(True, _("Yes")), (False, _("No"))]
),
"ignore_robots": forms.RadioSelect(
choices=[(True, _("Yes")), (False, _("No"))]
),
"respect_dnt": forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
"collect_ips": forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
"ignore_robots": forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
"hide_referrer_regex": forms.TextInput(),
"script_inject": forms.Textarea(attrs={"class": "font-mono", "rows": 5}),
}
labels = {
"origins": _("Allowed origins"),
"respect_dnt": _("Respect DNT"),
"ignored_ips": _("Ignored IP addresses"),
"ignore_robots": _("Ignore robots"),
"hide_referrer_regex": _("Hide specific referrers"),
"script_inject": _("Additional injected JS"),
"origins": "Allowed origins",
"respect_dnt": "Respect DNT",
"ignored_ips": "Ignored IP addresses",
"ignore_robots": "Ignore robots",
"hide_referrer_regex": "Hide specific referrers",
"script_inject": "Additional injected JS",
}
help_texts = {
"name": _("What should the service be called?"),
@ -51,30 +45,18 @@ class ServiceForm(forms.ModelForm):
"origins": _(
"At what origins does the service operate? Use commas to separate multiple values. This sets CORS headers, so use '*' if you're not sure (or don't care)."
),
"respect_dnt": _(
"Should visitors who have enabled <a href='https://en.wikipedia.org/wiki/Do_Not_Track'>Do Not Track</a> be excluded from all data?"
),
"ignored_ips": _(
"A comma-separated list of IP addresses or IP ranges (IPv4 and IPv6) to exclude from tracking (e.g., '192.168.0.2, 127.0.0.1/32')."
),
"ignore_robots": _(
"Should sessions generated by bots be excluded from tracking?"
),
"hide_referrer_regex": _(
"Any referrers that match this <a href='https://regexr.com/'>RegEx</a> will not be listed in the referrer summary. Sessions will still be tracked normally. No effect if left blank."
),
"script_inject": _(
"Optional additional JavaScript to inject at the end of the Shynet script. This code will be injected on every page where this service is installed."
),
"respect_dnt": "Should visitors who have enabled <a href='https://en.wikipedia.org/wiki/Do_Not_Track'>Do Not Track</a> be excluded from all data?",
"ignored_ips": "A comma-separated list of IP addresses or IP ranges (IPv4 and IPv6) to exclude from tracking (e.g., '192.168.0.2, 127.0.0.1/32').",
"ignore_robots": "Should sessions generated by bots be excluded from tracking?",
"hide_referrer_regex": "Any referrers that match this <a href='https://regexr.com/'>RegEx</a> will not be listed in the referrer summary. Sessions will still be tracked normally. No effect if left blank.",
"script_inject": "Optional additional JavaScript to inject at the end of the Shynet script. This code will be injected on every page where this service is installed.",
}
collect_ips = forms.BooleanField(
help_text=_("IP address collection is disabled globally by your administrator.")
help_text="IP address collection is disabled globally by your administrator."
if settings.BLOCK_ALL_IPS
else _(
"Should individual IP addresses be collected? IP metadata (location, host, etc) will still be collected."
),
widget=forms.RadioSelect(choices=[(True, _("Yes")), (False, _("No"))]),
else "Should individual IP addresses be collected? IP metadata (location, host, etc) will still be collected.",
widget=forms.RadioSelect(choices=[(True, "Yes"), (False, "No")]),
initial=False if settings.BLOCK_ALL_IPS else True,
required=False,
disabled=settings.BLOCK_ALL_IPS,
@ -86,9 +68,7 @@ class ServiceForm(forms.ModelForm):
return False if settings.BLOCK_ALL_IPS else collect_ips
collaborators = forms.CharField(
help_text=_(
"Which users on this Shynet instance should have read-only access to this service? (Comma separated list of emails.)"
),
help_text="Which users on this Shynet instance should have read-only access to this service? (Comma separated list of emails.)",
required=False,
)

View File

@ -1,698 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:43+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: forms.py:28 forms.py:29 forms.py:30 forms.py:59
msgid "Yes"
msgstr "Ja"
#: forms.py:28 forms.py:29 forms.py:30 forms.py:59
msgid "No"
msgstr "Nein"
#: forms.py:35
msgid "Allowed origins"
msgstr "Erlaubte origins"
#: forms.py:36
msgid "Respect DNT"
msgstr "DNT beachten"
#: forms.py:37
msgid "Ignored IP addresses"
msgstr "Ignorierte IP Adressen"
#: forms.py:38
msgid "Ignore robots"
msgstr "Robots ignorieren"
#: forms.py:39
msgid "Hide specific referrers"
msgstr "Bestimmte Referrer nicht zeigen"
#: forms.py:40
msgid "Additional injected JS"
msgstr "Zusätzlich injiziertes JS"
#: forms.py:43
msgid "What should the service be called?"
msgstr "Welchen Namen soll der Dienst haben?"
#: forms.py:44
msgid "What's the service's primary URL?"
msgstr "Was ist die primäre URL des Dienstes?"
#: forms.py:46
msgid ""
"At what origins does the service operate? Use commas to separate multiple "
"values. This sets CORS headers, so use '*' if you're not sure (or don't "
"care)."
msgstr ""
"Mit welchen origins arbeitet der Dienst? Verwenden Sie Kommas, um mehrere "
"Werte zu trennen. Dies setzt den CORS-Header. Verwenden Sie '*', wenn Sie "
"nicht sicher sind (oder es egal ist)."
#: forms.py:48
msgid ""
"Should visitors who have enabled <a href='https://en.wikipedia.org/wiki/"
"Do_Not_Track'>Do Not Track</a> be excluded from all data?"
msgstr ""
"Sollen Besucher, die <a href='https://en.wikipedia.org/wiki/Do_Not_Track'>Do "
"Not Track</a> aktiviert haben, von allen Daten ausgeschlossen werden?"
#: forms.py:49
msgid ""
"A comma-separated list of IP addresses or IP ranges (IPv4 and IPv6) to "
"exclude from tracking (e.g., '192.168.0.2, 127.0.0.1/32')."
msgstr ""
"Eine Komma-separierte Liste von IP Adressen oder IP Bereichen (IPv4 and "
"IPv6), die vom Tracking ausgeschlossen werden sollen (z.B. '192.168.0.2, "
"127.0.0.1/32')."
#: forms.py:50
msgid "Should sessions generated by bots be excluded from tracking?"
msgstr ""
"Sollten von Bots generierte Sitzungen vom Tracking ausgeschlossen werden?"
#: forms.py:51
msgid ""
"Any referrers that match this <a href='https://regexr.com/'>RegEx</a> will "
"not be listed in the referrer summary. Sessions will still be tracked "
"normally. No effect if left blank."
msgstr ""
"Alle Referrer, die diesem <a href='https://regexr.com/'>RegEx</a> "
"entsprechen, werden nicht in der Referrer-Zusammenfassung aufgeführt. Die "
"Sitzungen werden weiterhin normal verfolgt."
#: forms.py:52
msgid ""
"Optional additional JavaScript to inject at the end of the Shynet script. "
"This code will be injected on every page where this service is installed."
msgstr ""
"Optionales zusätzliches JavaScript, das am Ende des Shynet-Skripts eingefügt "
"wird. Dieser Code wird auf jeder Seite eingeschleust, auf der dieser Dienst "
"installiert ist."
#: forms.py:56
msgid "IP address collection is disabled globally by your administrator."
msgstr ""
"Die Erfassung von IP-Adressen wurde vom Administrator global deaktiviert."
#: forms.py:58
msgid ""
"Should individual IP addresses be collected? IP metadata (location, host, "
"etc) will still be collected."
msgstr ""
"Sollten einzelne IP-Adressen erfasst werden? IP-Metadaten (Standort, Host, "
"usw.) werden weiterhin erfasst."
#: forms.py:71
msgid ""
"Which users on this Shynet instance should have read-only access to this "
"service? (Comma separated list of emails.)"
msgstr ""
"Welche Benutzer dieser Shynet-Instanz sollen Lesezugriff auf diesen Dienst "
"haben? (Kommaseparierte Liste von E-Mails.)"
#: templates/account/account_inactive.html:5
#: templates/account/account_inactive.html:6
msgid "Account Inactive"
msgstr "Konto inaktiv"
#: templates/account/account_inactive.html:9
msgid "This account is inactive."
msgstr "Dieses Konto ist inaktiv"
#: templates/account/email.html:5 templates/account/email.html:6
msgid "Email Addresses"
msgstr "E-Mail Adressen"
#: templates/account/email.html:12
msgid "These are your known email addresses:"
msgstr "Ihre bekannten E-Mail Adressen:"
#: templates/account/email.html:26
msgid "Verified"
msgstr "Verifiziert"
#: templates/account/email.html:28
msgid "Unverified"
msgstr "Unverifiziert"
#: templates/account/email.html:30
msgid "Primary"
msgstr "Primär"
#: templates/account/email.html:36
msgid "Make Primary"
msgstr "Als primär kennzeichnen"
#: templates/account/email.html:37
msgid "Resend Verification"
msgstr "Verifikation erneut senden"
#: templates/account/email.html:38
msgid "Remove"
msgstr "Entfernen"
#: templates/account/email.html:46
msgid ""
"You currently do not have an email address associated with your account. "
"Without one, you won't be able to reset your password, receive "
"notifications, etc."
msgstr ""
"Sie haben noch keine E-Mail Adresse mit Ihrem Konto verknüpft. Ohne diese "
"können Sie Ihr Kennwort nicht zurücksetzen, keine Benachrichtigungen "
"erhalten etc."
#: templates/account/email.html:57
msgid "Add Address"
msgstr "Adresse hinzufügen"
#: templates/account/email.html:66
msgid "Do you really want to remove the selected email address?"
msgstr "Wollen Sie diese E-Mail Adresse wirkliche löschen?"
#: templates/account/email/email_confirmation_message.txt:1
#, python-format
msgid ""
"Hi there,\n"
"\n"
"You're receiving this email because %(user_display)s has listed this email "
"as a valid contact address for their account.\n"
"\n"
"To confirm this is correct, go to %(activate_url)s\n"
msgstr ""
"Hallo,\n"
"\n"
"Sie erhalten diese E-Mail, da der Benutzer %(user_display)s diese Adresse "
"als gültige Kontakt-Adressse für sein Konto angegeben hat.\n"
"\n"
"Um die E-Mail Adresse zu bestätigen, gehen Sie auf %(activate_url)s\n"
#: templates/account/email/email_confirmation_message.txt:7
#: templates/account/email/password_reset_key_message.txt:9
#, python-format
msgid ""
"Thank you,\n"
"%(site_name)s\n"
msgstr ""
#: templates/account/email/email_confirmation_subject.txt:3
#: templates/account/email_confirm.html:6
#: templates/account/email_confirm.html:7
msgid "Confirm Email Address"
msgstr "E-Mail Adresse bestätigen"
#: templates/account/email/password_reset_key_message.txt:1
msgid ""
"Hi there,\n"
"\n"
"You're receiving this email because you or someone else has requested a "
"password for your account.\n"
"\n"
"This message can be safely ignored if you did not request a password reset. "
"Click the link below to reset your password."
msgstr ""
"Hallo,\n"
"\n"
"Sie erhalten diese E-Mail, weil Sie oder jemand anderes ein Kennwort für Ihr "
"Konto angefordert hat.\n"
"\n"
"Sie können diese Nachricht ignorieren, wenn Sie kein Kennwort angefordert "
"haben. Klicken Sie auf den unten stehenden Link, um Ihr Kennwort "
"zurückzusetzen."
#: templates/account/email/password_reset_key_subject.txt:3
msgid "Password Reset Email"
msgstr "Kennwort zurücksetzen E-Mail"
#: templates/account/email_confirm.html:15
#, python-format
msgid ""
"Please confirm that <a\n"
" href=\"mailto:%(email)s\">%(email)s</a> is a valid email where we "
"can reach you."
msgstr ""
"Bitte bestätigen Sie, dass <a\n"
" href=\"mailto:%(email)s\">%(email)s</a> eine gültige E-Mail Adress "
"ist, unter der wie Sie erreichen können."
#: templates/account/email_confirm.html:21
msgid "Confirm"
msgstr "Bestätigen"
#: templates/account/email_confirm.html:28
#, python-format
msgid ""
"This email confirmation link expired or is invalid. Please <a href="
"\"%(email_url)s\">issue a new\n"
" email confirmation request</a>."
msgstr ""
"Diese Bestätigungs-E-Mail ist abgelaufen oder ungültig. Bitte <a href="
"\"%(email_url)s\">fordern Sie eine neue\n"
" Bestätigungs-E-Mail</a>. an"
#: templates/account/login.html:6 templates/account/login.html:7
#: templates/account/login.html:19
msgid "Sign In"
msgstr "Anmelden"
#: templates/account/login.html:20 templates/account/password_reset.html:21
msgid "Reset Password"
msgstr "Kennwort zurücksetzen"
#: templates/account/logout.html:5 templates/account/logout.html:6
#: templates/account/logout.html:16
msgid "Sign Out"
msgstr "Abmelden"
#: templates/account/logout.html:9
msgid "Are you sure you want to sign out?"
msgstr "Sind Sie sicher, dass Sie sich abmelden wollen?"
#: templates/account/messages/cannot_delete_primary_email.txt:2
#, python-format
msgid "You cannot remove your primary email address (%(email)s)."
msgstr "Sie können Ihre primäre E-Mail Adresse nicht entfernen (%(email)s)."
#: templates/account/messages/email_confirmation_sent.txt:2
#, python-format
msgid "Confirmation email sent to %(email)s."
msgstr "Bestätigungs-E-Mail gesendet an %(email)s."
#: templates/account/messages/email_confirmed.txt:2
#, python-format
msgid "Confirmed %(email)s."
msgstr "%(email)s bestätigt."
#: templates/account/messages/email_deleted.txt:2
#, python-format
msgid "Removed email address %(email)s."
msgstr "E-Mail-Adresse %(email)s entfernt."
#: templates/account/messages/logged_in.txt:4
#, python-format
msgid "Successfully signed in as %(name)s."
msgstr "Sid sind angemeldet als %(name)s"
#: templates/account/messages/logged_out.txt:2
msgid "You have signed out."
msgstr "Sie haben sich abgemeldet."
#: templates/account/messages/password_changed.txt:2
msgid "Password successfully changed."
msgstr "Ihr Kennwort wurde erfolgreich geändert."
#: templates/account/messages/password_set.txt:2
msgid "Password successfully set."
msgstr "Kennwort erfolgreich gesetzt."
#: templates/account/messages/primary_email_set.txt:2
msgid "New primary email address set."
msgstr "Eine neue primäre E-Mail Adresse wurde gesetzt."
#: templates/account/messages/unverified_primary_email.txt:2
msgid "Your primary email address must be verified."
msgstr "Ihre primäre E-Mail-Adresse muss verifiziert werden."
#: templates/account/password_change.html:5
#: templates/account/password_change.html:6
#: templates/account/password_change.html:12
#: templates/account/password_reset_from_key.html:4
#: templates/account/password_reset_from_key.html:5
#: templates/account/password_reset_from_key.html:16
#: templates/account/password_reset_from_key_done.html:4
#: templates/account/password_reset_from_key_done.html:5
msgid "Change Password"
msgstr "Kennwort ändern"
#: templates/account/password_reset.html:6
#: templates/account/password_reset.html:7
#: templates/account/password_reset_done.html:6
#: templates/account/password_reset_done.html:7
msgid "Password Reset"
msgstr "Kennwort zurücksetzen"
#: templates/account/password_reset.html:15
msgid ""
"Forgotten your password? Enter your email address below, and we'll send you "
"an email to reset it."
msgstr ""
"Haben Sie Ihr Kennwort vergessen? Geben Sie unten Ihre E-Mail-Adresse ein, "
"und wir senden Ihnen eine E-Mail, um es zurückzusetzen."
#: templates/account/password_reset_done.html:14
msgid ""
"We have sent you an email with a password reset link. Please try again if "
"you do not receive it within a few minutes."
msgstr ""
"Wir haben Ihnen eine E-Mail mit einem Link zum Zurücksetzen des Passworts "
"geschickt. Bitte versuchen Sie es erneut, wenn Sie ihn nicht innerhalb "
"weniger Minuten erhalten."
#: templates/account/password_reset_from_key.html:10
#, python-format
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a <a href=\"%(passwd_reset_url)s\">new password reset</"
"a>."
msgstr ""
"Der Link zum Zurücksetzen des Kennworts war ungültig, möglicherweise weil er "
"bereits verwendet wurde. Bitte fordern Sie eine <a href="
"\"%(passwd_reset_url)s\">neue Kennwortrücksetzung</a> an."
#: templates/account/password_reset_from_key.html:19
#: templates/account/password_reset_from_key_done.html:8
msgid "Your password is now changed."
msgstr "Ihr Kennwort wurde geändert."
#: templates/account/password_set.html:5 templates/account/password_set.html:6
#: templates/account/password_set.html:12
msgid "Set Password"
msgstr "Kennwort setzen"
#: templates/account/signup.html:5 templates/account/signup.html:6
#: templates/account/signup.html:17
msgid "Sign Up"
msgstr "Registrieren"
#: templates/account/signup.html:9
#, python-format
msgid ""
"Already have an account? Then please <a href=\"%(login_url)s\">sign in</a> "
"instead."
msgstr ""
"Sie haben bereits ein Konto? Dann melden Sie sich bitt<a href=\"%(login_url)s"
"\">sign in</a> "
#: templates/account/signup_closed.html:5
#: templates/account/signup_closed.html:6
msgid "Sign Up Closed"
msgstr "Registrierung geschlossen"
#: templates/account/signup_closed.html:9
msgid "Public sign-ups are not allowed at this time."
msgstr "Öffentliche Registrierungen sind zur Zeit nicht erlaubt."
#: templates/account/snippets/already_logged_in.html:6
msgid "Note"
msgstr "Hinweis"
#: templates/account/snippets/already_logged_in.html:6
#, python-format
msgid "you are already logged in as %(user_display)s."
msgstr "Sie sind bereits als %(user_display)s angemeldet."
#: templates/account/verification_sent.html:5
#: templates/account/verification_sent.html:6
#: templates/account/verified_email_required.html:5
#: templates/account/verified_email_required.html:6
msgid "Verify Email Address"
msgstr "E-Mail Adresse verifizieren"
#: templates/account/verification_sent.html:9
msgid ""
"We have sent an email to you for verification. Follow the link provided to "
"finalize the signup process. Please try to log in again if you do not "
"receive it within a few minutes."
msgstr ""
"Wir haben Ihnen eine E-Mail zur Verifizierung gesendet. Folgen Sie dem "
"enthaltenen Link, um den Registrierungsprozess abzuschließen. Versuchen Sie "
"sich erneut anzumelden, falls Sie die E-Mail nicht innerhalb weniger Minuten "
"erhalten."
#: templates/account/verified_email_required.html:11
msgid ""
"This part of the site requires us to verify that\n"
"you are who you claim to be. For this purpose, we require that you\n"
"verify ownership of your email address. "
msgstr ""
"Dieser Teil der Website erfordert eine Überprüfung, dass Sie derjenige "
"sind,\n"
"der Sie vorgeben zu sein. Zu diesem Zweck verlangen wir, dass Sie\n"
"den Besitz Ihrer E-Mail-Adresse bestätigen. "
#: templates/account/verified_email_required.html:15
msgid ""
"We have sent an email to you for\n"
"verification. Please click on the link inside this email. Please\n"
"try again if you do not receive it within a few minutes."
msgstr ""
"Wir haben Ihnen eine E-Mail zur Überprüfung gesendet.\n"
"Bitte klicken Sie auf den Link in dieser E-Mail. Bitte\n"
"versuchen Sie es erneut, wenn Sie die E-Mail nicht innerhalb \n"
"weniger Minuten erhalten."
#: templates/account/verified_email_required.html:19
#, python-format
msgid ""
"<strong>Note:</strong> you can still <a href=\"%(email_url)s\">change your "
"email address</a>."
msgstr ""
"<strong>Hinweis:</strong> Sie können Ihre E-Mail-Adresse noch <a href="
"\"%(email_url)s\">ändern</a>."
#: templates/base.html:47
msgid "Services"
msgstr "Sitzungen"
#: templates/base.html:60
msgid "+ Create"
msgstr "+ Neu"
#: templates/base.html:69
msgid "Collaborations"
msgstr "Zusammenarbeit"
#: templates/base.html:81
msgid "Account"
msgstr "Konto"
#: templates/dashboard/includes/service_form.html:8
msgid "Advanced settings"
msgstr "Erweiterte Einstellungen"
#: templates/dashboard/includes/service_overview.html:15
#: templates/dashboard/pages/service_session_list.html:5
msgid "Sessions"
msgstr "Sitzungen"
#: templates/dashboard/includes/service_overview.html:22
#: templates/dashboard/includes/session_list.html:9
#: templates/dashboard/pages/service.html:38
#: templates/dashboard/pages/service.html:110
msgid "Hits"
msgstr "Besuche"
#: templates/dashboard/includes/service_overview.html:29
#: templates/dashboard/pages/service.html:60
msgid "Bounce Rate"
msgstr "Absprungrate"
#: templates/dashboard/includes/service_overview.html:40
msgid "Avg. Duration"
msgstr "Durchschn. Dauer"
#: templates/dashboard/includes/session_list.html:5
msgid "Session Start"
msgstr "Sitzungsstart"
#: templates/dashboard/includes/session_list.html:6
msgid "Identity"
msgstr "Kennung"
#: templates/dashboard/includes/session_list.html:7
#: templates/dashboard/pages/service_session.html:43
msgid "Network"
msgstr "Netzwerk"
#: templates/dashboard/includes/session_list.html:8
#: templates/dashboard/pages/service.html:73
#: templates/dashboard/pages/service_session.html:81
msgid "Duration"
msgstr "Dauer"
#: templates/dashboard/includes/session_list.html:36
msgid "No data yet"
msgstr "Noch keine Daten"
#: templates/dashboard/pages/dashboard.html:16
msgid "New Service"
msgstr "Neuer Dienst"
#: templates/dashboard/pages/index.html:6
#: templates/dashboard/pages/service_session_list.html:9
msgid "Analytics"
msgstr "Analytik"
#: templates/dashboard/pages/index.html:8
msgid "Log In"
msgstr "Anmelden"
#: templates/dashboard/pages/service.html:9
msgid "Manage"
msgstr "Verwalten"
#: templates/dashboard/pages/service.html:17
msgid ""
"This service hasn't collected any data yet. To get started, place the "
"following code snippet at the end of the <code>&lt;body&gt;</code> tag on "
"any page you'd like to track."
msgstr ""
#: templates/dashboard/pages/service.html:29
#: templates/dashboard/pages/service.html:158
#: templates/dashboard/pages/service.html:192
#: templates/dashboard/pages/service.html:226
#: templates/dashboard/pages/service.html:260
#: templates/dashboard/pages/service.html:295
msgid "sessions"
msgstr "Sitzungen"
#: templates/dashboard/pages/service.html:47
msgid "Load Time"
msgstr "Ladezeit"
#: templates/dashboard/pages/service.html:86
msgid "Hits/Session"
msgstr "Besuche/Sitzung"
#: templates/dashboard/pages/service.html:109
#: templates/dashboard/pages/service_session.html:51
msgid "Location"
msgstr "Ort"
#: templates/dashboard/pages/service.html:133
msgid "No data yet..."
msgstr "Noch keine Daten..."
#: templates/dashboard/pages/service.html:141
msgid "Sessions by Geography"
msgstr "Sitzungen nach Geograpie"
#: templates/dashboard/pages/service.html:143
msgid "view table"
msgstr "Tabellenansicht"
#: templates/dashboard/pages/service.html:153
#: templates/dashboard/pages/service_session.html:47
msgid "Country"
msgstr "Land"
#: templates/dashboard/pages/service.html:191
msgid "Referrer"
msgstr ""
#: templates/dashboard/pages/service.html:225
msgid "Operating System"
msgstr "Betriebssystem"
#: templates/dashboard/pages/service.html:259
#: templates/dashboard/pages/service_session.html:27
msgid "Browser"
msgstr ""
#: templates/dashboard/pages/service.html:294
#: templates/dashboard/pages/service_session.html:35
msgid "Device Type"
msgstr "Gerätetyp"
#: templates/dashboard/pages/service.html:329
msgid "View more sessions"
msgstr "Weitere Sitzungen"
#: templates/dashboard/pages/service_create.html:5
#: templates/dashboard/pages/service_create.html:8
msgid "Create Service"
msgstr "Neuer Dienst"
#: templates/dashboard/pages/service_create.html:16
msgid "Create"
msgstr "Neu"
#: templates/dashboard/pages/service_create.html:17
#: templates/dashboard/pages/service_update.html:30
msgid "Cancel"
msgstr "Abbrechen"
#: templates/dashboard/pages/service_delete.html:5
#: templates/dashboard/pages/service_update.html:33
msgid "Delete"
msgstr "Löschen"
#: templates/dashboard/pages/service_delete.html:12
msgid ""
"Are you sure you want to delete this service? All of its analytics and "
"associated data will be permanently deleted."
msgstr ""
"Sind Sie sicher, dass Sie diesen Dienst löschen wollen? Alle damit "
"verbundenen Daten werden unwiederruflich gelöscht."
#: templates/dashboard/pages/service_session.html:31
msgid "Device"
msgstr "Geräte"
#: templates/dashboard/pages/service_session.html:39
msgid "OS"
msgstr "Betriebssystem"
#: templates/dashboard/pages/service_session.html:54
msgid "Open in Maps"
msgstr "In Karte öffnen"
#: templates/dashboard/pages/service_session.html:56
msgid "Unknown"
msgstr "Unbekannt"
#: templates/dashboard/pages/service_session.html:85
msgid "Load"
msgstr "Laden"
#: templates/dashboard/pages/service_session.html:89
msgid "Tracker"
msgstr ""
#: templates/dashboard/pages/service_update.html:5
msgid "Management"
msgstr "Verwaltung"
#: templates/dashboard/pages/service_update.html:8
msgid "View"
msgstr "Ansicht"
#: templates/dashboard/pages/service_update.html:13
msgid "Installation"
msgstr ""
#: templates/dashboard/pages/service_update.html:15
msgid ""
"Place the following snippet at the end of the <code>&lt;body&gt;</code> tag "
"on any page you'd like to track."
msgstr ""
"Kopieren Sie den folgenden Code ans Ende des <code>&lt;body&gt;</code> Tags "
"in allen Seiten, die Sie tracken möchten."
#: templates/dashboard/pages/service_update.html:21
msgid "Settings"
msgstr "Einstellungen"
#: templates/dashboard/pages/service_update.html:29
msgid "Save"
msgstr "Speichern"

View File

@ -1,659 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-24 13:43+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: forms.py:28 forms.py:29 forms.py:30 forms.py:59
msgid "Yes"
msgstr "是"
#: forms.py:28 forms.py:29 forms.py:30 forms.py:59
msgid "No"
msgstr "否"
#: forms.py:35
msgid "Allowed origins"
msgstr "允許的來源"
#: forms.py:36
msgid "Respect DNT"
msgstr "尊重停止追蹤 (Do Not Track) 設定"
#: forms.py:37
msgid "Ignored IP addresses"
msgstr "忽略的 IP"
#: forms.py:38
msgid "Ignore robots"
msgstr "忽略機器人"
#: forms.py:39
msgid "Hide specific referrers"
msgstr "隱藏特定的參照來源"
#: forms.py:40
msgid "Additional injected JS"
msgstr "額外插入的 JS"
#: forms.py:43
msgid "What should the service be called?"
msgstr "這項服務應該被稱為什麼?"
#: forms.py:44
msgid "What's the service's primary URL?"
msgstr "服務的主要 URL 是什麼?"
#: forms.py:46
msgid ""
"At what origins does the service operate? Use commas to separate multiple "
"values. This sets CORS headers, so use '*' if you're not sure (or don't "
"care)."
msgstr ""
"服務在哪些來源運作?使用逗號分隔多個值。這設定了 CORS 標頭,所以如果你不確定(或不在乎),請使用 '*'。"
#: forms.py:48
msgid ""
"Should visitors who have enabled <a href='https://en.wikipedia.org/wiki/"
"Do_Not_Track'>Do Not Track</a> be excluded from all data?"
msgstr ""
"是否應排除已啟用 <a href='https://en.wikipedia.org/wiki/Do_Not_Track'>停止追蹤 (Do Not Track)</a> 的訪客的所有資料?"
#: forms.py:49
msgid ""
"A comma-separated list of IP addresses or IP ranges (IPv4 and IPv6) to "
"exclude from tracking (e.g., '192.168.0.2, 127.0.0.1/32')."
msgstr ""
"要從追蹤中排除的 IP 位址或 IP 範圍IPv4 和 IPv6的逗號分隔列表例如'192.168.0.2, 127.0.0.1/32')。"
#: forms.py:50
msgid "Should sessions generated by bots be excluded from tracking?"
msgstr "是否應排除由機器人產生的工作階段從追蹤中?"
#: forms.py:51
msgid ""
"Any referrers that match this <a href='https://regexr.com/'>RegEx</a> will "
"not be listed in the referrer summary. Sessions will still be tracked "
"normally. No effect if left blank."
msgstr ""
"任何符合此 <a href='https://regexr.com/'>RegEx</a> 的參照來源將不會在參照來源摘要中列出。工作階段仍將正常追蹤。如果留空則無效果。"
#: forms.py:52
msgid ""
"Optional additional JavaScript to inject at the end of the Shynet script. "
"This code will be injected on every page where this service is installed."
msgstr ""
"選擇性的額外 JavaScript插入到 Shynet 指令碼的末端。此程式碼將插入到安裝此服務的每個頁面上。"
#: forms.py:56
msgid "IP address collection is disabled globally by your administrator."
msgstr "您的管理員已全域停用 IP 收集。"
#: forms.py:58
msgid ""
"Should individual IP addresses be collected? IP metadata (location, host, "
"etc) will still be collected."
msgstr "是否應收集個別 IP ?仍將收集 IP 中繼資料(位置、主機等)。"
#: forms.py:71
msgid ""
"Which users on this Shynet instance should have read-only access to this "
"service? (Comma separated list of emails.)"
msgstr ""
"此 Shynet 服務上的哪些使用者應具有對此服務的唯讀存取權限?(電子郵件的逗號分隔列表。)"
#: templates/account/account_inactive.html:5
#: templates/account/account_inactive.html:6
msgid "Account Inactive"
msgstr "帳戶不活躍"
#: templates/account/account_inactive.html:9
msgid "This account is inactive."
msgstr "此帳戶不活躍。"
#: templates/account/email.html:5 templates/account/email.html:6
msgid "Email Addresses"
msgstr "電子郵件地址"
#: templates/account/email.html:12
msgid "These are your known email addresses:"
msgstr "這些是您的已知電子郵件地址:"
#: templates/account/email.html:26
msgid "Verified"
msgstr "已驗證"
#: templates/account/email.html:28
msgid "Unverified"
msgstr "未驗證"
#: templates/account/email.html:30
msgid "Primary"
msgstr "主要"
#: templates/account/email.html:36
msgid "Make Primary"
msgstr "設為預設"
#: templates/account/email.html:37
msgid "Resend Verification"
msgstr "重新傳送驗證"
#: templates/account/email.html:38
msgid "Remove"
msgstr "移除"
#: templates/account/email.html:46
msgid ""
"You currently do not have an email address associated with your account. "
"Without one, you won't be able to reset your password, receive "
"notifications, etc."
msgstr ""
"您目前的帳戶沒有關聯的電子郵件地址。沒有它,您將無法重設密碼、接收通知等。"
#: templates/account/email.html:57
msgid "Add Address"
msgstr "新增地址"
#: templates/account/email.html:66
msgid "Do you really want to remove the selected email address?"
msgstr "您真的要移除選定的電子郵件地址嗎?"
#: templates/account/email/email_confirmation_message.txt:1
#, python-format
msgid ""
"Hi there,\n"
"\n"
"You're receiving this email because %(user_display)s has listed this email "
"as a valid contact address for their account.\n"
"\n"
"To confirm this is correct, go to %(activate_url)s\n"
msgstr ""
"您好,\n"
"\n"
"您收到此電子郵件是因為 %(user_display)s 已將此電子郵件列為其帳戶的有效聯絡地址。\n"
"\n"
"要確認這是正確的,請前往 %(activate_url)s\n"
#: templates/account/email/email_confirmation_message.txt:7
#: templates/account/email/password_reset_key_message.txt:9
#, python-format
msgid ""
"Thank you,\n"
"%(site_name)s\n"
msgstr ""
"謝謝您,\n"
"%(site_name)s\n"
#: templates/account/email/email_confirmation_subject.txt:3
#: templates/account/email_confirm.html:6
#: templates/account/email_confirm.html:7
msgid "Confirm Email Address"
msgstr "確認電子郵件地址"
#: templates/account/email/password_reset_key_message.txt:1
msgid ""
"Hi there,\n"
"\n"
"You're receiving this email because you or someone else has requested a "
"password for your account.\n"
"\n"
"This message can be safely ignored if you did not request a password reset. "
"Click the link below to reset your password."
msgstr ""
"您好,\n"
"\n"
"您收到此電子郵件是因為您或其他人已為您的帳戶請求密碼。\n"
"\n"
"如果您未請求重設密碼,則可以安全地忽略此訊息。點選下面的連結來重設您的密碼。"
#: templates/account/email/password_reset_key_subject.txt:3
msgid "Password Reset Email"
msgstr "密碼重設電子郵件"
#: templates/account/email_confirm.html:15
#, python-format
msgid ""
"Please confirm that <a\n"
" href=\"mailto:%(email)s\">%(email)s</a> is a valid email where we "
"can reach you."
msgstr ""
"請確認 <a\n"
" href=\"mailto:%(email)s\">%(email)s</a> 是我們可以聯絡您的有效電子郵件。"
#: templates/account/email_confirm.html:21
msgid "Confirm"
msgstr "確認"
#: templates/account/email_confirm.html:28
#, python-format
msgid ""
"This email confirmation link expired or is invalid. Please <a href="
"\"%(email_url)s\">issue a new\n"
" email confirmation request</a>."
msgstr ""
"此電子郵件確認連結已過期或無效。請<a href=\"%(email_url)s\">發出新的電子郵件確認請求</a>。"
#: templates/account/login.html:6 templates/account/login.html:7
#: templates/account/login.html:19
msgid "Sign In"
msgstr "登入"
#: templates/account/login.html:20 templates/account/password_reset.html:21
msgid "Reset Password"
msgstr "重設密碼"
#: templates/account/logout.html:5 templates/account/logout.html:6
#: templates/account/logout.html:16
msgid "Sign Out"
msgstr "登出"
#: templates/account/logout.html:9
msgid "Are you sure you want to sign out?"
msgstr "您確定要登出嗎?"
#: templates/account/messages/cannot_delete_primary_email.txt:2
#, python-format
msgid "You cannot remove your primary email address (%(email)s)."
msgstr "您不能移除您的主要電子郵件地址 (%(email)s)。"
#: templates/account/messages/email_confirmation_sent.txt:2
#, python-format
msgid "Confirmation email sent to %(email)s."
msgstr "確認電子郵件已傳送到 %(email)s。"
#: templates/account/messages/email_confirmed.txt:2
#, python-format
msgid "Confirmed %(email)s."
msgstr "已確認 %(email)s。"
#: templates/account/messages/email_deleted.txt:2
#, python-format
msgid "Removed email address %(email)s."
msgstr "已移除電子郵件地址 %(email)s。"
#: templates/account/messages/logged_in.txt:4
#, python-format
msgid "Successfully signed in as %(name)s."
msgstr "成功以 %(name)s 的身份登入。"
#: templates/account/messages/logged_out.txt:2
msgid "You have signed out."
msgstr "您已登出。"
#: templates/account/messages/password_changed.txt:2
msgid "Password successfully changed."
msgstr "密碼已成功更改。"
#: templates/account/messages/password_set.txt:2
msgid "Password successfully set."
msgstr "密碼已成功設定。"
#: templates/account/messages/primary_email_set.txt:2
msgid "New primary email address set."
msgstr "已設定新的主要電子郵件地址。"
#: templates/account/messages/unverified_primary_email.txt:2
msgid "Your primary email address must be verified."
msgstr "您的主要電子郵件地址必須經過驗證。"
#: templates/account/password_change.html:5
#: templates/account/password_change.html:6
#: templates/account/password_change.html:12
#: templates/account/password_reset_from_key.html:4
#: templates/account/password_reset_from_key.html:5
#: templates/account/password_reset_from_key.html:16
#: templates/account/password_reset_from_key_done.html:4
#: templates/account/password_reset_from_key_done.html:5
msgid "Change Password"
msgstr "更改密碼"
#: templates/account/password_reset.html:6
#: templates/account/password_reset.html:7
#: templates/account/password_reset_done.html:6
#: templates/account/password_reset_done.html:7
msgid "Password Reset"
msgstr "密碼重設"
#: templates/account/password_reset.html:15
msgid ""
"Forgotten your password? Enter your email address below, and we'll send you "
"an email to reset it."
msgstr ""
"忘記了您的密碼?在下面輸入您的電子郵件地址,我們將向您傳送電子郵件以重設它。"
#: templates/account/password_reset_done.html:14
msgid ""
"We have sent you an email with a password reset link. Please try again if "
"you do not receive it within a few minutes."
msgstr ""
"我們已向您發送了一封帶有密碼重設連結的電子郵件。如果您在幾分鐘內未收到,請再試一次。"
#: templates/account/password_reset_from_key.html:10
#, python-format
msgid ""
"The password reset link was invalid, possibly because it has already been "
"used. Please request a <a href=\"%(passwd_reset_url)s\">new password reset</"
"a>."
msgstr ""
"密碼重設連結無效,可能是因為它已被使用。請請求<a href=\"%(passwd_reset_url)s\">新的密碼重設</a>。"
#: templates/account/password_reset_from_key.html:19
#: templates/account/password_reset_from_key_done.html:8
msgid "Your password is now changed."
msgstr "您的密碼現在已更改。"
#: templates/account/password_set.html:5 templates/account/password_set.html:6
#: templates/account/password_set.html:12
msgid "Set Password"
msgstr "設定密碼"
#: templates/account/signup.html:5 templates/account/signup.html:6
#: templates/account/signup.html:17
msgid "Sign Up"
msgstr "註冊"
#: templates/account/signup.html:9
#, python-format
msgid ""
"Already have an account? Then please <a href=\"%(login_url)s\">sign in</a> "
"instead."
msgstr ""
"已經有帳戶了嗎?那麼請<a href=\"%(login_url)s\">登入</a>。"
#: templates/account/signup_closed.html:5
#: templates/account/signup_closed.html:6
msgid "Sign Up Closed"
msgstr "註冊已關閉"
#: templates/account/signup_closed.html:9
msgid "Public sign-ups are not allowed at this time."
msgstr "目前不允許公開註冊。"
#: templates/account/snippets/already_logged_in.html:6
msgid "Note"
msgstr "注意"
#: templates/account/snippets/already_logged_in.html:6
#, python-format
msgid "you are already logged in as %(user_display)s."
msgstr "您已經以 %(user_display)s 的身份登入。"
#: templates/account/verification_sent.html:5
#: templates/account/verification_sent.html:6
#: templates/account/verified_email_required.html:5
#: templates/account/verified_email_required.html:6
msgid "Verify Email Address"
msgstr "驗證電子郵件地址"
#: templates/account/verification_sent.html:9
msgid ""
"We have sent an email to you for verification. Follow the link provided to "
"finalize the signup process. Please try to log in again if you do not "
"receive it within a few minutes."
msgstr ""
"我們已向您發送了一封驗證電子郵件。按照提供的連結完成註冊過程。如果您在幾分鐘內未收到,請再試一次登入。"
#: templates/account/verified_email_required.html:11
msgid ""
"This part of the site requires us to verify that\n"
"you are who you claim to be. For this purpose, we require that you\n"
"verify ownership of your email address. "
msgstr ""
"該網站的這一部分要求我們驗證\n"
"您是您聲稱的人。為此,我們要求您\n"
"驗證您的電子郵件地址的所有權。"
#: templates/account/verified_email_required.html:15
msgid ""
"We have sent an email to you for\n"
"verification. Please click on the link inside this email. Please\n"
"try again if you do not receive it within a few minutes."
msgstr ""
"我們已向您發送了一封驗證電子郵件。\n"
"請點選此電子郵件內的連結。請\n"
"如果您在幾分鐘內未收到,請再試一次。"
#: templates/account/verified_email_required.html:19
#, python-format
msgid ""
"<strong>Note:</strong> you can still <a href=\"%(email_url)s\">change your "
"email address</a>."
msgstr ""
"<strong>注意:</strong>您仍然可以<a href=\"%(email_url)s\">更改您的電子郵件地址</a>。"
#: templates/base.html:47
msgid "Services"
msgstr "服務"
#: templates/base.html:60
msgid "+ Create"
msgstr "+ 建立"
#: templates/base.html:69
msgid "Collaborations"
msgstr "合作"
#: templates/base.html:81
msgid "Account"
msgstr "帳戶"
#: templates/dashboard/includes/service_form.html:8
msgid "Advanced settings"
msgstr "進階設定"
#: templates/dashboard/includes/service_overview.html:15
#: templates/dashboard/pages/service_session_list.html:5
msgid "Sessions"
msgstr "工作階段"
#: templates/dashboard/includes/service_overview.html:22
#: templates/dashboard/includes/session_list.html:9
#: templates/dashboard/pages/service.html:38
#: templates/dashboard/pages/service.html:110
msgid "Hits"
msgstr "點選次數"
#: templates/dashboard/includes/service_overview.html:29
#: templates/dashboard/pages/service.html:60
msgid "Bounce Rate"
msgstr "跳出率"
#: templates/dashboard/includes/service_overview.html:40
msgid "Avg. Duration"
msgstr "平均持續時間"
#: templates/dashboard/includes/session_list.html:5
msgid "Session Start"
msgstr "工作階段開始"
#: templates/dashboard/includes/session_list.html:6
msgid "Identity"
msgstr "身份"
#: templates/dashboard/includes/session_list.html:7
#: templates/dashboard/pages/service.html:73
#: templates/dashboard/pages/service_session.html:81
msgid "Duration"
msgstr "持續時間"
#: templates/dashboard/includes/session_list.html:36
msgid "No data yet"
msgstr "尚無資料"
#: templates/dashboard/pages/dashboard.html:16
msgid "New Service"
msgstr "新服務"
#: templates/dashboard/pages/index.html:6
#: templates/dashboard/pages/service_session_list.html:9
msgid "Analytics"
msgstr "分析"
#: templates/dashboard/pages/index.html:8
msgid "Log In"
msgstr "登入"
#: templates/dashboard/pages/service.html:9
msgid "Manage"
msgstr "管理"
#: templates/dashboard/pages/service.html:17
msgid ""
"This service hasn't collected any data yet. To get started, place the "
"following code snippet at the end of the <code>&lt;body&gt;</code> tag on "
"any page you'd like to track."
msgstr ""
"此服務尚未收集任何資料。要開始,請將以下程式碼片段放在您想要追蹤的任何頁面的 <code>&lt;body&gt;</code> 標籤的末端。"
#: templates/dashboard/pages/service.html:29
#: templates/dashboard/pages/service.html:158
#: templates/dashboard/pages/service.html:192
#: templates/dashboard/pages/service.html:226
#: templates/dashboard/pages/service.html:260
#: templates/dashboard/pages/service.html:295
msgid "sessions"
msgstr "工作階段"
#: templates/dashboard/pages/service.html:47
msgid "Load Time"
msgstr "載入時間"
#: templates/dashboard/pages/service.html:86
msgid "Hits/Session"
msgstr "每次工作階段點選次數"
#: templates/dashboard/pages/service.html:109
#: templates/dashboard/pages/service_session.html:51
msgid "Location"
msgstr "位置"
#: templates/dashboard/pages/service.html:133
msgid "No data yet..."
msgstr "尚無資料..."
#: templates/dashboard/pages/service.html:141
msgid "Sessions by Geography"
msgstr "工作階段依地理位置"
#: templates/dashboard/pages/service.html:143
msgid "view table"
msgstr "檢視表格"
#: templates/dashboard/pages/service.html:153
#: templates/dashboard/pages/service_session.html:47
msgid "Country"
msgstr "國家"
#: templates/dashboard/pages/service.html:191
msgid "Referrer"
msgstr "參照來源"
#: templates/dashboard/pages/service.html:225
msgid "Operating System"
msgstr "作業系統"
#: templates/dashboard/pages/service.html:259
#: templates/dashboard/pages/service_session.html:27
msgid "Browser"
msgstr "瀏覽器"
#: templates/dashboard/pages/service.html:294
#: templates/dashboard/pages/service_session.html:35
msgid "Device Type"
msgstr "裝置類型"
#: templates/dashboard/pages/service.html:329
msgid "View more sessions"
msgstr "檢視更多工作階段"
#: templates/dashboard/pages/service_create.html:5
#: templates/dashboard/pages/service_create.html:8
msgid "Create Service"
msgstr "建立服務"
#: templates/dashboard/pages/service_create.html:16
msgid "Create"
msgstr "建立"
#: templates/dashboard/pages/service_create.html:17
#: templates/dashboard/pages/service_update.html:30
msgid "Cancel"
msgstr "取消"
#: templates/dashboard/pages/service_delete.html:5
#: templates/dashboard/pages/service_update.html:33
msgid "Delete"
msgstr "刪除"
#: templates/dashboard/pages/service_delete.html:12
msgid ""
"Are you sure you want to delete this service? All of its analytics and "
"associated data will be permanently deleted."
msgstr ""
"您確定要刪除此服務嗎?其所有分析和相關資料將被永久刪除。"
#: templates/dashboard/pages/service_session.html:31
msgid "Device"
msgstr "裝置"
#: templates/dashboard/pages/service_session.html:39
msgid "OS"
msgstr "作業系統"
#: templates/dashboard/pages/service_session.html:54
msgid "Open in Maps"
msgstr "在地圖中開啟"
#: templates/dashboard/pages/service_session.html:56
msgid "Unknown"
msgstr "未知"
#: templates/dashboard/pages/service_session.html:85
msgid "Load"
msgstr "載入"
#: templates/dashboard/pages/service_session.html:89
msgid "Tracker"
msgstr "追蹤器"
#: templates/dashboard/pages/service_update.html:5
msgid "Management"
msgstr "管理"
#: templates/dashboard/pages/service_update.html:8
msgid "View"
msgstr "檢視"
#: templates/dashboard/pages/service_update.html:13
msgid "Installation"
msgstr "安裝"
#: templates/dashboard/pages/service_update.html:15
msgid ""
"Place the following snippet at the end of the <code>&lt;body&gt;</code> tag "
"on any page you'd like to track."
msgstr ""
"將以下片段放在您想要追蹤的任何頁面的 <code>&lt;body&gt;</code> 標籤的末端。"
#: templates/dashboard/pages/service_update.html:21
msgid "Settings"
msgstr "設定"
#: templates/dashboard/pages/service_update.html:29
msgid "Save"
msgstr "儲存"

View File

@ -26,36 +26,34 @@ class DateRangeMixin:
now = timezone.now()
return [
{
"name": "Last 3 days",
"start": now - timezone.timedelta(days=2),
"end": now,
'name': 'Last 3 days',
'start': now - timezone.timedelta(days=2),
'end': now,
},
{
"name": "Last 30 days",
"start": now - timezone.timedelta(days=29),
"end": now,
'name': 'Last 30 days',
'start': now - timezone.timedelta(days=29),
'end': now,
},
{
"name": "Last 90 days",
"start": now - timezone.timedelta(days=89),
"end": now,
'name': 'Last 90 days',
'start': now - timezone.timedelta(days=89),
'end': now,
},
{
"name": "This month",
"start": now.replace(day=1),
"end": now,
'name': 'This month',
'start': now.replace(day=1),
'end': now,
},
{
"name": "Last month",
"start": (now.replace(day=1) - timezone.timedelta(days=1)).replace(
day=1
),
"end": now.replace(day=1) - timezone.timedelta(days=1),
'name': 'Last month',
'start': now.replace(day=1, month=now.month - 1),
'end': now.replace(day=1, month=now.month) - timezone.timedelta(days=1),
},
{
"name": "This year",
"start": now.replace(day=1, month=1),
"end": now,
'name': 'This year',
'start': now.replace(day=1, month=1),
'end': now,
},
]

View File

@ -23,22 +23,6 @@
max-width: 0;
}
.min-w-48 {
min-width: 48px;
}
.geo-table {
display: none;
}
.geo-card--use-table-view .geo-map {
display: none;
}
.geo-card--use-table-view .geo-table {
display: inline-block;
}
:root {
--color-neutral-000: white;
--color-neutral-50: #F8FAFC;

View File

@ -1,10 +1,10 @@
{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=request.get_host %}Hi there,
{% load account %}{% user_display user as user_display %}{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hi there,
You're receiving this email because {{ user_display }} has listed this email as a valid contact address for their account.
To confirm this is correct, go to {{ activate_url }}
{% endblocktrans %}
{% blocktrans with site_name=current_site.name site_domain=request.get_host %}Thank you,
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you,
{{ site_name }}
{% endblocktrans %}
{% endautoescape %}

View File

@ -1,4 +1,4 @@
{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=request.get_host %}Hi there,
{% load i18n %}{% autoescape off %}{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Hi there,
You're receiving this email because you or someone else has requested a password for your account.
@ -6,7 +6,7 @@ This message can be safely ignored if you did not request a password reset. Clic
{{ password_reset_url }}
{% blocktrans with site_name=current_site.name site_domain=request.get_host %}Thank you,
{% blocktrans with site_name=current_site.name site_domain=current_site.domain %}Thank you,
{{ site_name }}
{% endblocktrans %}
{% endautoescape %}

View File

@ -2,8 +2,8 @@
{% load i18n a17t_tags %}
{% block head_title %}{% trans "Change authentication info" %}{% endblock %}
{% block page_title %}{% trans "Change authentication info" %}{% endblock %}
{% block head_title %}{% trans "Change Password" %}{% endblock %}
{% block page_title %}{% trans "Change Password" %}{% endblock %}
{% block card %}
<form method="POST" action="{% url 'account_change_password' %}" class="password_change max-w-lg">
@ -11,27 +11,4 @@
{{ form|a17t }}
<button type="submit" name="action" class="button ~urge !high">{% trans "Change Password" %}</button>
</form>
<hr class="sep">
<div>
<p class="label mb-1">Personal API token</p>
<div class="flex justify-between">
{% if request.user.api_token %}
<span class='chip ~info !normal'>{{request.user.api_token}}</span>
{% else %}
<span>Token not generated</span>
{% endif %}
<form method="POST" action="{% url 'dashboard:api_token_refresh' %}">
{% csrf_token %}
<button type="submit" name="action" class="button ~neutral @high">
{% if request.user.api_token %}
{% trans "Refresh token" %}
{% else %}
{% trans "Generate token" %}
{% endif %}
</button>
</form>
</div>
<p class="support mt-1">To learn more about the API, see our <a href="https://github.com/milesmcc/shynet/blob/master/GUIDE.md#api">API guide</a>.</p>
</div>
</div>
{% endblock %}

View File

@ -1,4 +1,4 @@
{% load static i18n rules helpers %}
{% load static rules helpers %}
<!DOCTYPE html>
<html>
@ -12,12 +12,11 @@
<script src="{% static 'apexcharts/dist/apexcharts.min.js'%}"></script>
<script src="{% static 'litepicker/dist/nocss/litepicker.js' %}"></script>
<script src="{% static 'litepicker/dist/plugins/ranges.js' %}"></script>
<script src="{% static 'd3/d3.min.js' %}"></script>
<script src="{% static 'topojson/build/topojson.min.js' %}"></script>
<script src="{% static 'datamaps/dist/datamaps.world.min.js' %}"></script>
<link rel="stylesheet" href="{% static 'litepicker/dist/css/litepicker.css' %}">
<script src="{% static 'dashboard/js/base.js' %}"></script>
<link rel="stylesheet" href="{% static 'dashboard/css/global.css' %}">
<link rel="stylesheet" href="{% static 'flag-icon-css/css/flag-icon.min.css' %}">
<link rel="stylesheet" href="{% static 'litepicker/dist/css/litepicker.css' %}">
{% block extra_head %}
{% endblock %}
</head>
@ -43,9 +42,7 @@
<div id="navMenuExpanded"
class="bg-neutral-000 shadow-lg md:shadow-none p-4 hidden rounded-lg md:block md:bg-transparent md:border-none md:p-0 w-full">
{% if user.owning_services.all %}
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">
{% trans 'Services' %}
</p>
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">Services</p>
{% for service in user.owning_services.all %}
{% contextual_url 'dashboard:service' service.uuid as url %}
@ -57,17 +54,14 @@
{% has_perm 'core.create_service' user as can_create %}
{% if can_create %}
{% url 'dashboard:service_create' as url %}
{% trans '+ Create' as create %}
{% include 'dashboard/includes/sidebar_portal.html' with label=create url=url %}
{% include 'dashboard/includes/sidebar_portal.html' with label="+ Create" url=url %}
<hr class="sep h-8">
{% endif %}
{% if user.collaborating_services.all %}
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">
{% trans 'Collaborations' %}
</p>
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">Collaborations</p>
{% for service in user.collaborating_services.all %}
{% contextual_url 'dashboard:service' service.uuid as url %}
@ -77,9 +71,7 @@
<hr class="sep h-8">
{% endif %}
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">
{% trans 'Account' %}
</p>
<p class="ml-2 mb-1 supra font-medium text-gray-500 pointer-events-none">Account</p>
{% if user.is_authenticated %}

View File

@ -1,6 +0,0 @@
{% load helpers %}
<div
class="absolute h-6 rounded-md"
style="width: {% bar_width count max total %}; top: 6px; left: 0px; height: calc(100% - 12px); background-color: var(--color-urge-100-fallback)"
>
</div>

View File

@ -1,10 +1,8 @@
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
<form method="GET" id="datePicker">
<input type="hidden" name="startDate" value="{{start_date.isoformat}}" id="startDate">
<input type="hidden" name="endDate" value="{{end_date.isoformat}}" id="endDate">
</form>
<input type="input" id="rangePicker" placeholder="Date range" class="input ~neutral !low bg-neutral-000 cursor-pointer" style="max-width: 200px;" readonly>
<input type="input" id="rangePicker" placeholder="Date range" class="input ~neutral bg-neutral-000 cursor-pointer w-auto" readonly>
<style>
:root {
--litepicker-button-prev-month-color-hover: var(--color-urge);
@ -22,21 +20,11 @@
}
</style>
<script>
function getLocaleDateString(locale) {
const formats = {
'de': "DD. MMM YY",
'zh_TW': "YYYY 年 MM 月 DD 日"
}
return formats[locale] || "MMM DD 'YY";
}
let locale = "{{ LANGUAGE_CODE }}";
let picker = new Litepicker({
var picker = new Litepicker({
element: document.getElementById('rangePicker'),
plugins: ['ranges'],
singleMode: false,
lang: locale,
format: getLocaleDateString(locale),
format: "MMM DD 'YY",
maxDate: new Date(),
startDate: Date.parse(document.getElementById("startDate").getAttribute("value")),
endDate: Date.parse(document.getElementById("endDate").getAttribute("value")),

View File

@ -1,66 +0,0 @@
{% load helpers %}
<div id="map-chart" class="relative"></div>
<script>
// Colors
const lightBlue = "#C4B5FD";
const highlightBlue = "#8B5CF6";
const white = "#ffffff";
// Data maps
const countryMapData = {};
const countryMapColors = {};
const countryMap = {
{% for country in countries %}"{{country.country|safe|datamap_id}}": {{country.count}},
{% endfor %}
};
// Max session count will be full opacity
const maxSessionCount = Math.max(...Object.values(countryMap));
// Color scale starts from opacity 0.1 - 1.0, 0 sessions gets opacity 0
const minPercentage = 0.1
// Loop over country map and transform data for Datamaps use
const keys = Object.keys(countryMap);
const length = keys.length;
for (let i = 0; i < length; i++) {
countryMapData[keys[i]] = {
sessionCount: countryMap[keys[i]],
color: `rgba(124, 58, 237, ${countryMap[keys[i]] === 0 ? 0 : minPercentage + (countryMap[keys[i]] / maxSessionCount * (1 - minPercentage))})`
};
countryMapColors[keys[i]] = countryMapData[keys[i]].color;
}
// Create datamap
var geoMap = new Datamap({
element: document.getElementById('map-chart'),
projection: 'mercator',
responsive: true,
geographyConfig: {
borderColor: lightBlue,
highlightBorderColor: highlightBlue,
highlightBorderWidth: 1.5,
highlightFillColor: (geography) => geography.color || white,
highlightFillOpacity: 0.9,
popupTemplate: (geography, data) => '<div class="hoverinfo"><strong>' + geography.properties.name + '</strong>: ' + data.sessionCount + ' sessions</div>'
},
fills: {
defaultFill: white
},
data: countryMapData,
aspectRatio: 0.68
});
geoMap.updateChoropleth(countryMapColors);
let debounceTimeout
const debounce = (func, debounce) => {
return function(event){
if(debounceTimeout) clearTimeout(debounceTimeout);
debounceTimeout = setTimeout(func,debounce,event);
};
}
window.addEventListener("resize",debounce(() => geoMap.resize(), 100))
</script>

View File

@ -1,11 +1,11 @@
{% load i18n a17t_tags %}
{% load a17t_tags %}
{{form.name|a17t}}
{{form.link|a17t}}
{{form.collaborators|a17t}}
<details {% if form.errors %}open{% endif %}>
<summary class="cursor-pointer text-sm">{% trans 'Advanced settings' %}</summary>
<summary class="cursor-pointer text-sm">Advanced settings</summary>
<hr class="sep h-4">
{{form.respect_dnt|a17t}}
{{form.collect_ips|a17t}}

View File

@ -1,4 +1,4 @@
{% load i18n humanize helpers %}
{% load humanize helpers %}
<a class="card chart-card overflow-visible ~neutral !low service mb-6 p-0" href="{% contextual_url 'dashboard:service' object.uuid %}">
{% with stats=object.stats %}
@ -12,21 +12,21 @@
</div>
<div class="grid grid-cols-2 md:grid-cols-4 gap-6 md:gap-3 lg:gap-6 md:flex-none">
<div>
<p>{% trans 'Sessions' %}</p>
<p>Sessions</p>
<p class="label">
{{stats.session_count|intcomma}}
{% compare stats.compare.session_count stats.session_count "UP" %}
</p>
</div>
<div>
<p>{% trans 'Hits' %}</p>
<p>Hits</p>
<p class="label">
{{stats.hit_count|intcomma}}
{% compare stats.compare.hit_count stats.hit_count "UP" %}
</p>
</div>
<div>
<p>{% trans 'Bounce Rate' %}</p>
<p>Bounce Rate</p>
<p class="label">
{% if stats.bounce_rate_pct != None %}
{{stats.bounce_rate_pct|floatformat:"-1"}}%
@ -37,7 +37,7 @@
</p>
</div>
<div>
<p>{% trans 'Avg. Duration' %}</p>
<p>Avg. Duration</p>
<p class="label">
{% if stats.avg_session_duration != None %}
{{stats.avg_session_duration|naturaldelta}}
@ -51,7 +51,7 @@
</div>
<hr class="sep h-4">
<div style="bottom: -1px;">
{% include 'dashboard/includes/time_chart.html' with data=stats.chart_data sparkline=True height=100 name=object.uuid tooltip_format=stats.chart_tooltip_format granularity=stats.chart_granularity %}
{% include 'dashboard/includes/time_chart.html' with data=stats.session_chart_data sparkline=True height=100 name=object.uuid %}
</div>
{% endwith %}
</a>
</a>

View File

@ -1,5 +1,5 @@
<div class="card ~neutral !high font-mono text-sm whitespace-pre-wrap break-all">{% filter force_escape %}<noscript>
<img src="{{script_protocol}}{{request.get_host}}{% url 'ingress:endpoint_pixel' object.uuid %}">
<img src="{{script_protocol}}{{request.site.domain}}{% url 'ingress:endpoint_pixel' object.uuid %}">
</noscript>
<script defer src="{{script_protocol}}{{request.get_host}}{% url 'ingress:endpoint_script' object.uuid %}"></script>{% endfilter %}
</div>
<script defer src="{{script_protocol}}{{request.site.domain}}{% url 'ingress:endpoint_script' object.uuid %}"></script>{% endfilter %}
</div>

View File

@ -1,12 +1,12 @@
{% load i18n humanize helpers %}
{% load humanize helpers %}
<table class="table">
<thead>
<th>{% trans 'Session Start' %}</th>
<th>{% trans 'Identity' %}</th>
<th>{% trans 'Network' %}</th>
<th class="rf">{% trans 'Duration' %}</th>
<th class="rf">{% trans 'Hits' %}</th>
<th>Session Start</th>
<th>Identity</th>
<th>Network</th>
<th class="rf">Duration</th>
<th class="rf">Hits</th>
</thead>
<tbody>
{% for session in object_list %}
@ -14,7 +14,7 @@
<td>
<a href="{% contextual_url 'dashboard:service_session' object.pk session.pk %}"
class="font-medium text-urge-700">
{{ session.start_time|date:"DATETIME_FORMAT"|capfirst }}
{{session.start_time|date:"M j Y, g:i a"|capfirst}}
{% if session.is_currently_active %}
<span class="badge ~positive">Online</span>
{% endif %}
@ -33,7 +33,7 @@
</tr>
{% empty %}
<tr>
<td><span class="text-gray-600">{% trans 'No data yet' %}...</span></td>
<td><span class="text-gray-600">No data yet...</span></td>
</tr>
{% endfor %}
</tbody>

View File

@ -1,6 +1,6 @@
{% load i18n helpers %}
{% load helpers %}
<div>
<a class="portal !low {% if request.get_full_path|startswith:url %}~urge active bg-neutral-100{% endif %} flex items-center" title="{% trans label %}"
{% if disable_turbolinks %}data-turbolinks="false"{% endif %} href="{{url}}">{{icon}} <span class="truncate">{% trans label %}</span></a>
<a class="portal !low {% if request.get_full_path|startswith:url %}~urge active bg-neutral-100{% endif %} flex items-center" title="{{label}}"
{% if disable_turbolinks %}data-turbolinks="false"{% endif %} href="{{url}}">{{icon}} <span class="truncate">{{label}}</span></a>
</div>

View File

@ -5,14 +5,9 @@
enabled: false
},
tooltip: {
shared: true,
x: {
format: '{{tooltip_format|default:"MMM d"}}',
},
},
legend: {
show: false,
shared: false,
},
colors: ["#805AD5"],
chart: {
zoom: {
enabled: false,
@ -20,7 +15,7 @@
toolbar: {
show: false,
},
type: 'line',
type: 'area',
height: {{height|default:"200"}},
offsetY: -1,
animations: {
@ -29,14 +24,16 @@
sparkline: {
enabled: {% if sparkline %}true{% else %}false{% endif %},
},
{% if granularity == "daily" and click_zoom %}
events: {
markerClick: function(event, chartContext, { seriesIndex, dataPointIndex, w: {config}}) {
const day = config.labels[dataPointIndex]
window.location.href = `?startDate=${day}&endDate=${day}`
fill: {
type: 'gradient',
gradient: {
shadeIntensity: 1,
inverseColors: false,
opacityFrom: 0.8,
opacityTo: 0,
stops: [0, 75, 100]
},
},
{% endif %}
},
grid: {
padding: {
@ -66,27 +63,15 @@
},
xaxis: {
type: "datetime",
labels: {
datetimeUTC: false
},
},
stroke: {
width: 2,
curve: 'smooth',
width: 1.5,
},
series: [{
name: "Hits",
type: 'area',
color: "#ddd6fe",
data: {{data.hits|safe}}
}, {
name: "Sessions",
type: 'line',
color: "#805AD5",
data: {{data.sessions|safe}}
}],
labels: {{data.labels|safe}}
name: "{{unit|default:'Sessions'}}",
data: {{data|safe}}
}]
};
var triggerMatchesChart = new ApexCharts(document.querySelector("#chart{{name|default:'Main'}}"), triggerMatchesChartOptions);
triggerMatchesChart.render();
</script>
</script>

View File

@ -1,6 +1,6 @@
{% extends "base.html" %}
{% load i18n rules pagination %}
{% load rules pagination %}
{% block content %}
<div class="md:flex justify-between items-center">
@ -13,7 +13,7 @@
</div>
{% has_perm "core.create_service" user as can_create %}
{% if can_create %}
<a href="{% url 'dashboard:service_create' %}" class="button field !low bg-neutral-000 w-auto">+ {% trans 'New Service' %}</a>
<a href="{% url 'dashboard:service_create' %}" class="button field bg-neutral-000 w-auto">+ New Service</a>
{% endif %}
</div>
</div>

View File

@ -1,10 +1,9 @@
{% extends "base.html" %}
{% load i18n %}
{% block content %}
<section class="content">
<h2>{{request.site.name}} {% trans 'Analytics' %}</h2>
<h2>{{request.site.name}} Analytics</h2>
<p>{{request.site.name}} uses Shynet. Eventually, more information about Shynet will be available here.</p>
<a href="{% url 'account_login' %}" class="button ~urge !high">{% trans 'Log In' %}</a>
<a href="{% url 'account_login' %}" class="button ~urge !high">Log In</a>
</section>
{% endblock %}

View File

@ -1,12 +1,12 @@
{% extends "dashboard/service_base.html" %}
{% load i18n humanize helpers rules %}
{% load humanize helpers rules %}
{% block service_actions %}
<div class="mr-2">{% include 'dashboard/includes/date_range.html' %}</div>
{% has_perm 'core.change_service' user object as can_update %}
{% if can_update %}
<a href="{% contextual_url 'dashboard:service_update' service.uuid %}" class="button field !low bg-neutral-000 w-auto">{% trans 'Manage' %} &rarr;</a>
<a href="{% contextual_url 'dashboard:service_update' service.uuid %}" class="button field bg-neutral-000 w-auto">Manage &rarr;</a>
{% endif %}
{% endblock %}
@ -14,11 +14,7 @@
{% if not stats.has_hits %}
<div class="content mb-6">
<p>
{% blocktrans trimmed %}
This service hasn't collected any data yet. To get started, place the
following code snippet at the end of the <code>&lt;body&gt;</code> tag on any
page you'd like to track.
{% endblocktrans %}
This service hasn't collected any data yet. To get started, place the following code snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.
</p>
{% include 'dashboard/includes/service_snippet.html' %}
</div>
@ -26,7 +22,7 @@
<div class="grid grid-cols-2 gap-6 md:flex justify-between mb-6 card ~neutral !high px-6" id="stats">
{% with classes="text-sm font-semibold" good_classes="text-positive-400" bad_classes="text-critical-400" neutral_classes="text-gray-400" %}
<article class="">
<p class="label text-gray-400">{% trans 'sessions' %}</p>
<p class="label text-gray-400">Sessions</p>
<p class="heading">
{{stats.session_count|intcomma}}
<div>
@ -35,7 +31,7 @@
</p>
</article>
<article class="">
<p class="label text-gray-400">{% trans 'Hits' %}</p>
<p class="label text-gray-400">Hits</p>
<p class="heading">
{{stats.hit_count|intcomma}}
<div>
@ -44,7 +40,7 @@
</p>
</article>
<article class="">
<p class="label text-gray-400">{% trans 'Load Time' %}</p>
<p class="label text-gray-400">Load Time</p>
<p class="heading">
{% if stats.avg_load_time %}
{{stats.avg_load_time|floatformat:"0"}}ms
@ -57,7 +53,7 @@
</p>
</article>
<article class="">
<p class="label text-gray-400">{% trans 'Bounce Rate' %}</p>
<p class="label text-gray-400">Bounce Rate</p>
<p class="heading">
{% if stats.bounce_rate_pct %}
{{stats.bounce_rate_pct|floatformat:"-1"}}%
@ -70,7 +66,7 @@
</p>
</article>
<article class="">
<p class="label text-gray-400">{% trans 'Duration' %}</p>
<p class="label text-gray-400">Duration</p>
<p class="heading">
{% if stats.avg_session_duration %}
{{stats.avg_session_duration|naturaldelta}}
@ -83,7 +79,7 @@
</p>
</article>
<article class="">
<p class="label text-gray-400">{% trans 'Hits/Session' %}</p>
<p class="label text-gray-400">Hits/Session</p>
<p class="heading">
{% if stats.avg_hits_per_session %}
{{stats.avg_hits_per_session|floatformat:"-1"}}
@ -98,89 +94,23 @@
{% endwith %}
</div>
<div class="card overflow-visible ~neutral !low py-0 mb-6">
{% include 'dashboard/includes/time_chart.html' with data=stats.chart_data tooltip_format=stats.chart_tooltip_format granularity=stats.chart_granularity click_zoom=True %}
{% include 'dashboard/includes/time_chart.html' with data=stats.session_chart_data %}
</div>
{% endif %}
<div id="card-grid" class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Location' %}</th>
<th class="rf">{% trans 'Hits' %}</th>
<th>Location</th>
<th class="rf">Hits</th>
</tr>
</thead>
<tbody>
{% for location in stats.locations %}
<tr>
<td class="truncate w-full max-w-0 relative">
{% include 'dashboard/includes/bar.html' with count=location.count max=stats.locations.0.count total=stats.hit_count %}
<div class="relative flex items-center">
{{location.location|default:"Unknown"|urldisplay}}
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{location.count|intcomma}}
<span class="text-xs rf min-w-48">
({{location.count|percent:stats.hit_count}})
</span>
</div>
</td>
</tr>
{% empty %}
<tr>
<td><span class="text-gray-600">{% trans 'No data yet...' %}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
{% if stats.locations.count == RESULTS_LIMIT %}
<hr class="sep h-8 md:h-12">
<a href="{% contextual_url 'dashboard:service_location_list' service.uuid %}" class="button ~neutral w-auto mb-2">
{% trans 'View more locations' %} &rarr;
</a>
{% endif %}
</div>
<div class="geo-map card ~neutral !low py-2 overflow-y-hidden">
<p class="text-sm font-semibold p-2 border-b mb-2" style="color: var(--color-title)">
{% trans 'Sessions by Geography' %} &nbsp
<button onclick="document.getElementById('card-grid').classList.add('geo-card--use-table-view')" class="text-xs select-none p-0 button ~urge !low">
({% trans 'view table' %})
</button>
</p>
{% include 'dashboard/includes/map_chart.html' with countries=stats.countries %}
</div>
<div class="geo-table card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
<tr>
<th>
{% trans 'Country' %} &nbsp
<button onclick="document.getElementById('card-grid').classList.remove('geo-card--use-table-view'); geoMap.resize()" class="text-xs select-none p-0 button ~urge !low">
(view map)
</button>
</th>
<th class="rf">{% trans 'sessions' %}</th>
</tr>
</thead>
<tbody>
{% for country in stats.countries %}
<tr>
<td class="truncate w-full max-w-0 relative" title="{{country.country|country_name}}">
{% include 'dashboard/includes/bar.html' with count=country.count max=stats.countries.0.count total=stats.session_count %}
<div class="relative flex items-center">
<span class="flex-none {{country.country|flag_class}}"></span> <span class="truncate">{{country.country|country_name}}</span>
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{country.count|intcomma}}
<span class="text-xs rf min-w-48">
({{country.count|percent:stats.session_count}})
</span>
</div>
</td>
<td class="truncate w-full max-w-0">{{location.location|default:"Unknown"|urldisplay}}</td>
<td class="rf">{{location.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
@ -194,27 +124,15 @@
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Referrer' %}</th>
<th class="rf">{% trans 'sessions' %}</th>
<th>Referrer</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for referrer in stats.referrers %}
<tr>
<td class="truncate w-full max-w-0 relative">
{% include 'dashboard/includes/bar.html' with count=referrer.count max=stats.referrers.0.count total=stats.session_count %}
<div class="relative flex items-center">
{{referrer.referrer|default:"Direct"|urldisplay}}
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{referrer.count|intcomma}}
<span class="text-xs rf min-w-48">
({{referrer.count|percent:stats.session_count}})
</span>
</div>
</td>
<td class="truncate w-full max-w-0">{{referrer.referrer|default:"Direct"|urldisplay}}</td>
<td class="rf">{{referrer.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
@ -228,27 +146,41 @@
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Operating System' %}</th>
<th class="rf">{% trans 'sessions' %}</th>
<th>Country</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for country in stats.countries %}
<tr>
<td class="truncate w-full max-w-0" title="{{country.country|country_name}}">
<span class="{{country.country|flag_class}}"></span> {{country.country|country_name}}
</td>
<td class="rf">{{country.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
<td><span class="text-gray-600">No data yet...</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="card ~neutral !low limited-height py-2">
<table class="table">
<thead class="text-sm">
<tr>
<th>Operating System</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for os in stats.operating_systems %}
<tr>
<td class="flex items-center truncate w-full max-w-0 relative" title="{{os.os|default:'Unknown'}}">
{% include 'dashboard/includes/bar.html' with count=os.count max=stats.operating_systems.0.count total=stats.session_count %}
<div class="relative flex items-center">
{{os.os|iconify}}<span class="truncate">{{os.os|default:"Unknown"}}</span>
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{os.count|intcomma}}
<span class="text-xs rf min-w-48">
({{os.count|percent:stats.session_count}})
</span>
</div>
<td class="flex items-center truncate w-full max-w-0" title="{{os.os|default:'Unknown'}}">
{{os.os|iconify}}<span>{{os.os|default:"Unknown"}}</span>
</td>
<td class="rf">{{os.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
@ -262,28 +194,16 @@
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Browser' %}</th>
<th class="rf">{% trans 'sessions' %}</th>
<th>Browser</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for browser in stats.browsers %}
<tr>
<td class="flex items-center truncate w-full max-w-0 relative" title="{{browser.browser|default:'Unknown'}}">
{% include 'dashboard/includes/bar.html' with count=browser.count max=stats.browsers.0.count total=stats.session_count %}
</div>
<div class="relative flex items-center">
{{browser.browser|iconify}}<span class="truncate">{{browser.browser|default:"Unknown"}}</span>
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{browser.count|intcomma}}
<span class="text-xs rf min-w-48">
({{browser.count|percent:stats.session_count}})
</span>
</div>
</td>
<td class="flex items-center truncate w-full max-w-0" title="{{browser.browser|default:'Unknown'}}">
{{browser.browser|iconify}}<span>{{browser.browser|default:"Unknown"}}</span></td>
<td class="rf">{{browser.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
@ -297,27 +217,15 @@
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Device Type' %}</th>
<th class="rf">{% trans 'sessions' %}</th>
<th>Device Type</th>
<th class="rf">Sessions</th>
</tr>
</thead>
<tbody>
{% for device_type in stats.device_types %}
<tr>
<td class="truncate w-full max-w-0 relative">
{% include 'dashboard/includes/bar.html' with count=device_type.count max=stats.device_types.0.count total=stats.session_count %}
<div class="relative flex items-center">
<span class="truncate">{{device_type.device_type|default:"Unknown"|title}}</span>
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{device_type.count|intcomma}}
<span class="text-xs rf min-w-48">
({{device_type.count|percent:stats.session_count}})
</span>
</div>
</td>
<td class="truncate w-full max-w-0">{{device_type.device_type|default:"Unknown"|title}}</td>
<td class="rf">{{device_type.count|intcomma}}</td>
</tr>
{% empty %}
<tr>
@ -328,11 +236,11 @@
</table>
</div>
</div>
<div class="card ~neutral !low py-2 overflow-auto">
<div class="card ~neutral !low limited-height py-2">
{% include 'dashboard/includes/session_list.html' %}
<hr class="sep h-8 md:h-12">
<a href="{% contextual_url 'dashboard:service_session_list' service.uuid %}" class="button ~neutral w-auto mb-2">
{% trans 'View more sessions' %} &rarr;
</a>
<a href="{% contextual_url 'dashboard:service_session_list' service.uuid %}" class="button ~neutral w-auto mb-2">View more
sessions
&rarr;</a>
</div>
{% endblock %}
{% endblock %}

View File

@ -1,11 +1,11 @@
{% extends "base.html" %}
{% load i18n a17t_tags %}
{% load a17t_tags %}
{% block head_title %}{% trans 'Create Service' %}{% endblock %}
{% block head_title %}Create Service{% endblock %}
{% block content %}
<h4 class="heading leading-none">{% trans 'Create Service' %}</h4>
<h4 class="heading leading-none">Create Service</h4>
<hr class="sep">
<form class="card ~neutral !low p-0 max-w-xl" method="POST">
{% csrf_token %}
@ -13,8 +13,8 @@
{% include 'dashboard/includes/service_form.html' %}
</div>
<div class="section ~urge !normal p-4">
<button type="submit" class="button ~urge !high">{% trans 'Create' %}</button>
<a href="{% url 'dashboard:dashboard' %}" class="button ~urge !low">{% trans 'Cancel' %}</a>
<button type="submit" class="button ~urge !high">Create</button>
<a href="{% url 'dashboard:dashboard' %}" class="button ~urge !low">Cancel</a>
</div>
</form>
{% endblock %}

View File

@ -1,19 +1,15 @@
{% extends "dashboard/service_base.html" %}
{% load i18n a17t_tags %}
{% load a17t_tags %}
{% block head_title %}{% trans 'Delete' %} {{object.name}}{% endblock %}
{% block head_title %}Delete {{object.name}}{% endblock %}
{% block service_content %}
<form class="card ~neutral !low p-0 max-w-xl" method="POST">
{% csrf_token %}
<div class="p-4">
<p>
{% blocktrans trimmed %}
Are you sure you want to delete this service? All of its
analytics and associated data will be permanently deleted.
{% endblocktrans %}
</p>
<p>Are you sure you want to delete this service? All of its
analytics and associated data will be permanently deleted.</p>
{{form|a17t}}
</div>
<div class="section ~critical !normal p-4">

View File

@ -1,47 +0,0 @@
{% extends "dashboard/service_base.html" %}
{% load i18n a17t_tags pagination humanize helpers %}
{% block head_title %}{{object.name}} {% trans 'Locations' %}{% endblock %}
{% block service_actions %}
<div class="mr-2">{% include 'dashboard/includes/date_range.html' %}</div>
<a href="{% contextual_url 'dashboard:service' object.uuid %}" class="button field ~neutral !low bg-neutral-000 w-auto">{% trans 'Analytics' %} &rarr;</a>
{% endblock %}
{% block service_content %}
<div class="card ~neutral !low mb-8 pt-2 max-w-full overflow-x-auto">
<table class="table">
<thead class="text-sm">
<tr>
<th>{% trans 'Location' %}</th>
<th class="rf">{% trans 'Hits' %}</th>
</tr>
</thead>
<tbody>
{% for location in object_list %}
<tr>
<td class="truncate w-full max-w-0 relative">
<div class="relative flex items-center">
{{location.location|default:"Unknown"|urldisplay}}
</div>
</td>
<td>
<div class="flex justify-end items-center">
{{location.count|intcomma}}
<span class="text-xs rf min-w-48">
({{location.count|percent:hit_count}})
</span>
</div>
</td>
</tr>
{% empty %}
<tr>
<td><span class="text-gray-600">{% trans 'No data yet...' %}</span></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% pagination page_obj request %}
{% endblock %}

View File

@ -1,11 +1,11 @@
{% extends "dashboard/service_base.html" %}
{% load i18n a17t_tags pagination humanize helpers %}
{% load a17t_tags pagination humanize helpers %}
{% block head_title %}{{object.name}} Session{% endblock %}
{% block service_actions %}
<a href="{% contextual_url 'dashboard:service' object.uuid %}" class="button field !low bg-neutral-000 w-auto">Analytics &rarr;</a>
<a href="{% contextual_url 'dashboard:service' object.uuid %}" class="button field bg-neutral-000 w-auto">Analytics &rarr;</a>
{% endblock %}
{% block service_content %}
@ -24,36 +24,37 @@
<hr class="sep h-8 md:h-12">
<div class="grid grid-cols-2 md:grid-cols-4 gap-4 text-gray-400 font-medium">
<div>
<p>{% trans 'Browser' %}</p>
<p>Browser</p>
<p class="label">{{session.browser|default:"Unknown"}}</p>
</div>
<div>
<p>{% trans 'Device' %}</p>
<p>Device</p>
<p class="label">{{session.device|default:"Unknown"}}</p>
</div>
<div>
<p{% trans 'Device Type' %}</p>
<p>Device Type</p>
<p class="label">{{session.device_type|title}}</p>
</div>
<div>
<p>{% trans 'OS' %}</p>
<p>OS</p>
<p class="label">{{session.os|default:"Unknown"}}</p>
</div>
<div>
<p>{% trans 'Network' %}</p>
<p>Network</p>
<p class="label">{{session.asn|default:"Unknown"}}</p>
</div>
<div>
<p>{% trans 'Country' %}</p>
<p>Country</p>
<p class="label"><span class="{{session.country|flag_class}}"></span>{{session.country|country_name}}</p>
</div>
<div>
<p>{% trans 'Location' %}</p>
<p>Location</p>
<p class="label">
{% if session.latitude %}
<a href="{{session|location_url}}" target="_blank">{% trans 'Open in Maps' %} &nearr;</a>
<a href="{{session|location_url}}" target="_blank">Open
in Maps &nearr;</a>
{% else %}
{% trans 'Unknown' %}
Unknown
{% endif %}
</p>
</div>
@ -78,15 +79,15 @@
</div>
<div class="grid grid-cols-3 gap-3 md:pl-8 md:w-1/2">
<div>
<p>{% trans 'Duration' %}</p>
<p>Duration</p>
<p class="label">{{hit.duration|naturaldelta}}</p>
</div>
<div>
<p>{% trans 'Load' %}</p>
<p>Load</p>
<p class="label">{{hit.load_time|floatformat:"0"}}ms</p>
</div>
<div>
<p>{% trans 'Tracker' %}</p>
<p>Tracker</p>
<p class="label">{{hit.tracker}}</p>
</div>
</div>

View File

@ -1,12 +1,12 @@
{% extends "dashboard/service_base.html" %}
{% load i18n a17t_tags pagination humanize helpers %}
{% load a17t_tags pagination humanize helpers %}
{% block head_title %}{{object.name}} {% trans 'Sessions' %}{% endblock %}
{% block head_title %}{{object.name}} Sessions{% endblock %}
{% block service_actions %}
<div class="mr-2">{% include 'dashboard/includes/date_range.html' %}</div>
<a href="{% contextual_url 'dashboard:service' object.uuid %}" class="button field ~neutral !low bg-neutral-000 w-auto">{% trans 'Analytics' %} &rarr;</a>
<a href="{% contextual_url 'dashboard:service' object.uuid %}" class="button field ~neutral bg-neutral-000 w-auto">Analytics &rarr;</a>
{% endblock %}
{% block service_content %}
@ -14,4 +14,4 @@
{% include 'dashboard/includes/session_list.html' %}
</div>
{% pagination page_obj request %}
{% endblock %}
{% endblock %}

View File

@ -1,24 +1,20 @@
{% extends "dashboard/service_base.html" %}
{% load i18n a17t_tags %}
{% load a17t_tags %}
{% block head_title %}{{object.name}} {% trans 'Management' %}{% endblock %}
{% block head_title %}{{object.name}} Management{% endblock %}
{% block service_actions %}
<a href="{% url 'dashboard:service' object.uuid %}" class="button field !low bg-neutral-000 w-auto">{% trans 'View' %} &rarr;</a>
<a href="{% url 'dashboard:service' object.uuid %}" class="button field bg-neutral-000 w-auto">View &rarr;</a>
{% endblock %}
{% block service_content %}
<div class="max-w-xl content">
<h5>{% trans 'Installation' %}</h5>
<p>
{% blocktrans trimmed %}
Place the following snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.
{% endblocktrans %}
</p>
<h5>Installation</h5>
<p>Place the following snippet at the end of the <code>&lt;body&gt;</code> tag on any page you'd like to track.</p>
{% include 'dashboard/includes/service_snippet.html' %}
<hr class="sep h-4">
<h5>{% trans 'Settings' %}</h5>
<h5>Settings</h5>
<form class="card ~neutral !low p-0" method="POST">
{% csrf_token %}
<div class="p-4">
@ -26,28 +22,13 @@
</div>
<div class="section ~neutral !normal p-4 flex justify-between">
<div>
<button type="submit" class="button ~neutral !high">{% trans 'Save' %}</button>
<a href="{% url 'dashboard:service' object.uuid %}" class="button ~neutral !low">{% trans 'Cancel' %}</a>
<button type="submit" class="button ~neutral !high">Save</button>
<a href="{% url 'dashboard:service' object.uuid %}" class="button ~neutral !low">Cancel</a>
</div>
<div>
<a href="{% url 'dashboard:service_delete' object.uuid %}" class="button ~critical !high">{% trans 'Delete' %}</a>
<a href="{% url 'dashboard:service_delete' object.uuid %}" class="button ~critical !high">Delete</a>
</div>
</div>
</form>
<hr class="sep h-4">
<h5>API</h5>
<div class="card ~neutral !low content">
<p>Shynet provides a simple API that you can use to pull data programmatically. You can access this data via this URL:</p>
<code class="text-sm">{{script_protocol}}{{request.get_host}}{% url 'api:services' %}?uuid={{object.uuid}}</code>
<p>
There are 2 optional query parameters:
<ul>
<li><code class="text-sm">startDate</code> &mdash; to set the start date (in format YYYY-MM-DD)</li>
<li><code class="text-sm">endDate</code> &mdash; to set the end date (in format YYYY-MM-DD)</li>
</ul>
</p>
<p>Example using cURL:</p>
<code class="text-sm">curl -H 'Authorization: Token (your API token, available on security page)' '{{script_protocol}}{{request.get_host}}{% url 'api:services' %}?uuid={{object.uuid}}&startDate=2021-01-01&endDate=2050-01-01'</code>
</div>
</div>
{% endblock %}

View File

@ -43,14 +43,6 @@ def country_name(isocode):
return "Unknown"
@register.filter
def datamap_id(isocode):
try:
return pycountry.countries.get(alpha_2=isocode).alpha_3
except:
return "UNKNOWN"
@register.simple_tag
def relative_stat_tone(
start,
@ -168,7 +160,6 @@ def iconify(text):
"firefox mobile": "firefox.com",
"edge mobile": "microsoft.com",
"chromium": "chromium.org",
"duckduckgo mobile": "duckduckgo.com",
}
domain = None
@ -190,12 +181,11 @@ def urldisplay(url):
if url.startswith("http"):
display_url = url.replace("http://", "").replace("https://", "")
return SafeString(
f"<a href='{url}' title='{url}' rel='nofollow' class='flex items-center mr-1 truncate'>{iconify(url)}<span class='truncate'>{escape(display_url)}</span></a>"
f"<a href='{url}' title='{url}' rel='nofollow' class='flex items-center mr-1'>{iconify(url)}<span class='truncate'>{escape(display_url)}</span></a>"
)
else:
return url
class ContextualURLNode(template.Node):
"""Extension of the Django URLNode to support including contextual parameters in URL outputs. In other words, URLs generated will keep the start and end date parameters."""
@ -215,13 +205,9 @@ class ContextualURLNode(template.Node):
url_parts = list(urlparse(url))
query = dict(urllib.parse.parse_qsl(url_parts[4]))
query.update(
{
param: context.request.GET.get(param)
for param in self.CONTEXT_PARAMS
if param in context.request.GET and param not in query
}
)
query.update({
param: context.request.GET.get(param) for param in self.CONTEXT_PARAMS if param in context.request.GET and param not in query
})
url_parts[4] = urllib.parse.urlencode(query)
@ -229,7 +215,7 @@ class ContextualURLNode(template.Node):
if self.urlnode.asvar:
context[self.urlnode.asvar] = url_final
return ""
return ''
else:
return url_final
@ -238,39 +224,7 @@ class ContextualURLNode(template.Node):
def contextual_url(*args, **kwargs):
urlnode = url_tag(*args, **kwargs)
return ContextualURLNode(urlnode)
@register.filter
def location_url(session):
return settings.LOCATION_URL.replace("$LATITUDE", str(session.latitude)).replace(
"$LONGITUDE", str(session.longitude)
)
@register.filter
def percent(value, total):
if total == 0:
return "N/A"
percent = value / total
if percent < 0.001:
return "<0.1%"
return f"{percent:.1%}"
@register.simple_tag
def bar_width(count, max, total):
if total == 0 or max == 0:
return "0"
if settings.USE_RELATIVE_MAX_IN_BAR_VISUALIZATION:
percent = count / max
else:
percent = count / total
if percent < 0.001:
return "0"
return f"{percent:.1%}"
return settings.LOCATION_URL.replace("$LATITUDE", str(session.latitude)).replace("$LONGITUDE", str(session.longitude))

View File

@ -1,43 +0,0 @@
from django.test import TestCase, RequestFactory
from django.conf import settings
from django.urls import reverse
from core.factories import UserFactory
from dashboard.views import DashboardView
class QuestionModelTests(TestCase):
def setUp(self):
# Every test needs access to the request factory.
self.factory = RequestFactory()
self.user = UserFactory()
def tearDown(self):
pass
def tests_unauthenticated_dashboard_view(self):
"""
GIVEN: Unauthenticated user
WHEN: Accessing the dashboard view
THEN: It's redirected to login page with NEXT url to dashboard
"""
login_url = settings.LOGIN_URL
response = self.client.get(reverse("dashboard:dashboard"))
self.assertEqual(response.status_code, 302)
self.assertEqual(
response.url, f"{login_url}?next={reverse('dashboard:dashboard')}"
)
def tests_authenticated_dashboard_view(self):
"""
GIVEN: Authenticated user
WHEN: Accessing the dashboard view
THEN: It should respond with 200 and render the view
"""
request = self.factory.get(reverse("dashboard:dashboard"))
request.user = self.user
# Use this syntax for class-based views.
response = DashboardView.as_view()(request)
self.assertEqual(response.status_code, 200)

View File

@ -1,4 +1,6 @@
from django.urls import path
from django.contrib import admin
from django.urls import include, path
from django.views.generic import RedirectView
from . import views
@ -26,14 +28,4 @@ urlpatterns = [
views.ServiceSessionView.as_view(),
name="service_session",
),
path(
"service/<pk>/locations/",
views.ServiceLocationsListView.as_view(),
name="service_location_list",
),
path(
"api-token-refresh/",
views.RefreshApiTokenView.as_view(),
name="api_token_refresh",
),
]

View File

@ -2,20 +2,21 @@ from django.conf import settings
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.core.cache import cache
from django.db.models import Q, Count
from django.shortcuts import get_object_or_404, reverse, redirect
from django.db.models import Q
from django.shortcuts import get_object_or_404, reverse
from django.utils import timezone
from django.views.generic import (
CreateView,
DeleteView,
DetailView,
ListView,
TemplateView,
UpdateView,
View,
)
from rules.contrib.views import PermissionRequiredMixin
from analytics.models import Session, Hit
from core.models import Service, _default_api_token, RESULTS_LIMIT
from analytics.models import Session
from core.models import Service
from .forms import ServiceForm
from .mixins import DateRangeMixin
@ -24,7 +25,7 @@ from .mixins import DateRangeMixin
class DashboardView(LoginRequiredMixin, DateRangeMixin, ListView):
model = Service
template_name = "dashboard/pages/dashboard.html"
paginate_by = settings.DASHBOARD_PAGE_SIZE
paginate_by = 5
def get_queryset(self):
return Service.objects.filter(
@ -67,7 +68,6 @@ class ServiceView(
data = super().get_context_data(**kwargs)
data["script_protocol"] = "https://" if settings.SCRIPT_USE_HTTPS else "http://"
data["stats"] = self.object.get_core_stats(data["start_date"], data["end_date"])
data["RESULTS_LIMIT"] = RESULTS_LIMIT
data["object_list"] = Session.objects.filter(
service=self.get_object(),
start_time__lt=self.get_end_date(),
@ -141,36 +141,6 @@ class ServiceSessionsListView(
return data
class ServiceLocationsListView(
LoginRequiredMixin, PermissionRequiredMixin, DateRangeMixin, ListView
):
model = Hit
template_name = "dashboard/pages/service_location_list.html"
paginate_by = RESULTS_LIMIT
permission_required = "core.view_service"
def get_object(self):
return get_object_or_404(Service, pk=self.kwargs.get("pk"))
def get_queryset(self):
hits = Hit.objects.filter(
service=self.get_object(),
start_time__lt=self.get_end_date(),
start_time__gt=self.get_start_date(),
)
self.hit_count = hits.count()
return (
hits.values("location").annotate(count=Count("location")).order_by("-count")
)
def get_context_data(self, **kwargs):
data = super().get_context_data(**kwargs)
data["object"] = self.get_object()
data["hit_count"] = self.hit_count
return data
class ServiceSessionView(LoginRequiredMixin, PermissionRequiredMixin, DetailView):
model = Session
template_name = "dashboard/pages/service_session.html"
@ -185,10 +155,3 @@ class ServiceSessionView(LoginRequiredMixin, PermissionRequiredMixin, DetailView
data = super().get_context_data(**kwargs)
data["object"] = get_object_or_404(Service, pk=self.kwargs.get("pk"))
return data
class RefreshApiTokenView(LoginRequiredMixin, View):
def post(self, request):
request.user.api_token = _default_api_token()
request.user.save()
return redirect("account_change_password")

View File

@ -10,8 +10,6 @@ https://docs.djangoproject.com/en/2.2/ref/settings/
import os
from dotenv import load_dotenv
# import module sys to get the type of exception
import sys
import urllib.parse as urlparse
@ -19,11 +17,8 @@ import urllib.parse as urlparse
# Messages
from django.contrib.messages import constants as messages
# Load environment variables
load_dotenv()
# Increment on new releases
VERSION = "0.13.1"
VERSION = "v0.8.2"
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
@ -39,7 +34,7 @@ SECRET_KEY = os.getenv("DJANGO_SECRET_KEY", "onlyusethisindev")
DEBUG = os.getenv("DEBUG", "False") == "True"
ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "*").split(",")
CSRF_TRUSTED_ORIGINS = filter(lambda k: len(k) > 0, os.getenv("CSRF_TRUSTED_ORIGINS", "").split(","))
# Application definition
@ -60,19 +55,16 @@ INSTALLED_APPS = [
"core",
"dashboard.apps.DashboardConfig",
"analytics",
"api",
"allauth",
"allauth.account",
"allauth.socialaccount",
"debug_toolbar",
"corsheaders",
]
MIDDLEWARE = [
"django.middleware.security.SecurityMiddleware",
"whitenoise.middleware.WhiteNoiseMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"corsheaders.middleware.CorsMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
@ -104,13 +96,13 @@ WSGI_APPLICATION = "shynet.wsgi.application"
# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
if os.getenv("SQLITE", "False") == "True":
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.environ.get("DB_NAME", "/var/local/shynet/db/db.sqlite3"),
"NAME": os.path.join(BASE_DIR, "db.sqlite3"),
}
}
else:
@ -205,7 +197,7 @@ LOGGING = {
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = os.getenv("LANGUAGE_CODE", "en-us")
LANGUAGE_CODE = "en-us"
TIME_ZONE = os.getenv("TIME_ZONE", "America/New_York")
@ -302,9 +294,6 @@ else:
EMAIL_USE_SSL = os.environ.get("EMAIL_USE_SSL")
EMAIL_USE_TLS = os.environ.get("EMAIL_USE_TLS")
# Auto fields
DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"
# NPM
NPM_ROOT_PATH = "../"
@ -321,13 +310,7 @@ NPM_FILE_PATTERNS = {
"stimulus": [os.path.join("dist", "stimulus.umd.js")],
"inter-ui": [os.path.join("Inter (web)", "*")],
"@fortawesome": [os.path.join("fontawesome-free", "js", "all.min.js")],
"datamaps": [os.path.join("dist", "datamaps.world.min.js")],
"d3": ["d3.min.js"],
"topojson": [os.path.join("build", "topojson.min.js")],
"flag-icon-css": [
os.path.join("css", "flag-icon.min.css"),
os.path.join("flags", "*"),
],
"flag-icon-css": [os.path.join("css", "flag-icon.min.css"), os.path.join("flags", "*")],
}
# Shynet
@ -363,31 +346,4 @@ BLOCK_ALL_IPS = os.getenv("BLOCK_ALL_IPS", "False") == "True"
AGGRESSIVE_HASH_SALTING = os.getenv("AGGRESSIVE_HASH_SALTING", "False") == "True"
# What location url should be linked to in the frontend?
LOCATION_URL = os.getenv(
"LOCATION_URL", "https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE"
)
# How many services should be displayed on dashboard page?
DASHBOARD_PAGE_SIZE = int(os.getenv("DASHBOARD_PAGE_SIZE", "5"))
# Should background bars be scaled to full width?
USE_RELATIVE_MAX_IN_BAR_VISUALIZATION = (
os.getenv("USE_RELATIVE_MAX_IN_BAR_VISUALIZATION", "True") == "True"
)
CORS_ALLOW_ALL_ORIGINS = True
CORS_ALLOW_METHODS = ["GET", "OPTIONS"]
# IPWare Precedence Options
IPWARE_META_PRECEDENCE_ORDER = (
'HTTP_CF_CONNECTING_IP',
'HTTP_X_FORWARDED_FOR', 'X_FORWARDED_FOR', # client, proxy1, proxy2
'HTTP_CLIENT_IP',
'HTTP_X_REAL_IP',
'HTTP_X_FORWARDED',
'HTTP_X_CLUSTER_CLIENT_IP',
'HTTP_FORWARDED_FOR',
'HTTP_FORWARDED',
'HTTP_VIA',
'REMOTE_ADDR',
)
LOCATION_URL = os.getenv("LOCATION_URL", "https://www.openstreetmap.org/?mlat=$LATITUDE&mlon=$LONGITUDE")

View File

@ -25,5 +25,4 @@ urlpatterns = [
path("dashboard/", include(("dashboard.urls", "dashboard"), namespace="dashboard")),
path("healthz/", include("health_check.urls")),
path("", include(("core.urls", "core"), namespace="core")),
path("api/v1/", include(("api.urls", "api"), namespace="api")),
]

View File

@ -16,6 +16,9 @@ if [[ ${startup_results[1]} == True ]]; then
echo "Warning: no admin user available. Consult docs for instructions."
fi
if [[ ${startup_results[2]} == True ]]; then
echo "Warning: Shynet's hostname is not set. The script won't work correctly. Consult docs for instructions."
fi
if [[ ${startup_results[3]} == True ]]; then
echo "Warning: Shynet's whitelabel is not set. Consult docs for instructions."
fi
echo "Startup checks complete!"