From 87a27aa5535070c8958fe81f336ded30f62e067d Mon Sep 17 00:00:00 2001 From: gesang Date: Thu, 6 Mar 2025 18:38:59 +0100 Subject: [PATCH 1/9] custom template for books that add shadow library links --- custom/edition.custom.html | 179 +++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 custom/edition.custom.html diff --git a/custom/edition.custom.html b/custom/edition.custom.html new file mode 100644 index 00000000..69ac024b --- /dev/null +++ b/custom/edition.custom.html @@ -0,0 +1,179 @@ +{% extends "item_base.html" %} +{% load static %} +{% load i18n %} +{% load l10n %} +{% load humanize %} +{% load mastodon %} +{% load strip_scheme %} +{% load thumb %} +{% block head %} + {% if item.author %} + + {% endif %} + {% if item.isbn %}{% endif %} +{% endblock %} +{% block details %} +
+ {% if item.isbn %} + {% trans 'ISBN' %}: {{ item.isbn }} + {% endif %} +
+
{% include '_people.html' with people=item.author role='author' max=5 %}
+
{% include '_people.html' with people=item.translator role='translator' max=5 %}
+
+ {% if item.format %} + {% trans 'book format' %}: {{ item.get_format_display }} + {% endif %} +
+
{% include '_people.html' with people=item.additional_title role='other title' max=99 %}
+
+ {% if item.pub_house %} + {% trans 'publishing house' %}: {{ item.pub_house }} + {% endif %} +
+
+ {% if item.imprint %} + {% trans 'imprint' %}: {{ item.imprint }} + {% endif %} +
+
+ {% if item.pub_year %} + {% trans 'publication date' %}: {{ item.pub_year }} + {% if item.pub_month %}-{{ item.pub_month }}{% endif %} + {% endif %} +
+
+ {% if item.series %} + {% trans 'series' %}: {{ item.series }} + {% endif %} +
+
{% include '_people.html' with people=item.language role='language' max=10 %}
+
+ {% if item.binding %} + {% trans 'binding' %}: {{ item.binding }} + {% endif %} +
+
+ {% if item.price %} + {% trans 'price' %}: {{ item.price }} + {% endif %} +
+
+ {% if item.pages %} + {% trans 'number of pages' %}: {{ item.pages }} + {% endif %} +
+ {% if item.other_info %} + {% for k, v in item.other_info.items %}
{{ k }}: {{ v|urlizetrunc:24 }}
{% endfor %} + {% endif %} +{% endblock %} +{% block content %} + {% if item.contents %} +
contents
+

{{ item.contents | linebreaksbr }}

+ {% endif %} + {% with related_books=item.sibling_items %} + {% if related_books.count > 0 %} +
+ + + + + + + + +
{% trans 'other editions' %}
+ +
+ {% endif %} + {% endwith %} +{% endblock %} +{% block left_sidebar %} + + {% if item.isbn %} +
+
+ {% trans 'Borrow or Buy' %} +
+
+ WorldCat +
+
+ Open Library +
+
+ + OAPEN +
+
+
+
+ {% endif %} +
+
+ Shadow Libraries + {% if item.isbn %} +
+ Search by ISBN:
+ Anna's Archive + | + Z-Library +
+ {% endif %} +
+ Search by title:
+ Anna's Archive + | + Z-Library +
+
+
+ dufs.itmens +
+{% endblock %} From 3a2bb41f0dd36055ef3f93e65990d800de5ec4a5 Mon Sep 17 00:00:00 2001 From: gesang Date: Thu, 6 Mar 2025 20:12:29 +0100 Subject: [PATCH 2/9] let compose.yml use the custom template --- compose.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/compose.yml b/compose.yml index 80096559..4b2f954f 100644 --- a/compose.yml +++ b/compose.yml @@ -92,6 +92,7 @@ x-shared: - ${NEODB_DATA:-../data}/takahe-media:/www/media - ${NEODB_DATA:-../data}/takahe-cache:/www/cache - ${NEODB_DATA:-../data}/www-root:/www/root + - ./custom/edition.custom.html:/neodb/catalog/templates/edition.html depends_on: - redis - neodb-db From ff899eacbc9be335f5e839afed9ad805ff08cc99 Mon Sep 17 00:00:00 2001 From: gesang Date: Thu, 6 Mar 2025 22:23:44 +0100 Subject: [PATCH 3/9] use compose.override.yml instead of the original one --- .gitignore | 1 - common/templates/_footer.html | 22 +++ compose.override.yml | 321 ++++++++++++++++++++++++++++++++++ compose.yml | 1 - 4 files changed, 343 insertions(+), 2 deletions(-) create mode 100644 compose.override.yml diff --git a/.gitignore b/.gitignore index 361c034b..d88d1f18 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ .venv /.env /neodb.env -/compose.override.yml /typings # Byte-compiled / optimized / DLL files diff --git a/common/templates/_footer.html b/common/templates/_footer.html index bef464a1..fc043465 100644 --- a/common/templates/_footer.html +++ b/common/templates/_footer.html @@ -48,3 +48,25 @@ }, 0); }); + + diff --git a/compose.override.yml b/compose.override.yml new file mode 100644 index 00000000..4b2f954f --- /dev/null +++ b/compose.override.yml @@ -0,0 +1,321 @@ +# NEODB Docker Compose File +# +# Note: may not be secure for production usage, use at your own risk +# +# The following env variable are expected from .env or command line +# - NEODB_SECRET_KEY +# - NEODB_SITE_DOMAIN +# - NEODB_SITE_NAME +# - NEODB_DATA + +x-shared: + neodb-service: &neodb-service + build: . + image: ${NEODB_IMAGE:-neodb/neodb:latest} + environment: + NEODB_DEBUG: + NEODB_SECRET_KEY: + NEODB_SITE_NAME: + NEODB_SITE_DOMAIN: + NEODB_SITE_INTRO: + NEODB_SITE_HEAD: + NEODB_SITE_LOGO: + NEODB_SITE_ICON: + NEODB_USER_ICON: + NEODB_SITE_COLOR: + NEODB_SITE_LINKS: + NEODB_SITE_DESCRIPTION: + NEODB_ALTERNATIVE_DOMAINS: + NEODB_PREFERRED_LANGUAGES: + NEODB_INVITE_ONLY: + NEODB_LOGIN_MASTODON_WHITELIST: + NEODB_MASTODON_CLIENT_SCOPE: + NEODB_DISABLE_DEFAULT_RELAY: + NEODB_DISABLE_CRON_JOBS: + NEODB_SEARCH_PEERS: + NEODB_SEARCH_SITES: + NEODB_MIN_MARKS_FOR_DISCOVER: + NEODB_DISCOVER_UPDATE_INTERVAL: + NEODB_DISCOVER_FILTER_LANGUAGE: + NEODB_DISCOVER_SHOW_LOCAL_ONLY: + NEODB_DISCOVER_SHOW_POPULAR_POSTS: + NEODB_SENTRY_DSN: + TAKAHE_SENTRY_DSN: + NEODB_SENTRY_SAMPLE_RATE: + NEODB_DB_URL: ${NEODB_DB_URL:-postgres://neodb:aubergine@neodb-db/neodb} + TAKAHE_DB_URL: ${TAKAHE_DB_URL:-postgres://takahe:aubergine@takahe-db/takahe} + NEODB_REDIS_URL: ${NEODB_REDIS_URL:-redis://redis:6379/0} + NEODB_SEARCH_URL: ${NEODB_SEARCH_URL:-typesense://user:eggplant@typesense:8108/catalog} + NEODB_EMAIL_URL: + NEODB_EMAIL_FROM: no-reply@${NEODB_SITE_DOMAIN} + NEODB_ENABLE_LOCAL_ONLY: + NEODB_ENABLE_LOGIN_BLUESKY: + NEODB_ENABLE_LOGIN_THREADS: + NEODB_EXTRA_APPS: + NEODB_FANOUT_LIMIT_DAYS: + TAKAHE_FANOUT_LIMIT_DAYS: + NEODB_DOWNLOADER_PROXY_LIST: + NEODB_DOWNLOADER_BACKUP_PROXY: + NEODB_DOWNLOADER_SAVE_DIR: + NEODB_MEDIA_ROOT: /www/m + NEODB_VENV: /neodb-venv + TAKAHE_ENVIRONMENT: ${ENVIRONMENT:-production} + TAKAHE_SECRET_KEY: ${NEODB_SECRET_KEY} + TAKAHE_MAIN_DOMAIN: ${NEODB_SITE_DOMAIN} + TAKAHE_MEDIA_URL: https://${NEODB_SITE_DOMAIN}/media/ + TAKAHE_EMAIL_FROM: no-reply@${NEODB_SITE_DOMAIN} + TAKAHE_DATABASE_SERVER: ${TAKAHE_DATABASE_SERVER:-postgres://takahe:aubergine@takahe-db/takahe} + TAKAHE_CACHES_DEFAULT: ${TAKAHE_CACHES_DEFAULT:-redis://redis:6379/0} + TAKAHE_MEDIA_BACKEND: local://www/media/ + TAKAHE_MEDIA_ROOT: /www/media + TAKAHE_USE_PROXY_HEADERS: true + TAKAHE_STATOR_CONCURRENCY: ${TAKAHE_STATOR_CONCURRENCY:-4} + TAKAHE_STATOR_CONCURRENCY_PER_MODEL: ${TAKAHE_STATOR_CONCURRENCY_PER_MODEL:-2} + TAKAHE_VAPID_PUBLIC_KEY: + TAKAHE_VAPID_PRIVATE_KEY: + TAKAHE_DEBUG: ${NEODB_DEBUG:-False} + TAKAHE_VENV: /takahe-venv + THREADS_APP_ID: + THREADS_APP_SECRET: + SPOTIFY_API_KEY: + TMDB_API_V3_KEY: + GOOGLE_API_KEY: + DISCOGS_API_KEY: + IGDB_API_CLIENT_ID: + IGDB_API_CLIENT_SECRET: + DISCORD_WEBHOOKS: + SLACK_API_TOKEN: + SSL_ONLY: + restart: "unless-stopped" + volumes: + - ${NEODB_DATA:-../data}/neodb-media:/www/m + - ${NEODB_DATA:-../data}/takahe-media:/www/media + - ${NEODB_DATA:-../data}/takahe-cache:/www/cache + - ${NEODB_DATA:-../data}/www-root:/www/root + - ./custom/edition.custom.html:/neodb/catalog/templates/edition.html + depends_on: + - redis + - neodb-db + - typesense + - takahe-db + profiles: + - production + + dev-neodb-service: &dev-neodb-service + <<: *neodb-service + # environment: + # NEODB_DEBUG: True + volumes: + - ${NEODB_DATA:-../data}/www-root:/www/root + - ${NEODB_DATA:-../data}/neodb-media:/www/m + - ${NEODB_DATA:-../data}/takahe-media:/www/media + - ${NEODB_DATA:-../data}/takahe-cache:/www/cache + - ${NEODB_DATA:-../data}/nginx-log:/var/log/nginx + - ${NEODB_SRC:-.}:/neodb + - ${TAKAHE_SRC:-./neodb-takahe}:/takahe + profiles: + - dev + +services: + redis: + image: redis:alpine + command: redis-server --save 60 1 --loglevel warning + volumes: + - ${NEODB_DATA:-../data}/redis:/data + + typesense: + image: typesense/typesense:${TYPESENSE_VERSION:-0.25.2} + restart: "on-failure" + # healthcheck: + # test: ['CMD', 'curl', '-vf', 'http://127.0.0.1:8108/health'] + # ports: + # - "18108:8108" + environment: + GLOG_minloglevel: 2 + volumes: + - ${NEODB_DATA:-../data}/typesense:/data + command: "--data-dir /data --api-key=eggplant" + + neodb-db: + image: postgres:${POSTGRES_VERSION:-14-alpine} + healthcheck: + test: ["CMD", "pg_isready", "-U", "neodb"] + volumes: + - ${NEODB_DATA:-../data}/neodb-db:/var/lib/postgresql/data + environment: + - POSTGRES_DB=neodb + - POSTGRES_USER=neodb + - POSTGRES_PASSWORD=aubergine + + takahe-db: + image: postgres:${POSTGRES_VERSION:-14-alpine} + healthcheck: + test: ["CMD", "pg_isready", "-U", "takahe"] + volumes: + - ${NEODB_DATA:-../data}/takahe-db:/var/lib/postgresql/data + environment: + - POSTGRES_DB=takahe + - POSTGRES_USER=takahe + - POSTGRES_PASSWORD=aubergine + + migration: + <<: *neodb-service + restart: "no" + command: /bin/neodb-init + depends_on: + neodb-db: + condition: service_healthy + typesense: + condition: service_started + redis: + condition: service_started + takahe-db: + condition: service_healthy + + neodb-web: + <<: *neodb-service + command: ${NEODB_VENV:-/neodb-venv}/bin/gunicorn boofilsic.wsgi -w ${NEODB_WEB_WORKER_NUM:-8} --preload --max-requests 2000 --timeout 60 -b 0.0.0.0:8000 + healthcheck: + test: + [ + "CMD", + "wget", + "-qO/tmp/test", + "--header", + "X-Forwarded-Proto: https", + "http://127.0.0.1:8000/nodeinfo/2.0/", + ] + depends_on: + migration: + condition: service_completed_successfully + + neodb-web-api: + <<: *neodb-service + command: ${NEODB_VENV:-/neodb-venv}/bin/gunicorn boofilsic.wsgi -w ${NEODB_API_WORKER_NUM:-4} --preload --max-requests 2000 --timeout 30 -b 0.0.0.0:8000 + healthcheck: + test: + [ + "CMD", + "wget", + "-qO/tmp/test", + "--header", + "X-Forwarded-Proto: https", + "http://127.0.0.1:8000/nodeinfo/2.0/", + ] + depends_on: + migration: + condition: service_completed_successfully + + neodb-worker: + <<: *neodb-service + command: neodb-manage rqworker --with-scheduler import export mastodon fetch crawl ap cron + depends_on: + migration: + condition: service_completed_successfully + + neodb-worker-extra: + <<: *neodb-service + command: neodb-manage rqworker-pool --num-workers ${NEODB_RQ_WORKER_NUM:-4} mastodon fetch crawl ap + depends_on: + migration: + condition: service_completed_successfully + + takahe-web: + <<: *neodb-service + command: ${TAKAHE_VENV:-/takahe-venv}/bin/gunicorn --chdir /takahe takahe.wsgi -w ${TAKAHE_WEB_WORKER_NUM:-8} --max-requests 2000 --timeout 60 --preload -b 0.0.0.0:8000 + healthcheck: + test: + [ + "CMD", + "wget", + "-qO/tmp/test", + "--header", + "X-Forwarded-Proto: https", + "http://127.0.0.1:8000/api/v1/instance", + ] + depends_on: + migration: + condition: service_completed_successfully + + takahe-stator: + <<: *neodb-service + command: takahe-manage runstator + stop_signal: SIGINT + depends_on: + migration: + condition: service_completed_successfully + + nginx: + <<: *neodb-service + user: "root:root" + command: nginx-start + environment: + NEODB_WEB_SERVER: neodb-web:8000 + NEODB_API_SERVER: neodb-web-api:8000 + TAKAHE_WEB_SERVER: takahe-web:8000 + NGINX_CONF: /neodb/misc/nginx.conf.d/neodb.conf + depends_on: + takahe-web: + condition: service_started + neodb-web: + condition: service_started + ports: + - "${NEODB_PORT:-8000}:8000" + + shell: + <<: *neodb-service + command: bash + profiles: ["tools"] + + root: + <<: *neodb-service + command: bash + profiles: ["tools"] + user: "root:root" + + dev-neodb-web: + <<: *dev-neodb-service + command: neodb-manage runserver 0.0.0.0:8000 + stop_signal: SIGINT + + dev-neodb-worker: + <<: *dev-neodb-service + # command: neodb-manage rqworker-pool --num-workers 4 import export mastodon fetch crawl ap cron + command: neodb-manage rqworker --with-scheduler import export mastodon fetch crawl crawl ap cron + + dev-takahe-web: + <<: *dev-neodb-service + command: takahe-manage runserver 0.0.0.0:8000 + stop_signal: SIGINT + + dev-takahe-stator: + <<: *dev-neodb-service + command: takahe-manage runstator + stop_signal: SIGINT + + dev-nginx: + <<: *dev-neodb-service + user: "root:root" + command: nginx-start + environment: + NEODB_WEB_SERVER: dev-neodb-web:8000 + TAKAHE_WEB_SERVER: dev-takahe-web:8000 + NGINX_CONF: /neodb/misc/nginx.conf.d/neodb-dev.conf + depends_on: + dev-takahe-web: + condition: service_started + dev-neodb-web: + condition: service_started + ports: + - "${NEODB_PORT:-8000}:8000" + + dev-shell: + <<: *dev-neodb-service + command: bash + profiles: ["tools"] + + dev-root: + <<: *dev-neodb-service + command: bash + profiles: ["tools"] + user: "root:root" diff --git a/compose.yml b/compose.yml index 4b2f954f..80096559 100644 --- a/compose.yml +++ b/compose.yml @@ -92,7 +92,6 @@ x-shared: - ${NEODB_DATA:-../data}/takahe-media:/www/media - ${NEODB_DATA:-../data}/takahe-cache:/www/cache - ${NEODB_DATA:-../data}/www-root:/www/root - - ./custom/edition.custom.html:/neodb/catalog/templates/edition.html depends_on: - redis - neodb-db From 86379378038d995e6e7f836e98648cd81d40e22f Mon Sep 17 00:00:00 2001 From: gesang Date: Thu, 6 Mar 2025 22:26:05 +0100 Subject: [PATCH 4/9] revert mathjax script --- common/templates/_footer.html | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/common/templates/_footer.html b/common/templates/_footer.html index fc043465..bef464a1 100644 --- a/common/templates/_footer.html +++ b/common/templates/_footer.html @@ -48,25 +48,3 @@ }, 0); }); - - From acdd0d2894697f194cab5b6ae9a92e1a3f5df996 Mon Sep 17 00:00:00 2001 From: gesang Date: Fri, 7 Mar 2025 01:33:22 +0100 Subject: [PATCH 5/9] fix stupid typos --- .gitignore | 1 + custom/edition.custom.html | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d88d1f18..e14ff683 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.env /neodb.env /typings +/upgrade # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/custom/edition.custom.html b/custom/edition.custom.html index 69ac024b..f288ddc6 100644 --- a/custom/edition.custom.html +++ b/custom/edition.custom.html @@ -153,11 +153,11 @@ Search by ISBN:
Anna's Archive + href="https://annas-archive.org/search?q={{ item.isbn }}">Anna's Archive | Z-Library + href="https://zlib.gs/s/{{ item.isbn }}">Z-Library {% endif %}
From 0d88a77a95603797edb589123ed4656aa2189084 Mon Sep 17 00:00:00 2001 From: gesang Date: Fri, 7 Mar 2025 01:42:50 +0100 Subject: [PATCH 6/9] only let registered user see dufs.itmens link --- custom/edition.custom.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom/edition.custom.html b/custom/edition.custom.html index f288ddc6..729b4464 100644 --- a/custom/edition.custom.html +++ b/custom/edition.custom.html @@ -170,10 +170,13 @@ rel="noopener" href="https://zlib.gs/s/{{ item.display_title }}">Z-Library
+ {% if request.user.is_authenticated %}

+ Registered user only:
dufs.itmens
+ {% endif %} {% endblock %} From decf6338d674d5aee7a6e4a56a24570d1d6dc18d Mon Sep 17 00:00:00 2001 From: gesang Date: Fri, 7 Mar 2025 02:07:32 +0100 Subject: [PATCH 7/9] add libgen+li source to shadow libraries --- custom/edition.custom.html | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/custom/edition.custom.html b/custom/edition.custom.html index 729b4464..fe9a2577 100644 --- a/custom/edition.custom.html +++ b/custom/edition.custom.html @@ -158,6 +158,10 @@ Z-Library + | + Libgen+LI {% endif %}
@@ -169,6 +173,10 @@ Z-Library + | + Libgen+LI
{% if request.user.is_authenticated %}
From ca760052276c03cd505ac9b4f05a12270e67e49a Mon Sep 17 00:00:00 2001 From: gesang Date: Fri, 7 Mar 2025 02:11:21 +0100 Subject: [PATCH 8/9] fix typo --- custom/edition.custom.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/custom/edition.custom.html b/custom/edition.custom.html index fe9a2577..f4c88d4f 100644 --- a/custom/edition.custom.html +++ b/custom/edition.custom.html @@ -157,7 +157,7 @@ | Z-Library + href="https://z-lib.gs/s/{{ item.isbn }}">Z-Library | Z-Library + href="https://z-lib.gs/s/{{ item.display_title }}">Z-Library | Date: Fri, 7 Mar 2025 14:05:56 +0100 Subject: [PATCH 9/9] typo --- custom/edition.custom.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/custom/edition.custom.html b/custom/edition.custom.html index f4c88d4f..073ec366 100644 --- a/custom/edition.custom.html +++ b/custom/edition.custom.html @@ -161,7 +161,7 @@ | Libgen+LI + href="https://libgen.li/index.php?req={{ item.isbn }}">Libgen+LI
{% endif %}