Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Oct 25, 2017
0 parents commit e668461
Show file tree
Hide file tree
Showing 17 changed files with 1,618 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org

root = true

[*.md]
trim_trailing_whitespace = false
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
.DS_Store

Mak-win32-x64
Mak-darwin-x64
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## 0.0.2 (Oct 9, 2017)
- Added env tags injection.
- Set App window size.

## 0.0.3 (Oct 10, 2017)
- Added icons.

## 0.0.4 (Oct 10, 2017)
- Added setting overwrites.

## 0.1.0 (Oct 18, 2017)
- Using mak.ink.
- New icon.
- Background color changes.
- Added contextmenu.
- Fixed keybindings.

## 0.1.1 (Oct 25, 2017)
- Added Mac TouchBar support.
- Fixed external URL issues.
- Re-arrange options.
- Added version info.
- Added readme and screenshots.

## 0.1.2 (Oct 25, 2017)
- Fixed tray icon in Windows.
- Fixed skipTaskbar in Windows.
- Code refactorings.
Binary file added Icon.icns
Binary file not shown.
Binary file added Icon.ico
Binary file not shown.
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<img src='assets/mak-mini.png' width=128 height=128 align='right'/>

# Mak<sup>mini<sup>
[<img src='https://img.shields.io/gitter/room/inns/mak.svg'/>](https://gitter.im/inns/mak) <img src='https://img.shields.io/github/package-json/v/inns/mak-mini.svg'/> [<img src='https://img.shields.io/website-up-down-green-red/https/mak.ink.svg?label=mak.ink'/>](https://mak.ink)

A (small) piece of paper.

Build on top of [Mak](https://github.com/inns/mak).


## The App
[Download latest releases](https://github.com/quietshu/makpad-mini/releases).

<img src='screenshot/mak.png' width=539 align='right'/>

### macOS

Mak<sup>mini</sup> is a menubar App, just as simple as Mak. But unlike the browser version ([mak.ink](https://mak.ink)), Mak<sup>mini</sup> is **NOT** designed to be focused on. The key point is **easy to access**.

You can use it just like stickers, todo list, quick notes, temporary clipboard with read-it-later URLs, or **any mess you don't know where to put**.

It's not a focus writing tool. The reading and split mode are both disabled currently.

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width=880 />

<img src='screenshot/touchbar.png' width=650 align='right'/>

### TouchBar Support (MacBook 2016)

TouchBar is convenient and intuitive. That's also parts of Mak's philosophy, and Mak<sup>mini</sup> works perfectly with it.

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width=880 />

<img src='screenshot/windows-mak.png' width=531 align='right'/>

### Windows

Mak<sup>mini</sup> is also supported in Windows.

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" width=880 />


## Source Code

### Install dependencies
`$ yarn`

### Development
In macOS, run `$ yarn dev:darwin`.
In Windows PowerShell, run `$ yarn dev:win32`.

When running development mode, you can use the Inspector for debugging.

### Build Production
For macOS build, run `$ yarn build:darwin`.
For Windows build, run `$ yarn build:win32`.


## Share Mak<sup>mini</sup>
[![Twitter URL](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=A+small+piece+of+paper:&url=https%3A%2F%2Fgithub.com%2Finns%2Fmak-mini)


## License & Acknowledgement
[TBD.]

By Shu ([email protected]), SH 2017
https://shud.in
Binary file added assets/darwin-IconTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/mak-mini.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/win32-IconTemplate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
188 changes: 188 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
const path = require('path')
const platform = require('os').platform()

const menubar = require('menubar')

const env = process.env.NODE_ENV
const isDev = env && env.trim() === 'development'

const { Menu, shell, TouchBar } = require('electron')
const {
TouchBarLabel,
TouchBarButton,
TouchBarSpacer,
TouchBarGroup
} = TouchBar

const INDEX = 'https://mak.ink'
const WIDTH = 400
const HEIGHT = 600
const VERSION = require('./package.json').version

const openExternal = URI => shell.openExternal(URI)
const execJS = (...args) =>
mb.window && mb.window.webContents.executeJavaScript(...args)

var mb = menubar({
icon: path.join(__dirname, 'assets', `${platform}-IconTemplate.png`),
index: INDEX,
preloadWindow: true,
width: WIDTH,
height: HEIGHT,
backgroundColor: 'white'
})

const contextMenu = Menu.buildFromTemplate([
{
label: 'Mak in Browser',
click: () => openExternal('https://mak.ink')
},
{ type: 'separator' },
{
label: 'Home',
click: () => {
execJS(`;window.location = '${INDEX}';`)
mb.showWindow()
}
},
{
label: 'List',
click: () => {
execJS(`;window.location = '${INDEX}#list';`)
mb.showWindow()
}
},
{
label: 'Preferences',
click: () => {
execJS(`;window.location = '${INDEX}#preferences';`)
mb.showWindow()
}
},
{ type: 'separator' },
{
label: `About Mak v${VERSION}`,
click: () => openExternal('https://github.com/inns/mak')
},
...(isDev
? [
{ type: 'separator' },
{
label: 'Development ' + platform
},
{
label: 'Inspect',
click: () => mb.window.openDevTools()
},
{ type: 'separator' }
]
: [{ type: 'separator' }]),
{ label: 'Quit', role: 'quit' }
])

const homeBtn = new TouchBarButton({
label: '#',
click: () => execJS(`;window.location = '${INDEX}#';`)
})

const listBtn = new TouchBarButton({
label: '#list',
click: () => execJS(`;window.location = '${INDEX}#list';`)
})

const preferencesBtn = new TouchBarButton({
label: '#preferences',
click: () => execJS(`;window.location = '${INDEX}#preferences';`)
})

const themeBtn = new TouchBarButton({
label: '🌖',
backgroundColor: '#000',
click: () =>
execJS(`
;window[window.settings.theme === 'light' ? 'dark' : 'light']();
`)
})

const cntBtn = new TouchBarButton({
label: '✍️',
backgroundColor: '#000',
click: () => execJS(`;window[window.settings.cnt ? 'nocnt' : 'cnt']();`)
})

const titleBtn = new TouchBarButton({
label: 'Mak',
backgroundColor: '#000',
click: () => execJS(`;window[window.settings.cnt ? 'nocnt' : 'cnt']();`)
})

const touchBar = new TouchBar({
items: [
new TouchBarSpacer({ size: 'small' }),
new TouchBarGroup({
items: [homeBtn, listBtn, preferencesBtn]
}),
new TouchBarSpacer({ size: 'small' }),
themeBtn,
cntBtn,
new TouchBarSpacer({ size: 'small' })
],
escapeItem: titleBtn
})

const tick = () => {
if (mb.window) {
mb.window.webContents.executeJavaScript(
'window.document.title',
false,
title => {
titleBtn.label = title
}
)
}
}

const shortCuts = [
{
label: 'Mak',
submenu: [
{ label: 'Quit', accelerator: 'Command+Q', click: () => mb.app.quit() },
{ label: 'Undo', accelerator: 'CmdOrCtrl+Z', selector: 'undo:' },
{ label: 'Redo', accelerator: 'Shift+CmdOrCtrl+Z', selector: 'redo:' },
{ label: 'Cut', accelerator: 'CmdOrCtrl+X', selector: 'cut:' },
{ label: 'Copy', accelerator: 'CmdOrCtrl+C', selector: 'copy:' },
{ label: 'Paste', accelerator: 'CmdOrCtrl+V', selector: 'paste:' },
{
label: 'Select All',
accelerator: 'CmdOrCtrl+A',
selector: 'selectAll:'
}
]
}
]

mb.on('ready', function() {
mb.window.setSkipTaskbar(true)

mb.window.webContents.on('did-finish-load', function() {
mb.window.webContents.executeJavaScript(';window.IS_MAK_MINI = true;')
setInterval(tick, 500)
})

mb.window.webContents.on('will-navigate', function(event, url) {
if (!url.startsWith(INDEX)) {
// external links
event.preventDefault()
shell.openExternal(url)
}
})

mb.tray.on('right-click', function() {
mb.tray.popUpContextMenu(contextMenu)
})

mb.window.setTouchBar(touchBar)

Menu.setApplicationMenu(Menu.buildFromTemplate(shortCuts))
// mb.app.commandLine.appendSwitch('--enable-experimental-web-platform-features')
})
24 changes: 24 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "mak-mini",
"version": "0.1.2",
"description": "A (small) piece of paper.",
"main": "main.js",
"repository": "https://github.com/inns/mak-mini",
"author": "Shu Ding @shdin",
"license": "MIT",
"scripts": {
"build:win32":
"electron-packager . Mak --platform=win32 --arch=x64 --version=0.1.2 --icon=Icon.ico --overwrite",
"build:darwin":
"electron-packager . Mak --platform=darwin --arch=x64 --version=0.1.2 --icon=Icon.icns --overwrite",
"dev:win32": "set NODE_ENV=development && electron .",
"dev:darwin": "NODE_ENV=development electron ."
},
"dependencies": {
"electron": "^1.7.8",
"menubar": "^5.2.3"
},
"devDependencies": {
"electron-packager": "^9.1.0"
}
}
Binary file added screenshot/mak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/touchbar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshot/windows-mak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit e668461

Please sign in to comment.