Skip to content

Commit fe945ca

Browse files
committed
Initial commit
0 parents  commit fe945ca

File tree

9 files changed

+1720
-0
lines changed

9 files changed

+1720
-0
lines changed

.editorconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
root = true
2+
3+
[*]
4+
indent_style = tab
5+
indent_size = 2
6+
trim_trailing_whitespace = true
7+
insert_final_newline = true
8+
9+
[{.travis.yml,npm-shrinkwrap.json,package.json}]
10+
indent_style = space
11+
indent_size = 2

.gitignore

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
6+
# Runtime data
7+
pids
8+
*.pid
9+
*.seed
10+
*.pid.lock
11+
12+
# Directory for instrumented libs generated by jscoverage/JSCover
13+
lib-cov
14+
15+
# Coverage directory used by tools like istanbul
16+
coverage
17+
18+
# nyc test coverage
19+
.nyc_output
20+
21+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
22+
.grunt
23+
24+
# node-waf configuration
25+
.lock-wscript
26+
27+
# Compiled binary addons (http://nodejs.org/api/addons.html)
28+
build/Release
29+
30+
# Dependency directories
31+
node_modules
32+
jspm_packages
33+
34+
# Optional npm cache directory
35+
.npm
36+
37+
# Optional eslint cache
38+
.eslintcache
39+
40+
# Optional REPL history
41+
.node_repl_history
42+
43+
# Output of 'npm pack'
44+
*.tgz
45+
46+
# Yarn Integrity file
47+
.yarn-integrity
48+
49+
dist

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# HackMD Desktop Client
2+
3+
## Tools
4+
5+
- electron
6+
7+
## Development
8+
9+
```bash
10+
npm install -g yarn
11+
yarn
12+
13+
npm run dev # if you've started HackMD in localhost:3000
14+
npm run start # load https://hackmd.io
15+
```

build/.gitkeep

Whitespace-only changes.

main.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { app, BrowserWindow } = require('electron');
2+
const os = require('os');
3+
const fs = require('fs');
4+
5+
let mainWin;
6+
7+
const winOption = {
8+
width: 1024,
9+
height: 768,
10+
webPreferences: {
11+
webSecurity: false,
12+
nodeIntegration: false
13+
}
14+
}
15+
16+
const isDarwin = os.platform() === 'darwin';
17+
18+
function initializeApp () {
19+
mainWin = new BrowserWindow(
20+
(isDarwin
21+
? Object.assign({}, winOption, {titleBarStyle: 'hidden-inset'})
22+
: winOption)
23+
);
24+
25+
if (process.env.NODE_ENV === 'development') {
26+
mainWin.loadURL('http://localhost:3000');
27+
} else {
28+
mainWin.loadURL('https://hackmd.io');
29+
}
30+
31+
mainWin.webContents.on('did-finish-load', function() {
32+
let cssPath = isDarwin ? '/static/darwin.css' : '/static/app.css';
33+
34+
fs.readFile(__dirname + cssPath, 'utf-8', function(error, data) {
35+
if (!error) {
36+
mainWin.webContents.insertCSS(data);
37+
}
38+
});
39+
});
40+
}
41+
42+
app.on('ready', () => {
43+
initializeApp();
44+
});

package.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"name": "hackmd-desktop",
3+
"version": "0.0.1",
4+
"description": "HackMD desktop client",
5+
"main": "main.js",
6+
"scripts": {
7+
"dev": "cross-env NODE_ENV=development electron .",
8+
"start": "cross-env NODE_ENV=production electron .",
9+
"dist": "build -mwl"
10+
},
11+
"author": "Yukai Huang <yukaihuangtw@gmail.com> (https://yukaii.tw)",
12+
"license": "MIT",
13+
"devDependencies": {
14+
"cross-env": "^3.1.4",
15+
"electron": "^1.4.15",
16+
"electron-builder": "^11.4.4"
17+
},
18+
"build": {
19+
"appId": "com.hackmd.desktop",
20+
"mac": {
21+
"category": "public.app-category.productivity"
22+
}
23+
}
24+
}

static/app.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.navbar.navbar-default {
2+
-webkit-app-region: drag;
3+
}

static/darwin.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.navbar-header {
2+
margin-left: 70px;
3+
}
4+
5+
.navbar.navbar-default {
6+
-webkit-app-region: drag;
7+
}

0 commit comments

Comments
 (0)