Follow

Mastodon 要设置 elastic search 中文优化是不是必须修改源文件?

如果是 docker 部署的是不是自己维护一个镜像比较方便?

:tmks047: 可以直接本地修改下镜像,感觉小改动另外开一个 git 还是挺麻烦的 ... 

@zeka
> Dockerfile

FROM tootsuite/mastodon:v3.4.1

# Elasticsearch 分词优化
COPY --chown=991:991 ./chewy /opt/mastodon/app/chewy

RUN echo "修改字数上限" \
&& sed -i "s|MAX_CHARS = 500|MAX_CHARS = 20000|" /opt/mastodon/app/validators/status_length_validator.rb \
&& sed -i "s|length(fulltext) > 500|length(fulltext) > 20000|" /opt/mastodon/app/javascript/mastodon/features/compose/components/compose_form.js \
&& sed -i "s|CharacterCounter max={500}|CharacterCounter max={20000}|" /opt/mastodon/app/javascript/mastodon/features/compose/components/compose_form.js \
&& echo "修改媒体上限" \
&& sed -i "s|MAX_IMAGE_PIXELS = 2073600|MAX_IMAGE_PIXELS = 9999999|" /opt/mastodon/app/javascript/mastodon/utils/resize_image.js \
&& sed -i "s|pixels: 2_073_600|pixels: 9_999_999|" /opt/mastodon/app/models/media_attachment.rb \
&& sed -i "s|IMAGE_LIMIT = 10|IMAGE_LIMIT = 80|" /opt/mastodon/app/models/media_attachment.rb \
&& sed -i "s|VIDEO_LIMIT = 40|VIDEO_LIMIT = 100|" /opt/mastodon/app/models/media_attachment.rb \
&& echo "修改投票上限" \
&& sed -i "s|options.size >= 4|options.size >= 16|" /opt/mastodon/app/javascript/mastodon/features/compose/components/poll_form.js \
&& sed -i "s|MAX_OPTIONS = 4|MAX_OPTIONS = 16|" /opt/mastodon/app/validators/poll_validator.rb \
&& echo "修改客户端接口" \
&& sed -i "s|:settings|:settings, :max_toot_chars|" /opt/mastodon/app/serializers/initial_state_serializer.rb \
&& sed -i "s|private|def max_toot_chars\n StatusLengthValidator::MAX_CHARS\n end\n\n private|" /opt/mastodon/app/serializers/initial_state_serializer.rb \
&& sed -i "s|:invites_enabled|:invites_enabled, :max_toot_chars|" /opt/mastodon/app/serializers/rest/instance_serializer.rb \
&& sed -i "s|private|def max_toot_chars\n StatusLengthValidator::MAX_CHARS\n end\n\n private|" /opt/mastodon/app/serializers/rest/instance_serializer.rb \
&& echo "重新编译资源文件" \
&& OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder rails assets:precompile \
&& yarn cache clean

@[email protected] 我就因为改了中文优化和站点图标新开了一个 git repo 和 docker hub repo (逃x

@Candinya 哈哈,最近也在考虑,因为要加功能还是自己 fork 一份方便

@zeka 我是自己另外建仓库维护的。mastodon中es的index设置是用代码来同步的,这是一个好设计,不然es实例关闭或者迁移那些index设置就丢失了

Sign in to participate in the conversation
Zeka和它的Kemomimi

Some personal instance.