Skip to content

Commit

Permalink
Rename include_rotted filtering query param and app config key to `…
Browse files Browse the repository at this point in the history
…include_dead`
  • Loading branch information
le717 committed Aug 6, 2024
1 parent 4d1c542 commit 24bf7f1
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 18 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ _Released TDB_

- **Breaking change**: An auth key is now provided as a `Bearer` token in the
HTTP `Authorization` header
- Rename `include_rotted` filtering query param and app config key to `include_dead`
- Update minimum Python version to 3.12
- Update Docker image to `python:3.12-slim`

Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ ENV PYTHONPATH=/app \
FLASK_SKIP_DOTENV=1 \
TIMES_FAILED_THRESHOLD=10 \
ENABLE_DISCORD_LOGGING=false \
FILTER_INCLUDE_ROTTED=true \
FILTER_INCLUDE_WEB_ARCHIVE=true \
FILTER_EXCLUDE_ORIGIN=true
FILTER_INCLUDE_DEAD=true \
FILTER_EXCLUDE_ORIGIN=true \
FILTER_INCLUDE_WEB_ARCHIVE=true

# Copy the app files into the container
RUN mkdir -p /app
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,11 @@ options are provided through query parameters to the URLs.
Filtering out the site requesting the webring from the webring entries requires the HTTP `ORIGIN`
header to be properly set for the request.

- `include_rotted: bool = "yes"`: Include entries that have been determined to be rotten
- `include_web_archive: bool = "yes"`: Include entries that can only be accessed through
the Web Archive (added in version 1.4.0)
- `include_dead: bool = "yes"`: Include entries that have been determined to be dead links
- `exclude_origin: bool = "yes"`: Remove the site requesting the webring from the entries,
if present
- `include_web_archive: bool = "yes"`: Include entries that can only be accessed through
the Web Archive (added in version 1.4.0)

These values can also be set globally through the app configuration but will be overridden by
individual requests.
Expand Down Expand Up @@ -85,7 +85,7 @@ non-heavily trafficked page of your site.
### Discord channel logger

If the [Discord](https://discord.com) logger is enabled and configured, entries that are found to be
rotting or rotted will be reported in a Discord channel. This can be helpful for keeping up with
rotting or dead will be reported in a Discord channel. This can be helpful for keeping up with
the webring's health and ensuring entries are available. Configuring the Discord logger
is kept as simple as possible.

Expand All @@ -99,25 +99,26 @@ A text file logger for events is always configured.
### Auth key creation/management

All administrative operations (effectively anything except fetching the webring entries) are
protected by an auth key which is intentionally kept extremely simple. Any string of characters
can be used as a key. All keys are defined as a JSON list called `AUTH_KEYS`. The key is to be
passed to the request via the HTTP `Authorization` header as a `Bearer` token. If the key is not
provided, a `400 BAD REQUEST` HTTP error is raised. If the key is in the defined list, the
operation succeeds. If it is not, a `403 FORBIDDEN` HTTP error is raised.
protected by an auth key. The system is intentionally kept extremely simple. Any string of
characters can be used as a key. All keys are defined as a JSON list called `AUTH_KEYS`. The key is
to be passed to the request via the HTTP `Authorization` header as a `Bearer` token. If the key is
not provided, a `400 BAD REQUEST` HTTP error is raised. If it is not in the list, a `403 FORBIDDEN`
HTTP error is raised.

## Required Secret/Configuration Keys

- Flask secret key (`SECRET_KEY`)
- Flask app environment (`FLASK_ENV`) set to `"production"`
- Absolute path to SQLite file (`DB_PATH`)
- JSON list of auth keys for all administrative operations (`AUTH_KEYS`)
- Integer number of times supposed rotted links should be checked (`TIMES_FAILED_THRESHOLD`, default: 10)
- Integer number of times supposed rotted links should be checked
(`TIMES_FAILED_THRESHOLD`, default: 10)
- Discord linkrot event logging boolean (`ENABLE_DISCORD_LOGGING`, default: `False`)
- Discord webhook URL (`DISCORD_WEBHOOK_URL`)
- Webring entry filtering
- `FILTER_INCLUDE_ROTTED`, default: `True`
- `FILTER_INCLUDE_WEB_ARCHIVE`, default: `True`
- `FILTER_INCLUDE_DEAD`, default: `True`
- `FILTER_EXCLUDE_ORIGIN`, default: `True`
- `FILTER_INCLUDE_WEB_ARCHIVE`, default: `True`

## Development

Expand Down
2 changes: 1 addition & 1 deletion src/core/database/linkrot.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __record_failure(entry: Entry, history_entry: LinkrotHistory) -> Check:
def check_all() -> list[RotResult]:
"""Check all links for rotting."""
return [
check_one(link) for link in weblink.get_all(include_rotted=True, include_web_archive=False)
check_one(link) for link in weblink.get_all(include_dead=True, include_web_archive=False)
]


Expand Down
1 change: 1 addition & 0 deletions src/core/database/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

def get() -> dict[str, str]:
"""Get meta information about this webring instance."""
# TODO: Add defaults for webring.json
return sys_vars.get_json("webring.json") | {
"software": "https://github.com/le717/webring",
"version": current_app.config["API_VERSION"],
Expand Down
2 changes: 1 addition & 1 deletion src/core/database/weblink.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def get_all(**kwargs: Any) -> list[Entry]:
filters.append(func.lower(Entry.url) != func.lower(origin))

# Filter out dead and/or Web Archive only links
if not kwargs["include_rotted"]:
if not kwargs["include_dead"]:
filters.append(Entry.is_dead == False)
if not kwargs["include_web_archive"]:
filters.append(Entry.is_web_archive == False)
Expand Down
2 changes: 1 addition & 1 deletion src/core/models/WebLink.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class EntryCreate(Schema):


class RingArgs(Schema):
include_rotted = fields.Boolean(load_default=sys_vars.get_bool("FILTER_INCLUDE_ROTTED"))
include_dead = fields.Boolean(load_default=sys_vars.get_bool("FILTER_INCLUDE_DEAD"))
include_web_archive = fields.Boolean(
load_default=sys_vars.get_bool("FILTER_INCLUDE_WEB_ARCHIVE")
)
Expand Down

0 comments on commit 24bf7f1

Please sign in to comment.