diff --git a/Dockerfile b/Dockerfile index 8917ffa5..1db9c23d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ENV PYTHONDONTWRITEBYTECODE=1 ENV PYTHONUNBUFFERED=1 RUN --mount=type=cache,sharing=locked,target=/var/cache/apt apt-get update \ - && apt-get install -y --no-install-recommends build-essential libpq-dev python3-venv opencc git + && apt-get install -y --no-install-recommends build-essential libpq-dev python3-venv git COPY requirements.txt /neodb/ WORKDIR /neodb @@ -27,8 +27,7 @@ RUN --mount=type=cache,sharing=locked,target=/var/cache/apt-run apt-get update \ && apt-get install -y --no-install-recommends libpq-dev \ busybox \ nginx \ - gettext-base \ - opencc + gettext-base RUN busybox --install COPY . /neodb @@ -40,7 +39,6 @@ RUN /neodb-venv/bin/python3 manage.py collectstatic --noinput RUN mv /neodb/neodb-takahe /takahe WORKDIR /takahe COPY --from=build /takahe-venv /takahe-venv -RUN pwd && ls RUN TAKAHE_DATABASE_SERVER="postgres://x@y/z" TAKAHE_SECRET_KEY="t" TAKAHE_MAIN_DOMAIN="x.y" /takahe-venv/bin/python3 manage.py collectstatic --noinput WORKDIR /neodb @@ -51,5 +49,4 @@ RUN rm -rf /var/lib/apt/lists/* USER app:app -# invoke check by default CMD [ "neodb-hello"] diff --git a/common/templatetags/highlight.py b/common/templatetags/highlight.py index 48a23c36..45ab84ae 100644 --- a/common/templatetags/highlight.py +++ b/common/templatetags/highlight.py @@ -3,21 +3,28 @@ from django import template from django.template.defaultfilters import stringfilter from django.utils.safestring import mark_safe -from opencc import OpenCC -cc = OpenCC("t2s") register = template.Library() +# opencc is removed for now due to package installation issues +# to re-enable it, add it to Dockerfile/requirements.txt and uncomment the following lines +# from opencc import OpenCC +# cc = OpenCC("t2s") +def _cc(text): + return text + # return cc.convert(text) + + @register.filter @stringfilter def highlight(text, search): - otext = cc.convert(text.lower()) + otext = _cc(text.lower()) l = len(text) if l != len(otext): return text # in rare cases, the lowered&converted text has a different length rtext = "" - words = list(set([w for w in cc.convert(search.strip().lower()).split(" ") if w])) + words = list(set([w for w in _cc(search.strip().lower()).split(" ") if w])) words.sort(key=len, reverse=True) i = 0 while i < l: diff --git a/requirements.txt b/requirements.txt index b093a612..c9dccdf8 100644 --- a/requirements.txt +++ b/requirements.txt @@ -33,7 +33,6 @@ loguru lxml markdownify mistune -opencc openpyxl podcastparser psycopg2-binary