diff --git a/Dockerfile b/Dockerfile index e45f5188..1a701d00 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM benweet/stackedit-base +FROM node:11.15.0 RUN mkdir -p /opt/stackedit WORKDIR /opt/stackedit diff --git a/README.md b/README.md index 1c650418..2dc20cc3 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,22 @@ # StackEdit +从 [StackEdit 官方](https://github.com/benweet/stackedit) fork出来,然后加上了 **Gitee** 的支持,并且已经重新打了镜像,以下官方的部署方式,除了Docker镜像地址不同,其他均一致。 + +Fork出来修改的原因:Stackedit的作者可能因为什么原因,已经很久不维护了,Github授权登录很早之前就登录不了了,并且还没发支持国内常用的Gitee,比较蛋疼,所以想到Fork出来改,大概花了周末一整天终于改好了。 + +新的Docker镜像在中央仓库为:mafgwo/stackedit,当前最新版本为:5.15.1(延续原有版本号) + +并增加了以下三个环境变量: +- `GITEE_CLIENT_ID` Gitee 的 Client ID +- `GITEE_CLIENT_SECRET` Gitee 的 Client Secret +- `GITEE_CALLBACK` Gitee的回调地址,Gitee授权获取token时还需要传入回调地址,格式是 http[s]://[hostname]:[port]/oauth2/callback + + [![Build Status](https://img.shields.io/travis/benweet/stackedit.svg?style=flat)](https://travis-ci.org/benweet/stackedit) [![NPM version](https://img.shields.io/npm/v/stackedit.svg?style=flat)](https://www.npmjs.org/package/stackedit) > Full-featured, open-source Markdown editor based on PageDown, the Markdown library used by Stack Overflow and the other Stack Exchange sites. -https://stackedit.io/ +https://edit.qicoder.com/ ### Ecosystem diff --git a/chart/values.yaml b/chart/values.yaml index 653a6a4e..3fddafb8 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -8,6 +8,8 @@ googleClientId: "" googleApiKey: "" githubClientId: "" githubClientSecret: "" +giteeClientId: "" +giteeClientSecret: "" wordpressClientId: "" wordpressSecret: "" paypalReceiverEmail: "" diff --git a/chrome-app/manifest.json b/chrome-app/manifest.json index 4c700d40..cc047edb 100644 --- a/chrome-app/manifest.json +++ b/chrome-app/manifest.json @@ -15,10 +15,10 @@ }, "app": { "urls": [ - "https://stackedit.io/" + "https://edit.qicoder.com/" ], "launch": { - "web_url": "https://stackedit.io/app" + "web_url": "https://edit.qicoder.com/app" } }, "offline_enabled": true, diff --git a/config/dev.env.js b/config/dev.env.js index efead7c8..ff2021b2 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -3,4 +3,4 @@ var prodEnv = require('./prod.env') module.exports = merge(prodEnv, { NODE_ENV: '"development"' -}) +}) \ No newline at end of file diff --git a/config/index.js b/config/index.js index 9fecd843..83533712 100644 --- a/config/index.js +++ b/config/index.js @@ -23,7 +23,7 @@ module.exports = { }, dev: { env: require('./dev.env'), - port: 8080, + port: 80, autoOpenBrowser: false, assetsSubDirectory: 'static', assetsPublicPath: '/', diff --git a/index.html b/index.html index 2fbca80a..890a9459 100644 --- a/index.html +++ b/index.html @@ -3,15 +3,26 @@ StackEdit - + +
+ diff --git a/package.json b/package.json index 8d822a96..c0517642 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { "name": "stackedit", - "version": "5.14.10", + "version": "5.15.1", "description": "Free, open-source, full-featured Markdown editor", "author": "Benoit Schweblin", "license": "Apache-2.0", "bugs": { - "url": "https://github.com/benweet/stackedit/issues" + "url": "https://github.com/mafgwo/stackedit/issues" }, "main": "index.js", "scripts": { diff --git a/server/conf.js b/server/conf.js index 7aa256a3..e71d6dd8 100644 --- a/server/conf.js +++ b/server/conf.js @@ -8,6 +8,9 @@ const dropboxAppKey = process.env.DROPBOX_APP_KEY; const dropboxAppKeyFull = process.env.DROPBOX_APP_KEY_FULL; const githubClientId = process.env.GITHUB_CLIENT_ID; const githubClientSecret = process.env.GITHUB_CLIENT_SECRET; +const giteeClientId = process.env.GITEE_CLIENT_ID; +const giteeClientSecret = process.env.GITEE_CLIENT_SECRET; +const giteeCallback = process.env.GITEE_CALLBACK; const googleClientId = process.env.GOOGLE_CLIENT_ID; const googleApiKey = process.env.GOOGLE_API_KEY; const wordpressClientId = process.env.WORDPRESS_CLIENT_ID; @@ -22,6 +25,9 @@ exports.values = { dropboxAppKeyFull, githubClientId, githubClientSecret, + giteeClientId, + giteeClientSecret, + giteeCallback, googleClientId, googleApiKey, wordpressClientId, @@ -31,6 +37,7 @@ exports.publicValues = { dropboxAppKey, dropboxAppKeyFull, githubClientId, + giteeClientId, googleClientId, googleApiKey, wordpressClientId, diff --git a/server/gitee.js b/server/gitee.js new file mode 100644 index 00000000..9ac6eb5f --- /dev/null +++ b/server/gitee.js @@ -0,0 +1,45 @@ +const qs = require('qs'); // eslint-disable-line import/no-extraneous-dependencies +const request = require('request'); +const conf = require('./conf'); + +function giteeToken(clientId, code) { + console.log('clientId: ' + clientId); + console.log('code: ' + code); + console.log('client_secret: ' + conf.values.giteeClientSecret); + console.log('redirect_uri: ' + conf.values.giteeCallback); + return new Promise((resolve, reject) => { + request({ + method: 'POST', + url: 'https://gitee.com/oauth/token', + form: { + client_id: clientId, + client_secret: conf.values.giteeClientSecret, + code, + grant_type: 'authorization_code', + scope: 'authorization_code', + redirect_uri: conf.values.giteeCallback, + }, + json: true + }, (err, res, body) => { + if (err) { + reject(err); + } + const token = body.access_token; + if (token) { + resolve(token); + } else { + reject(res.statusCode + ',body:' + JSON.stringify(body)); + } + }); + }); +} + +exports.giteeToken = (req, res) => { + giteeToken(req.query.clientId, req.query.code) + .then( + token => res.send(token), + err => res + .status(400) + .send(err ? err.message || err.toString() : 'bad_code'), + ); +}; diff --git a/server/index.js b/server/index.js index 8691e14e..2bfb0e45 100644 --- a/server/index.js +++ b/server/index.js @@ -4,6 +4,7 @@ const bodyParser = require('body-parser'); const path = require('path'); const user = require('./user'); const github = require('./github'); +const gitee = require('./gitee'); const pdf = require('./pdf'); const pandoc = require('./pandoc'); const conf = require('./conf'); @@ -25,6 +26,7 @@ module.exports = (app) => { } app.get('/oauth2/githubToken', github.githubToken); + app.get('/oauth2/giteeToken', gitee.giteeToken); app.get('/conf', (req, res) => res.send(conf.publicValues)); app.get('/userInfo', user.userInfo); app.post('/pdfExport', pdf.generate); @@ -37,6 +39,8 @@ module.exports = (app) => { app.get('/', (req, res) => res.sendFile(resolvePath('static/landing/index.html'))); // Serve sitemap.xml app.get('/sitemap.xml', (req, res) => res.sendFile(resolvePath('static/sitemap.xml'))); + // Serve google-api.js + app.get('/google-api.js', (req, res) => res.sendFile(resolvePath('static/google-api.js'))); // Serve callback.html app.get('/oauth2/callback', (req, res) => res.sendFile(resolvePath('static/oauth2/callback.html'))); // Google Drive action receiver diff --git a/src/assets/iconGitee.svg b/src/assets/iconGitee.svg new file mode 100644 index 00000000..816bb791 --- /dev/null +++ b/src/assets/iconGitee.svg @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/components/Modal.vue b/src/components/Modal.vue index 79ce9b4a..6e6babca 100644 --- a/src/components/Modal.vue +++ b/src/components/Modal.vue @@ -1,7 +1,7 @@