Skip to content

Commit

Permalink
Merge pull request #46 from ofuton/develop
Browse files Browse the repository at this point in the history
Release 1.1.1 πŸŽ‰
  • Loading branch information
emiksk committed Feb 18, 2019
2 parents f918c73 + 8d663a3 commit c18b480
Show file tree
Hide file tree
Showing 25 changed files with 218 additions and 177 deletions.
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"env": {
"browser": true
"es6": true,
"browser": true,
"webextensions": true
},
"extends": [
"eslint:recommended",
Expand All @@ -10,4 +12,4 @@
"rules": {
"prettier/prettier": "error"
}
}
}
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
node_modules/
dist/
*.zip
src/js/templates/*.js
src/js/templates/*.pjs
.DS_Store
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# maimodorun

Maimodorun is a chrome extension to recover unsaved texts on Rich Text Editor(RTE) for kintone.

![maimodorun branding logo](./figs/branding_images/branding_logo_for_README_440x180.png)

## Features

1. Automaticaly store texts on RTE.
1. Recover stored text into the original RTE.

## How to recover the stored text

- To click the icon in RTE toolbar.
- To select the text to recover in the popup page.

## Demo

![Demo image](./figs/maimodorun-demo.gif)

## Supported Pages [6/6]

- [x] threads
- [x] thread replies
- [x] people
- [x] people replies
- [x] messages
- [x] app record comments

## License

This software is released under the MIT License. See [LICENSE](./LICENSE)

## Disclaimer

This OSS is my own personal work and does not have any relationship with Cybozu Inc. or any other organization which I belong to.

## Authors

1. [Keisuke Emi](https://github.com/emiksk)
1. [Ryota Konno](https://github.com/rkonno)
1. Rei Asano
1. Haruka Kunihiro
1. Yumi Saijo
1. Shogo Ninomiya
29 changes: 0 additions & 29 deletions README.org

This file was deleted.

Binary file modified figs/branding_images/screen_shot_1280x800.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 figs/maimodorun-demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed figs/maimodorun.gif
Binary file not shown.
5 changes: 3 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ gulp.task('js', () => {
filename: '[name].js'
},
resolve: {
extensions: [ '.js' ],
// .pjs files are created from pug templates.
extensions: [ '.js', '.pjs' ],
modules: [ scripts, 'node_modules' ]
},
};
Expand Down Expand Up @@ -110,7 +111,7 @@ gulp.task('manifest', () => {

gulp.task('clean:templates', () => {
const del = require('del');
return del('./src/js/templates/*.js', { force:true });
return del('./src/js/templates/*.pjs', { force:true });
});

gulp.task('clean:dist', () => {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maimodorun",
"version": "1.1.0",
"version": "1.1.1",
"description": "Maimodorun is a chrome extension to recover unsaved texts on Rich Text Editor(RTE) for kintone.",
"main": "./dist/js/maimodorun.js",
"devDependencies": {
Expand Down Expand Up @@ -33,8 +33,8 @@
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"eslint": "./node_modules/.bin/eslint ./src/scripts/*.js",
"eslint:fix": "./node_modules/.bin/eslint --fix ./src/scripts/*.js",
"eslint": "./node_modules/.bin/eslint ./src/js/**/*.js",
"eslint:fix": "./node_modules/.bin/eslint --fix ./src/js/**/*.js",
"gulp:watch": "./node_modules/.bin/gulp watch",
"gulp:build": "./node_modules/.bin/gulp build",
"gulp:clean": "./node_modules/.bin/gulp clean:all",
Expand Down
10 changes: 5 additions & 5 deletions scripts/pug-compile-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const compileRecoveryButton = () => {
module: true,
compileDebug: false
});
fs.writeFileSync('./src/js/templates/recovery-button.js', recoveryButtonTemplate);
fs.writeFileSync('./src/js/templates/recovery-button.pjs', recoveryButtonTemplate);
};

const compileAutoSavedSign = () => {
Expand All @@ -28,7 +28,7 @@ const compileAutoSavedSign = () => {
module: true,
compileDebug: false
});
fs.writeFileSync('./src/js/templates/auto-saved-sign.js', autoSavedSignTemplate);
fs.writeFileSync('./src/js/templates/auto-saved-sign.pjs', autoSavedSignTemplate);
};

const compileFailedToSaveSign = () => {
Expand All @@ -39,7 +39,7 @@ const compileFailedToSaveSign = () => {
module: true,
compileDebug: false
});
fs.writeFileSync('./src/js/templates/failed-to-save-sign.js', failedToSaveSignTemplate);
fs.writeFileSync('./src/js/templates/failed-to-save-sign.pjs', failedToSaveSignTemplate);
};

const compileHistoriesTemplate = () => {
Expand All @@ -51,7 +51,7 @@ const compileHistoriesTemplate = () => {
compileDebug: false
}
);
fs.writeFileSync('./src/js/templates/histories.js', historiesTemplate);
fs.writeFileSync('./src/js/templates/histories.pjs', historiesTemplate);
};

const compileHistoryEmptyTemplate = () => {
Expand All @@ -63,7 +63,7 @@ const compileHistoryEmptyTemplate = () => {
compileDebug: false
}
);
fs.writeFileSync('./src/js/templates/history-empty.js', historyEmptyTemplate);
fs.writeFileSync('./src/js/templates/history-empty.pjs', historyEmptyTemplate);
};

const compileClient = () => {
Expand Down
2 changes: 1 addition & 1 deletion src/js/background/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import MessageListener from 'background/message-listener';

new MessageListener().run()
new MessageListener().run();
90 changes: 54 additions & 36 deletions src/js/background/message-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,55 @@ import messages from 'background/messages';
export default class MessageClient {
initStorage() {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({ type: messages.STORAGE_INIT }, response => {
if (response.status === messages.STATUS_OK) {
resolve(response);
} else {
reject(new Error(response.status));
}
});
chrome.runtime.sendMessage(
{ type: messages.STORAGE_INIT },
response => {
if (response.status === messages.STATUS_OK) {
resolve(response);
} else {
reject(new Error(response.status));
}
},
);
});
}

getValueFromStorage(key) {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({ type: messages.STORAGE_LOAD, url: key }, response => {
if (response.status === messages.STATUS_OK) {
resolve(response.value);
} else {
reject(new Error(response.status));
}
});
chrome.runtime.sendMessage(
{ type: messages.STORAGE_LOAD, url: key },
response => {
if (response.status === messages.STATUS_OK) {
resolve(response.value);
} else {
reject(new Error(response.status));
}
},
);
});
}

getAllValueFromStorage() {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({ type: messages.STORAGE_LOAD_ALL }, response => {
if (response.status === messages.STATUS_OK) {
resolve(response.value);
} else {
reject(new Error(response.status));
}
});
chrome.runtime.sendMessage(
{ type: messages.STORAGE_LOAD_ALL },
response => {
if (response.status === messages.STATUS_OK) {
resolve(response.value);
} else {
reject(new Error(response.status));
}
},
);
});
}

setValueIntoStorage(payload) {
return new Promise((resolve, reject) => {
const body = Object.assign({ type: messages.STORAGE_STORE }, payload);
const body = Object.assign(
{ type: messages.STORAGE_STORE },
payload,
);
chrome.runtime.sendMessage(body, response => {
if (response.status === messages.STATUS_OK) {
resolve(response.value);
Expand All @@ -52,25 +64,31 @@ export default class MessageClient {

removeValueInStorage(key) {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({ type: messages.STORAGE_REMOVE, url: key }, response => {
if (response.status === messages.STATUS_OK) {
resolve();
} else {
reject(new Error(response.status));
}
});
chrome.runtime.sendMessage(
{ type: messages.STORAGE_REMOVE, url: key },
response => {
if (response.status === messages.STATUS_OK) {
resolve();
} else {
reject(new Error(response.status));
}
},
);
});
}

recoveryWithNewTab(key) {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage({ type: messages.STORAGE_RECOVERY, url: key }, response => {
if (response.status === messages.STATUS_OK) {
resolve();
} else {
reject(new Error(response.status));
}
});
chrome.runtime.sendMessage(
{ type: messages.STORAGE_RECOVERY, url: key },
response => {
if (response.status === messages.STATUS_OK) {
resolve();
} else {
reject(new Error(response.status));
}
},
);
});
}
}
58 changes: 30 additions & 28 deletions src/js/background/message-listener.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,36 @@ export default class MessageListener {
}

run() {
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
switch (request.type) {
case messages.STORAGE_INIT:
this.initStorage(sendResponse);
break;
case messages.STORAGE_LOAD:
this.loadFromStorage(request, sendResponse);
break;
case messages.STORAGE_STORE:
this.storeRequest(request, sendResponse);
break;
case messages.STORAGE_LOAD_ALL:
this.loadAllFromStorage(request, sendResponse);
break;
case messages.STORAGE_REMOVE:
// FIXME: ε‰Šι™€γ—γŸγ‚‰ε―ΎεΏœγ™γ‚‹γ‚Ώγƒ–γ«ζΆˆγ—γŸγ“γ¨γ‚’ι€šηŸ₯する
this.removeFromStorage(request, sendResponse);
break;
case messages.STORAGE_RECOVERY:
this.recoveryWithNewTab(request, sendResponse);
break;
default:
sendResponse({ status: 'Failed' });
break;
}
chrome.runtime.onMessage.addListener(
(request, sender, sendResponse) => {
switch (request.type) {
case messages.STORAGE_INIT:
this.initStorage(sendResponse);
break;
case messages.STORAGE_LOAD:
this.loadFromStorage(request, sendResponse);
break;
case messages.STORAGE_STORE:
this.storeRequest(request, sendResponse);
break;
case messages.STORAGE_LOAD_ALL:
this.loadAllFromStorage(request, sendResponse);
break;
case messages.STORAGE_REMOVE:
// FIXME: ε‰Šι™€γ—γŸγ‚‰ε―ΎεΏœγ™γ‚‹γ‚Ώγƒ–γ«ζΆˆγ—γŸγ“γ¨γ‚’ι€šηŸ₯する
this.removeFromStorage(request, sendResponse);
break;
case messages.STORAGE_RECOVERY:
this.recoveryWithNewTab(request, sendResponse);
break;
default:
sendResponse({ status: 'Failed' });
break;
}

return true;
});
return true;
},
);
}

async initStorage(sendResponse) {
Expand All @@ -53,7 +55,7 @@ export default class MessageListener {
title: request.title,
timestamp: request.timestamp,
coverImageUrl: request.coverImageUrl,
contents: request.contents
contents: request.contents,
};

sendResponse(await this.commandStorage.store(value));
Expand Down
2 changes: 1 addition & 1 deletion src/js/background/messages.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export default {
STORAGE_REMOVE: 'storage.remove',
STORAGE_RECOVERY: 'storage.recovery',

STATUS_OK: 'OK'
STATUS_OK: 'OK',
};
Loading

0 comments on commit c18b480

Please sign in to comment.