Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
runtime = electron
target = 1.6.11
target_arch = x64
disturl = https://atom.io/download/atom-shell
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,38 @@ List of contributors that have helped shaped this version of autoEdit by contrib



<!--
to work with google speech to text module

https://stackoverflow.com/questions/42616008/node-module-version-conflict-when-installing-modules-for-electron


npm install --save-dev electron-rebuild


./node_modules/.bin/electron-rebuild


ENV var
```
# Electron's version.
export npm_config_target=1.6.11
# The architecture of Electron, can be ia32 or x64.
export npm_config_arch=x64
export npm_config_target_arch=x64
# Download headers for Electron.
export npm_config_disturl=https://atom.io/download/electron
# Tell node-pre-gyp that we are building for Electron.
export npm_config_runtime=electron
# Tell node-pre-gyp to build module from source code.
export npm_config_build_from_source=true
# Install all dependencies, and store cache to ~/.electron-gyp.
HOME=~/.electron-gyp npm install

```

npm rebuild


-->

2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ <h3 id="open-source">Open source</h3>

<a href="mailto:[email protected]?Subject=autoEdit%202%20question">[email protected]</a> |

<a href="http://tiwtter.com/autoEdit2" target="_blank">Twitter</a> |
<a href="http://twitter.com/autoedit2" target="_blank">Twitter</a> |
<a href="https://www.facebook.com/autoEdit.io" target="_blank">Facebook</a> | <a href="http://eepurl.com/cMzwSX" target="_blank">Mailing list</a>
</div>
</div>
Expand Down
404 changes: 236 additions & 168 deletions electron/app.js

Large diffs are not rendered by default.

25 changes: 23 additions & 2 deletions electron/db.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict';
// 'use strict';
/**
* @module db
* @description Manages the backend of the app by overwrighting backbone.sync function
Expand Down Expand Up @@ -99,6 +99,12 @@ function makeLinvoCallback(success, error) {
* @returns {object} sucess callback with backbone model containing db id
*/
DB.create = function(model, success, error){






console.debug('DB.create', model.constructor.modelType);
if (model.constructor.modelType == 'transcription') {
var newElement = model.toJSON();
Expand All @@ -121,6 +127,21 @@ DB.create = function(model, success, error){
// returning saved transcription callback
success(model);

//TODO: there might be a way to make this more seamless. need to decide where this logic would go.
//setting STT API Keys for appropriate service, if needed. (eg Offline Open source STT Gentle and Pocketsphinx don't need it)
var sttServiceKeys = "";
if(newElement.sttEngine =="ibm"){
sttServiceKeys = window.IBMWatsonKeys();
}else if(newElement.sttEngine =="google"){
sttServiceKeys = window.GoogleKeys();
sttServiceKeys.path = window.getGoogleAPIKeysPath();
}else if(newElement.sttEngine =="microsoft"){
console.error("microsoft not yet implemented in backend");
}
// else{
// console.error("ERROR: no STT API credentials provided")
// }

// using interactive_transcription_generator to generate metadata,
// transcription json
// webm video preview
Expand All @@ -134,7 +155,7 @@ DB.create = function(model, success, error){
// destFolder:"/media",
tmpWorkFolder: tmpMediaFolder,
destFolder: mediaFolder,
keys: window.IBMWatsonKeys(),
keys: sttServiceKeys,
languageModel: newElement.languageModel,
sttEngine: newElement.sttEngine,
cbMetadata: function(respM) {
Expand Down
89 changes: 89 additions & 0 deletions electron/google_keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
var fs = require('fs');
var electron = require('electron');
var currentWindow = electron.remote.getCurrentWindow();

var googleKeysPath;

if (window.process !== 'undefined') {
googleKeysPath = currentWindow.dataPath + '/gckeys.json';
}else{
//not in nwjs
googleKeysPath = "/";
}

var googleKeys = {
"apiKey": ""
}

var googleKeysSet = false;

// load keys on startup
window.document.addEventListener('DOMContentLoaded', function() {
if (areGoogleAPIkeysSet()) {
googleKeys = getGoogleAPIkeys();
}
});

//helper funciton to check/validate the keys
function keysAreValid(tempKeys){
console.log('tempKeys',tempKeys);
//if hte object has the required attributes
// if (tempKeys.username.length > 0 && tempKeys.password.length > 0) {
return true;
// }else{
// return false;
// }
}

// get
function getGoogleAPIkeys(){
if (fs.existsSync(googleKeysPath)) {
googleKeys = JSON.parse(fs.readFileSync(googleKeysPath).toString());
return googleKeys;
}else{
return googleKeys;
}
}

function getGoogleAPIKeysPath(){
return googleKeysPath;
}

//set
function setGoogleAPIkeys(keys){
// then assuming is a file path
// if(typeof keys == 'string'){
// //TODO change to read.
// const fs = require('fs');
// keys = JSON.parse(fs.readFileSync(keys, 'utf8'));
// // keys = require('keys');
// }
// if(keysAreValid(keys)){
fs.writeFileSync(googleKeysPath, JSON.stringify(keys));
// }else{
// not setting keys. should add some error handling it, but
// at the moment validation check is handled in view
// }
}

//check if they are set
function areGoogleAPIkeysSet(){
// fs.writeFileSync(googleKeysPath, JSON.stringify(tempKeys));
if (fs.existsSync(googleKeysPath)) {
// TODO: add some more validation that values actually make sense
googleKeys = JSON.parse(fs.readFileSync(googleKeysPath).toString());
var result = keysAreValid(googleKeys);
// googleKeysSet = true;
return result;
} else {
// googleKeysSet = false2;
return false;
}
}

module.exports = {
areGoogleAPIkeysSet: areGoogleAPIkeysSet,
setGoogleAPIkeys: setGoogleAPIkeys,
getGoogleAPIkeys: getGoogleAPIkeys,
getGoogleAPIKeysPath: getGoogleAPIKeysPath
};
26 changes: 24 additions & 2 deletions electron/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<li ><a href="#paperedits">Paperedits</a></li>
<!-- settings -->
<li ><a href="#settings"><span class="glyphicon glyphicon-cog" aria-hidden="true"></span></a></li>
<li><a class="externalLink" href="https://donorbox.org/c9762eef-0e08-468e-90cb-2d00643697f8?recurring=true" class="custom-dbox-popup" target="_blank"><span class="glyphicon glyphicon-gift" aria-hidden="true"> Donate</a></li>
<li><a class="externalLink" href="https://donorbox.org/c9762eef-0e08-468e-90cb-2d00643697f8?recurring=true" class="custom-dbox-popup" target="_blank"><span class="glyphicon glyphicon-gift" aria-hidden="true"></span> Donate</a></li>

<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Help
Expand Down Expand Up @@ -81,6 +81,14 @@
window.setWatsonAPIkeys = require('./watson_keys.js').setWatsonAPIkeys;
window.areWatsonAPIkeysSet = require('./watson_keys.js').areWatsonAPIkeysSet;

window.GoogleKeys = require('./google_keys.js').getGoogleAPIkeys;
window.setGoogleAPIkeys = require('./google_keys.js').setGoogleAPIkeys;
window.areGoogleAPIkeysSet = require('./google_keys.js').areGoogleAPIkeysSet;
window.getGoogleAPIKeysPath = require('./google_keys.js').getGoogleAPIKeysPath;

//TODO: do the same for microsoft


// if you drag a file onto the app, it stops from the window opening that file.
// TODO: it be awesome if whichever view you are in if you drag a file onto the window, it opens the transcription form view, with that file prepopulated.
document.addEventListener('drop', function(e) {
Expand Down Expand Up @@ -145,7 +153,21 @@
{
properties: ['openFile'],
filters: [
{name: 'Movies',extensions: ffmpegExentions},
{name: 'Movies',extensions: ffmpegExentions}
]
},
function(fileName){
if(cb){cb(fileName)};
});
}

window.openFileDiaglogueJSON = function(cb){
dialog.showOpenDialog(
{
properties: ['openFile'],
//filter for JSON not working, not sure how.
filters: [
{name: 'All Files',extensions: 'json'}
]
},
function(fileName){
Expand Down
71 changes: 71 additions & 0 deletions electron/microsoft_keys.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
var fs = require('fs');
var electron = require('electron');
var currentWindow = electron.remote.getCurrentWindow();

if (window.process !== 'undefined') {
var keysPath = currentWindow.dataPath + '/keys.json';
}else{
//not in nwjs
var keysPath = "/";
}

var keys = {username: "", password: ""};
var keysSet = false;

// load keys on startup
window.document.addEventListener('DOMContentLoaded', function() {
if (areAPIkeysSet()) {
keys = getAPIkeys();
}
});

//helper funciton to check/validate the keys
function keysAreValid(tempKeys){
//if hte object has the required attributes
if (tempKeys.username.length > 0 && tempKeys.password.length > 0) {
return true;
}else{
return false;
}
}

// get
function getAPIkeys(){
if (fs.existsSync(keysPath)) {
keys = JSON.parse(fs.readFileSync(keysPath).toString());
return keys;
}else{
return keys;
}
}

//set
function setWatsonAPIkeys(keys){
if(keysAreValid(keys)){
fs.writeFileSync(keysPath, JSON.stringify(keys));
}else{
// not setting keys. should add some error handling it, but
// at the moment validation check is handled in view
}
}

//check if they are set
function areAPIkeysSet(){
// fs.writeFileSync(keysPath, JSON.stringify(tempKeys));
if (fs.existsSync(keysPath)) {
// TODO: add some more validation that values actually make sense
keys = JSON.parse(fs.readFileSync(keysPath).toString());
var result = keysAreValid(keys);
// keysSet = true;
return result;
} else {
// keysSet = false2;
return false;
}
}

module.exports = {
areAPIkeysSet: areAPIkeysSet,
setWatsonAPIkeys: setWatsonAPIkeys,
getAPIkeys: getAPIkeys
};
8 changes: 4 additions & 4 deletions lib/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@ $(document).ready(function() {
*/

if (window.process !== undefined) {
console.info("In Electron v ", process.versions.electron);
console.info("Using chrome v ", process.versions.chrome);
console.info("Using v8 engine v ", process.versions.v8);
console.info("Using node v ", process.versions.node);
console.info("In Electron v ", window.process.versions.electron);
console.info("Using chrome v ", window.process.versions.chrome);
console.info("Using v8 engine v ", window.process.versions.v8);
console.info("Using node v ", window.process.versions.node);

//TODO: update this part with Electron compatible code

Expand Down
6 changes: 5 additions & 1 deletion lib/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ module.exports = Backbone.Router.extend({

settingsPanel: function(){
console.debug('Router: settings panel: ');
var tmpSettings ={credentials: {ibm: window.IBMWatsonKeys() }} ;
var tmpSettings ={credentials: {
ibm: window.IBMWatsonKeys(),
microsoft: {key:"TBC"},
google: window.GoogleKeys()
}} ;
var settingsView = new SettingsView({settings: tmpSettings});
displayMain(settingsView);
},
Expand Down
Loading