mirror of
https://github.com/dgtlmoon/changedetection.io.git
synced 2025-11-26 03:13:21 +00:00
Compare commits
84 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d66160e8c | ||
|
|
f877af75b9 | ||
|
|
b752690f89 | ||
|
|
a10efa951b | ||
|
|
24a38f26f8 | ||
|
|
1d0018dced | ||
|
|
18c7a18be8 | ||
|
|
c11adcbe4a | ||
|
|
cd6ce89587 | ||
|
|
4164ad29e3 | ||
|
|
4953e253e9 | ||
|
|
64e172433a | ||
|
|
92c0fa90ee | ||
|
|
ee8053e0e8 | ||
|
|
7f5b592f6f | ||
|
|
1e45156bc0 | ||
|
|
c7169ebba1 | ||
|
|
a58679f983 | ||
|
|
661542b056 | ||
|
|
2ea48cb90a | ||
|
|
2a80022cd9 | ||
|
|
8861f70ac4 | ||
|
|
07113216d5 | ||
|
|
02062c5893 | ||
|
|
a11f09062b | ||
|
|
0bb48cbd43 | ||
|
|
7109a17a8e | ||
|
|
4ed026aba6 | ||
|
|
3b79f8ed4e | ||
|
|
5d02c4fe6f | ||
|
|
f2b06c63bf | ||
|
|
ab6f4d11ed | ||
|
|
5311a95140 | ||
|
|
fb723c264d | ||
|
|
3ad722d63c | ||
|
|
9c16695932 | ||
|
|
35fc76c02c | ||
|
|
934d8c6211 | ||
|
|
294256d5c3 | ||
|
|
b7efdfd52c | ||
|
|
6a78b5ad1d | ||
|
|
98f3e61314 | ||
|
|
e322c44d3e | ||
|
|
7b226e1d54 | ||
|
|
35e597a4c8 | ||
|
|
0a1a8340c2 | ||
|
|
8b5cd40593 | ||
|
|
7d978a6e65 | ||
|
|
fdab52d400 | ||
|
|
782795310f | ||
|
|
2280e6d497 | ||
|
|
822f3e6d20 | ||
|
|
35546c331c | ||
|
|
982a0d7781 | ||
|
|
c5c3e8c6c2 | ||
|
|
ff1b19cdb8 | ||
|
|
df96b8d76c | ||
|
|
89134b5b6c | ||
|
|
b31bf34890 | ||
|
|
5b2fda1a6e | ||
|
|
fb38b06eae | ||
|
|
e0578acca2 | ||
|
|
187523d8d6 | ||
|
|
b0975694c8 | ||
|
|
b1fb47e689 | ||
|
|
a82e9243a6 | ||
|
|
e3e36b3cef | ||
|
|
cd6465f844 | ||
|
|
30d53c353f | ||
|
|
47fcb8b4f8 | ||
|
|
0ec9edb971 | ||
|
|
f1da8f96b6 | ||
|
|
8bc7b5be40 | ||
|
|
022826493b | ||
|
|
092f77f066 | ||
|
|
013cbcabd4 | ||
|
|
66be95ecc6 | ||
|
|
efe0356f37 | ||
|
|
ec1ac300af | ||
|
|
468184bc3a | ||
|
|
0855017dca | ||
|
|
ae0f640ff4 | ||
|
|
cd6629ac2d | ||
|
|
3c3ca7944b |
2
.dockerignore
Normal file
2
.dockerignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.git
|
||||||
|
.github
|
||||||
9
.github/FUNDING.yml
vendored
9
.github/FUNDING.yml
vendored
@@ -1,12 +1,3 @@
|
|||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
|
|
||||||
github: dgtlmoon
|
github: dgtlmoon
|
||||||
patreon: # Replace with a single Patreon username
|
|
||||||
open_collective: # Replace with a single Open Collective username
|
|
||||||
ko_fi: # Replace with a single Ko-fi username
|
|
||||||
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
||||||
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
||||||
liberapay: # Replace with a single Liberapay username
|
|
||||||
issuehunt: # Replace with a single IssueHunt username
|
|
||||||
otechie: # Replace with a single Otechie username
|
|
||||||
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
|
||||||
|
|||||||
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
67
.github/workflows/codeql-analysis.yml
vendored
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ master ]
|
||||||
|
schedule:
|
||||||
|
- cron: '27 9 * * 4'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'javascript', 'python' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v1
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v1
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v1
|
||||||
77
.github/workflows/image.yml
vendored
Normal file
77
.github/workflows/image.yml
vendored
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
name: Test, build and push to Docker Hub
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ master ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.9
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install flake8 pytest
|
||||||
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
cd backend; pytest
|
||||||
|
|
||||||
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v1
|
||||||
|
with:
|
||||||
|
image: tonistiigi/binfmt:latest
|
||||||
|
platforms: all
|
||||||
|
- name: Login to Docker Hub
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
username: ${{ secrets.DOCKER_HUB_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
id: buildx
|
||||||
|
uses: docker/setup-buildx-action@v1
|
||||||
|
with:
|
||||||
|
install: true
|
||||||
|
version: latest
|
||||||
|
driver-opts: image=moby/buildkit:master
|
||||||
|
- name: Build and push
|
||||||
|
id: docker_build
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ secrets.DOCKER_HUB_USERNAME }}/changedetection.io:latest
|
||||||
|
# ${{ secrets.DOCKER_HUB_USERNAME }}:/changedetection.io:${{ env.RELEASE_VERSION }}
|
||||||
|
platforms: linux/amd64,linux/arm64,linux/arm/v6,linux/arm/v7
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Image digest
|
||||||
|
run: echo ${{ steps.docker_build.outputs.digest }}
|
||||||
|
|
||||||
|
- name: Cache Docker layers
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: /tmp/.buildx-cache
|
||||||
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
|
restore-keys: |
|
||||||
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
|
|
||||||
37
.github/workflows/python-app.yml
vendored
37
.github/workflows/python-app.yml
vendored
@@ -1,37 +0,0 @@
|
|||||||
# This workflow will install Python dependencies, run tests and lint with a single version of Python
|
|
||||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
|
|
||||||
|
|
||||||
name: changedetection.io
|
|
||||||
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches: [ master ]
|
|
||||||
pull_request:
|
|
||||||
branches: [ master ]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
- name: Set up Python 3.9
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: 3.9
|
|
||||||
- name: Install dependencies
|
|
||||||
run: |
|
|
||||||
python -m pip install --upgrade pip
|
|
||||||
pip install flake8 pytest
|
|
||||||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
|
||||||
- name: Lint with flake8
|
|
||||||
run: |
|
|
||||||
# stop the build if there are Python syntax errors or undefined names
|
|
||||||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
|
||||||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
|
||||||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
|
||||||
- name: Test with pytest
|
|
||||||
run: |
|
|
||||||
cd backend; pytest
|
|
||||||
33
.github/workflows/test-only.yml
vendored
Normal file
33
.github/workflows/test-only.yml
vendored
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
name: Test only
|
||||||
|
|
||||||
|
# Triggers the workflow on push or pull request events
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Set up Python 3.9
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: 3.9
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
python -m pip install --upgrade pip
|
||||||
|
pip install flake8 pytest
|
||||||
|
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
|
||||||
|
|
||||||
|
- name: Lint with flake8
|
||||||
|
run: |
|
||||||
|
# stop the build if there are Python syntax errors or undefined names
|
||||||
|
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
|
||||||
|
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
|
||||||
|
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
|
||||||
|
- name: Test with pytest
|
||||||
|
run: |
|
||||||
|
# Each test is totally isolated and performs its own cleanup/reset
|
||||||
|
cd backend; ./run_all_tests.sh
|
||||||
|
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
FROM python:3.8-slim
|
FROM python:3.8-slim
|
||||||
COPY requirements.txt /tmp/requirements.txt
|
COPY requirements.txt /tmp/requirements.txt
|
||||||
RUN pip3 install -r /tmp/requirements.txt
|
RUN apt-get update && apt-get install -y gcc libc-dev libxslt-dev zlib1g-dev g++ --no-install-recommends && rm -rf /var/lib/apt/lists/* /var/cache/apt/*
|
||||||
|
|
||||||
|
RUN pip3 install --no-cache-dir -r /tmp/requirements.txt
|
||||||
|
|
||||||
|
|
||||||
RUN [ ! -d "/app" ] && mkdir /app
|
RUN [ ! -d "/app" ] && mkdir /app
|
||||||
|
|||||||
48
README.md
48
README.md
@@ -1,19 +1,21 @@
|
|||||||
# changedetection.io
|
# changedetection.io
|
||||||

|

|
||||||
<a href="https://hub.docker.com/r/dgtlmoon/changedetection.io" target="_blank" title="Change detection docker hub">
|
<a href="https://hub.docker.com/r/dgtlmoon/changedetection.io" target="_blank" title="Change detection docker hub">
|
||||||
<img src="https://img.shields.io/docker/pulls/dgtlmoon/changedetection.io" alt="Docker Pulls"/>
|
<img src="https://img.shields.io/docker/pulls/dgtlmoon/changedetection.io" alt="Docker Pulls"/>
|
||||||
</a>
|
</a>
|
||||||
<a href="https://hub.docker.com/r/dgtlmoon/changedetection.io" target="_blank" title="Change detection docker hub">
|
<a href="https://hub.docker.com/r/dgtlmoon/changedetection.io" target="_blank" title="Change detection docker hub">
|
||||||
<img src="https://img.shields.io/docker/v/dgtlmoon/changedetection.io" alt="Change detection latest tag version"/>
|
<img src="https://img.shields.io/github/v/release/dgtlmoon/changedetection.io" alt="Change detection latest tag version"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
## Self-hosted change monitoring of web pages.
|
## Self-hosted change monitoring of web pages.
|
||||||
|
|
||||||
_Know when web pages change! Stay ontop of new information!_
|
_Know when web pages change! Stay ontop of new information!_
|
||||||
|
|
||||||

|
Live your data-life *pro-actively* instead of *re-actively*, do not rely on manipulative social media for consuming important information.
|
||||||
|
|
||||||
|
|
||||||
|
<img src="https://raw.githubusercontent.com/dgtlmoon/changedetection.io/master/screenshot.png" style="max-width:100%;" alt="Self-hosted web page change monitoring" title="Self-hosted web page change monitoring" />
|
||||||
|
|
||||||
#### Example use cases
|
#### Example use cases
|
||||||
|
|
||||||
Know when ...
|
Know when ...
|
||||||
@@ -48,16 +50,36 @@ docker run -d --restart always -p "127.0.0.1:5000:5000" -v datastore-volume:/dat
|
|||||||
|
|
||||||
Examining differences in content.
|
Examining differences in content.
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
### Future plans
|
|
||||||
|
|
||||||
- Greater configuration of check interval times, page request headers.
|
|
||||||
- ~~General options for timeout, default headers~~
|
|
||||||
- On change detection, callout to another API (handy for notices/issue trackers)
|
|
||||||
- ~~Explore the differences that were detected~~
|
|
||||||
- Add more options to explore versions of differences
|
|
||||||
- Use a graphic/rendered page difference instead of text (see the experimental `selenium-screenshot-diff` branch)
|
|
||||||
|
|
||||||
|
<img src="https://raw.githubusercontent.com/dgtlmoon/changedetection.io/master/screenshot-diff.png" style="max-width:100%;" alt="Self-hosted web page change monitoring context difference " title="Self-hosted web page change monitoring context difference " />
|
||||||
|
|
||||||
Please :star: star :star: this project and help it grow! https://github.com/dgtlmoon/changedetection.io/
|
Please :star: star :star: this project and help it grow! https://github.com/dgtlmoon/changedetection.io/
|
||||||
|
|
||||||
|
### Notifications
|
||||||
|
|
||||||
|
ChangeDetection.io supports a massive amount of notifications (including email, office365, custom APIs, etc) when a web-page has a change detected thanks to the <a href="https://github.com/caronc/apprise">apprise</a> library.
|
||||||
|
Simply set one or more notification URL's in the _[edit]_ tab of that watch.
|
||||||
|
|
||||||
|
Just some examples
|
||||||
|
|
||||||
|
discord://webhook_id/webhook_token
|
||||||
|
flock://app_token/g:channel_id
|
||||||
|
gitter://token/room
|
||||||
|
gchat://workspace/key/token
|
||||||
|
msteams://TokenA/TokenB/TokenC/
|
||||||
|
o365://TenantID:AccountEmail/ClientID/ClientSecret/TargetEmail
|
||||||
|
rocket://user:password@hostname/#Channel
|
||||||
|
mailto://user:pass@example.com?to=receivingAddress@example.com
|
||||||
|
json://someserver.com/custom-api
|
||||||
|
syslog://
|
||||||
|
|
||||||
|
<a href="https://github.com/caronc/apprise">And everything else in this list!</a>
|
||||||
|
|
||||||
|
<img src="https://raw.githubusercontent.com/dgtlmoon/changedetection.io/master/screenshot-notifications.png" style="max-width:100%;" alt="Self-hosted web page change monitoring notifications" title="Self-hosted web page change monitoring notifications" />
|
||||||
|
|
||||||
|
|
||||||
|
### Notes
|
||||||
|
|
||||||
|
- Does not yet support Javascript
|
||||||
|
- Wont work with Cloudfare type "Please turn on javascript" protected pages
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,8 @@
|
|||||||
|
|
||||||
|
|
||||||
# @todo logging
|
# @todo logging
|
||||||
# @todo sort by last_changed
|
|
||||||
# @todo extra options for url like , verify=False etc.
|
# @todo extra options for url like , verify=False etc.
|
||||||
# @todo enable https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl as option?
|
# @todo enable https://urllib3.readthedocs.io/en/latest/user-guide.html#ssl as option?
|
||||||
# @todo maybe a button to reset all 'last-changed'.. so you can see it clearly when something happens since your last visit
|
|
||||||
# @todo option for interval day/6 hour/etc
|
# @todo option for interval day/6 hour/etc
|
||||||
# @todo on change detected, config for calling some API
|
# @todo on change detected, config for calling some API
|
||||||
# @todo make tables responsive!
|
# @todo make tables responsive!
|
||||||
@@ -17,11 +15,20 @@
|
|||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
import timeago
|
import timeago
|
||||||
|
import flask_login
|
||||||
|
from flask_login import login_required
|
||||||
|
|
||||||
import threading
|
import threading
|
||||||
|
from threading import Event
|
||||||
|
|
||||||
import queue
|
import queue
|
||||||
|
|
||||||
from flask import Flask, render_template, request, send_file, send_from_directory, abort, redirect, url_for
|
from flask import Flask, render_template, request, send_from_directory, abort, redirect, url_for
|
||||||
|
|
||||||
|
from feedgen.feed import FeedGenerator
|
||||||
|
from flask import make_response
|
||||||
|
import datetime
|
||||||
|
import pytz
|
||||||
|
|
||||||
datastore = None
|
datastore = None
|
||||||
|
|
||||||
@@ -34,12 +41,18 @@ extra_stylesheets = []
|
|||||||
|
|
||||||
update_q = queue.Queue()
|
update_q = queue.Queue()
|
||||||
|
|
||||||
app = Flask(__name__, static_url_path="/var/www/change-detection/backen/static")
|
notification_q = queue.Queue()
|
||||||
|
|
||||||
|
app = Flask(__name__, static_url_path="/var/www/change-detection/backend/static")
|
||||||
|
|
||||||
# Stop browser caching of assets
|
# Stop browser caching of assets
|
||||||
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0
|
||||||
|
|
||||||
app.config['STOP_THREADS'] = False
|
app.config.exit = Event()
|
||||||
|
|
||||||
|
app.config['NEW_VERSION_AVAILABLE'] = False
|
||||||
|
|
||||||
|
app.config['LOGIN_DISABLED'] = False
|
||||||
|
|
||||||
# Disables caching of the templates
|
# Disables caching of the templates
|
||||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
@@ -73,26 +86,129 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"):
|
|||||||
# return datetime.datetime.utcfromtimestamp(timestamp).strftime(format)
|
# return datetime.datetime.utcfromtimestamp(timestamp).strftime(format)
|
||||||
|
|
||||||
|
|
||||||
def changedetection_app(config=None, datastore_o=None):
|
class User(flask_login.UserMixin):
|
||||||
|
id=None
|
||||||
|
|
||||||
|
def set_password(self, password):
|
||||||
|
return True
|
||||||
|
def get_user(self, email="defaultuser@changedetection.io"):
|
||||||
|
return self
|
||||||
|
def is_authenticated(self):
|
||||||
|
|
||||||
|
return True
|
||||||
|
def is_active(self):
|
||||||
|
return True
|
||||||
|
def is_anonymous(self):
|
||||||
|
return False
|
||||||
|
def get_id(self):
|
||||||
|
return str(self.id)
|
||||||
|
|
||||||
|
def check_password(self, password):
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
import base64
|
||||||
|
|
||||||
|
# Getting the values back out
|
||||||
|
raw_salt_pass = base64.b64decode(datastore.data['settings']['application']['password'])
|
||||||
|
salt_from_storage = raw_salt_pass[:32] # 32 is the length of the salt
|
||||||
|
|
||||||
|
# Use the exact same setup you used to generate the key, but this time put in the password to check
|
||||||
|
new_key = hashlib.pbkdf2_hmac(
|
||||||
|
'sha256',
|
||||||
|
password.encode('utf-8'), # Convert the password to bytes
|
||||||
|
salt_from_storage,
|
||||||
|
100000
|
||||||
|
)
|
||||||
|
new_key = salt_from_storage + new_key
|
||||||
|
|
||||||
|
return new_key == raw_salt_pass
|
||||||
|
|
||||||
|
pass
|
||||||
|
|
||||||
|
def changedetection_app(conig=None, datastore_o=None):
|
||||||
global datastore
|
global datastore
|
||||||
datastore = datastore_o
|
datastore = datastore_o
|
||||||
# Hmm
|
|
||||||
app.config.update(dict(DEBUG=True))
|
app.config.update(dict(DEBUG=True))
|
||||||
app.config.update(config or {})
|
#app.config.update(config or {})
|
||||||
|
|
||||||
|
login_manager = flask_login.LoginManager(app)
|
||||||
|
login_manager.login_view = 'login'
|
||||||
|
|
||||||
|
|
||||||
# Setup cors headers to allow all domains
|
# Setup cors headers to allow all domains
|
||||||
# https://flask-cors.readthedocs.io/en/latest/
|
# https://flask-cors.readthedocs.io/en/latest/
|
||||||
# CORS(app)
|
# CORS(app)
|
||||||
|
|
||||||
|
@login_manager.user_loader
|
||||||
|
def user_loader(email):
|
||||||
|
user = User()
|
||||||
|
user.get_user(email)
|
||||||
|
return user
|
||||||
|
|
||||||
|
@login_manager.unauthorized_handler
|
||||||
|
def unauthorized_handler():
|
||||||
|
# @todo validate its a URL of this host and use that
|
||||||
|
return redirect(url_for('login', next=url_for('index')))
|
||||||
|
|
||||||
|
@app.route('/logout')
|
||||||
|
def logout():
|
||||||
|
flask_login.logout_user()
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
# https://github.com/pallets/flask/blob/93dd1709d05a1cf0e886df6223377bdab3b077fb/examples/tutorial/flaskr/__init__.py#L39
|
# https://github.com/pallets/flask/blob/93dd1709d05a1cf0e886df6223377bdab3b077fb/examples/tutorial/flaskr/__init__.py#L39
|
||||||
# You can divide up the stuff like this
|
# You can divide up the stuff like this
|
||||||
|
@app.route('/login', methods=['GET', 'POST'])
|
||||||
|
def login():
|
||||||
|
|
||||||
@app.route("/", methods=['GET'])
|
|
||||||
def index():
|
|
||||||
global messages
|
global messages
|
||||||
|
|
||||||
|
if request.method == 'GET':
|
||||||
|
output = render_template("login.html", messages=messages)
|
||||||
|
# Show messages but once.
|
||||||
|
messages = []
|
||||||
|
return output
|
||||||
|
|
||||||
|
user = User()
|
||||||
|
user.id = "defaultuser@changedetection.io"
|
||||||
|
|
||||||
|
password = request.form.get('password')
|
||||||
|
|
||||||
|
if (user.check_password(password)):
|
||||||
|
flask_login.login_user(user, remember=True)
|
||||||
|
next = request.args.get('next')
|
||||||
|
# if not is_safe_url(next):
|
||||||
|
# return flask.abort(400)
|
||||||
|
return redirect(next or url_for('index'))
|
||||||
|
|
||||||
|
else:
|
||||||
|
messages.append({'class': 'error', 'message': 'Incorrect password'})
|
||||||
|
|
||||||
|
return redirect(url_for('login'))
|
||||||
|
|
||||||
|
@app.before_request
|
||||||
|
def do_something_whenever_a_request_comes_in():
|
||||||
|
# Disable password loginif there is not one set
|
||||||
|
app.config['LOGIN_DISABLED'] = datastore.data['settings']['application']['password'] == False
|
||||||
|
|
||||||
|
@app.route("/", methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
def index():
|
||||||
|
global messages
|
||||||
limit_tag = request.args.get('tag')
|
limit_tag = request.args.get('tag')
|
||||||
|
|
||||||
|
pause_uuid = request.args.get('pause')
|
||||||
|
|
||||||
|
if pause_uuid:
|
||||||
|
try:
|
||||||
|
datastore.data['watching'][pause_uuid]['paused'] ^= True
|
||||||
|
datastore.needs_write = True
|
||||||
|
|
||||||
|
return redirect(url_for('index', tag = limit_tag))
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
# Sort by last_changed and add the uuid which is usually the key..
|
# Sort by last_changed and add the uuid which is usually the key..
|
||||||
sorted_watches = []
|
sorted_watches = []
|
||||||
for uuid, watch in datastore.data['watching'].items():
|
for uuid, watch in datastore.data['watching'].items():
|
||||||
@@ -112,17 +228,44 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
sorted_watches.sort(key=lambda x: x['last_changed'], reverse=True)
|
sorted_watches.sort(key=lambda x: x['last_changed'], reverse=True)
|
||||||
|
|
||||||
existing_tags = datastore.get_all_tags()
|
existing_tags = datastore.get_all_tags()
|
||||||
|
rss = request.args.get('rss')
|
||||||
|
|
||||||
|
if rss:
|
||||||
|
fg = FeedGenerator()
|
||||||
|
fg.title('changedetection.io')
|
||||||
|
fg.description('Feed description')
|
||||||
|
fg.link(href='https://changedetection.io')
|
||||||
|
|
||||||
|
for watch in sorted_watches:
|
||||||
|
if not watch['viewed']:
|
||||||
|
fe = fg.add_entry()
|
||||||
|
fe.title(watch['url'])
|
||||||
|
fe.link(href=watch['url'])
|
||||||
|
fe.description(watch['url'])
|
||||||
|
fe.guid(watch['uuid'], permalink=False)
|
||||||
|
dt = datetime.datetime.fromtimestamp(int(watch['newest_history_key']))
|
||||||
|
dt = dt.replace(tzinfo=pytz.UTC)
|
||||||
|
fe.pubDate(dt)
|
||||||
|
|
||||||
|
response = make_response(fg.rss_str())
|
||||||
|
response.headers.set('Content-Type', 'application/rss+xml')
|
||||||
|
return response
|
||||||
|
|
||||||
|
else:
|
||||||
output = render_template("watch-overview.html",
|
output = render_template("watch-overview.html",
|
||||||
watches=sorted_watches,
|
watches=sorted_watches,
|
||||||
messages=messages,
|
messages=messages,
|
||||||
tags=existing_tags,
|
tags=existing_tags,
|
||||||
active_tag=limit_tag)
|
active_tag=limit_tag,
|
||||||
|
has_unviewed=datastore.data['has_unviewed'])
|
||||||
|
|
||||||
# Show messages but once.
|
# Show messages but once.
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@app.route("/scrub", methods=['GET', 'POST'])
|
@app.route("/scrub", methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
def scrub_page():
|
def scrub_page():
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -130,19 +273,16 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
confirmtext = request.form.get('confirmtext')
|
confirmtext = request.form.get('confirmtext')
|
||||||
|
limit_timestamp = int(request.form.get('limit_date'))
|
||||||
|
|
||||||
if confirmtext == 'scrub':
|
if confirmtext == 'scrub':
|
||||||
|
|
||||||
for txt_file_path in Path(app.config['datastore_path']).rglob('*.txt'):
|
|
||||||
os.unlink(txt_file_path)
|
|
||||||
|
|
||||||
for uuid, watch in datastore.data['watching'].items():
|
for uuid, watch in datastore.data['watching'].items():
|
||||||
watch['last_checked'] = 0
|
if len(str(limit_timestamp)) == 10:
|
||||||
watch['last_changed'] = 0
|
datastore.scrub_watch(uuid, limit_timestamp = limit_timestamp)
|
||||||
watch['previous_md5'] = None
|
else:
|
||||||
watch['history'] = {}
|
datastore.scrub_watch(uuid)
|
||||||
|
|
||||||
datastore.needs_write = True
|
|
||||||
messages.append({'class': 'ok', 'message': 'Cleaned all version history.'})
|
messages.append({'class': 'ok', 'message': 'Cleaned all version history.'})
|
||||||
else:
|
else:
|
||||||
messages.append({'class': 'error', 'message': 'Wrong confirm text.'})
|
messages.append({'class': 'error', 'message': 'Wrong confirm text.'})
|
||||||
@@ -151,46 +291,168 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
|
|
||||||
return render_template("scrub.html")
|
return render_template("scrub.html")
|
||||||
|
|
||||||
@app.route("/edit", methods=['GET', 'POST'])
|
# If they edited an existing watch, we need to know to reset the current/previous md5 to include
|
||||||
def edit_page():
|
# the excluded text.
|
||||||
|
def get_current_checksum_include_ignore_text(uuid):
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
from backend import fetch_site_status
|
||||||
|
|
||||||
|
# Get the most recent one
|
||||||
|
newest_history_key = datastore.get_val(uuid, 'newest_history_key')
|
||||||
|
|
||||||
|
# 0 means that theres only one, so that there should be no 'unviewed' history availabe
|
||||||
|
if newest_history_key == 0:
|
||||||
|
newest_history_key = list(datastore.data['watching'][uuid]['history'].keys())[0]
|
||||||
|
|
||||||
|
if newest_history_key:
|
||||||
|
with open(datastore.data['watching'][uuid]['history'][newest_history_key],
|
||||||
|
encoding='utf-8') as file:
|
||||||
|
raw_content = file.read()
|
||||||
|
|
||||||
|
handler = fetch_site_status.perform_site_check(datastore=datastore)
|
||||||
|
stripped_content = handler.strip_ignore_text(raw_content,
|
||||||
|
datastore.data['watching'][uuid]['ignore_text'])
|
||||||
|
|
||||||
|
checksum = hashlib.md5(stripped_content).hexdigest()
|
||||||
|
return checksum
|
||||||
|
|
||||||
|
return datastore.data['watching'][uuid]['previous_md5']
|
||||||
|
|
||||||
|
@app.route("/edit/<string:uuid>", methods=['GET', 'POST'])
|
||||||
|
@login_required
|
||||||
|
def edit_page(uuid):
|
||||||
global messages
|
global messages
|
||||||
import validators
|
import validators
|
||||||
|
|
||||||
|
# More for testing, possible to return the first/only
|
||||||
|
if uuid == 'first':
|
||||||
|
uuid = list(datastore.data['watching'].keys()).pop()
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
uuid = request.args.get('uuid')
|
|
||||||
|
|
||||||
url = request.form.get('url').strip()
|
url = request.form.get('url').strip()
|
||||||
tag = request.form.get('tag').strip()
|
tag = request.form.get('tag').strip()
|
||||||
|
|
||||||
|
# Extra headers
|
||||||
form_headers = request.form.get('headers').strip().split("\n")
|
form_headers = request.form.get('headers').strip().split("\n")
|
||||||
extra_headers = {}
|
extra_headers = {}
|
||||||
if form_headers:
|
if form_headers:
|
||||||
for header in form_headers:
|
for header in form_headers:
|
||||||
if len(header):
|
if len(header):
|
||||||
parts = header.split(':', 1)
|
parts = header.split(':', 1)
|
||||||
|
if len(parts) == 2:
|
||||||
extra_headers.update({parts[0].strip(): parts[1].strip()})
|
extra_headers.update({parts[0].strip(): parts[1].strip()})
|
||||||
|
|
||||||
validators.url(url) # @todo switch to prop/attr/observer
|
update_obj = {'url': url,
|
||||||
datastore.data['watching'][uuid].update({'url': url,
|
|
||||||
'tag': tag,
|
'tag': tag,
|
||||||
'headers': extra_headers})
|
'headers': extra_headers
|
||||||
|
}
|
||||||
|
|
||||||
|
# Notification URLs
|
||||||
|
form_notification_text = request.form.get('notification_urls')
|
||||||
|
notification_urls = []
|
||||||
|
if form_notification_text:
|
||||||
|
for text in form_notification_text.strip().split("\n"):
|
||||||
|
text = text.strip()
|
||||||
|
if len(text):
|
||||||
|
notification_urls.append(text)
|
||||||
|
|
||||||
|
datastore.data['watching'][uuid]['notification_urls'] = notification_urls
|
||||||
|
|
||||||
|
# Ignore text
|
||||||
|
form_ignore_text = request.form.get('ignore-text')
|
||||||
|
ignore_text = []
|
||||||
|
if form_ignore_text:
|
||||||
|
for text in form_ignore_text.strip().split("\n"):
|
||||||
|
text = text.strip()
|
||||||
|
if len(text):
|
||||||
|
ignore_text.append(text)
|
||||||
|
|
||||||
|
datastore.data['watching'][uuid]['ignore_text'] = ignore_text
|
||||||
|
|
||||||
|
# Reset the previous_md5 so we process a new snapshot including stripping ignore text.
|
||||||
|
if len(datastore.data['watching'][uuid]['history']):
|
||||||
|
update_obj['previous_md5'] = get_current_checksum_include_ignore_text(uuid=uuid)
|
||||||
|
|
||||||
|
validators.url(url) # @todo switch to prop/attr/observer
|
||||||
|
datastore.data['watching'][uuid].update(update_obj)
|
||||||
datastore.needs_write = True
|
datastore.needs_write = True
|
||||||
|
|
||||||
messages.append({'class': 'ok', 'message': 'Updated watch.'})
|
messages.append({'class': 'ok', 'message': 'Updated watch.'})
|
||||||
|
|
||||||
|
trigger_n = request.form.get('trigger-test-notification')
|
||||||
|
if trigger_n:
|
||||||
|
n_object = {'watch_url': url,
|
||||||
|
'notification_urls': datastore.data['settings']['application']['notification_urls']}
|
||||||
|
notification_q.put(n_object)
|
||||||
|
|
||||||
|
messages.append({'class': 'ok', 'message': 'Notifications queued.'})
|
||||||
|
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
uuid = request.args.get('uuid')
|
|
||||||
output = render_template("edit.html", uuid=uuid, watch=datastore.data['watching'][uuid], messages=messages)
|
output = render_template("edit.html", uuid=uuid, watch=datastore.data['watching'][uuid], messages=messages)
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@app.route("/settings", methods=['GET', "POST"])
|
@app.route("/settings", methods=['GET', "POST"])
|
||||||
|
@login_required
|
||||||
def settings_page():
|
def settings_page():
|
||||||
global messages
|
global messages
|
||||||
|
|
||||||
|
if request.method == 'GET':
|
||||||
|
if request.values.get('notification-test'):
|
||||||
|
url_count = len(datastore.data['settings']['application']['notification_urls'])
|
||||||
|
if url_count:
|
||||||
|
import apprise
|
||||||
|
apobj = apprise.Apprise()
|
||||||
|
apobj.debug = True
|
||||||
|
|
||||||
|
# Add each notification
|
||||||
|
for n in datastore.data['settings']['application']['notification_urls']:
|
||||||
|
apobj.add(n)
|
||||||
|
outcome = apobj.notify(
|
||||||
|
body='Hello from the worlds best and simplest web page change detection and monitoring service!',
|
||||||
|
title='Changedetection.io Notification Test',
|
||||||
|
)
|
||||||
|
|
||||||
|
if outcome:
|
||||||
|
messages.append(
|
||||||
|
{'class': 'notice', 'message': "{} Notification URLs reached.".format(url_count)})
|
||||||
|
else:
|
||||||
|
messages.append(
|
||||||
|
{'class': 'error', 'message': "One or more Notification URLs failed"})
|
||||||
|
|
||||||
|
return redirect(url_for('settings_page'))
|
||||||
|
|
||||||
|
if request.values.get('removepassword'):
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
datastore.data['settings']['application']['password'] = False
|
||||||
|
messages.append({'class': 'notice', 'message': "Password protection removed."})
|
||||||
|
flask_login.logout_user()
|
||||||
|
|
||||||
|
return redirect(url_for('settings_page'))
|
||||||
|
|
||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
|
|
||||||
|
password = request.values.get('password')
|
||||||
|
if password:
|
||||||
|
import hashlib
|
||||||
|
import base64
|
||||||
|
import secrets
|
||||||
|
|
||||||
|
# Make a new salt on every new password and store it with the password
|
||||||
|
salt = secrets.token_bytes(32)
|
||||||
|
|
||||||
|
key = hashlib.pbkdf2_hmac('sha256', password.encode('utf-8'), salt, 100000)
|
||||||
|
store = base64.b64encode(salt + key).decode('ascii')
|
||||||
|
datastore.data['settings']['application']['password'] = store
|
||||||
|
messages.append({'class': 'notice', 'message': "Password protection enabled."})
|
||||||
|
flask_login.logout_user()
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
minutes = int(request.values.get('minutes').strip())
|
minutes = int(request.values.get('minutes').strip())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@@ -200,19 +462,36 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
if minutes >= 5:
|
if minutes >= 5:
|
||||||
datastore.data['settings']['requests']['minutes_between_check'] = minutes
|
datastore.data['settings']['requests']['minutes_between_check'] = minutes
|
||||||
datastore.needs_write = True
|
datastore.needs_write = True
|
||||||
|
|
||||||
messages.append({'class': 'ok', 'message': "Updated"})
|
|
||||||
else:
|
else:
|
||||||
messages.append(
|
messages.append(
|
||||||
{'class': 'error', 'message': "Must be atleast 5 minutes."})
|
{'class': 'error', 'message': "Must be atleast 5 minutes."})
|
||||||
|
|
||||||
|
# 'validators' package doesnt work because its often a non-stanadard protocol. :(
|
||||||
|
datastore.data['settings']['application']['notification_urls'] = []
|
||||||
|
trigger_n = request.form.get('trigger-test-notification')
|
||||||
|
|
||||||
|
for n in request.values.get('notification_urls').strip().split("\n"):
|
||||||
|
url = n.strip()
|
||||||
|
datastore.data['settings']['application']['notification_urls'].append(url)
|
||||||
|
datastore.needs_write = True
|
||||||
|
|
||||||
|
if trigger_n:
|
||||||
|
n_object = {'watch_url': "Test from changedetection.io!",
|
||||||
|
'notification_urls': datastore.data['settings']['application']['notification_urls']}
|
||||||
|
notification_q.put(n_object)
|
||||||
|
|
||||||
|
messages.append({'class': 'ok', 'message': 'Notifications queued.'})
|
||||||
|
|
||||||
output = render_template("settings.html", messages=messages,
|
output = render_template("settings.html", messages=messages,
|
||||||
minutes=datastore.data['settings']['requests']['minutes_between_check'])
|
minutes=datastore.data['settings']['requests']['minutes_between_check'],
|
||||||
|
notification_urls="\r\n".join(
|
||||||
|
datastore.data['settings']['application']['notification_urls']))
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
@app.route("/import", methods=['GET', "POST"])
|
@app.route("/import", methods=['GET', "POST"])
|
||||||
|
@login_required
|
||||||
def import_page():
|
def import_page():
|
||||||
import validators
|
import validators
|
||||||
global messages
|
global messages
|
||||||
@@ -236,16 +515,32 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
messages.append({'class': 'ok', 'message': "{} Imported, {} Skipped.".format(good, len(remaining_urls))})
|
messages.append({'class': 'ok', 'message': "{} Imported, {} Skipped.".format(good, len(remaining_urls))})
|
||||||
|
|
||||||
if len(remaining_urls) == 0:
|
if len(remaining_urls) == 0:
|
||||||
|
# Looking good, redirect to index.
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
|
||||||
|
# Could be some remaining, or we could be on GET
|
||||||
output = render_template("import.html",
|
output = render_template("import.html",
|
||||||
messages=messages,
|
messages=messages,
|
||||||
remaining="\n".join(remaining_urls)
|
remaining="\n".join(remaining_urls)
|
||||||
)
|
)
|
||||||
messages = []
|
messages = []
|
||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
# Clear all statuses, so we do not see the 'unviewed' class
|
||||||
|
@app.route("/api/mark-all-viewed", methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
def mark_all_viewed():
|
||||||
|
|
||||||
|
# Save the current newest history as the most recently viewed
|
||||||
|
for watch_uuid, watch in datastore.data['watching'].items():
|
||||||
|
datastore.set_last_viewed(watch_uuid, watch['newest_history_key'])
|
||||||
|
|
||||||
|
messages.append({'class': 'ok', 'message': "Cleared all statuses."})
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route("/diff/<string:uuid>", methods=['GET'])
|
@app.route("/diff/<string:uuid>", methods=['GET'])
|
||||||
|
@login_required
|
||||||
def diff_history_page(uuid):
|
def diff_history_page(uuid):
|
||||||
global messages
|
global messages
|
||||||
|
|
||||||
@@ -266,9 +561,9 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
dates.sort(reverse=True)
|
dates.sort(reverse=True)
|
||||||
dates = [str(i) for i in dates]
|
dates = [str(i) for i in dates]
|
||||||
|
|
||||||
|
|
||||||
if len(dates) < 2:
|
if len(dates) < 2:
|
||||||
messages.append({'class': 'error', 'message': "Not enough saved change detection snapshots to produce a report."})
|
messages.append(
|
||||||
|
{'class': 'error', 'message': "Not enough saved change detection snapshots to produce a report."})
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
# Save the current newest history as the most recently viewed
|
# Save the current newest history as the most recently viewed
|
||||||
@@ -301,13 +596,40 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
|
@app.route("/preview/<string:uuid>", methods=['GET'])
|
||||||
|
@login_required
|
||||||
|
def preview_page(uuid):
|
||||||
|
global messages
|
||||||
|
|
||||||
|
# More for testing, possible to return the first/only
|
||||||
|
if uuid == 'first':
|
||||||
|
uuid = list(datastore.data['watching'].keys()).pop()
|
||||||
|
|
||||||
|
extra_stylesheets = ['/static/css/diff.css']
|
||||||
|
|
||||||
|
try:
|
||||||
|
watch = datastore.data['watching'][uuid]
|
||||||
|
except KeyError:
|
||||||
|
messages.append({'class': 'error', 'message': "No history found for the specified link, bad link?"})
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
|
print(watch)
|
||||||
|
with open(list(watch['history'].values())[-1], 'r') as f:
|
||||||
|
content = f.readlines()
|
||||||
|
|
||||||
|
output = render_template("preview.html", content=content, extra_stylesheets=extra_stylesheets)
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
@app.route("/favicon.ico", methods=['GET'])
|
@app.route("/favicon.ico", methods=['GET'])
|
||||||
def favicon():
|
def favicon():
|
||||||
return send_from_directory("/app/static/images", filename="favicon.ico")
|
return send_from_directory("/app/static/images", filename="favicon.ico")
|
||||||
|
|
||||||
# We're good but backups are even better!
|
# We're good but backups are even better!
|
||||||
@app.route("/backup", methods=['GET'])
|
@app.route("/backup", methods=['GET'])
|
||||||
|
@login_required
|
||||||
def get_backup():
|
def get_backup():
|
||||||
|
|
||||||
import zipfile
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
@@ -316,26 +638,31 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
|
|
||||||
# We only care about UUIDS from the current index file
|
# We only care about UUIDS from the current index file
|
||||||
uuids = list(datastore.data['watching'].keys())
|
uuids = list(datastore.data['watching'].keys())
|
||||||
|
backup_filepath = os.path.join(app.config['datastore_path'], backupname)
|
||||||
|
|
||||||
with zipfile.ZipFile(os.path.join(app.config['datastore_path'], backupname), 'w',
|
with zipfile.ZipFile(backup_filepath, "w",
|
||||||
compression=zipfile.ZIP_DEFLATED,
|
compression=zipfile.ZIP_DEFLATED,
|
||||||
compresslevel=6) as zipObj:
|
compresslevel=8) as zipObj:
|
||||||
|
|
||||||
# Be sure we're written fresh
|
# Be sure we're written fresh
|
||||||
datastore.sync_to_json()
|
datastore.sync_to_json()
|
||||||
|
|
||||||
# Add the index
|
# Add the index
|
||||||
zipObj.write(os.path.join(app.config['datastore_path'], "url-watches.json"))
|
zipObj.write(os.path.join(app.config['datastore_path'], "url-watches.json"), arcname="url-watches.json")
|
||||||
# Add any snapshot data we find
|
|
||||||
|
# Add the flask app secret
|
||||||
|
zipObj.write(os.path.join(app.config['datastore_path'], "secret.txt"), arcname="secret.txt")
|
||||||
|
|
||||||
|
# Add any snapshot data we find, use the full path to access the file, but make the file 'relative' in the Zip.
|
||||||
for txt_file_path in Path(app.config['datastore_path']).rglob('*.txt'):
|
for txt_file_path in Path(app.config['datastore_path']).rglob('*.txt'):
|
||||||
parent_p = txt_file_path.parent
|
parent_p = txt_file_path.parent
|
||||||
if parent_p.name in uuids:
|
if parent_p.name in uuids:
|
||||||
zipObj.write(txt_file_path)
|
zipObj.write(txt_file_path,
|
||||||
|
arcname=str(txt_file_path).replace(app.config['datastore_path'], ''),
|
||||||
|
compress_type=zipfile.ZIP_DEFLATED,
|
||||||
|
compresslevel=8)
|
||||||
|
|
||||||
return send_file(os.path.join(app.config['datastore_path'], backupname),
|
return send_from_directory(app.config['datastore_path'], backupname)
|
||||||
as_attachment=True,
|
|
||||||
mimetype="application/zip",
|
|
||||||
attachment_filename=backupname)
|
|
||||||
|
|
||||||
@app.route("/static/<string:group>/<string:filename>", methods=['GET'])
|
@app.route("/static/<string:group>/<string:filename>", methods=['GET'])
|
||||||
def static_content(group, filename):
|
def static_content(group, filename):
|
||||||
@@ -349,11 +676,17 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
@app.route("/api/add", methods=['POST'])
|
@app.route("/api/add", methods=['POST'])
|
||||||
|
@login_required
|
||||||
def api_watch_add():
|
def api_watch_add():
|
||||||
global messages
|
global messages
|
||||||
|
|
||||||
|
url = request.form.get('url').strip()
|
||||||
|
if datastore.url_exists(url):
|
||||||
|
messages.append({'class': 'error', 'message': 'The URL {} already exists'.format(url)})
|
||||||
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
# @todo add_watch should throw a custom Exception for validation etc
|
# @todo add_watch should throw a custom Exception for validation etc
|
||||||
new_uuid = datastore.add_watch(url=request.form.get('url').strip(), tag=request.form.get('tag').strip())
|
new_uuid = datastore.add_watch(url=url, tag=request.form.get('tag').strip())
|
||||||
# Straight into the queue.
|
# Straight into the queue.
|
||||||
update_q.put(new_uuid)
|
update_q.put(new_uuid)
|
||||||
|
|
||||||
@@ -361,6 +694,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route("/api/delete", methods=['GET'])
|
@app.route("/api/delete", methods=['GET'])
|
||||||
|
@login_required
|
||||||
def api_delete():
|
def api_delete():
|
||||||
global messages
|
global messages
|
||||||
uuid = request.args.get('uuid')
|
uuid = request.args.get('uuid')
|
||||||
@@ -370,6 +704,7 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route("/api/checknow", methods=['GET'])
|
@app.route("/api/checknow", methods=['GET'])
|
||||||
|
@login_required
|
||||||
def api_watch_checknow():
|
def api_watch_checknow():
|
||||||
|
|
||||||
global messages
|
global messages
|
||||||
@@ -393,15 +728,17 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
# Items that have this current tag
|
# Items that have this current tag
|
||||||
for watch_uuid, watch in datastore.data['watching'].items():
|
for watch_uuid, watch in datastore.data['watching'].items():
|
||||||
if (tag != None and tag in watch['tag']):
|
if (tag != None and tag in watch['tag']):
|
||||||
i += 1
|
if watch_uuid not in running_uuids and not datastore.data['watching'][watch_uuid]['paused']:
|
||||||
if watch_uuid not in running_uuids:
|
|
||||||
update_q.put(watch_uuid)
|
update_q.put(watch_uuid)
|
||||||
|
i += 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# No tag, no uuid, add everything.
|
# No tag, no uuid, add everything.
|
||||||
for watch_uuid, watch in datastore.data['watching'].items():
|
for watch_uuid, watch in datastore.data['watching'].items():
|
||||||
i += 1
|
|
||||||
if watch_uuid not in running_uuids:
|
if watch_uuid not in running_uuids and not datastore.data['watching'][watch_uuid]['paused']:
|
||||||
update_q.put(watch_uuid)
|
update_q.put(watch_uuid)
|
||||||
|
i += 1
|
||||||
|
|
||||||
messages.append({'class': 'ok', 'message': "{} watches are rechecking.".format(i)})
|
messages.append({'class': 'ok', 'message': "{} watches are rechecking.".format(i)})
|
||||||
return redirect(url_for('index', tag=tag))
|
return redirect(url_for('index', tag=tag))
|
||||||
@@ -409,81 +746,95 @@ def changedetection_app(config=None, datastore_o=None):
|
|||||||
# @todo handle ctrl break
|
# @todo handle ctrl break
|
||||||
ticker_thread = threading.Thread(target=ticker_thread_check_time_launch_checks).start()
|
ticker_thread = threading.Thread(target=ticker_thread_check_time_launch_checks).start()
|
||||||
|
|
||||||
|
threading.Thread(target=notification_runner).start()
|
||||||
|
|
||||||
|
# Check for new release version
|
||||||
|
threading.Thread(target=check_for_new_version).start()
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
# Requests for checking on the site use a pool of thread Workers managed by a Queue.
|
# Check for new version and anonymous stats
|
||||||
class Worker(threading.Thread):
|
def check_for_new_version():
|
||||||
current_uuid = None
|
import requests
|
||||||
|
|
||||||
def __init__(self, q, *args, **kwargs):
|
import urllib3
|
||||||
self.q = q
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def run(self):
|
while not app.config.exit.is_set():
|
||||||
from backend import fetch_site_status
|
try:
|
||||||
|
r = requests.post("https://changedetection.io/check-ver.php",
|
||||||
|
data={'version': datastore.data['version_tag'],
|
||||||
|
'app_guid': datastore.data['app_guid']},
|
||||||
|
|
||||||
update_handler = fetch_site_status.perform_site_check(datastore=datastore)
|
verify=False)
|
||||||
|
except:
|
||||||
while True:
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
uuid = self.q.get(block=True, timeout=1)
|
if "new_version" in r.text:
|
||||||
|
app.config['NEW_VERSION_AVAILABLE'] = True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Check daily
|
||||||
|
app.config.exit.wait(86400)
|
||||||
|
|
||||||
|
def notification_runner():
|
||||||
|
|
||||||
|
while not app.config.exit.is_set():
|
||||||
|
try:
|
||||||
|
# At the moment only one thread runs (single runner)
|
||||||
|
n_object = notification_q.get(block=False)
|
||||||
except queue.Empty:
|
except queue.Empty:
|
||||||
# We have a chance to kill this thread that needs to monitor for new jobs..
|
time.sleep(1)
|
||||||
# Delays here would be caused by a current response object pending
|
pass
|
||||||
# @todo switch to threaded response handler
|
|
||||||
if app.config['STOP_THREADS']:
|
|
||||||
return
|
|
||||||
else:
|
else:
|
||||||
self.current_uuid = uuid
|
import apprise
|
||||||
|
|
||||||
if uuid in list(datastore.data['watching'].keys()):
|
|
||||||
|
|
||||||
|
# Create an Apprise instance
|
||||||
try:
|
try:
|
||||||
changed_detected, result, contents = update_handler.run(uuid)
|
apobj = apprise.Apprise()
|
||||||
|
for url in n_object['notification_urls']:
|
||||||
|
apobj.add(url.strip())
|
||||||
|
|
||||||
except PermissionError as s:
|
apobj.notify(
|
||||||
app.logger.error("File permission error updating", uuid, str(s))
|
body=n_object['watch_url'],
|
||||||
else:
|
# @todo This should be configurable.
|
||||||
if result:
|
title="ChangeDetection.io Notification - {}".format(n_object['watch_url'])
|
||||||
|
)
|
||||||
|
|
||||||
datastore.update_watch(uuid=uuid, update_obj=result)
|
except Exception as e:
|
||||||
if changed_detected:
|
print("Watch URL: {} Error {}".format(n_object['watch_url'],e))
|
||||||
# A change was detected
|
|
||||||
datastore.save_history_text(uuid=uuid, contents=contents, result_obj=result)
|
|
||||||
|
|
||||||
|
|
||||||
self.current_uuid = None # Done
|
|
||||||
self.q.task_done()
|
|
||||||
|
|
||||||
|
|
||||||
# Thread runner to check every minute, look for new watches to feed into the Queue.
|
# Thread runner to check every minute, look for new watches to feed into the Queue.
|
||||||
def ticker_thread_check_time_launch_checks():
|
def ticker_thread_check_time_launch_checks():
|
||||||
|
from backend import update_worker
|
||||||
|
|
||||||
# Spin up Workers.
|
# Spin up Workers.
|
||||||
for _ in range(datastore.data['settings']['requests']['workers']):
|
for _ in range(datastore.data['settings']['requests']['workers']):
|
||||||
new_worker = Worker(update_q)
|
new_worker = update_worker.update_worker(update_q, notification_q, app, datastore)
|
||||||
running_update_threads.append(new_worker)
|
running_update_threads.append(new_worker)
|
||||||
new_worker.start()
|
new_worker.start()
|
||||||
|
|
||||||
# Every minute check for new UUIDs to follow up on
|
while not app.config.exit.is_set():
|
||||||
while True:
|
|
||||||
|
|
||||||
if app.config['STOP_THREADS']:
|
|
||||||
return
|
|
||||||
|
|
||||||
running_uuids = []
|
running_uuids = []
|
||||||
for t in running_update_threads:
|
for t in running_update_threads:
|
||||||
|
if t.current_uuid:
|
||||||
running_uuids.append(t.current_uuid)
|
running_uuids.append(t.current_uuid)
|
||||||
|
|
||||||
# Look at the dataset, find a stale watch to process
|
# Look at the dataset, find a stale watch to process
|
||||||
minutes = datastore.data['settings']['requests']['minutes_between_check']
|
|
||||||
for uuid, watch in datastore.data['watching'].items():
|
|
||||||
if watch['last_checked'] <= time.time() - (minutes * 60):
|
|
||||||
|
|
||||||
# @todo maybe update_q.queue is enough?
|
# Every minute check for new UUIDs to follow up on, should be inside the loop incase it changes.
|
||||||
|
minutes = datastore.data['settings']['requests']['minutes_between_check']
|
||||||
|
|
||||||
|
threshold = time.time() - (minutes * 60)
|
||||||
|
for uuid, watch in datastore.data['watching'].items():
|
||||||
|
if not watch['paused'] and watch['last_checked'] <= threshold:
|
||||||
if not uuid in running_uuids and uuid not in update_q.queue:
|
if not uuid in running_uuids and uuid not in update_q.queue:
|
||||||
update_q.put(uuid)
|
update_q.put(uuid)
|
||||||
|
|
||||||
# Should be low so we can break this out in testing
|
# Should be low so we can break this out in testing
|
||||||
time.sleep(1)
|
app.config.exit.wait(1)
|
||||||
|
|||||||
@@ -3,9 +3,6 @@ FROM python:3.8-slim
|
|||||||
# https://stackoverflow.com/questions/58701233/docker-logs-erroneously-appears-empty-until-container-stops
|
# https://stackoverflow.com/questions/58701233/docker-logs-erroneously-appears-empty-until-container-stops
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
# Should be mounted from docker-compose-development.yml
|
|
||||||
RUN pip3 install -r /requirements.txt
|
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
RUN [ ! -d "/datastore" ] && mkdir /datastore
|
RUN [ ! -d "/datastore" ] && mkdir /datastore
|
||||||
|
|||||||
@@ -2,7 +2,8 @@ import time
|
|||||||
import requests
|
import requests
|
||||||
import hashlib
|
import hashlib
|
||||||
from inscriptis import get_text
|
from inscriptis import get_text
|
||||||
|
import urllib3
|
||||||
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
||||||
|
|
||||||
# Some common stuff here that can be moved to a base class
|
# Some common stuff here that can be moved to a base class
|
||||||
class perform_site_check():
|
class perform_site_check():
|
||||||
@@ -11,6 +12,24 @@ class perform_site_check():
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.datastore = datastore
|
self.datastore = datastore
|
||||||
|
|
||||||
|
def strip_ignore_text(self, content, list_ignore_text):
|
||||||
|
ignore = []
|
||||||
|
for k in list_ignore_text:
|
||||||
|
ignore.append(k.encode('utf8'))
|
||||||
|
|
||||||
|
output = []
|
||||||
|
for line in content.splitlines():
|
||||||
|
line = line.encode('utf8')
|
||||||
|
|
||||||
|
# Always ignore blank lines in this mode. (when this function gets called)
|
||||||
|
if len(line.strip()):
|
||||||
|
if not any(skip_text in line for skip_text in ignore):
|
||||||
|
output.append(line)
|
||||||
|
|
||||||
|
return "\n".encode('utf8').join(output)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def run(self, uuid):
|
def run(self, uuid):
|
||||||
timestamp = int(time.time()) # used for storage etc too
|
timestamp = int(time.time()) # used for storage etc too
|
||||||
stripped_text_from_html = False
|
stripped_text_from_html = False
|
||||||
@@ -76,7 +95,15 @@ class perform_site_check():
|
|||||||
if not len(r.text):
|
if not len(r.text):
|
||||||
update_obj["last_error"] = "Empty reply"
|
update_obj["last_error"] = "Empty reply"
|
||||||
|
|
||||||
fetched_md5 = hashlib.md5(stripped_text_from_html.encode('utf-8')).hexdigest()
|
# If there's text to skip
|
||||||
|
# @todo we could abstract out the get_text() to handle this cleaner
|
||||||
|
if len(self.datastore.data['watching'][uuid]['ignore_text']):
|
||||||
|
content = self.strip_ignore_text(stripped_text_from_html,
|
||||||
|
self.datastore.data['watching'][uuid]['ignore_text'])
|
||||||
|
else:
|
||||||
|
content = stripped_text_from_html.encode('utf8')
|
||||||
|
|
||||||
|
fetched_md5 = hashlib.md5(content).hexdigest()
|
||||||
|
|
||||||
# could be None or False depending on JSON type
|
# could be None or False depending on JSON type
|
||||||
if self.datastore.data['watching'][uuid]['previous_md5'] != fetched_md5:
|
if self.datastore.data['watching'][uuid]['previous_md5'] != fetched_md5:
|
||||||
|
|||||||
@@ -1,2 +1,12 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
addopts = --no-start-live-server --live-server-port=5005
|
addopts = --no-start-live-server --live-server-port=5005
|
||||||
|
#testpaths = tests pytest_invenio
|
||||||
|
#live_server_scope = function
|
||||||
|
|
||||||
|
filterwarnings =
|
||||||
|
ignore::DeprecationWarning:urllib3.*:
|
||||||
|
|
||||||
|
; logging options
|
||||||
|
log_cli = 1
|
||||||
|
log_cli_level = DEBUG
|
||||||
|
log_cli_format = %(asctime)s %(name)s: %(levelname)s %(message)s
|
||||||
16
backend/run_all_tests.sh
Executable file
16
backend/run_all_tests.sh
Executable file
@@ -0,0 +1,16 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
# live_server will throw errors even with live_server_scope=function if I have the live_server setup in different functions
|
||||||
|
# and I like to restart the server for each test (and have the test cleanup after each test)
|
||||||
|
# merge request welcome :)
|
||||||
|
|
||||||
|
|
||||||
|
# exit when any command fails
|
||||||
|
set -e
|
||||||
|
|
||||||
|
find tests/test_*py -type f|while read test_name
|
||||||
|
do
|
||||||
|
echo "TEST RUNNING $test_name"
|
||||||
|
pytest $test_name
|
||||||
|
done
|
||||||
@@ -88,11 +88,16 @@ section.content {
|
|||||||
margin: 0 3px 0 5px;
|
margin: 0 3px 0 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#check-all-button {
|
#post-list-buttons {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
padding: 0px;
|
||||||
|
margin: 0px;
|
||||||
|
}
|
||||||
|
#post-list-buttons li {
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
#check-all-button a {
|
#post-list-buttons a {
|
||||||
border-top-left-radius: initial;
|
border-top-left-radius: initial;
|
||||||
border-top-right-radius: initial;
|
border-top-right-radius: initial;
|
||||||
border-bottom-left-radius: 5px;
|
border-bottom-left-radius: 5px;
|
||||||
@@ -237,3 +242,36 @@ body:after, body:before {
|
|||||||
user-select:none;
|
user-select:none;
|
||||||
-o-user-select:none;
|
-o-user-select:none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
footer {
|
||||||
|
padding: 10px;
|
||||||
|
background: #fff;
|
||||||
|
color: #444;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#feed-icon {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#version {
|
||||||
|
position: absolute;
|
||||||
|
top: 80px;
|
||||||
|
right: 0px;
|
||||||
|
font-size: 8px;
|
||||||
|
background: #fff;
|
||||||
|
padding: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#new-version-text a{
|
||||||
|
color: #e07171;
|
||||||
|
}
|
||||||
|
|
||||||
|
.paused-state.state-False img {
|
||||||
|
opacity: 0.2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.paused-state.state-False:hover img{
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
18
backend/static/images/Generic_Feed-icon.svg
Normal file
18
backend/static/images/Generic_Feed-icon.svg
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg"
|
||||||
|
id="RSSicon"
|
||||||
|
viewBox="0 0 8 8" width="256" height="256">
|
||||||
|
|
||||||
|
<title>RSS feed icon</title>
|
||||||
|
|
||||||
|
<style type="text/css">
|
||||||
|
.button {stroke: none; fill: orange;}
|
||||||
|
.symbol {stroke: none; fill: white;}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<rect class="button" width="8" height="8" rx="1.5" />
|
||||||
|
<circle class="symbol" cx="2" cy="6" r="1" />
|
||||||
|
<path class="symbol" d="m 1,4 a 3,3 0 0 1 3,3 h 1 a 4,4 0 0 0 -4,-4 z" />
|
||||||
|
<path class="symbol" d="m 1,2 a 5,5 0 0 1 5,5 h 1 a 6,6 0 0 0 -6,-6 z" />
|
||||||
|
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 569 B |
84
backend/static/images/pause.svg
Normal file
84
backend/static/images/pause.svg
Normal file
@@ -0,0 +1,84 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
|
<svg
|
||||||
|
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||||
|
xmlns:cc="http://creativecommons.org/ns#"
|
||||||
|
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||||
|
xmlns:svg="http://www.w3.org/2000/svg"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
version="1.1"
|
||||||
|
id="Capa_1"
|
||||||
|
x="0px"
|
||||||
|
y="0px"
|
||||||
|
viewBox="0 0 15 14.998326"
|
||||||
|
xml:space="preserve"
|
||||||
|
width="15"
|
||||||
|
height="14.998326"><metadata
|
||||||
|
id="metadata39"><rdf:RDF><cc:Work
|
||||||
|
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||||
|
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||||
|
id="defs37" />
|
||||||
|
<path
|
||||||
|
id="path2"
|
||||||
|
style="fill:#1b98f8;fill-opacity:1;stroke-width:0.0292893"
|
||||||
|
d="M 7.4975161,6.5052867e-4 C 4.549072,-0.04028702 1.7055675,1.8548221 0.58868606,4.5801341 -0.57739762,7.2574642 0.02596981,10.583326 2.069916,12.671949 4.0364753,14.788409 7.2763651,15.56067 9.989207,14.57284 12.801145,13.617602 14.87442,10.855325 14.985833,7.8845744 15.172496,4.9966544 13.49856,2.1100704 10.911002,0.8209349 9.8598067,0.28073592 8.6791261,-0.00114855 7.4975161,6.5052867e-4 Z M 6.5602569,10.251923 c -0.00509,0.507593 -0.5693885,0.488472 -0.9352002,0.468629 -0.3399386,0.0018 -0.8402048,0.07132 -0.9297965,-0.374189 -0.015842,-1.8973128 -0.015872,-3.7979649 0,-5.6952784 0.1334405,-0.5224315 0.7416869,-0.3424086 1.1377562,-0.374189 0.3969969,-0.084515 0.8245634,0.1963256 0.7272405,0.6382917 0,1.7789118 0,3.5578239 0,5.3367357 z m 3.7490371,0 c -0.0051,0.507593 -0.5693888,0.488472 -0.9352005,0.468629 -0.3399386,0.0018 -0.8402048,0.07132 -0.9297965,-0.374189 -0.015842,-1.8973128 -0.015872,-3.7979649 0,-5.6952784 0.1334405,-0.5224315 0.7416869,-0.3424086 1.1377562,-0.374189 0.3969969,-0.084515 0.8245638,0.1963256 0.7272408,0.6382917 0,1.7789118 0,3.5578239 0,5.3367357 z" />
|
||||||
|
<g
|
||||||
|
id="g4"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g6"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g8"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g10"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g12"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g14"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g16"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g18"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g20"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g22"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g24"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g26"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g28"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g30"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
<g
|
||||||
|
id="g32"
|
||||||
|
transform="translate(-0.01903604,0.02221043)">
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 2.9 KiB |
132
backend/store.py
132
backend/store.py
@@ -22,10 +22,10 @@ class ChangeDetectionStore:
|
|||||||
self.datastore_path = datastore_path
|
self.datastore_path = datastore_path
|
||||||
self.json_store_path = "{}/url-watches.json".format(self.datastore_path)
|
self.json_store_path = "{}/url-watches.json".format(self.datastore_path)
|
||||||
self.stop_thread = False
|
self.stop_thread = False
|
||||||
|
|
||||||
self.__data = {
|
self.__data = {
|
||||||
'note': "Hello! If you change this file manually, please be sure to restart your changedetection.io instance!",
|
'note': "Hello! If you change this file manually, please be sure to restart your changedetection.io instance!",
|
||||||
'watching': {},
|
'watching': {},
|
||||||
'tag': "0.25",
|
|
||||||
'settings': {
|
'settings': {
|
||||||
'headers': {
|
'headers': {
|
||||||
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36',
|
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36',
|
||||||
@@ -37,6 +37,10 @@ class ChangeDetectionStore:
|
|||||||
'timeout': 15, # Default 15 seconds
|
'timeout': 15, # Default 15 seconds
|
||||||
'minutes_between_check': 3 * 60, # Default 3 hours
|
'minutes_between_check': 3 * 60, # Default 3 hours
|
||||||
'workers': 10 # Number of threads, lower is better for slow connections
|
'workers': 10 # Number of threads, lower is better for slow connections
|
||||||
|
},
|
||||||
|
'application': {
|
||||||
|
'password': False,
|
||||||
|
'notification_urls': [] # Apprise URL list
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,13 +51,16 @@ class ChangeDetectionStore:
|
|||||||
'tag': None,
|
'tag': None,
|
||||||
'last_checked': 0,
|
'last_checked': 0,
|
||||||
'last_changed': 0,
|
'last_changed': 0,
|
||||||
|
'paused': False,
|
||||||
'last_viewed': 0, # history key value of the last viewed via the [diff] link
|
'last_viewed': 0, # history key value of the last viewed via the [diff] link
|
||||||
'newest_history_key': "",
|
'newest_history_key': "",
|
||||||
'title': None,
|
'title': None,
|
||||||
'previous_md5': "",
|
'previous_md5': "",
|
||||||
'uuid': str(uuid_builder.uuid4()),
|
'uuid': str(uuid_builder.uuid4()),
|
||||||
'headers': {}, # Extra headers to send
|
'headers': {}, # Extra headers to send
|
||||||
'history': {} # Dict of timestamp and output stripped filename
|
'history': {}, # Dict of timestamp and output stripped filename
|
||||||
|
'ignore_text': [], # List of text to ignore when calculating the comparison checksum
|
||||||
|
'notification_urls': [] # List of URLs to add to the notification Queue (Usually AppRise)
|
||||||
}
|
}
|
||||||
|
|
||||||
if path.isfile('/source.txt'):
|
if path.isfile('/source.txt'):
|
||||||
@@ -63,6 +70,7 @@ class ChangeDetectionStore:
|
|||||||
self.__data['build_sha'] = f.read()
|
self.__data['build_sha'] = f.read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# @todo retest with ", encoding='utf-8'"
|
||||||
with open(self.json_store_path) as json_file:
|
with open(self.json_store_path) as json_file:
|
||||||
from_disk = json.load(json_file)
|
from_disk = json.load(json_file)
|
||||||
|
|
||||||
@@ -71,6 +79,9 @@ class ChangeDetectionStore:
|
|||||||
if 'watching' in from_disk:
|
if 'watching' in from_disk:
|
||||||
self.__data['watching'].update(from_disk['watching'])
|
self.__data['watching'].update(from_disk['watching'])
|
||||||
|
|
||||||
|
if 'app_guid' in from_disk:
|
||||||
|
self.__data['app_guid'] = from_disk['app_guid']
|
||||||
|
|
||||||
if 'settings' in from_disk:
|
if 'settings' in from_disk:
|
||||||
if 'headers' in from_disk['settings']:
|
if 'headers' in from_disk['settings']:
|
||||||
self.__data['settings']['headers'].update(from_disk['settings']['headers'])
|
self.__data['settings']['headers'].update(from_disk['settings']['headers'])
|
||||||
@@ -78,10 +89,12 @@ class ChangeDetectionStore:
|
|||||||
if 'requests' in from_disk['settings']:
|
if 'requests' in from_disk['settings']:
|
||||||
self.__data['settings']['requests'].update(from_disk['settings']['requests'])
|
self.__data['settings']['requests'].update(from_disk['settings']['requests'])
|
||||||
|
|
||||||
|
if 'application' in from_disk['settings']:
|
||||||
|
self.__data['settings']['application'].update(from_disk['settings']['application'])
|
||||||
|
|
||||||
# Reinitialise each `watching` with our generic_definition in the case that we add a new var in the future.
|
# Reinitialise each `watching` with our generic_definition in the case that we add a new var in the future.
|
||||||
# @todo pretty sure theres a python we todo this with an abstracted(?) object!
|
# @todo pretty sure theres a python we todo this with an abstracted(?) object!
|
||||||
|
for uuid, watch in self.__data['watching'].items():
|
||||||
for uuid, watch in self.data['watching'].items():
|
|
||||||
_blank = deepcopy(self.generic_definition)
|
_blank = deepcopy(self.generic_definition)
|
||||||
_blank.update(watch)
|
_blank.update(watch)
|
||||||
self.__data['watching'].update({uuid: _blank})
|
self.__data['watching'].update({uuid: _blank})
|
||||||
@@ -98,6 +111,18 @@ class ChangeDetectionStore:
|
|||||||
self.add_watch(url='https://www.gov.uk/coronavirus', tag='Covid')
|
self.add_watch(url='https://www.gov.uk/coronavirus', tag='Covid')
|
||||||
self.add_watch(url='https://changedetection.io', tag='Tech news')
|
self.add_watch(url='https://changedetection.io', tag='Tech news')
|
||||||
|
|
||||||
|
self.__data['version_tag'] = "0.30"
|
||||||
|
|
||||||
|
if not 'app_guid' in self.__data:
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
if "pytest" in sys.modules or "PYTEST_CURRENT_TEST" in os.environ:
|
||||||
|
self.__data['app_guid'] = "test-" + str(uuid_builder.uuid4())
|
||||||
|
else:
|
||||||
|
self.__data['app_guid'] = str(uuid_builder.uuid4())
|
||||||
|
|
||||||
|
self.needs_write = True
|
||||||
|
|
||||||
# Finally start the thread that will manage periodic data saves to JSON
|
# Finally start the thread that will manage periodic data saves to JSON
|
||||||
save_data_thread = threading.Thread(target=self.save_datastore).start()
|
save_data_thread = threading.Thread(target=self.save_datastore).start()
|
||||||
|
|
||||||
@@ -117,11 +142,15 @@ class ChangeDetectionStore:
|
|||||||
return 0
|
return 0
|
||||||
|
|
||||||
def set_last_viewed(self, uuid, timestamp):
|
def set_last_viewed(self, uuid, timestamp):
|
||||||
self.data['watching'][uuid].update({'last_viewed': str(timestamp)})
|
self.data['watching'][uuid].update({'last_viewed': int(timestamp)})
|
||||||
self.needs_write = True
|
self.needs_write = True
|
||||||
|
|
||||||
def update_watch(self, uuid, update_obj):
|
def update_watch(self, uuid, update_obj):
|
||||||
|
|
||||||
|
# Skip if 'paused' state
|
||||||
|
if self.__data['watching'][uuid]['paused']:
|
||||||
|
return
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
|
||||||
# In python 3.9 we have the |= dict operator, but that still will lose data on nested structures...
|
# In python 3.9 we have the |= dict operator, but that still will lose data on nested structures...
|
||||||
@@ -139,6 +168,18 @@ class ChangeDetectionStore:
|
|||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
||||||
|
has_unviewed = False
|
||||||
|
for uuid, v in self.__data['watching'].items():
|
||||||
|
self.__data['watching'][uuid]['newest_history_key'] = self.get_newest_history_key(uuid)
|
||||||
|
if int(v['newest_history_key']) <= int(v['last_viewed']):
|
||||||
|
self.__data['watching'][uuid]['viewed'] = True
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.__data['watching'][uuid]['viewed'] = False
|
||||||
|
has_unviewed = True
|
||||||
|
|
||||||
|
self.__data['has_unviewed'] = has_unviewed
|
||||||
|
|
||||||
return self.__data
|
return self.__data
|
||||||
|
|
||||||
def get_all_tags(self):
|
def get_all_tags(self):
|
||||||
@@ -154,15 +195,35 @@ class ChangeDetectionStore:
|
|||||||
tags.sort()
|
tags.sort()
|
||||||
return tags
|
return tags
|
||||||
|
|
||||||
|
def unlink_history_file(self, path):
|
||||||
|
try:
|
||||||
|
os.unlink(path)
|
||||||
|
except (FileNotFoundError, IOError):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Delete a single watch by UUID
|
||||||
def delete(self, uuid):
|
def delete(self, uuid):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
del (self.__data['watching'][uuid])
|
if uuid == 'all':
|
||||||
|
self.__data['watching'] = {}
|
||||||
|
|
||||||
|
# GitHub #30 also delete history records
|
||||||
|
for uuid in self.data['watching']:
|
||||||
|
for path in self.data['watching'][uuid]['history'].values():
|
||||||
|
self.unlink_history_file(path)
|
||||||
|
|
||||||
|
else:
|
||||||
|
for path in self.data['watching'][uuid]['history'].values():
|
||||||
|
self.unlink_history_file(path)
|
||||||
|
|
||||||
|
del self.data['watching'][uuid]
|
||||||
|
|
||||||
self.needs_write = True
|
self.needs_write = True
|
||||||
|
|
||||||
def url_exists(self, url):
|
def url_exists(self, url):
|
||||||
|
|
||||||
# Probably their should be dict...
|
# Probably their should be dict...
|
||||||
for watch in self.data['watching']:
|
for watch in self.data['watching'].values():
|
||||||
if watch['url'] == url:
|
if watch['url'] == url:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -172,6 +233,47 @@ class ChangeDetectionStore:
|
|||||||
# Probably their should be dict...
|
# Probably their should be dict...
|
||||||
return self.data['watching'][uuid].get(val)
|
return self.data['watching'][uuid].get(val)
|
||||||
|
|
||||||
|
# Remove a watchs data but keep the entry (URL etc)
|
||||||
|
def scrub_watch(self, uuid, limit_timestamp = False):
|
||||||
|
|
||||||
|
import hashlib
|
||||||
|
del_timestamps = []
|
||||||
|
|
||||||
|
for timestamp, path in self.data['watching'][uuid]['history'].items():
|
||||||
|
if not limit_timestamp or (limit_timestamp is not False and int(timestamp) > limit_timestamp):
|
||||||
|
self.unlink_history_file(path)
|
||||||
|
del_timestamps.append(timestamp)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if not limit_timestamp:
|
||||||
|
self.data['watching'][uuid]['last_checked'] = 0
|
||||||
|
self.data['watching'][uuid]['last_changed'] = 0
|
||||||
|
self.data['watching'][uuid]['previous_md5'] = 0
|
||||||
|
|
||||||
|
for timestamp in del_timestamps:
|
||||||
|
del self.data['watching'][uuid]['history'][str(timestamp)]
|
||||||
|
|
||||||
|
# If there was a limitstamp, we need to reset some meta data about the entry
|
||||||
|
# This has to happen after we remove the others from the list
|
||||||
|
if limit_timestamp:
|
||||||
|
newest_key = self.get_newest_history_key(uuid)
|
||||||
|
if newest_key:
|
||||||
|
self.data['watching'][uuid]['last_checked'] = int(newest_key)
|
||||||
|
# @todo should be the original value if it was less than newest key
|
||||||
|
self.data['watching'][uuid]['last_changed'] = int(newest_key)
|
||||||
|
try:
|
||||||
|
with open(self.data['watching'][uuid]['history'][str(newest_key)], "rb") as fp:
|
||||||
|
content = fp.read()
|
||||||
|
self.data['watching'][uuid]['previous_md5'] = hashlib.md5(content).hexdigest()
|
||||||
|
except (FileNotFoundError, IOError):
|
||||||
|
self.data['watching'][uuid]['previous_md5'] = False
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
self.needs_write = True
|
||||||
|
|
||||||
|
|
||||||
def add_watch(self, url, tag):
|
def add_watch(self, url, tag):
|
||||||
with self.lock:
|
with self.lock:
|
||||||
# @todo use a common generic version of this
|
# @todo use a common generic version of this
|
||||||
@@ -213,8 +315,18 @@ class ChangeDetectionStore:
|
|||||||
|
|
||||||
def sync_to_json(self):
|
def sync_to_json(self):
|
||||||
print("Saving..")
|
print("Saving..")
|
||||||
|
data ={}
|
||||||
|
|
||||||
|
try:
|
||||||
|
data = deepcopy(self.__data)
|
||||||
|
except RuntimeError:
|
||||||
|
time.sleep(0.5)
|
||||||
|
print ("! Data changed when writing to JSON, trying again..")
|
||||||
|
self.sync_to_json()
|
||||||
|
return
|
||||||
|
else:
|
||||||
with open(self.json_store_path, 'w') as json_file:
|
with open(self.json_store_path, 'w') as json_file:
|
||||||
json.dump(self.__data, json_file, indent=4)
|
json.dump(data, json_file, indent=4)
|
||||||
logging.info("Re-saved index")
|
logging.info("Re-saved index")
|
||||||
|
|
||||||
self.needs_write = False
|
self.needs_write = False
|
||||||
@@ -227,8 +339,8 @@ class ChangeDetectionStore:
|
|||||||
if self.stop_thread:
|
if self.stop_thread:
|
||||||
print("Shutting down datastore thread")
|
print("Shutting down datastore thread")
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.needs_write:
|
if self.needs_write:
|
||||||
self.sync_to_json()
|
self.sync_to_json()
|
||||||
time.sleep(1)
|
time.sleep(3)
|
||||||
|
|
||||||
# body of the constructor
|
|
||||||
|
|||||||
@@ -17,13 +17,21 @@
|
|||||||
|
|
||||||
<div class="header">
|
<div class="header">
|
||||||
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
<div class="home-menu pure-menu pure-menu-horizontal pure-menu-fixed">
|
||||||
|
{% if has_password and not current_user.is_authenticated %}
|
||||||
|
<a class="pure-menu-heading" href="https://github.com/dgtlmoon/changedetection.io" rel="noopener"><strong>Change</strong>Detection.io</a>
|
||||||
|
{% else %}
|
||||||
<a class="pure-menu-heading" href="/"><strong>Change</strong>Detection.io</a>
|
<a class="pure-menu-heading" href="/"><strong>Change</strong>Detection.io</a>
|
||||||
|
{% endif %}
|
||||||
{% if current_diff_url %}
|
{% if current_diff_url %}
|
||||||
<a class=current-diff-url href="{{ current_diff_url }}"><span style="max-width: 30%; overflow: hidden;">{{ current_diff_url }}</a>
|
<a class=current-diff-url href="{{ current_diff_url }}"><span style="max-width: 30%; overflow: hidden;">{{ current_diff_url }}</span></a>
|
||||||
|
{% else %}
|
||||||
|
{% if new_version_available %}
|
||||||
|
<span id="new-version-text" class="pure-menu-heading"><a href="https://github.com/dgtlmoon/changedetection.io">A new version is available</a></span>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<ul class="pure-menu-list">
|
<ul class="pure-menu-list">
|
||||||
|
{% if current_user.is_authenticated or not has_password %}
|
||||||
<li class="pure-menu-item">
|
<li class="pure-menu-item">
|
||||||
<a href="/backup" class="pure-menu-link">BACKUP</a>
|
<a href="/backup" class="pure-menu-link">BACKUP</a>
|
||||||
</li>
|
</li>
|
||||||
@@ -33,21 +41,27 @@
|
|||||||
<li class="pure-menu-item">
|
<li class="pure-menu-item">
|
||||||
<a href="/settings" class="pure-menu-link">SETTINGS</a>
|
<a href="/settings" class="pure-menu-link">SETTINGS</a>
|
||||||
</li>
|
</li>
|
||||||
|
{% else %}
|
||||||
|
<li class="pure-menu-item">
|
||||||
|
<a class="pure-menu-link" href="https://github.com/dgtlmoon/changedetection.io">Website Change Detection and Notification.</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if current_user.is_authenticated %}
|
||||||
|
<li class="pure-menu-item"><a href="/logout" class="pure-menu-link">LOG OUT</a></li>
|
||||||
|
{% endif %}
|
||||||
<li class="pure-menu-item"><a class="github-link" href="https://github.com/dgtlmoon/changedetection.io">
|
<li class="pure-menu-item"><a class="github-link" href="https://github.com/dgtlmoon/changedetection.io">
|
||||||
<svg class="octicon octicon-mark-github v-align-middle" height="32" viewBox="0 0 16 16" version="1.1"
|
<svg class="octicon octicon-mark-github v-align-middle" height="32" viewBox="0 0 16 16"
|
||||||
|
version="1.1"
|
||||||
width="32" aria-hidden="true">
|
width="32" aria-hidden="true">
|
||||||
<path fill-rule="evenodd"
|
<path fill-rule="evenodd"
|
||||||
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
|
d="M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.013 8.013 0 0016 8c0-4.42-3.58-8-8-8z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
</a></li>
|
</a></li>
|
||||||
<!--
|
|
||||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Tour</a></li>
|
|
||||||
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Sign Up</a></li>
|
|
||||||
-->
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="version">v{{ version }}</div>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<header>
|
<header>
|
||||||
{% block header %}{% endblock %}
|
{% block header %}{% endblock %}
|
||||||
@@ -66,5 +80,6 @@
|
|||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -90,6 +90,10 @@ function changed() {
|
|||||||
|
|
||||||
result.textContent = '';
|
result.textContent = '';
|
||||||
result.appendChild(fragment);
|
result.appendChild(fragment);
|
||||||
|
|
||||||
|
// Jump at start
|
||||||
|
inputs.current=0;
|
||||||
|
next_diff();
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
@@ -112,6 +116,7 @@ window.onload = function() {
|
|||||||
|
|
||||||
onDiffTypeChange(document.querySelector('#settings [name="diff_type"]:checked'));
|
onDiffTypeChange(document.querySelector('#settings [name="diff_type"]:checked'));
|
||||||
changed();
|
changed();
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
a.onpaste = a.onchange =
|
a.onpaste = a.onchange =
|
||||||
@@ -140,6 +145,7 @@ for (var i = 0; i < radio.length; i++) {
|
|||||||
var inputs = document.getElementsByClassName('change');
|
var inputs = document.getElementsByClassName('change');
|
||||||
inputs.current=0;
|
inputs.current=0;
|
||||||
|
|
||||||
|
|
||||||
function next_diff() {
|
function next_diff() {
|
||||||
|
|
||||||
var element = inputs[inputs.current];
|
var element = inputs[inputs.current];
|
||||||
@@ -159,6 +165,7 @@ function next_diff() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
<div class="edit-form">
|
<div class="edit-form">
|
||||||
|
|
||||||
|
|
||||||
<form class="pure-form pure-form-stacked" action="/edit?uuid={{uuid}}" method="POST">
|
<form class="pure-form pure-form-stacked" action="/edit/{{uuid}}" method="POST">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<label for="url">URL</label>
|
<label for="url">URL</label>
|
||||||
@@ -18,10 +18,26 @@
|
|||||||
<span class="pure-form-message-inline">Grouping tags, can be a comma separated list.</span>
|
<span class="pure-form-message-inline">Grouping tags, can be a comma separated list.</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- @todo: move to tabs --->
|
||||||
|
<fieldset class="pure-group">
|
||||||
|
<label for="ignore-text">Ignore text</label>
|
||||||
|
|
||||||
|
<textarea id="ignore-text" name="ignore-text" class="pure-input-1-2" placeholder=""
|
||||||
|
style="width: 100%;
|
||||||
|
font-family:monospace;
|
||||||
|
white-space: pre;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
overflow-x: scroll;" rows="5">{% for value in watch.ignore_text %}{{ value }}
|
||||||
|
{% endfor %}</textarea>
|
||||||
|
<span class="pure-form-message-inline">Each line will be processed separately as an ignore rule.</span>
|
||||||
|
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!-- @todo: move to tabs --->
|
||||||
<fieldset class="pure-group">
|
<fieldset class="pure-group">
|
||||||
<label for="headers">Extra request headers</label>
|
<label for="headers">Extra request headers</label>
|
||||||
|
|
||||||
<textarea id=headers name="headers" class="pure-input-1-2" placeholder="Example
|
<textarea id="headers" name="headers" class="pure-input-1-2" placeholder="Example
|
||||||
Cookie: foobar
|
Cookie: foobar
|
||||||
User-Agent: wonderbra 1.0"
|
User-Agent: wonderbra 1.0"
|
||||||
style="width: 100%;
|
style="width: 100%;
|
||||||
@@ -33,6 +49,24 @@ User-Agent: wonderbra 1.0"
|
|||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="tag">Notification URLs</label>
|
||||||
|
<textarea id="notification_urls" name="notification_urls" class="pure-input-1-2" placeholder=""
|
||||||
|
style="width: 100%;
|
||||||
|
font-family:monospace;
|
||||||
|
white-space: pre;
|
||||||
|
overflow-wrap: normal;
|
||||||
|
overflow-x: scroll;" rows="5">{% for value in watch.notification_urls %}{{ value }}
|
||||||
|
{% endfor %}</textarea>
|
||||||
|
<span class="pure-form-message-inline">Use <a target=_new href="https://github.com/caronc/apprise">AppRise URLs</a> for notification to just about any service!</a> </span>
|
||||||
|
<br/>
|
||||||
|
<div class="pure-controls">
|
||||||
|
<span class="pure-form-message-inline"><label for="trigger-test-notification" class="pure-checkbox">
|
||||||
|
<input type="checkbox" id="trigger-test-notification" name="trigger-test-notification"> Send test notification on save.</label></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<br/>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<button type="submit" class="pure-button pure-button-primary">Save</button>
|
<button type="submit" class="pure-button pure-button-primary">Save</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
20
backend/templates/login.html
Normal file
20
backend/templates/login.html
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="edit-form">
|
||||||
|
<form class="pure-form pure-form-stacked" action="/login" method="POST">
|
||||||
|
<fieldset>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="password">Password</label>
|
||||||
|
<input type="password" id="password" required="" name="password" value=""
|
||||||
|
size="15"/>
|
||||||
|
<input type="hidden" id="email" name="email" value="defaultuser@changedetection.io" />
|
||||||
|
</div>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<button type="submit" class="pure-button pure-button-primary">Login</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
26
backend/templates/preview.html
Normal file
26
backend/templates/preview.html
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div id="settings">
|
||||||
|
<h1>Current</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="diff-ui">
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<!-- just proof of concept copied straight from github.com/kpdecker/jsdiff -->
|
||||||
|
|
||||||
|
<td id="diff-col">
|
||||||
|
<span id="result">{% for row in content %}<pre>{{row}}</pre>{% endfor %}</span>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
@@ -17,14 +17,19 @@
|
|||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<br/>
|
<br/>
|
||||||
<label for="confirmtext">Confirm</label><br/>
|
<label for="confirmtext">Confirm text</label><br/>
|
||||||
<input type="text" id="confirmtext" required="" name="confirmtext" value="" size="10"/>
|
<input type="text" id="confirmtext" required="" name="confirmtext" value="" size="10"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<br/>
|
||||||
|
<label for="confirmtext">Limit delete history including and after date</label><br/>
|
||||||
|
<input type="text" id="limit_date" required="" name="limit_date" value="" size="10"/>
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<button type="submit" class="pure-button pure-button-primary">Scrub!</button>
|
<button type="submit" class="pure-button pure-button-primary">Scrub!</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -12,7 +12,36 @@
|
|||||||
size="5"/>
|
size="5"/>
|
||||||
<span class="pure-form-message-inline">This is a required field.</span>
|
<span class="pure-form-message-inline">This is a required field.</span>
|
||||||
</div>
|
</div>
|
||||||
|
<br/>
|
||||||
|
<hr>
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="minutes">Password protection</label>
|
||||||
|
<input type="password" id="password" name="password" size="15"/>
|
||||||
|
{% if current_user.is_authenticated %}
|
||||||
|
<a href="/settings?removepassword=true" class="pure-button pure-button-primary">Remove password</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<hr>
|
||||||
|
|
||||||
|
<div class="pure-control-group">
|
||||||
|
<label for="minutes">Global notification settings</label><br/>
|
||||||
|
Notification URLs <a href="https://github.com/caronc/apprise"> see Apprise examples</a>.
|
||||||
|
<textarea style="overflow-wrap: normal; overflow-x: scroll;" id="notification_urls" name="notification_urls" cols="80"
|
||||||
|
rows="6" wrap=off placeholder="Example:
|
||||||
|
|
||||||
|
Gitter - gitter://token/room
|
||||||
|
Office365 - o365://TenantID:AccountEmail/ClientID/ClientSecret/TargetEmail
|
||||||
|
AWS SNS - sns://AccessKeyID/AccessSecretKey/RegionName/+PhoneNo
|
||||||
|
SMTPS - mailtos://user:pass@mail.domain.com?to=receivingAddress@example.com
|
||||||
|
">{{notification_urls}}</textarea>
|
||||||
|
</div>
|
||||||
|
<div class="pure-controls">
|
||||||
|
<span class="pure-form-message-inline"><label for="trigger-test-notification" class="pure-checkbox">
|
||||||
|
<input type="checkbox" id="trigger-test-notification" name="trigger-test-notification"> Send test notification on save.</label></span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
@@ -22,7 +51,7 @@
|
|||||||
|
|
||||||
<div class="pure-control-group">
|
<div class="pure-control-group">
|
||||||
<a href="/" class="pure-button button-small button-cancel">Back</a>
|
<a href="/" class="pure-button button-small button-cancel">Back</a>
|
||||||
<a href="/scrub" class="pure-button button-small button-cancel">Reset all version data</a>
|
<a href="/scrub" class="pure-button button-small button-cancel">Delete history version data</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,11 +15,9 @@
|
|||||||
<!-- user/pass r = requests.get('https://api.github.com/user', auth=('user', 'pass')) -->
|
<!-- user/pass r = requests.get('https://api.github.com/user', auth=('user', 'pass')) -->
|
||||||
</form>
|
</form>
|
||||||
<div>
|
<div>
|
||||||
|
<a href="/" class="pure-button button-tag {{'active' if not active_tag }}">All</a>
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
{% if tag == "" %}
|
{% if tag != "" %}
|
||||||
<a href="/" class="pure-button button-tag {{'active' if active_tag == tag }}">All</a>
|
|
||||||
{% else %}
|
|
||||||
<a href="/?tag={{ tag}}" class="pure-button button-tag {{'active' if active_tag == tag }}">{{ tag }}</a>
|
<a href="/?tag={{ tag}}" class="pure-button button-tag {{'active' if active_tag == tag }}">{{ tag }}</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -31,6 +29,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
<th>#</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
|
<th></th>
|
||||||
<th>Last Checked</th>
|
<th>Last Checked</th>
|
||||||
<th>Last Changed</th>
|
<th>Last Changed</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
@@ -43,10 +42,12 @@
|
|||||||
<tr id="{{ watch.uuid }}"
|
<tr id="{{ watch.uuid }}"
|
||||||
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }}
|
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }}
|
||||||
{% if watch.last_error is defined and watch.last_error != False %}error{% endif %}
|
{% if watch.last_error is defined and watch.last_error != False %}error{% endif %}
|
||||||
|
{% if watch.paused is defined and watch.paused != False %}paused{% endif %}
|
||||||
{% if watch.newest_history_key| int > watch.last_viewed| int %}unviewed{% endif %}">
|
{% if watch.newest_history_key| int > watch.last_viewed| int %}unviewed{% endif %}">
|
||||||
<td>{{ loop.index }}</td>
|
<td>{{ loop.index }}</td>
|
||||||
|
<td class="paused-state state-{{watch.paused}}"><a href="/?pause={{ watch.uuid}}{% if active_tag %}&tag={{active_tag}}{% endif %}"><img src="/static/images/pause.svg" alt="Pause"/></a></td>
|
||||||
<td class="title-col">{{watch.title if watch.title is not none else watch.url}}
|
<td class="title-col">{{watch.title if watch.title is not none else watch.url}}
|
||||||
<a class="external" target=_blank href="{{ watch.url }}"></a>
|
<a class="external" target="_blank" rel="noopener" href="{{ watch.url }}"></a>
|
||||||
{% if watch.last_error is defined and watch.last_error != False %}
|
{% if watch.last_error is defined and watch.last_error != False %}
|
||||||
<div class="fetch-error">{{ watch.last_error }}</div>
|
<div class="fetch-error">{{ watch.last_error }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -64,22 +65,33 @@
|
|||||||
<td>
|
<td>
|
||||||
<a href="/api/checknow?uuid={{ watch.uuid}}{% if request.args.get('tag') %}&tag={{request.args.get('tag')}}{% endif %}"
|
<a href="/api/checknow?uuid={{ watch.uuid}}{% if request.args.get('tag') %}&tag={{request.args.get('tag')}}{% endif %}"
|
||||||
class="pure-button button-small pure-button-primary">Recheck</a>
|
class="pure-button button-small pure-button-primary">Recheck</a>
|
||||||
<a href="/edit?uuid={{ watch.uuid}}" class="pure-button button-small pure-button-primary">Edit</a>
|
<a href="/edit/{{ watch.uuid}}" class="pure-button button-small pure-button-primary">Edit</a>
|
||||||
{% if watch.history|length >= 2 %}
|
{% if watch.history|length >= 2 %}
|
||||||
<a href="/diff/{{ watch.uuid}}" class="pure-button button-small pure-button-primary">Diff</a>
|
<a href="/diff/{{ watch.uuid}}" target="{{watch.uuid}}" class="pure-button button-small pure-button-primary">Diff</a>
|
||||||
|
{% else %}
|
||||||
|
{% if watch.history|length == 1 %}
|
||||||
|
<a href="/preview/{{ watch.uuid}}" target="{{watch.uuid}}" class="pure-button button-small pure-button-primary">Preview</a>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
<div id="check-all-button">
|
<ul id="post-list-buttons">
|
||||||
|
{% if has_unviewed %}
|
||||||
|
<li>
|
||||||
|
<a href="/api/mark-all-viewed" class="pure-button button-tag ">Mark all viewed</a>
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
<li>
|
||||||
<a href="/api/checknow{% if active_tag%}?tag={{active_tag}}{%endif%}" class="pure-button button-tag ">Recheck
|
<a href="/api/checknow{% if active_tag%}?tag={{active_tag}}{%endif%}" class="pure-button button-tag ">Recheck
|
||||||
all {% if active_tag%}in "{{active_tag}}"{%endif%}</a>
|
all {% if active_tag%}in "{{active_tag}}"{%endif%}</a>
|
||||||
</div>
|
</li>
|
||||||
|
<li>
|
||||||
|
<a href="{{ url_for('index', tag=active_tag , rss=true)}}"><img id="feed-icon" src="/static/images/Generic_Feed-icon.svg" height="15px"></a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -7,17 +7,14 @@ import os
|
|||||||
|
|
||||||
|
|
||||||
# https://github.com/pallets/flask/blob/1.1.2/examples/tutorial/tests/test_auth.py
|
# https://github.com/pallets/flask/blob/1.1.2/examples/tutorial/tests/test_auth.py
|
||||||
|
|
||||||
# Much better boilerplate than the docs
|
# Much better boilerplate than the docs
|
||||||
# https://www.python-boilerplate.com/py3+flask+pytest/
|
# https://www.python-boilerplate.com/py3+flask+pytest/
|
||||||
|
|
||||||
global app
|
global app
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope='session')
|
@pytest.fixture(scope='session')
|
||||||
def app(request):
|
def app(request):
|
||||||
"""Create application for the tests."""
|
"""Create application for the tests."""
|
||||||
|
|
||||||
datastore_path = "./test-datastore"
|
datastore_path = "./test-datastore"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -33,11 +30,18 @@ def app(request):
|
|||||||
app_config = {'datastore_path': datastore_path}
|
app_config = {'datastore_path': datastore_path}
|
||||||
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'], include_default_watches=False)
|
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'], include_default_watches=False)
|
||||||
app = changedetection_app(app_config, datastore)
|
app = changedetection_app(app_config, datastore)
|
||||||
|
app.config['STOP_THREADS'] = True
|
||||||
|
|
||||||
def teardown():
|
def teardown():
|
||||||
datastore.stop_thread = True
|
datastore.stop_thread = True
|
||||||
app.config['STOP_THREADS'] = True
|
app.config.exit.set()
|
||||||
|
for fname in ["url-watches.json", "count.txt", "output.txt"]:
|
||||||
|
try:
|
||||||
|
os.unlink("{}/{}".format(datastore_path, fname))
|
||||||
|
except FileNotFoundError:
|
||||||
|
# This is fine in the case of a failure.
|
||||||
|
pass
|
||||||
|
|
||||||
request.addfinalizer(teardown)
|
request.addfinalizer(teardown)
|
||||||
|
yield app
|
||||||
|
|
||||||
return app
|
|
||||||
|
|||||||
58
backend/tests/test_access_control.py
Normal file
58
backend/tests/test_access_control.py
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
from flask import url_for
|
||||||
|
|
||||||
|
def test_check_access_control(app, client):
|
||||||
|
# Still doesnt work, but this is closer.
|
||||||
|
return
|
||||||
|
with app.test_client() as c:
|
||||||
|
|
||||||
|
# Check we dont have any password protection enabled yet.
|
||||||
|
res = c.get(url_for("settings_page"))
|
||||||
|
assert b"Remove password" not in res.data
|
||||||
|
|
||||||
|
# Enable password check.
|
||||||
|
res = c.post(
|
||||||
|
url_for("settings_page"),
|
||||||
|
data={"password": "foobar"},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert b"Password protection enabled." in res.data
|
||||||
|
assert b"LOG OUT" not in res.data
|
||||||
|
print ("SESSION:", res.session)
|
||||||
|
# Check we hit the login
|
||||||
|
|
||||||
|
res = c.get(url_for("settings_page"), follow_redirects=True)
|
||||||
|
res = c.get(url_for("login"), follow_redirects=True)
|
||||||
|
|
||||||
|
assert b"Login" in res.data
|
||||||
|
|
||||||
|
print ("DEBUG >>>>>",res.data)
|
||||||
|
# Menu should not be available yet
|
||||||
|
assert b"SETTINGS" not in res.data
|
||||||
|
assert b"BACKUP" not in res.data
|
||||||
|
assert b"IMPORT" not in res.data
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#defaultuser@changedetection.io is actually hardcoded for now, we only use a single password
|
||||||
|
res = c.post(
|
||||||
|
url_for("login"),
|
||||||
|
data={"password": "foobar", "email": "defaultuser@changedetection.io"},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
|
||||||
|
assert b"LOG OUT" in res.data
|
||||||
|
res = c.get(url_for("settings_page"))
|
||||||
|
|
||||||
|
# Menu should be available now
|
||||||
|
assert b"SETTINGS" in res.data
|
||||||
|
assert b"BACKUP" in res.data
|
||||||
|
assert b"IMPORT" in res.data
|
||||||
|
|
||||||
|
assert b"LOG OUT" in res.data
|
||||||
|
|
||||||
|
# Now remove the password so other tests function, @todo this should happen before each test automatically
|
||||||
|
|
||||||
|
c.get(url_for("settings_page", removepassword="true"))
|
||||||
|
c.get(url_for("import_page"))
|
||||||
|
assert b"LOG OUT" not in res.data
|
||||||
|
|
||||||
@@ -3,52 +3,16 @@
|
|||||||
import time
|
import time
|
||||||
from flask import url_for
|
from flask import url_for
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
from . util import set_original_response, set_modified_response, live_server_setup
|
||||||
|
|
||||||
|
sleep_time_for_fetch_thread = 3
|
||||||
|
|
||||||
|
|
||||||
def set_original_response():
|
|
||||||
test_return_data = """<html>
|
|
||||||
<body>
|
|
||||||
Some initial text</br>
|
|
||||||
<p>Which is across multiple lines</p>
|
|
||||||
</br>
|
|
||||||
So let's see what happens. </br>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
with open("test-datastore/output.txt", "w") as f:
|
|
||||||
f.write(test_return_data)
|
|
||||||
|
|
||||||
|
|
||||||
def set_modified_response():
|
|
||||||
test_return_data = """<html>
|
|
||||||
<body>
|
|
||||||
Some initial text</br>
|
|
||||||
<p>which has this one new line</p>
|
|
||||||
</br>
|
|
||||||
So let's see what happens. </br>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
"""
|
|
||||||
|
|
||||||
with open("test-datastore/output.txt", "w") as f:
|
|
||||||
f.write(test_return_data)
|
|
||||||
|
|
||||||
|
|
||||||
def test_check_basic_change_detection_functionality(client, live_server):
|
def test_check_basic_change_detection_functionality(client, live_server):
|
||||||
sleep_time_for_fetch_thread = 5
|
|
||||||
|
|
||||||
@live_server.app.route('/test-endpoint')
|
|
||||||
def test_endpoint():
|
|
||||||
# Tried using a global var here but didn't seem to work, so reading from a file instead.
|
|
||||||
with open("test-datastore/output.txt", "r") as f:
|
|
||||||
return f.read()
|
|
||||||
|
|
||||||
set_original_response()
|
set_original_response()
|
||||||
|
live_server_setup(live_server)
|
||||||
live_server.start()
|
|
||||||
|
|
||||||
# Add our URL to the import page
|
# Add our URL to the import page
|
||||||
res = client.post(
|
res = client.post(
|
||||||
@@ -72,6 +36,12 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
assert b'unviewed' not in res.data
|
assert b'unviewed' not in res.data
|
||||||
assert b'test-endpoint' in res.data
|
assert b'test-endpoint' in res.data
|
||||||
|
|
||||||
|
# Default no password set, this stuff should be always available.
|
||||||
|
|
||||||
|
assert b"SETTINGS" in res.data
|
||||||
|
assert b"BACKUP" in res.data
|
||||||
|
assert b"IMPORT" in res.data
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
|
|
||||||
# Make a change
|
# Make a change
|
||||||
@@ -97,7 +67,7 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|
||||||
# Do this a few times.. ensures we dont accidently set the status
|
# Do this a few times.. ensures we dont accidently set the status
|
||||||
for n in range(3):
|
for n in range(2):
|
||||||
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
|
||||||
# Give the thread time to pick it up
|
# Give the thread time to pick it up
|
||||||
@@ -108,10 +78,14 @@ def test_check_basic_change_detection_functionality(client, live_server):
|
|||||||
assert b'unviewed' not in res.data
|
assert b'unviewed' not in res.data
|
||||||
assert b'test-endpoint' in res.data
|
assert b'test-endpoint' in res.data
|
||||||
|
|
||||||
|
|
||||||
set_original_response()
|
set_original_response()
|
||||||
|
|
||||||
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
time.sleep(sleep_time_for_fetch_thread)
|
time.sleep(sleep_time_for_fetch_thread)
|
||||||
res = client.get(url_for("index"))
|
res = client.get(url_for("index"))
|
||||||
assert b'unviewed' in res.data
|
assert b'unviewed' in res.data
|
||||||
|
|
||||||
|
# Cleanup everything
|
||||||
|
res = client.get(url_for("api_delete", uuid="all"), follow_redirects=True)
|
||||||
|
assert b'Deleted' in res.data
|
||||||
|
|
||||||
|
|||||||
153
backend/tests/test_ignore_text.py
Normal file
153
backend/tests/test_ignore_text.py
Normal file
@@ -0,0 +1,153 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import time
|
||||||
|
from flask import url_for
|
||||||
|
from . util import live_server_setup
|
||||||
|
|
||||||
|
def test_setup(live_server):
|
||||||
|
live_server_setup(live_server)
|
||||||
|
|
||||||
|
# Unit test of the stripper
|
||||||
|
# Always we are dealing in utf-8
|
||||||
|
def test_strip_text_func():
|
||||||
|
from backend import fetch_site_status
|
||||||
|
|
||||||
|
test_content = """
|
||||||
|
Some content
|
||||||
|
is listed here
|
||||||
|
|
||||||
|
but sometimes we want to remove the lines.
|
||||||
|
|
||||||
|
but not always."""
|
||||||
|
|
||||||
|
ignore_lines = ["sometimes"]
|
||||||
|
|
||||||
|
fetcher = fetch_site_status.perform_site_check(datastore=False)
|
||||||
|
stripped_content = fetcher.strip_ignore_text(test_content, ignore_lines)
|
||||||
|
|
||||||
|
assert b"sometimes" not in stripped_content
|
||||||
|
assert b"Some content" in stripped_content
|
||||||
|
|
||||||
|
|
||||||
|
def set_original_ignore_response():
|
||||||
|
test_return_data = """<html>
|
||||||
|
<body>
|
||||||
|
Some initial text</br>
|
||||||
|
<p>Which is across multiple lines</p>
|
||||||
|
</br>
|
||||||
|
So let's see what happens. </br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("test-datastore/output.txt", "w") as f:
|
||||||
|
f.write(test_return_data)
|
||||||
|
|
||||||
|
|
||||||
|
def set_modified_original_ignore_response():
|
||||||
|
test_return_data = """<html>
|
||||||
|
<body>
|
||||||
|
Some NEW nice initial text</br>
|
||||||
|
<p>Which is across multiple lines</p>
|
||||||
|
</br>
|
||||||
|
So let's see what happens. </br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("test-datastore/output.txt", "w") as f:
|
||||||
|
f.write(test_return_data)
|
||||||
|
|
||||||
|
|
||||||
|
# Is the same but includes ZZZZZ, 'ZZZZZ' is the last line in ignore_text
|
||||||
|
def set_modified_ignore_response():
|
||||||
|
test_return_data = """<html>
|
||||||
|
<body>
|
||||||
|
Some initial text</br>
|
||||||
|
<p>Which is across multiple lines</p>
|
||||||
|
<P>ZZZZZ</P>
|
||||||
|
</br>
|
||||||
|
So let's see what happens. </br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("test-datastore/output.txt", "w") as f:
|
||||||
|
f.write(test_return_data)
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_ignore_text_functionality(client, live_server):
|
||||||
|
sleep_time_for_fetch_thread = 3
|
||||||
|
|
||||||
|
ignore_text = "XXXXX\nYYYYY\nZZZZZ"
|
||||||
|
set_original_ignore_response()
|
||||||
|
|
||||||
|
# Give the endpoint time to spin up
|
||||||
|
time.sleep(1)
|
||||||
|
|
||||||
|
# Add our URL to the import page
|
||||||
|
test_url = url_for('test_endpoint', _external=True)
|
||||||
|
res = client.post(
|
||||||
|
url_for("import_page"),
|
||||||
|
data={"urls": test_url},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert b"1 Imported" in res.data
|
||||||
|
|
||||||
|
# Trigger a check
|
||||||
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
|
||||||
|
# Give the thread time to pick it up
|
||||||
|
time.sleep(sleep_time_for_fetch_thread)
|
||||||
|
|
||||||
|
# Goto the edit page, add our ignore text
|
||||||
|
# Add our URL to the import page
|
||||||
|
res = client.post(
|
||||||
|
url_for("edit_page", uuid="first"),
|
||||||
|
data={"ignore-text": ignore_text, "url": test_url, "tag": "", "headers": ""},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert b"Updated watch." in res.data
|
||||||
|
|
||||||
|
# Check it saved
|
||||||
|
res = client.get(
|
||||||
|
url_for("edit_page", uuid="first"),
|
||||||
|
)
|
||||||
|
assert bytes(ignore_text.encode('utf-8')) in res.data
|
||||||
|
|
||||||
|
# Trigger a check
|
||||||
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
|
||||||
|
# Give the thread time to pick it up
|
||||||
|
time.sleep(sleep_time_for_fetch_thread)
|
||||||
|
|
||||||
|
# It should report nothing found (no new 'unviewed' class)
|
||||||
|
res = client.get(url_for("index"))
|
||||||
|
assert b'unviewed' not in res.data
|
||||||
|
assert b'/test-endpoint' in res.data
|
||||||
|
|
||||||
|
# Make a change
|
||||||
|
set_modified_ignore_response()
|
||||||
|
|
||||||
|
# Trigger a check
|
||||||
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
# Give the thread time to pick it up
|
||||||
|
time.sleep(sleep_time_for_fetch_thread)
|
||||||
|
|
||||||
|
# It should report nothing found (no new 'unviewed' class)
|
||||||
|
res = client.get(url_for("index"))
|
||||||
|
assert b'unviewed' not in res.data
|
||||||
|
assert b'/test-endpoint' in res.data
|
||||||
|
|
||||||
|
# Just to be sure.. set a regular modified change..
|
||||||
|
set_modified_original_ignore_response()
|
||||||
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
time.sleep(sleep_time_for_fetch_thread)
|
||||||
|
res = client.get(url_for("index"))
|
||||||
|
assert b'unviewed' in res.data
|
||||||
|
|
||||||
|
res = client.get(url_for("api_delete", uuid="all"), follow_redirects=True)
|
||||||
|
assert b'Deleted' in res.data
|
||||||
66
backend/tests/test_notification.py
Normal file
66
backend/tests/test_notification.py
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
|
||||||
|
import time
|
||||||
|
from flask import url_for
|
||||||
|
from . util import set_original_response, set_modified_response, live_server_setup
|
||||||
|
|
||||||
|
# Hard to just add more live server URLs when one test is already running (I think)
|
||||||
|
# So we add our test here (was in a different file)
|
||||||
|
def test_check_notification(client, live_server):
|
||||||
|
|
||||||
|
live_server_setup(live_server)
|
||||||
|
set_original_response()
|
||||||
|
|
||||||
|
# Give the endpoint time to spin up
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# Add our URL to the import page
|
||||||
|
test_url = url_for('test_endpoint', _external=True)
|
||||||
|
res = client.post(
|
||||||
|
url_for("import_page"),
|
||||||
|
data={"urls": test_url},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert b"1 Imported" in res.data
|
||||||
|
|
||||||
|
# Give the thread time to pick it up
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# Goto the edit page, add our ignore text
|
||||||
|
# Add our URL to the import page
|
||||||
|
url = url_for('test_notification_endpoint', _external=True)
|
||||||
|
notification_url = url.replace('http', 'json')
|
||||||
|
|
||||||
|
print (">>>> Notification URL: "+notification_url)
|
||||||
|
res = client.post(
|
||||||
|
url_for("edit_page", uuid="first"),
|
||||||
|
data={"notification_urls": notification_url, "url": test_url, "tag": "", "headers": ""},
|
||||||
|
follow_redirects=True
|
||||||
|
)
|
||||||
|
assert b"Updated watch." in res.data
|
||||||
|
|
||||||
|
# Hit the edit page, be sure that we saved it
|
||||||
|
res = client.get(
|
||||||
|
url_for("edit_page", uuid="first"))
|
||||||
|
assert bytes(notification_url.encode('utf-8')) in res.data
|
||||||
|
|
||||||
|
set_modified_response()
|
||||||
|
|
||||||
|
# Trigger a check
|
||||||
|
client.get(url_for("api_watch_checknow"), follow_redirects=True)
|
||||||
|
|
||||||
|
# Give the thread time to pick it up
|
||||||
|
time.sleep(3)
|
||||||
|
|
||||||
|
# Did the front end see it?
|
||||||
|
res = client.get(
|
||||||
|
url_for("index"))
|
||||||
|
assert bytes("just now".encode('utf-8')) in res.data
|
||||||
|
|
||||||
|
|
||||||
|
# Check it triggered
|
||||||
|
res = client.get(
|
||||||
|
url_for("test_notification_counter"),
|
||||||
|
)
|
||||||
|
print (res.data)
|
||||||
|
|
||||||
|
assert bytes("we hit it".encode('utf-8')) in res.data
|
||||||
60
backend/tests/util.py
Normal file
60
backend/tests/util.py
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
|
||||||
|
def set_original_response():
|
||||||
|
test_return_data = """<html>
|
||||||
|
<body>
|
||||||
|
Some initial text</br>
|
||||||
|
<p>Which is across multiple lines</p>
|
||||||
|
</br>
|
||||||
|
So let's see what happens. </br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("test-datastore/output.txt", "w") as f:
|
||||||
|
f.write(test_return_data)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def set_modified_response():
|
||||||
|
test_return_data = """<html>
|
||||||
|
<body>
|
||||||
|
Some initial text</br>
|
||||||
|
<p>which has this one new line</p>
|
||||||
|
</br>
|
||||||
|
So let's see what happens. </br>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("test-datastore/output.txt", "w") as f:
|
||||||
|
f.write(test_return_data)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def live_server_setup(live_server):
|
||||||
|
|
||||||
|
@live_server.app.route('/test-endpoint')
|
||||||
|
def test_endpoint():
|
||||||
|
# Tried using a global var here but didn't seem to work, so reading from a file instead.
|
||||||
|
with open("test-datastore/output.txt", "r") as f:
|
||||||
|
return f.read()
|
||||||
|
|
||||||
|
@live_server.app.route('/test_notification_endpoint', methods=['POST'])
|
||||||
|
def test_notification_endpoint():
|
||||||
|
with open("test-datastore/count.txt", "w") as f:
|
||||||
|
f.write("we hit it")
|
||||||
|
print("\n>> Test notification endpoint was hit.\n")
|
||||||
|
return "Text was set"
|
||||||
|
|
||||||
|
# And this should return not zero.
|
||||||
|
@live_server.app.route('/test_notification_counter')
|
||||||
|
def test_notification_counter():
|
||||||
|
try:
|
||||||
|
with open("test-datastore/count.txt", "r") as f:
|
||||||
|
return f.read()
|
||||||
|
except FileNotFoundError:
|
||||||
|
return "nope :("
|
||||||
|
|
||||||
|
live_server.start()
|
||||||
67
backend/update_worker.py
Normal file
67
backend/update_worker.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import threading
|
||||||
|
import queue
|
||||||
|
|
||||||
|
# Requests for checking on the site use a pool of thread Workers managed by a Queue.
|
||||||
|
class update_worker(threading.Thread):
|
||||||
|
current_uuid = None
|
||||||
|
|
||||||
|
def __init__(self, q, notification_q, app, datastore, *args, **kwargs):
|
||||||
|
self.q = q
|
||||||
|
self.app = app
|
||||||
|
self.notification_q = notification_q
|
||||||
|
self.datastore = datastore
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
from backend import fetch_site_status
|
||||||
|
|
||||||
|
update_handler = fetch_site_status.perform_site_check(datastore=self.datastore)
|
||||||
|
|
||||||
|
while not self.app.config.exit.is_set():
|
||||||
|
|
||||||
|
try:
|
||||||
|
uuid = self.q.get(block=False)
|
||||||
|
except queue.Empty:
|
||||||
|
pass
|
||||||
|
|
||||||
|
else:
|
||||||
|
self.current_uuid = uuid
|
||||||
|
|
||||||
|
if uuid in list(self.datastore.data['watching'].keys()):
|
||||||
|
try:
|
||||||
|
changed_detected, result, contents = update_handler.run(uuid)
|
||||||
|
|
||||||
|
except PermissionError as s:
|
||||||
|
self.app.logger.error("File permission error updating", uuid, str(s))
|
||||||
|
else:
|
||||||
|
if result:
|
||||||
|
try:
|
||||||
|
self.datastore.update_watch(uuid=uuid, update_obj=result)
|
||||||
|
if changed_detected:
|
||||||
|
# A change was detected
|
||||||
|
self.datastore.save_history_text(uuid=uuid, contents=contents, result_obj=result)
|
||||||
|
|
||||||
|
watch = self.datastore.data['watching'][uuid]
|
||||||
|
|
||||||
|
# Did it have any notification alerts to hit?
|
||||||
|
if len(watch['notification_urls']):
|
||||||
|
print("Processing notifications for UUID: {}".format(uuid))
|
||||||
|
n_object = {'watch_url': self.datastore.data['watching'][uuid]['url'],
|
||||||
|
'notification_urls': watch['notification_urls']}
|
||||||
|
self.notification_q.put(n_object)
|
||||||
|
|
||||||
|
|
||||||
|
# No? maybe theres a global setting, queue them all
|
||||||
|
elif len(self.datastore.data['settings']['application']['notification_urls']):
|
||||||
|
print("Processing GLOBAL notifications for UUID: {}".format(uuid))
|
||||||
|
n_object = {'watch_url': self.datastore.data['watching'][uuid]['url'],
|
||||||
|
'notification_urls': self.datastore.data['settings']['application'][
|
||||||
|
'notification_urls']}
|
||||||
|
self.notification_q.put(n_object)
|
||||||
|
except Exception as e:
|
||||||
|
print("!!!! Exception in update_worker !!!\n", e)
|
||||||
|
|
||||||
|
self.current_uuid = None # Done
|
||||||
|
self.q.task_done()
|
||||||
|
|
||||||
|
self.app.config.exit.wait(1)
|
||||||
@@ -3,6 +3,7 @@
|
|||||||
# Launch as a eventlet.wsgi server instance.
|
# Launch as a eventlet.wsgi server instance.
|
||||||
|
|
||||||
import getopt
|
import getopt
|
||||||
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import eventlet
|
import eventlet
|
||||||
@@ -12,10 +13,31 @@ import backend
|
|||||||
from backend import store
|
from backend import store
|
||||||
|
|
||||||
|
|
||||||
|
def init_app_secret(datastore_path):
|
||||||
|
secret = ""
|
||||||
|
|
||||||
|
path = "{}/secret.txt".format(datastore_path)
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(path, "r") as f:
|
||||||
|
secret = f.read()
|
||||||
|
|
||||||
|
except FileNotFoundError:
|
||||||
|
|
||||||
|
import secrets
|
||||||
|
with open(path, "w") as f:
|
||||||
|
secret = secrets.token_hex(32)
|
||||||
|
f.write(secret)
|
||||||
|
|
||||||
|
return secret
|
||||||
|
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
ssl_mode = False
|
ssl_mode = False
|
||||||
port = 5000
|
port = 5000
|
||||||
datastore_path = "./datastore"
|
|
||||||
|
# Must be absolute so that send_from_directory doesnt try to make it relative to backend/
|
||||||
|
datastore_path = os.path.join(os.getcwd(), "datastore")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
opts, args = getopt.getopt(argv, "sd:p:", "purge")
|
opts, args = getopt.getopt(argv, "sd:p:", "purge")
|
||||||
@@ -38,18 +60,22 @@ def main(argv):
|
|||||||
if opt == '-d':
|
if opt == '-d':
|
||||||
datastore_path = arg
|
datastore_path = arg
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# threads can read from disk every x seconds right?
|
|
||||||
# front end can just save
|
|
||||||
# We just need to know which threads are looking at which UUIDs
|
|
||||||
|
|
||||||
# isnt there some @thingy to attach to each route to tell it, that this route needs a datastore
|
# isnt there some @thingy to attach to each route to tell it, that this route needs a datastore
|
||||||
app_config = {'datastore_path': datastore_path}
|
app_config = {'datastore_path': datastore_path}
|
||||||
|
|
||||||
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'])
|
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'])
|
||||||
app = backend.changedetection_app(app_config, datastore)
|
app = backend.changedetection_app(app_config, datastore)
|
||||||
|
|
||||||
|
app.config['datastore_path'] = datastore_path
|
||||||
|
app.secret_key = init_app_secret(app_config['datastore_path'])
|
||||||
|
|
||||||
|
@app.context_processor
|
||||||
|
def inject_version():
|
||||||
|
return dict(version=datastore.data['version_tag'],
|
||||||
|
new_version_available=app.config['NEW_VERSION_AVAILABLE'],
|
||||||
|
has_password=datastore.data['settings']['application']['password'] != False
|
||||||
|
)
|
||||||
|
|
||||||
if ssl_mode:
|
if ssl_mode:
|
||||||
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
# @todo finalise SSL config, but this should get you in the right direction if you need it.
|
||||||
eventlet.wsgi.server(eventlet.wrap_ssl(eventlet.listen(('', port)),
|
eventlet.wsgi.server(eventlet.wrap_ssl(eventlet.listen(('', port)),
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
version: "2"
|
|
||||||
services:
|
|
||||||
|
|
||||||
# I have a feeling we can get rid of this, and just use one docker-compose.yml, and just set a ENV var if
|
|
||||||
# we want dev mode (just gives a docker shell) or not.
|
|
||||||
|
|
||||||
backend:
|
|
||||||
build: ./backend/dev-docker
|
|
||||||
image: dgtlmoon/changedetection.io:dev
|
|
||||||
container_name: changedetection.io-dev
|
|
||||||
volumes:
|
|
||||||
- ./backend:/app
|
|
||||||
- ./requirements.txt:/requirements.txt # Normally COPY'ed in the Dockerfile
|
|
||||||
- ./datastore:/datastore
|
|
||||||
|
|
||||||
ports:
|
|
||||||
- "127.0.0.1:5001:5000"
|
|
||||||
|
|
||||||
networks:
|
|
||||||
- changenet
|
|
||||||
|
|
||||||
networks:
|
|
||||||
changenet:
|
|
||||||
@@ -1,24 +1,14 @@
|
|||||||
aiohttp
|
|
||||||
async-timeout
|
|
||||||
chardet==2.3.0
|
chardet==2.3.0
|
||||||
multidict
|
flask~= 1.0
|
||||||
python-engineio
|
pytest ~=6.2
|
||||||
six==1.10.0
|
pytest-flask ~=1.2
|
||||||
yarl
|
eventlet>=0.31.0
|
||||||
flask
|
requests ~= 2.15
|
||||||
|
|
||||||
pytest
|
|
||||||
pytest-flask # for live_server
|
|
||||||
|
|
||||||
eventlet
|
|
||||||
requests
|
|
||||||
validators
|
validators
|
||||||
|
timeago ~=1.0
|
||||||
bleach==3.2.1
|
inscriptis ~= 1.1
|
||||||
html5lib==0.9999999 # via bleach
|
feedgen ~= 0.9
|
||||||
timeago
|
flask-login ~= 0.5
|
||||||
html2text
|
pytz
|
||||||
inscriptis
|
urllib3
|
||||||
|
apprise ~= 0.9
|
||||||
# @notes
|
|
||||||
# - Dont install socketio, it interferes with flask_socketio
|
|
||||||
|
|||||||
BIN
screenshot-notifications.png
Normal file
BIN
screenshot-notifications.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
screenshot.png
BIN
screenshot.png
Binary file not shown.
|
Before Width: | Height: | Size: 217 KiB After Width: | Height: | Size: 213 KiB |
Reference in New Issue
Block a user