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
|
||||
|
||||
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"]
|
||||
|
|
|
@ -3,21 +3,28 @@ import re
|
|||
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:
|
||||
|
|
|
@ -33,7 +33,6 @@ loguru
|
|||
lxml
|
||||
markdownify
|
||||
mistune
|
||||
opencc
|
||||
openpyxl
|
||||
podcastparser
|
||||
psycopg2-binary
|
||||
|
|
Loading…
Add table
Reference in a new issue