Skip to content

Commit

Permalink
Add goto daily note command
Browse files Browse the repository at this point in the history
  • Loading branch information
mooz committed Aug 23, 2020
1 parent 3e9f6bc commit a969c16
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions package/settings.default.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ config.globalKeyMap = {
F: keysnail.command(() => keysnail.forward(), "History forward"),
L: keysnail.command(() => keysnail.forward(), "History backward"),
f: keysnail.command(() => keysnail.focusFirstInput(), "Focus to the first input"),
a: {
a: keysnail.command(() => $notify("scrap"), "Scrap this page (Scrapbox)"),
n: keysnail.command(() => $notify("gotoDailyNote"), "Goto daily note (Scrapbox)"),
},
g: {
g: keysnail.command(() => keysnail.cursorTop(), "Goto the beginning of the page"),
i: keysnail.command(() => keysnail.focusFirstInput(), "Focus to the first input"),
Expand Down
1 change: 1 addition & 0 deletions src/TabBrowser/Tab/TabContentWebView.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class TabContentWebView extends Component {
exitApplication: () => $app.close(),
share: () => this.browser.share(),
scrap: () => this.browser.scrap(),
gotoDailyNote: () => this.browser.gotoDailyNote(),
message: ({ message, duration }) => {
$ui.toast(message, duration || 3);
},
Expand Down
3 changes: 3 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,15 @@ ${JSON.stringify(candidates)}, { toggle: true, initialIndex: ${idx}, action: ind
return `${todayYear}-${todayMonth}-${todayDate}`;
}

gotoDailyNote() {
if (!this.config.SCRAPBOX_USER) {
$ui.toast(
`Specify Scrapbox user in settings.js: config.SCRAPBOX_USER = 'XXX';`
);
return;
}
this.visitURL(`https://scrapbox.io/${this.config.SCRAPBOX_USER}/${this._getTodayString()}`);
}

scrap() {
if (!this.config.SCRAPBOX_USER) {
Expand Down

0 comments on commit a969c16

Please sign in to comment.