Skip to content

Commit 6dfc186

Browse files
authored
Merge pull request #326 from hackmdio/es6-integration
ES6 integration
2 parents fc00fa7 + 0e47911 commit 6dfc186

21 files changed

Lines changed: 871 additions & 940 deletions

.babelrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"presets": [
3+
"es2015"
4+
],
5+
"plugins": [
6+
"transform-runtime"
7+
]
8+
}

.eslintrc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
],
1717
"array-callback-return": "error",
1818
"arrow-body-style": "error",
19-
"arrow-parens": "error",
2019
"arrow-spacing": "error",
2120
"block-scoped-var": "off",
2221
"block-spacing": "error",
@@ -123,7 +122,7 @@
123122
"no-extend-native": "error",
124123
"no-extra-bind": "error",
125124
"no-extra-label": "error",
126-
"no-extra-parens": "error",
125+
"no-extra-parens": "warn",
127126
"no-floating-decimal": "error",
128127
"no-global-assign": "error",
129128
"no-implicit-coercion": "error",
@@ -195,7 +194,7 @@
195194
"no-unneeded-ternary": "error",
196195
"no-unsafe-negation": "error",
197196
"no-unused-expressions": "error",
198-
"no-use-before-define": "error",
197+
"no-use-before-define": "warn",
199198
"no-useless-call": "error",
200199
"no-useless-computed-key": "error",
201200
"no-useless-concat": "error",

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ backups/
1818

1919
# ignore config files
2020
config.json
21-
public/js/config.js
2221
.sequelizerc
2322

2423
# ignore webpack build

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Get started
5959
2. Enter the directory and type `bin/setup`, which will install npm dependencies and create configs. The setup script is written in Bash, you would need bash as a prerequisite.
6060
3. Setup the configs, see more below
6161
4. Setup environment variables which will overwrite the configs
62-
5. Build front-end bundle by `npm run build:prod` (use `npm run build:dev` if you are in development)
62+
5. Build front-end bundle by `npm run build` (use `npm run dev` if you are in development)
6363
6. Run the server as you like (node, forever, pm2)
6464

6565
Upgrade guide
@@ -70,7 +70,7 @@ If you are upgrading HackMD from an older version, follow these steps:
7070
1. Fully stop your old server first (important)
7171
2. `git pull` or do whatever that updates the files
7272
3. `npm install` to update dependencies
73-
4. Build front-end bundle by `npm run build:prod` (use `npm run build:dev` if you are in development)
73+
4. Build front-end bundle by `npm run build` (use `npm run dev` if you are in development)
7474
5. Modify the file named `.sequelizerc`, change the value of the variable `url` with your db connection string
7575
For example: `postgres://username:password@localhost:5432/hackmd`
7676
6. Run `node_modules/.bin/sequelize db:migrate`, this step will migrate your db to the latest schema
@@ -97,19 +97,9 @@ Configuration files
9797
There are some configs you need to change in the files below
9898

9999
```
100-
./config.json --- for server settings
101-
./public/js/config.js --- for client settings
100+
./config.json ----application settings
102101
```
103102

104-
Client settings `config.js`
105-
---
106-
107-
| variables | example values | description |
108-
| --------- | ------ | ----------- |
109-
| debug | `true` or `false` | set debug mode, show more logs |
110-
| domain | `localhost` | domain name |
111-
| urlpath | `hackmd` | sub url path, like: `www.example.com/<urlpath>` |
112-
113103
Environment variables (will overwrite other server configs)
114104
---
115105

@@ -158,7 +148,7 @@ Environment variables (will overwrite other server configs)
158148
| HMD_S3_REGION | `ap-northeast-1` | AWS S3 region |
159149
| HMD_S3_BUCKET | no example | AWS S3 bucket name |
160150

161-
Server settings `config.json`
151+
Application settings `config.json`
162152
---
163153

164154
| variables | example values | description |
@@ -207,7 +197,7 @@ Third-party integration api key settings
207197
| ------- | --------- | ----------- |
208198
| facebook, twitter, github, gitlab, dropbox, google, ldap | environment variables or `config.json` | for signin |
209199
| imgur | environment variables or `config.json` | for image upload |
210-
| google drive, dropbox | `public/js/config.js` | for export and import |
200+
| google drive(`google/apiKey`, `google/clientID`), dropbox(`dropbox/appKey`) | `config.json` | for export and import |
211201

212202
Third-party integration oauth callback urls
213203
---

bin/heroku

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ EOF
2828
2929
EOF
3030

31-
cp public/js/config.js.example public/js/config.js
32-
3331
# build app
34-
npm run build:prod
32+
npm run build
3533
fi

bin/setup

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ if [ ! -f config.json ]; then
2121
cp config.json.example config.json
2222
fi
2323

24-
if [ ! -f publis/js/config.js ]; then
25-
cp public/js/config.js.example public/js/config.js
26-
fi
27-
2824
if [ ! -f .sequelizerc ]; then
2925
cp .sequelizerc.example .sequelizerc
3026
fi

config.json.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,13 @@
4545
},
4646
"dropbox": {
4747
"clientID": "change this",
48-
"clientSecret": "change this"
48+
"clientSecret": "change this",
49+
"appKey": "change this"
4950
},
5051
"google": {
5152
"clientID": "change this",
52-
"clientSecret": "change this"
53+
"clientSecret": "change this",
54+
"apiKey": "change this"
5355
},
5456
"ldap": {
5557
"url": "ldap://change_this",

lib/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,11 @@ var gitlab = (process.env.HMD_GITLAB_CLIENTID && process.env.HMD_GITLAB_CLIENTSE
9090
var dropbox = (process.env.HMD_DROPBOX_CLIENTID && process.env.HMD_DROPBOX_CLIENTSECRET) ? {
9191
clientID: process.env.HMD_DROPBOX_CLIENTID,
9292
clientSecret: process.env.HMD_DROPBOX_CLIENTSECRET
93-
} : config.dropbox || false;
93+
} : (config.dropbox && config.dropbox.clientID && config.dropbox.clientSecret && config.dropbox) || false;
9494
var google = (process.env.HMD_GOOGLE_CLIENTID && process.env.HMD_GOOGLE_CLIENTSECRET) ? {
9595
clientID: process.env.HMD_GOOGLE_CLIENTID,
9696
clientSecret: process.env.HMD_GOOGLE_CLIENTSECRET
97-
} : config.google || false;
97+
} : (config.google && config.google.clientID && config.google.clientSecret && config.google) || false;
9898
var ldap = config.ldap || (
9999
process.env.HMD_LDAP_URL ||
100100
process.env.HMD_LDAP_BINDDN ||

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"main": "app.js",
66
"license": "MIT",
77
"scripts": {
8-
"build:dev": "webpack --config webpack.config.js --progress --colors --watch",
9-
"build:prod": "webpack --config webpack.production.js --progress --colors",
8+
"dev": "webpack --config webpack.config.js --progress --colors --watch",
9+
"build": "webpack --config webpack.production.js --progress --colors",
1010
"postinstall": "bin/heroku",
1111
"start": "node app.js"
1212
},
@@ -140,6 +140,12 @@
140140
"url": "https://github.com/hackmdio/hackmd.git"
141141
},
142142
"devDependencies": {
143+
"babel-cli": "^6.18.0",
144+
"babel-core": "^6.21.0",
145+
"babel-loader": "^6.2.10",
146+
"babel-plugin-transform-runtime": "^6.15.0",
147+
"babel-preset-es2015": "^6.18.0",
148+
"babel-runtime": "^6.20.0",
143149
"copy-webpack-plugin": "^4.0.1",
144150
"css-loader": "^0.26.1",
145151
"ejs-loader": "^0.3.0",

public/js/common.js

Lines changed: 0 additions & 118 deletions
This file was deleted.

0 commit comments

Comments
 (0)