Closed zgq354 closed 2 years ago
把 /vendor/flarum/emoji/js/dist/forum.js
中的
const y="https://cdn.jsdelivr.net/gh/twitter/twemoji@"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[1]+"/assets/";
替换为:
const y="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twemoji/"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[0]+"/";
但由于这个插件不是本项目控制范围,目前是在安装依赖之后自动化的方式去编辑,需要修改 composer.json,运行一段 post-install 的 shell 命令。
这种方案还需要一段 sed
的命令(参考 这里的 composer.json 配置),预期得花时间处理一堆转义字符的细节问题,我暂时没时间,欢迎贡献(可以直接留言到 issue)😄
Consider using sd, which support String-literal mode eg:
sd -s 'const y="https://cdn.jsdelivr.net/gh/twitter/twemoji@"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[1]+"/assets/";' 'const y="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twemoji/"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[0]+"/";' toReplace.js
or
sd -s 'cdn.jsdelivr.net/gh/twitter/twemoji@' 'lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twemoji' toReplace.js; sd '/assest/' '/' toReplace.js
Which will both get the job done perfectly, without escaping a single character.
Consider using sd, which support String-literal mode eg:
sd -s 'const y="https://cdn.jsdelivr.net/gh/twitter/twemoji@"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[1]+"/assets/";' 'const y="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twemoji/"+/([0-9]+).[0-9]+.[0-9]+/g.exec(h.base)[0]+"/";' toReplace.js
or
sd -s 'cdn.jsdelivr.net/gh/twitter/twemoji@' 'lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/twemoji' toReplace.js; sd '/assest/' '/' toReplace.js
Which will both get the job done perfectly, without escaping a single character.
Great tool, but it is not preinstalled on various Linux distributions, and we just need a pieces of one-time code, additional install this may comes with some cognitive load at Local Development Env (at production env it works well just add one line apk add sd
to the Dockerfile).
So I prefered a "sed escaped string generator" rather than introducing a new tool. I just tried this one and it works fine. 😊
fixed.
一点细节:cdn.bytedance.com 目前 twemoji 最高只支持 13,而最新版插件依赖 14 以上版本,所以先写死用 13 的地址,接下来再考虑优化问题
众所周知原因 cdn.jsdelivr.net 被干,导致大陆 emoji 图裂掉,需要替换成合适的 cdn(推荐字节的)