Skip to content

Commit 0e63fe1

Browse files
committed
Create example config
1 parent ca59d86 commit 0e63fe1

File tree

3 files changed

+155
-0
lines changed

3 files changed

+155
-0
lines changed

.sequelizerc.example

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
var path = require('path');
2+
3+
module.exports = {
4+
'config': path.resolve('config.json'),
5+
'migrations-path': path.resolve('lib', 'migrations'),
6+
'models-path': path.resolve('lib', 'models'),
7+
'url': 'change this'
8+
}

config.json.example

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"development": {
3+
"domain": "localhost",
4+
"db": {
5+
"username": "",
6+
"password": "",
7+
"database": "hackmd",
8+
"host": "localhost",
9+
"port": "3306",
10+
"dialect": "mysql"
11+
}
12+
},
13+
"production": {
14+
"domain": "localhost",
15+
"db": {
16+
"username": "",
17+
"password": "",
18+
"database": "hackmd",
19+
"host": "localhost",
20+
"port": "5432",
21+
"dialect": "postgres"
22+
},
23+
"facebook": {
24+
"clientID": "change this",
25+
"clientSecret": "change this"
26+
},
27+
"twitter": {
28+
"consumerKey": "change this",
29+
"consumerSecret": "change this"
30+
},
31+
"github": {
32+
"clientID": "change this",
33+
"clientSecret": "change this"
34+
},
35+
"gitlab": {
36+
"baseURL": "change this",
37+
"clientID": "change this",
38+
"clientSecret": "change this"
39+
},
40+
"dropbox": {
41+
"clientID": "change this",
42+
"clientSecret": "change this"
43+
},
44+
"google": {
45+
"clientID": "change this",
46+
"clientSecret": "change this"
47+
},
48+
"imgur": {
49+
"clientID": "change this"
50+
}
51+
}
52+
}

public/js/common.js.example

+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//common
2+
var domain = ''; // domain name
3+
var urlpath = ''; // sub url path, like: www.example.com/<urlpath>
4+
//settings
5+
var debug = false;
6+
7+
var GOOGLE_API_KEY = '';
8+
var GOOGLE_CLIENT_ID = '';
9+
10+
var DROPBOX_APP_KEY = '';
11+
12+
var port = window.location.port;
13+
var serverurl = window.location.protocol + '//' + (domain ? domain : window.location.hostname) + (port ? ':' + port : '') + (urlpath ? '/' + urlpath : '');
14+
var noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1];
15+
var noteurl = serverurl + '/' + noteid;
16+
17+
var version = '0.4.4';
18+
19+
var checkAuth = false;
20+
var profile = null;
21+
var lastLoginState = getLoginState();
22+
var lastUserId = getUserId();
23+
var loginStateChangeEvent = null;
24+
25+
function resetCheckAuth() {
26+
checkAuth = false;
27+
}
28+
29+
function setLoginState(bool, id) {
30+
Cookies.set('loginstate', bool, {
31+
expires: 365
32+
});
33+
if (id) {
34+
Cookies.set('userid', id, {
35+
expires: 365
36+
});
37+
} else {
38+
Cookies.remove('userid');
39+
}
40+
lastLoginState = bool;
41+
lastUserId = id;
42+
checkLoginStateChanged();
43+
}
44+
45+
function checkLoginStateChanged() {
46+
if (getLoginState() != lastLoginState || getUserId() != lastUserId) {
47+
if(loginStateChangeEvent)
48+
loginStateChangeEvent();
49+
return true;
50+
} else {
51+
return false;
52+
}
53+
}
54+
55+
function getLoginState() {
56+
var state = Cookies.get('loginstate');
57+
return state === "true" || state === true;
58+
}
59+
60+
function getUserId() {
61+
return Cookies.get('userid');
62+
}
63+
64+
function clearLoginState() {
65+
Cookies.remove('loginstate');
66+
}
67+
68+
function checkIfAuth(yesCallback, noCallback) {
69+
var cookieLoginState = getLoginState();
70+
if (checkLoginStateChanged())
71+
checkAuth = false;
72+
if (!checkAuth || typeof cookieLoginState == 'undefined') {
73+
$.get(serverurl + '/me')
74+
.done(function (data) {
75+
if (data && data.status == 'ok') {
76+
profile = data;
77+
yesCallback(profile);
78+
setLoginState(true, data.id);
79+
} else {
80+
noCallback();
81+
setLoginState(false);
82+
}
83+
})
84+
.fail(function () {
85+
noCallback();
86+
})
87+
.always(function () {
88+
checkAuth = true;
89+
});
90+
} else if (cookieLoginState) {
91+
yesCallback(profile);
92+
} else {
93+
noCallback();
94+
}
95+
}

0 commit comments

Comments
 (0)