-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added database * Removed console / Added TODO * Fixed lint error
- Loading branch information
Showing
11 changed files
with
125 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ jspm_packages | |
log.txt | ||
|
||
text-logger-* | ||
|
||
*.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export const SERVICE = { | ||
GOOGLE: 'google', | ||
GLOSBE: 'glosbe' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default class { | ||
constructor(source, google, glosbe) { | ||
this.key = source; | ||
this.google = google; | ||
this.glosbe = glosbe; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {clipboard} from 'electron'; | ||
import levelup from 'level'; | ||
import googleTranslate from './google-translate'; | ||
import glosbeTranslate from './glosbe-translate'; | ||
import Contents from './content'; | ||
|
||
// TODO: remove, for backward compatibility | ||
import fs from 'fs'; | ||
import setting from '../setting.json'; | ||
import {SERVICE} from './constants'; | ||
import {logPath} from './main'; | ||
export function saveContents() { | ||
const clip = clipboard.readText(); | ||
if (setting.enableServiceHook) { | ||
let service; | ||
if (setting.service === SERVICE.GOOGLE) service = googleTranslate; | ||
else if (setting.service === SERVICE.GLOSBE) service = glosbeTranslate; | ||
else { | ||
// TODO: ERROR handle | ||
} | ||
service(clip) | ||
.then(translated => `${clip} => ${translated}\n`) | ||
.then(contents => { | ||
fs.appendFileSync(logPath, contents); | ||
}); | ||
return; | ||
} | ||
fs.appendFileSync(logPath, clip); | ||
} | ||
|
||
const db = levelup('log.db', {valueEncoding: 'json'}); | ||
export async function store(cb) { | ||
const clip = clipboard.readText(); | ||
|
||
const tranGoogle = await googleTranslate(clip); | ||
const tranGlosbe = await glosbeTranslate(clip); | ||
|
||
const contents = new Contents(clip, tranGoogle, tranGlosbe); | ||
db.put(contents.key, contents, err => { | ||
if (err) throw err; | ||
cb(contents); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
// install babel hooks in the main process | ||
require('babel-register'); | ||
require('babel-polyfill'); | ||
require('./app/core/main.js'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
"license": "MIT", | ||
"repository": "[email protected]:ovekyc/textlogger.git", | ||
"scripts": { | ||
"start": "electron .", | ||
"start": "./node_modules/.bin/electron .", | ||
"lint": "./node_modules/.bin/eslint app/**/*.js", | ||
"test": "npm run lint" | ||
}, | ||
|
@@ -20,13 +20,16 @@ | |
"babel-preset-stage-0": "^6.16.0", | ||
"babel-register": "^6.18.0", | ||
"electron": "^1.4.3", | ||
"level": "^1.5.0", | ||
"menubar": "^5.2.0", | ||
"react": "^15.4.1", | ||
"react-addons-update": "^15.4.1", | ||
"react-dom": "^15.4.1" | ||
}, | ||
"devDependencies": { | ||
"babel-eslint": "^7.1.1", | ||
"babel-polyfill": "^6.20.0", | ||
"electron-rebuild": "^1.5.5", | ||
"eslint": "^3.12.2", | ||
"eslint-plugin-react": "^6.8.0", | ||
"pre-commit": "^1.2.2" | ||
|