remove opencc #346
This commit is contained in:
parent
65a2b82383
commit
a761eaca19
3 changed files with 13 additions and 10 deletions
|
@ -4,7 +4,7 @@ ENV PYTHONDONTWRITEBYTECODE=1
|
||||||
ENV PYTHONUNBUFFERED=1
|
ENV PYTHONUNBUFFERED=1
|
||||||
|
|
||||||
RUN --mount=type=cache,sharing=locked,target=/var/cache/apt apt-get update \
|
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/
|
COPY requirements.txt /neodb/
|
||||||
WORKDIR /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 \
|
&& apt-get install -y --no-install-recommends libpq-dev \
|
||||||
busybox \
|
busybox \
|
||||||
nginx \
|
nginx \
|
||||||
gettext-base \
|
gettext-base
|
||||||
opencc
|
|
||||||
RUN busybox --install
|
RUN busybox --install
|
||||||
|
|
||||||
COPY . /neodb
|
COPY . /neodb
|
||||||
|
@ -40,7 +39,6 @@ RUN /neodb-venv/bin/python3 manage.py collectstatic --noinput
|
||||||
RUN mv /neodb/neodb-takahe /takahe
|
RUN mv /neodb/neodb-takahe /takahe
|
||||||
WORKDIR /takahe
|
WORKDIR /takahe
|
||||||
COPY --from=build /takahe-venv /takahe-venv
|
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
|
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
|
WORKDIR /neodb
|
||||||
|
@ -51,5 +49,4 @@ RUN rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
USER app:app
|
USER app:app
|
||||||
|
|
||||||
# invoke check by default
|
|
||||||
CMD [ "neodb-hello"]
|
CMD [ "neodb-hello"]
|
||||||
|
|
|
@ -3,21 +3,28 @@ import re
|
||||||
from django import template
|
from django import template
|
||||||
from django.template.defaultfilters import stringfilter
|
from django.template.defaultfilters import stringfilter
|
||||||
from django.utils.safestring import mark_safe
|
from django.utils.safestring import mark_safe
|
||||||
from opencc import OpenCC
|
|
||||||
|
|
||||||
cc = OpenCC("t2s")
|
|
||||||
register = template.Library()
|
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
|
@register.filter
|
||||||
@stringfilter
|
@stringfilter
|
||||||
def highlight(text, search):
|
def highlight(text, search):
|
||||||
otext = cc.convert(text.lower())
|
otext = _cc(text.lower())
|
||||||
l = len(text)
|
l = len(text)
|
||||||
if l != len(otext):
|
if l != len(otext):
|
||||||
return text # in rare cases, the lowered&converted text has a different length
|
return text # in rare cases, the lowered&converted text has a different length
|
||||||
rtext = ""
|
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)
|
words.sort(key=len, reverse=True)
|
||||||
i = 0
|
i = 0
|
||||||
while i < l:
|
while i < l:
|
||||||
|
|
|
@ -33,7 +33,6 @@ loguru
|
||||||
lxml
|
lxml
|
||||||
markdownify
|
markdownify
|
||||||
mistune
|
mistune
|
||||||
opencc
|
|
||||||
openpyxl
|
openpyxl
|
||||||
podcastparser
|
podcastparser
|
||||||
psycopg2-binary
|
psycopg2-binary
|
||||||
|
|
Loading…
Add table
Reference in a new issue