From 17712891886bd904848cd3d895480595f67c4e4c Mon Sep 17 00:00:00 2001 From: Nicolas Giard Date: Fri, 18 Jan 2019 15:58:39 -0500 Subject: [PATCH] feat: twemoji + headers fix --- client/themes/default/scss/app.scss | 39 ++++++++++++++----- dev/build/Dockerfile | 22 +++++------ dev/build/supervisord.conf | 23 ----------- package.json | 1 + .../modules/rendering/html-core/renderer.js | 2 +- .../rendering/html-twemoji/definition.yml | 8 ++++ .../rendering/html-twemoji/renderer.js | 9 +++++ .../rendering/markdown-emoji/renderer.js | 5 +++ 8 files changed, 65 insertions(+), 44 deletions(-) delete mode 100644 dev/build/supervisord.conf create mode 100644 server/modules/rendering/html-twemoji/definition.yml create mode 100644 server/modules/rendering/html-twemoji/renderer.js diff --git a/client/themes/default/scss/app.scss b/client/themes/default/scss/app.scss index 05133214..be51c6df 100644 --- a/client/themes/default/scss/app.scss +++ b/client/themes/default/scss/app.scss @@ -69,6 +69,7 @@ padding: 8px 0 0 0; color: mc('grey', '800'); position: relative; + margin-top: 1rem; @at-root .theme--dark & { color: mc('grey', '500'); @@ -134,6 +135,11 @@ } } + .emoji { + height: 1.25em; + margin: 0 1px -4px; + } + blockquote { padding: 0 0 1rem 0; border: 1px solid mc('blue', '500'); @@ -214,6 +220,30 @@ } } + // --------------------------------- + // LISTS + // --------------------------------- + + ol, ul { + padding: 1rem 24px 0 24px; + list-style-position: inside; + + li + li { + margin-top: .5rem; + } + } + + ul { + list-style: none; + + > li::before { + content: '\25b8'; + color: mc('grey', '600'); + display: inline-block; + width: 1.35rem; + } + } + // --------------------------------- // CODE // --------------------------------- @@ -232,15 +262,6 @@ } } - ol, ul { - padding: 1rem 24px 0 24px; - list-style-position: inside; - - li + li { - margin-top: .5rem; - } - } - .prismjs{ border: none; border-radius: 5px; diff --git a/dev/build/Dockerfile b/dev/build/Dockerfile index 37c58cee..32a7ba40 100644 --- a/dev/build/Dockerfile +++ b/dev/build/Dockerfile @@ -1,14 +1,14 @@ # ==================== # --- Build Assets --- # ==================== -FROM node:10.14-alpine AS assets +FROM node:10.15-alpine AS assets RUN apk update && \ apk add yarn g++ make python --no-cache && \ rm -rf /var/cache/apk/* && \ - mkdir -p /var/wiki + mkdir -p /wiki -WORKDIR /var/wiki +WORKDIR /wiki COPY ./client ./client COPY ./dev ./dev @@ -19,28 +19,28 @@ COPY ./.eslintrc.yml ./.eslintrc.yml RUN yarn --cache-folder /codefresh/volume/yarn RUN yarn build -RUN rm -rf /var/wiki/node_modules +RUN rm -rf /wiki/node_modules RUN yarn --production # =============== # --- Release --- # =============== -FROM node:10.14-alpine +FROM node:10.15-alpine LABEL maintainer="requarks.io" RUN apk update && \ apk add bash curl git openssh supervisor --no-cache && \ rm -rf /var/cache/apk/* && \ - mkdir -p /var/wiki && \ + mkdir -p /wiki && \ mkdir -p /logs -WORKDIR /var/wiki +WORKDIR /wiki COPY ./dev/build/supervisord.conf /etc/supervisord.conf -COPY --from=assets /var/wiki/assets ./assets -COPY --from=assets /var/wiki/node_modules ./node_modules +COPY --from=assets /wiki/assets ./assets +COPY --from=assets /wiki/node_modules ./node_modules COPY ./server ./server -COPY --from=assets /var/wiki/server/views ./server/views +COPY --from=assets /wiki/server/views ./server/views COPY ./dev/build/config.yml ./config.yml COPY ./dev/docker/wait.sh ./wait.sh COPY ./package.json ./package.json @@ -48,4 +48,4 @@ COPY ./LICENSE ./LICENSE EXPOSE 3000 -CMD ["supervisord", "--nodaemon", "-c", "/etc/supervisord.conf"] +CMD ["node", "server"] diff --git a/dev/build/supervisord.conf b/dev/build/supervisord.conf deleted file mode 100644 index 7ff97ef4..00000000 --- a/dev/build/supervisord.conf +++ /dev/null @@ -1,23 +0,0 @@ -[unix_http_server] -file=/var/run/supervisor.sock -chmod=0700 - -[supervisord] -logfile=/logs/supervisord.log -pidfile=/var/run/supervisord.pid -childlogdir=/logs - -[rpcinterface:supervisor] -supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface - -[supervisorctl] -serverurl=unix:///var/run/supervisor.sock - -[program:wikijs] -command = node server -autostart=true -autorestart=true -priority=5 -directory=/var/wiki -stdout_logfile=/logs/wiki-stdout.log -stderr_logfile=/logs/wiki-stderr.log diff --git a/package.json b/package.json index 3b99116a..feb7acd1 100644 --- a/package.json +++ b/package.json @@ -155,6 +155,7 @@ "serve-favicon": "2.5.0", "sqlite3": "4.0.4", "subscriptions-transport-ws": "0.9.15", + "twemoji": "11.2.0", "uslug": "1.0.4", "uuid": "3.3.2", "validate.js": "0.12.0", diff --git a/server/modules/rendering/html-core/renderer.js b/server/modules/rendering/html-core/renderer.js index 8bfad0d0..becdabf1 100644 --- a/server/modules/rendering/html-core/renderer.js +++ b/server/modules/rendering/html-core/renderer.js @@ -14,6 +14,6 @@ module.exports = { renderer.init($, child.config) } - return $.html() + return $.html('body').replace('', '').replace('', '') } } diff --git a/server/modules/rendering/html-twemoji/definition.yml b/server/modules/rendering/html-twemoji/definition.yml new file mode 100644 index 00000000..69d3fc10 --- /dev/null +++ b/server/modules/rendering/html-twemoji/definition.yml @@ -0,0 +1,8 @@ +key: htmlTwemoji +title: Twemoji +description: Apply Twitter Emojis to all Unicode emojis +author: requarks.io +icon: whatshot +enabledDefault: true +dependsOn: htmlCore +props: {} diff --git a/server/modules/rendering/html-twemoji/renderer.js b/server/modules/rendering/html-twemoji/renderer.js new file mode 100644 index 00000000..94884009 --- /dev/null +++ b/server/modules/rendering/html-twemoji/renderer.js @@ -0,0 +1,9 @@ +// ------------------------------------ +// HTML - Twemoji +// ------------------------------------ + +module.exports = { + init ($, conf) { + + } +} diff --git a/server/modules/rendering/markdown-emoji/renderer.js b/server/modules/rendering/markdown-emoji/renderer.js index fa256682..f1971767 100644 --- a/server/modules/rendering/markdown-emoji/renderer.js +++ b/server/modules/rendering/markdown-emoji/renderer.js @@ -1,4 +1,5 @@ const mdEmoji = require('markdown-it-emoji') +const twemoji = require('twemoji') // ------------------------------------ // Markdown - Emoji @@ -7,5 +8,9 @@ const mdEmoji = require('markdown-it-emoji') module.exports = { init (md, conf) { md.use(mdEmoji) + + md.renderer.rules.emoji = (token, idx) => { + return twemoji.parse(token[idx].content) + } } }