Missing well-known files
authorRadek Czajka <radekczajka@wolnelektury.pl>
Mon, 23 Nov 2026 13:07:54 +0000 (14:07 +0100)
committerRadek Czajka <radekczajka@wolnelektury.pl>
Mon, 23 Nov 2026 13:07:54 +0000 (14:07 +0100)
Dockerfile
docker-compose.yml
scripts/fold_hunspell.py [deleted file]
scripts/nginx.conf [deleted file]
scripts/nginx/nginx.conf [new file with mode: 0644]
scripts/nginx/well-known/apple-app-site-association [new file with mode: 0644]
scripts/nginx/well-known/assetlinks.json [new file with mode: 0644]
scripts/postgres-polish.sql [deleted file]
scripts/postgres/fold_hunspell.py [new file with mode: 0644]
scripts/postgres/postgres-polish.sql [new file with mode: 0644]

index d9a71d9..1722739 100644 (file)
@@ -111,7 +111,8 @@ FROM nginx:alpine AS nginx
 ARG UID
 ARG GID
 
 ARG UID
 ARG GID
 
-# COPY nginx.conf conf.d/...
+COPY scripts/nginx/nginx.conf /etc/nginx/conf.d/default.conf
+COPY scripts/nginx/well-known /app/.well-known
 
 RUN addgroup -g $GID app && addgroup nginx app
 COPY --from=static-builder /app/var/static /app/var/static
 
 RUN addgroup -g $GID app && addgroup nginx app
 COPY --from=static-builder /app/var/static /app/var/static
@@ -129,7 +130,7 @@ RUN apt-get update \
  && apt-get install -y --no-install-recommends hunspell-pl \
  && rm -rf /var/lib/apt/lists/*
 
  && apt-get install -y --no-install-recommends hunspell-pl \
  && rm -rf /var/lib/apt/lists/*
 
-COPY scripts/fold_hunspell.py /usr/local/bin/fold_hunspell.py
+COPY scripts/postgres/fold_hunspell.py /usr/local/bin/fold_hunspell.py
 
 RUN set -eu; \
     mkdir /out; cd /tmp; \
 
 RUN set -eu; \
     mkdir /out; cd /tmp; \
@@ -152,7 +153,7 @@ COPY --from=polish-dict /out/ /tmp/polish-dict/
 RUN mv /tmp/polish-dict/* "/usr/share/postgresql/$PG_MAJOR/tsearch_data/" \
  && rmdir /tmp/polish-dict
 
 RUN mv /tmp/polish-dict/* "/usr/share/postgresql/$PG_MAJOR/tsearch_data/" \
  && rmdir /tmp/polish-dict
 
-COPY scripts/postgres-polish.sql /docker-entrypoint-initdb.d/10-postgres-polish.sql
+COPY scripts/postgres/postgres-polish.sql /docker-entrypoint-initdb.d/10-postgres-polish.sql
 
 
 ##########
 
 
 ##########
index afa1786..025589f 100644 (file)
@@ -30,7 +30,7 @@ services:
     command: python -Wall ./manage.py runserver 0.0.0.0:8000
     ports:
       # Dev: use http://localhost:8000/ directly
     command: python -Wall ./manage.py runserver 0.0.0.0:8000
     ports:
       # Dev: use http://localhost:8000/ directly
-      - "127.0.0.1:8000:8000"
+      - "8000:8000"
 
   celery:
     <<: *app-base
 
   celery:
     <<: *app-base
@@ -65,7 +65,7 @@ services:
       - "127.0.0.1:8101:80"
     volumes:
       - ./var/media:/app/var/media:ro
       - "127.0.0.1:8101:80"
     volumes:
       - ./var/media:/app/var/media:ro
-      - ./scripts/nginx.conf:/etc/nginx/conf.d/default.conf:ro
+      - ./scripts/nginx/nginx.conf:/etc/nginx/conf.d/default.conf:ro
     depends_on:
       - web
 
     depends_on:
       - web
 
diff --git a/scripts/fold_hunspell.py b/scripts/fold_hunspell.py
deleted file mode 100644 (file)
index bc63e78..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/usr/bin/env python3
-"""
-Tworzy wersję słownika hunspell bez polskich znaków dla PostgreSQL (szablon ispell).
-
-Użycie:
-    fold_hunspell.py polish.dict polish.affix polish_ascii.dict polish_ascii.affix
-
-Pliki wejściowe muszą być w UTF-8 (po iconv z ISO-8859-2).
-
-Samo usunięcie znaków psuje warunki reguł z klasami negowanymi: np.
-`SFX H ć ło [^ąeśź]ć` (wszystko poza ą, e, ś, ź przed ć) po zamianie
-stałoby się `[^aesz]c` i przestało pasować do czasowników na -ać.
-Dlatego litera zostaje w klasie negowanej tylko wtedy, gdy oryginał
-wykluczał wszystkie litery, które się na nią składają; w przeciwnym
-razie jest usuwana, a pusta klasa zamienia się w `.`. Reguły stają się
-przez to nieco zbyt liberalne (nadmiarowe formy), ale żadna forma nie ginie.
-"""
-import re
-import sys
-import unicodedata
-
-
-def fold(text):
-    text = text.replace('ł', 'l').replace('Ł', 'L')
-    return ''.join(
-        c for c in unicodedata.normalize('NFKD', text)
-        if not unicodedata.combining(c)
-    )
-
-
-LETTERS = 'aąbcćdeęfghijklłmnńoóprsśtuvwxyzźż'
-GROUPS = {}
-for letter in LETTERS:
-    GROUPS.setdefault(fold(letter), set()).add(letter)
-
-
-def fold_negated_class(match):
-    excluded = set(match.group(1))
-    keep = []
-    for c in match.group(1):
-        folded = fold(c)
-        if GROUPS.get(folded, {c}) <= excluded and folded not in keep:
-            keep.append(folded)
-    return '[^' + ''.join(keep) + ']' if keep else '.'
-
-
-def fold_affix_line(line):
-    parts = line.split()
-    if len(parts) >= 5 and parts[0] in ('SFX', 'PFX') and '[^' in parts[4]:
-        condition = re.sub(r'\[\^([^\]]*)\]', fold_negated_class, parts[4])
-        line = line.replace(parts[4], condition, 1)
-    if line.startswith('SET '):
-        return 'SET UTF-8\n'
-    return fold(line)
-
-
-def main(dict_in, affix_in, dict_out, affix_out):
-    with open(dict_in, encoding='utf-8') as src, open(dict_out, 'w', encoding='utf-8') as dst:
-        dst.write(fold(src.read()))
-    with open(affix_in, encoding='utf-8') as src, open(affix_out, 'w', encoding='utf-8') as dst:
-        for line in src:
-            dst.write(fold_affix_line(line))
-
-
-if __name__ == '__main__':
-    main(*sys.argv[1:5])
diff --git a/scripts/nginx.conf b/scripts/nginx.conf
deleted file mode 100644 (file)
index 561a5d4..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-server {
-    listen 80;
-
-    access_log off;
-    error_log /dev/stderr warn;
-
-    client_max_body_size 4G;
-    send_timeout 300s;
-    proxy_buffers 16 16k;
-    proxy_buffer_size 32k;
-
-    location /static/ {
-        root /app/var;
-        expires 30d;
-    }
-
-    location /media/ {
-        root /app/var;
-        expires 30d;
-    }
-    location ~ ^/media/.*\.(mp3|ogg|daisy\.zip)$ {
-        add_header Content-Disposition "attachment";
-    }
-    location ~ ^/media/.*\.txt$ {
-        add_header Content-Type "text/plain; charset=utf-8";
-    }
-    location ~ ^/media/book/(pdf|epub|mobi|fb2|cover|xml)/ {
-        # kill cache
-        add_header Last-Modified $date_gmt;
-        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
-        if_modified_since off;
-        expires off;
-        etag off;
-    }
-
-    location /api/ {
-        add_header 'Access-Control-Allow-Origin' '*' always;
-        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE' always;
-        add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
-        add_header 'Access-Control-Expose-Headers' 'Link' always;
-
-        if ($request_method = OPTIONS) {
-            return 204;
-        }
-
-        proxy_set_header Accept-Language "";
-        proxy_set_header Host $host;
-        proxy_pass http://web:8000;
-    }
-    location / {
-       root /app/var/static/root;
-       try_files $uri @backend;
-    }
-
-    location @backend {
-        proxy_set_header Accept-Language "";
-        proxy_set_header Host $host;
-        proxy_pass http://web:8000;
-    }
-}
diff --git a/scripts/nginx/nginx.conf b/scripts/nginx/nginx.conf
new file mode 100644 (file)
index 0000000..a34ef55
--- /dev/null
@@ -0,0 +1,62 @@
+server {
+    listen 80;
+
+    access_log off;
+    error_log /dev/stderr warn;
+
+    client_max_body_size 4G;
+    send_timeout 300s;
+    proxy_buffers 16 16k;
+    proxy_buffer_size 32k;
+
+    root /app/var;
+
+    location /.well-known/ {}
+
+    location /static/ {
+        expires 30d;
+    }
+
+    location /media/ {
+        expires 30d;
+    }
+    location ~ ^/media/.*\.(mp3|ogg|daisy\.zip)$ {
+        add_header Content-Disposition "attachment";
+    }
+    location ~ ^/media/.*\.txt$ {
+        charset utf-8;
+    }
+    location ~ ^/media/book/(pdf|epub|mobi|fb2|cover|xml)/ {
+        # kill cache
+        add_header Last-Modified $date_gmt;
+        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
+        if_modified_since off;
+        expires off;
+        etag off;
+    }
+
+    location /api/ {
+        add_header 'Access-Control-Allow-Origin' '*' always;
+        add_header 'Access-Control-Allow-Methods' 'GET, POST, PUT, DELETE' always;
+        add_header 'Access-Control-Allow-Headers' 'Authorization, Content-Type' always;
+        add_header 'Access-Control-Expose-Headers' 'Link' always;
+
+        if ($request_method = OPTIONS) {
+            return 204;
+        }
+
+        proxy_set_header Accept-Language "";
+        proxy_set_header Host $host;
+        proxy_pass http://web:8000;
+    }
+    location / {
+       root /app/var/static/root;
+       try_files $uri @backend;
+    }
+
+    location @backend {
+        proxy_set_header Accept-Language "";
+        proxy_set_header Host $host;
+        proxy_pass http://web:8000;
+    }
+}
diff --git a/scripts/nginx/well-known/apple-app-site-association b/scripts/nginx/well-known/apple-app-site-association
new file mode 100644 (file)
index 0000000..afeaa3e
--- /dev/null
@@ -0,0 +1,13 @@
+{
+    "applinks": {
+        "apps": [],
+        "details": [
+            {
+                "appID": "WX9PLY5GYU.pl.app.wolnelektury",
+                "paths": [
+                    "/*"
+                ]
+            }
+        ]
+    }
+}
\ No newline at end of file
diff --git a/scripts/nginx/well-known/assetlinks.json b/scripts/nginx/well-known/assetlinks.json
new file mode 100644 (file)
index 0000000..9154b21
--- /dev/null
@@ -0,0 +1,14 @@
+[
+    {
+        "relation": [
+            "delegate_permission/common.handle_all_urls"
+        ],
+        "target": {
+            "namespace": "android_app",
+            "package_name": "pl.app.wolnelektury",
+            "sha256_cert_fingerprints": [
+                "4F:5E:3E:70:18:02:00:AF:7F:91:93:65:DC:55:B1:2D:81:C8:DF:62:9C:22:00:C3:D8:52:33:DF:41:E5:2C:BF"
+            ]
+        }
+    }
+]
diff --git a/scripts/postgres-polish.sql b/scripts/postgres-polish.sql
deleted file mode 100644 (file)
index 100764a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-CREATE EXTENSION IF NOT EXISTS unaccent;
-
-DO $$
-  BEGIN
-  IF NOT EXISTS (SELECT 1 FROM pg_ts_dict
-               WHERE dictname = 'polish_hunspell'
-                 AND dictnamespace = 'public'::regnamespace) THEN
-    CREATE TEXT SEARCH DICTIONARY public.polish_hunspell (
-        TEMPLATE = ispell, DictFile = polish, AffFile = polish
-    );
-  END IF;
-  IF NOT EXISTS (SELECT 1 FROM pg_ts_config
-                      WHERE cfgname = 'polish'
-               AND cfgnamespace = 'public'::regnamespace) THEN
-    CREATE TEXT SEARCH CONFIGURATION public.polish (COPY = pg_catalog.simple);
-  END IF;
-END $$;
-
-ALTER TEXT SEARCH DICTIONARY public.polish_hunspell (
-  DictFile = polish, AffFile = polish, StopWords
-);
-
-ALTER TEXT SEARCH CONFIGURATION public.polish
-  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
-  WITH unaccent, polish_hunspell, simple;
-
-
diff --git a/scripts/postgres/fold_hunspell.py b/scripts/postgres/fold_hunspell.py
new file mode 100644 (file)
index 0000000..bc63e78
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/env python3
+"""
+Tworzy wersję słownika hunspell bez polskich znaków dla PostgreSQL (szablon ispell).
+
+Użycie:
+    fold_hunspell.py polish.dict polish.affix polish_ascii.dict polish_ascii.affix
+
+Pliki wejściowe muszą być w UTF-8 (po iconv z ISO-8859-2).
+
+Samo usunięcie znaków psuje warunki reguł z klasami negowanymi: np.
+`SFX H ć ło [^ąeśź]ć` (wszystko poza ą, e, ś, ź przed ć) po zamianie
+stałoby się `[^aesz]c` i przestało pasować do czasowników na -ać.
+Dlatego litera zostaje w klasie negowanej tylko wtedy, gdy oryginał
+wykluczał wszystkie litery, które się na nią składają; w przeciwnym
+razie jest usuwana, a pusta klasa zamienia się w `.`. Reguły stają się
+przez to nieco zbyt liberalne (nadmiarowe formy), ale żadna forma nie ginie.
+"""
+import re
+import sys
+import unicodedata
+
+
+def fold(text):
+    text = text.replace('ł', 'l').replace('Ł', 'L')
+    return ''.join(
+        c for c in unicodedata.normalize('NFKD', text)
+        if not unicodedata.combining(c)
+    )
+
+
+LETTERS = 'aąbcćdeęfghijklłmnńoóprsśtuvwxyzźż'
+GROUPS = {}
+for letter in LETTERS:
+    GROUPS.setdefault(fold(letter), set()).add(letter)
+
+
+def fold_negated_class(match):
+    excluded = set(match.group(1))
+    keep = []
+    for c in match.group(1):
+        folded = fold(c)
+        if GROUPS.get(folded, {c}) <= excluded and folded not in keep:
+            keep.append(folded)
+    return '[^' + ''.join(keep) + ']' if keep else '.'
+
+
+def fold_affix_line(line):
+    parts = line.split()
+    if len(parts) >= 5 and parts[0] in ('SFX', 'PFX') and '[^' in parts[4]:
+        condition = re.sub(r'\[\^([^\]]*)\]', fold_negated_class, parts[4])
+        line = line.replace(parts[4], condition, 1)
+    if line.startswith('SET '):
+        return 'SET UTF-8\n'
+    return fold(line)
+
+
+def main(dict_in, affix_in, dict_out, affix_out):
+    with open(dict_in, encoding='utf-8') as src, open(dict_out, 'w', encoding='utf-8') as dst:
+        dst.write(fold(src.read()))
+    with open(affix_in, encoding='utf-8') as src, open(affix_out, 'w', encoding='utf-8') as dst:
+        for line in src:
+            dst.write(fold_affix_line(line))
+
+
+if __name__ == '__main__':
+    main(*sys.argv[1:5])
diff --git a/scripts/postgres/postgres-polish.sql b/scripts/postgres/postgres-polish.sql
new file mode 100644 (file)
index 0000000..100764a
--- /dev/null
@@ -0,0 +1,27 @@
+CREATE EXTENSION IF NOT EXISTS unaccent;
+
+DO $$
+  BEGIN
+  IF NOT EXISTS (SELECT 1 FROM pg_ts_dict
+               WHERE dictname = 'polish_hunspell'
+                 AND dictnamespace = 'public'::regnamespace) THEN
+    CREATE TEXT SEARCH DICTIONARY public.polish_hunspell (
+        TEMPLATE = ispell, DictFile = polish, AffFile = polish
+    );
+  END IF;
+  IF NOT EXISTS (SELECT 1 FROM pg_ts_config
+                      WHERE cfgname = 'polish'
+               AND cfgnamespace = 'public'::regnamespace) THEN
+    CREATE TEXT SEARCH CONFIGURATION public.polish (COPY = pg_catalog.simple);
+  END IF;
+END $$;
+
+ALTER TEXT SEARCH DICTIONARY public.polish_hunspell (
+  DictFile = polish, AffFile = polish, StopWords
+);
+
+ALTER TEXT SEARCH CONFIGURATION public.polish
+  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
+  WITH unaccent, polish_hunspell, simple;
+
+