summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--.eslintrc5
-rw-r--r--.gitignore1
-rw-r--r--README.md16
-rwxr-xr-xbin/heroku2
-rwxr-xr-xbin/setup4
-rw-r--r--config.json.example6
-rw-r--r--lib/config.js4
-rw-r--r--public/js/config.js.example11
-rw-r--r--public/js/cover.js2
-rw-r--r--public/js/extra.js2
-rw-r--r--public/js/history.js8
-rw-r--r--public/js/index.js7
-rw-r--r--public/js/lib/common/login.js (renamed from public/js/common.js)27
-rw-r--r--public/js/lib/config/index.js19
14 files changed, 45 insertions, 69 deletions
diff --git a/.eslintrc b/.eslintrc
index 53a6dcb0..bd14731c 100644
--- a/.eslintrc
+++ b/.eslintrc
@@ -16,7 +16,6 @@
],
"array-callback-return": "error",
"arrow-body-style": "error",
- "arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": "error",
@@ -123,7 +122,7 @@
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-label": "error",
- "no-extra-parens": "error",
+ "no-extra-parens": "warn",
"no-floating-decimal": "error",
"no-global-assign": "error",
"no-implicit-coercion": "error",
@@ -195,7 +194,7 @@
"no-unneeded-ternary": "error",
"no-unsafe-negation": "error",
"no-unused-expressions": "error",
- "no-use-before-define": "error",
+ "no-use-before-define": "warn",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
diff --git a/.gitignore b/.gitignore
index f48b3c6f..ab83c145 100644
--- a/.gitignore
+++ b/.gitignore
@@ -18,7 +18,6 @@ backups/
# ignore config files
config.json
-public/js/config.js
.sequelizerc
# ignore webpack build
diff --git a/README.md b/README.md
index e2ab06a7..3025f84e 100644
--- a/README.md
+++ b/README.md
@@ -97,19 +97,9 @@ Configuration files
There are some configs you need to change in the files below
```
-./config.json --- for server settings
-./public/js/config.js --- for client settings
+./config.json ----application settings
```
-Client settings `config.js`
----
-
-| variables | example values | description |
-| --------- | ------ | ----------- |
-| debug | `true` or `false` | set debug mode, show more logs |
-| domain | `localhost` | domain name |
-| urlpath | `hackmd` | sub url path, like: `www.example.com/<urlpath>` |
-
Environment variables (will overwrite other server configs)
---
@@ -158,7 +148,7 @@ Environment variables (will overwrite other server configs)
| HMD_S3_REGION | `ap-northeast-1` | AWS S3 region |
| HMD_S3_BUCKET | no example | AWS S3 bucket name |
-Server settings `config.json`
+Application settings `config.json`
---
| variables | example values | description |
@@ -207,7 +197,7 @@ Third-party integration api key settings
| ------- | --------- | ----------- |
| facebook, twitter, github, gitlab, dropbox, google, ldap | environment variables or `config.json` | for signin |
| imgur | environment variables or `config.json` | for image upload |
-| google drive, dropbox | `public/js/config.js` | for export and import |
+| google drive(`google/apiKey`, `google/clientID`), dropbox(`dropbox/appKey`) | `config.json` | for export and import |
Third-party integration oauth callback urls
---
diff --git a/bin/heroku b/bin/heroku
index e8010038..1228b283 100755
--- a/bin/heroku
+++ b/bin/heroku
@@ -28,8 +28,6 @@ EOF
EOF
- cp public/js/config.js.example public/js/config.js
-
# build app
npm run build
fi
diff --git a/bin/setup b/bin/setup
index e24d4de7..6724b2d5 100755
--- a/bin/setup
+++ b/bin/setup
@@ -21,10 +21,6 @@ if [ ! -f config.json ]; then
cp config.json.example config.json
fi
-if [ ! -f publis/js/config.js ]; then
- cp public/js/config.js.example public/js/config.js
-fi
-
if [ ! -f .sequelizerc ]; then
cp .sequelizerc.example .sequelizerc
fi
diff --git a/config.json.example b/config.json.example
index 57669cf9..80662b0f 100644
--- a/config.json.example
+++ b/config.json.example
@@ -45,11 +45,13 @@
},
"dropbox": {
"clientID": "change this",
- "clientSecret": "change this"
+ "clientSecret": "change this",
+ "appKey": "change this"
},
"google": {
"clientID": "change this",
- "clientSecret": "change this"
+ "clientSecret": "change this",
+ "apiKey": "change this"
},
"ldap": {
"url": "ldap://change_this",
diff --git a/lib/config.js b/lib/config.js
index f6e7f2c4..84f6b3d7 100644
--- a/lib/config.js
+++ b/lib/config.js
@@ -90,11 +90,11 @@ var gitlab = (process.env.HMD_GITLAB_CLIENTID && process.env.HMD_GITLAB_CLIENTSE
var dropbox = (process.env.HMD_DROPBOX_CLIENTID && process.env.HMD_DROPBOX_CLIENTSECRET) ? {
clientID: process.env.HMD_DROPBOX_CLIENTID,
clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET
-} : config.dropbox || false;
+} : (config.dropbox && config.dropbox.clientID && config.dropbox.clientSecret) || false;
var google = (process.env.HMD_GOOGLE_CLIENTID && process.env.HMD_GOOGLE_CLIENTSECRET) ? {
clientID: process.env.HMD_GOOGLE_CLIENTID,
clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET
-} : config.google || false;
+} : (config.google && config.google.clientID && config.google.clientSecret) || false;
var ldap = config.ldap || (
process.env.HMD_LDAP_URL ||
process.env.HMD_LDAP_BINDDN ||
diff --git a/public/js/config.js.example b/public/js/config.js.example
deleted file mode 100644
index c5de388f..00000000
--- a/public/js/config.js.example
+++ /dev/null
@@ -1,11 +0,0 @@
-module.exports = {
- domain: '', // domain name
- urlpath: '', // sub url path, like: www.example.com/<urlpath>
-
- // settings
- debug: false,
-
- GOOGLE_API_KEY: '',
- GOOGLE_CLIENT_ID: '',
- DROPBOX_APP_KEY: ''
-};
diff --git a/public/js/cover.js b/public/js/cover.js
index 08e0d225..a3ed7784 100644
--- a/public/js/cover.js
+++ b/public/js/cover.js
@@ -9,7 +9,7 @@ import {
getLoginState,
resetCheckAuth,
setloginStateChangeEvent
-} from './common';
+} from './lib/common/login';
import {
clearDuplicatedHistory,
diff --git a/public/js/extra.js b/public/js/extra.js
index 6cfb5b0a..b651d9e6 100644
--- a/public/js/extra.js
+++ b/public/js/extra.js
@@ -11,7 +11,7 @@ import PDFObject from 'pdfobject';
import S from 'string';
import { saveAs } from 'file-saver';
-require('./common');
+require('./lib/common/login');
require('../vendor/md-toc');
var Viz = require("viz.js");
diff --git a/public/js/history.js b/public/js/history.js
index f1201683..34b2cba7 100644
--- a/public/js/history.js
+++ b/public/js/history.js
@@ -1,9 +1,13 @@
import store from 'store';
import S from 'string';
+
+import {
+ checkIfAuth
+} from './lib/common/login';
+
import {
- checkIfAuth,
urlpath
-} from './common';
+} from './lib/config';
window.migrateHistoryFromTempCallback = null;
diff --git a/public/js/index.js b/public/js/index.js
index 946dfc3e..a7e69e81 100644
--- a/public/js/index.js
+++ b/public/js/index.js
@@ -19,7 +19,10 @@ var List = require('list.js');
import {
checkLoginStateChanged,
- setloginStateChangeEvent,
+ setloginStateChangeEvent
+} from './lib/common/login';
+
+import {
debug,
DROPBOX_APP_KEY,
GOOGLE_API_KEY,
@@ -28,7 +31,7 @@ import {
noteurl,
urlpath,
version
-} from './common';
+} from './lib/config';
import {
autoLinkify,
diff --git a/public/js/common.js b/public/js/lib/common/login.js
index 6d54b450..f1a03c72 100644
--- a/public/js/common.js
+++ b/public/js/lib/common/login.js
@@ -1,21 +1,4 @@
-// import config from './config';
-
-import {
- domain, // domain name
- urlpath, // sub url path, like: www.example.com/<urlpath>
- debug,
- GOOGLE_API_KEY,
- GOOGLE_CLIENT_ID,
- DROPBOX_APP_KEY
-} from './config';
-
-//common
-export const port = window.location.port;
-window.serverurl = `${window.location.protocol}//${domain ? domain : window.location.hostname}${port ? ':' + port : ''}${urlpath ? '/' + urlpath : ''}`;
-export const noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1];
-export const noteurl = `${serverurl}/${noteid}`;
-
-export const version = '0.5.0';
+import { serverurl } from '../config';
let checkAuth = false;
let profile = null;
@@ -49,7 +32,7 @@ export function setLoginState(bool, id) {
export function checkLoginStateChanged() {
if (getLoginState() != lastLoginState || getUserId() != lastUserId) {
- if(loginStateChangeEvent) {
+ if (loginStateChangeEvent) {
loginStateChangeEvent();
}
return true;
@@ -101,12 +84,6 @@ export function checkIfAuth(yesCallback, noCallback) {
}
export default {
- domain,
- urlpath,
- debug,
- GOOGLE_API_KEY,
- GOOGLE_CLIENT_ID,
- DROPBOX_APP_KEY,
checkAuth,
profile,
lastLoginState,
diff --git a/public/js/lib/config/index.js b/public/js/lib/config/index.js
new file mode 100644
index 00000000..2b73679f
--- /dev/null
+++ b/public/js/lib/config/index.js
@@ -0,0 +1,19 @@
+import configJson from '../../../../config.json'; // root path json config
+
+const config = 'production' === process.env.NODE_ENV ? configJson.production : configJson.development;
+
+export const GOOGLE_API_KEY = (config.google && config.google.apiKey) || '';
+export const GOOGLE_CLIENT_ID = (config.google && config.google.clientID) || '';
+export const DROPBOX_APP_KEY = (config.dropbox && config.dropbox.appKey) || '';
+
+export const domain = config.domain || ''; // domain name
+export const urlpath = config.urlpath || ''; // sub url path, like: www.example.com/<urlpath>
+export const debug = config.debug || false;
+
+export const port = window.location.port;
+export const serverurl = `${window.location.protocol}//${domain ? domain : window.location.hostname}${port ? ':' + port : ''}${urlpath ? '/' + urlpath : ''}`;
+window.serverurl = serverurl;
+export const noteid = urlpath ? window.location.pathname.slice(urlpath.length + 1, window.location.pathname.length).split('/')[1] : window.location.pathname.split('/')[1];
+export const noteurl = `${serverurl}/${noteid}`;
+
+export const version = '0.5.0';