Skip to content

Commit 6c137ae

Browse files
committed
fix: mattermost has been deprecated, use mattermost-redux instead it.
1. change mattermost color and gitlab color to official color 2. Add mattermost icon because Fork-awesome/font-awesome doesn’t provide mattermost icon Signed-off-by: BoHong Li <a60814billy@gmail.com>
1 parent 013ee9a commit 6c137ae

File tree

7 files changed

+242
-104
lines changed

7 files changed

+242
-104
lines changed

lib/models/note.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ var path = require('path')
55
var LZString = require('@hackmd/lz-string')
66
var base64url = require('base64url')
77
var md = require('markdown-it')()
8-
var metaMarked = require('meta-marked')
8+
var metaMarked = require('@hackmd/meta-marked')
99
var cheerio = require('cheerio')
1010
var shortId = require('shortid')
1111
var Sequelize = require('sequelize')

lib/web/auth/mattermost/index.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
'use strict'
2-
2+
require('babel-polyfill')
3+
require('isomorphic-fetch');
34
const Router = require('express').Router
45
const passport = require('passport')
5-
const Mattermost = require('mattermost')
6+
const MattermostClient = require('mattermost-redux/client/client4').default
67
const OAuthStrategy = require('passport-oauth2').Strategy
78
const config = require('../../../config')
89
const { setReturnToFromReferer, passportGeneralCallback } = require('../utils')
910

10-
const mattermost = new Mattermost.Client()
11-
1211
let mattermostAuth = module.exports = Router()
1312

13+
const mattermostClient = new MattermostClient()
14+
1415
let mattermostStrategy = new OAuthStrategy({
1516
authorizationURL: config.mattermost.baseURL + '/oauth/authorize',
1617
tokenURL: config.mattermost.baseURL + '/oauth/access_token',
@@ -20,17 +21,11 @@ let mattermostStrategy = new OAuthStrategy({
2021
}, passportGeneralCallback)
2122

2223
mattermostStrategy.userProfile = (accessToken, done) => {
23-
mattermost.setUrl(config.mattermost.baseURL)
24-
mattermost.token = accessToken
25-
mattermost.useHeaderToken()
26-
mattermost.getMe(
27-
(data) => {
28-
done(null, data)
29-
},
30-
(err) => {
31-
done(err)
32-
}
33-
)
24+
mattermostClient.setUrl(config.mattermost.baseURL)
25+
mattermostClient.setToken(accessToken)
26+
mattermostClient.getMe()
27+
.then((data) => done(null, data))
28+
.catch((err) => done(err))
3429
}
3530

3631
passport.use(mattermostStrategy)

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
"highlight.js": "~9.12.0",
6666
"i18n": "~0.8.3",
6767
"ionicons": "~2.0.1",
68+
"isomorphic-fetch": "^2.2.1",
6869
"jquery": "~3.1.1",
6970
"jquery-mousewheel": "~3.1.13",
7071
"jquery-ui": "~1.12.1",
@@ -89,7 +90,7 @@
8990
"markdown-it-sup": "~1.0.0",
9091
"markdown-pdf": "~9.0.0",
9192
"mathjax": "~2.7.0",
92-
"mattermost": "~3.4.0",
93+
"mattermost-redux": "^5.9.0",
9394
"mermaid": "~7.1.0",
9495
"method-override": "~2.3.7",
9596
"minimist": "~1.2.0",

public/css/cover.css

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,4 +371,42 @@ select {
371371
.ui-use-tags {
372372
max-width: 100%;
373373
}
374-
}
374+
}
375+
376+
.btn-mattermost {
377+
background-color: #2179ec;
378+
border-color: rgba(0,0,0,0.2);
379+
color: #fff;
380+
}
381+
382+
.btn-gitlab {
383+
background-color: #e35431;
384+
border-color: rgba(0,0,0,0.2);
385+
color: #fff;
386+
}
387+
388+
.btn-mattermost:hover, .btn-mattermost:active {
389+
background-color: #105fc6;
390+
border-color: rgba(0,0,0,0.2);
391+
color: #fff;
392+
}
393+
394+
.btn-gitlab:hover, .btn-gitlab:active {
395+
background-color: #c23b1a;
396+
border-color: rgba(0,0,0,0.2);
397+
color: #fff;
398+
}
399+
400+
a.btn.btn-social > i.oauth-icon {
401+
display: inline-flex;
402+
height: 45px;
403+
width: 45px;
404+
line-height: inherit;
405+
padding: 6px;
406+
}
407+
408+
a.btn.btn-social > i.oauth-icon > img {
409+
width: 100%;
410+
height: 100%;
411+
line-height: inherit;
412+
}

public/images/mattermost-logo.svg

Lines changed: 33 additions & 0 deletions
Loading

public/views/shared/signin-modal.ejs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@
2424
</a>
2525
<% } %>
2626
<% if (authProviders.gitlab) { %>
27-
<a href="<%- serverURL %>/auth/gitlab" class="btn btn-lg btn-block btn-social btn-soundcloud">
27+
<a href="<%- serverURL %>/auth/gitlab" class="btn btn-lg btn-block btn-social btn-gitlab">
2828
<i class="fa fa-gitlab"></i> <%= __('Sign in via %s', 'GitLab') %>
2929
</a>
3030
<% } %>
3131
<% if (authProviders.mattermost) { %>
32-
<a href="<%- serverURL %>/auth/mattermost" class="btn btn-lg btn-block btn-social btn-soundcloud">
33-
<i class="fa fa-mattermost"></i> <%= __('Sign in via %s', 'Mattermost') %>
32+
<a href="<%- serverURL %>/auth/mattermost" class="btn btn-lg btn-block btn-social btn-mattermost">
33+
<i class="oauth-icon"><img alt="mattermost-logo" src="<%- serverURL %>/images/mattermost-logo.svg" /></i> <%= __('Sign in via %s', 'Mattermost') %>
3434
</a>
3535
<% } %>
3636
<% if (authProviders.dropbox) { %>

0 commit comments

Comments
 (0)