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
&& 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 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
##########
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
- "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
+++ /dev/null
-#!/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])
+++ /dev/null
-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;
- }
-}
--- /dev/null
+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;
+ }
+}
--- /dev/null
+{
+ "applinks": {
+ "apps": [],
+ "details": [
+ {
+ "appID": "WX9PLY5GYU.pl.app.wolnelektury",
+ "paths": [
+ "/*"
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
--- /dev/null
+[
+ {
+ "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"
+ ]
+ }
+ }
+]
+++ /dev/null
-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;
-
-
--- /dev/null
+#!/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])
--- /dev/null
+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;
+
+