Skip to content

Commit

Permalink
Merge pull request #37 from TalasZh/master
Browse files Browse the repository at this point in the history
4.0.0: Add-on migration to WebExtension
  • Loading branch information
TalasZh authored Nov 24, 2017
2 parents 867578a + 5c842da commit 1623d65
Show file tree
Hide file tree
Showing 46 changed files with 8,804 additions and 7,448 deletions.
167 changes: 54 additions & 113 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ module.exports = function(grunt) {
cwd: 'bower_components/requirejs/',
src: 'require.js',
dest: 'build/e2e-plugin.safariextension/'
},
{
expand: true,
cwd: 'bower_components/requirejs/',
src: 'require.js',
dest: 'build/firefox/'
}
]
},
Expand All @@ -156,7 +162,7 @@ module.exports = function(grunt) {
common_browser: {
files: [
{
expand: true,
expand: true,
src: ['common/**/*', '!common/lib/**/*'],
cwd: 'build/',
dest: 'build/chrome/'
Expand All @@ -167,31 +173,12 @@ module.exports = function(grunt) {
cwd: 'build/common/lib/',
dest: 'build/chrome/lib/common/'
},
{
expand: true,
src: ['common/**/*', '!common/lib/**/*'],
cwd: 'build/',
dest: 'build/firefox/data/'
},
{
expand: true,
src: '**/*',
cwd: 'build/common/lib/',
dest: 'build/firefox/lib/common/'
},
{
expand: true,
src: 'porto.js',
cwd: 'build/common/ui',
dest: 'build/firefox/lib/common/'
},
{
expand: true,
src: '**/*',
cwd: 'locales',
dest: 'build/chrome/_locales'
},

{
expand: true,
cwd: 'common/img/icons/',
Expand All @@ -218,26 +205,26 @@ module.exports = function(grunt) {
src: '**/*',
cwd: 'locales',
dest: 'build/e2e-plugin.safariextension/_locales'
}]
},
locale_firefox: {
expand: true,
src: '**/*.json',
cwd: 'locales',
dest: 'build/firefox/locale/',
rename: function(dest, src) {
return dest + src.match(/^[\w-]{2,5}/)[0].replace('_', '-') + '.properties';
},
options: {
process: function(content, srcpath) {
var locale = JSON.parse(content);
var result = '';
for (var key in locale) {
result += key + '= ' + locale[key].message.replace(/\$(\d)/g, '%$1s') + '\n';
}
return result;
}
{
expand: true,
src: ['common/**/*', '!common/lib/**/*'],
cwd: 'build/',
dest: 'build/firefox/'
},
{
expand: true,
src: '**/*',
cwd: 'build/common/lib/',
dest: 'build/firefox/lib/common/'
},
{
expand: true,
src: '**/*',
cwd: 'locales',
dest: 'build/firefox/_locales'
}
]
},
dep: {
files: [{
Expand Down Expand Up @@ -305,66 +292,39 @@ module.exports = function(grunt) {
{
expand: true,
flatten: true,
src: ['dep/firefox/openpgpjs/openpgp.min.js', 'dep/firefox/openpgpjs/openpgp.worker.min.js'],
dest: 'build/firefox/data/'
},
{
expand: true,
flatten: true,
src: 'node_modules/mailreader/src/mailreader-parser.js',
dest: 'build/firefox/node_modules/mailreader-parser'
},
{
expand: true,
flatten: true,
src: 'node_modules/mailreader/node_modules/emailjs-mime-parser/src/*.js',
dest: 'build/firefox/node_modules/emailjs-mime-parser'
},
{
expand: true,
flatten: true,
src: 'node_modules/emailjs-mime-codec/src/*.js',
dest: 'build/firefox/node_modules/emailjs-mime-codec'
src: ['dep/firefox/openpgpjs/openpgp.js', 'dep/firefox/openpgpjs/openpgp.worker.js'],
dest: 'build/firefox/dep/'
},
{
expand: true,
flatten: true,
src: 'node_modules/mailreader/node_modules/emailjs-mime-parser/node_modules/emailjs-addressparser/src/*.js',
dest: 'build/firefox/node_modules/emailjs-addressparser'
},
{
expand: true,
flatten: true,
src: 'node_modules/emailjs-mime-builder/src/*.js',
dest: 'build/firefox/node_modules/emailjs-mime-builder'
},
{
expand: true,
flatten: true,
src: 'node_modules/emailjs-mime-builder/node_modules/emailjs-mime-types/src/*.js',
dest: 'build/firefox/node_modules/emailjs-mime-types'
cwd: 'node_modules/',
src: [
'mailreader/src/mailreader-parser.js',
'mailreader/node_modules/emailjs-mime-parser/src/*.js',
'mailreader/node_modules/emailjs-mime-parser/node_modules/emailjs-addressparser/src/*.js',
'emailjs-mime-codec/src/*.js',
'emailjs-mime-builder/src/*.js',
'emailjs-mime-builder/node_modules/emailjs-mime-types/src/*.js'
],
dest: 'build/firefox/lib/'
},
{
expand: true,
flatten: true,
src: 'node_modules/emailjs-mime-builder/node_modules/punycode/*.js',
dest: 'build/firefox/node_modules/emailjs-punycode'
}]
},
xpi: {
expand: true,
flatten: true,
src: 'dist/*.xpi',
dest: 'dist/',
rename: function(dest) {
return dest + 'e2e-plugin.firefox.xpi';
dest: 'build/firefox/lib/',
rename: function(dest) {
return dest + 'emailjs-punycode.js';
}
}
]
}
},

watch: {
scripts: {
files: ['Gruntfile.js', '{common,dep,chrome,firefox,e2e-plugin.safariextension}/**/*.js'],
files: ['Gruntfile.js', '{common,dep,chrome,firefox,e2e-plugin.safariextension}/**/*'],
tasks: ['default', 'dist-ff', 'dist-cr'],
options: {
spawn: false
Expand All @@ -384,18 +344,6 @@ module.exports = function(grunt) {
src: ['chrome/**/*', 'chrome/!**/.*'],
cwd: 'build/'
}]
},
doc: {
options: {
mode: 'zip',
archive: 'dist/e2e-plugin.client-api-documentation.zip',
pretty: true
},
files: [{
expand: true,
src: ['**/*'],
cwd: 'build/doc/'
}]
}
},

Expand All @@ -419,21 +367,14 @@ module.exports = function(grunt) {
from: /("version"\s:\s"[\d\.]+)/,
to: '$1' + ' build: ' + (new Date()).toISOString().slice(0, 19)
}]
},
openpgp_ff: {
src: ['dep/firefox/openpgpjs/openpgp.min.js'],
dest: ['build/firefox/node_modules/openpgp/openpgp.js'],
replacements: [{
from: "*/",
to: "*/\nvar window = require('./window');"
}]
}
},

jpm: {
options: {
src: "./build/firefox",
xpi: "./dist/"
shell: {
move_firefox_dist: {
command: 'mv dist/subutai_e2e_plugin-*.zip dist/e2e-plugin.firefox.zip'
},
webex_build: {
command: 'web-ext build --source-dir=build/firefox --artifacts-dir=dist'
}
},

Expand All @@ -458,22 +399,22 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks("grunt-jscs");
grunt.loadNpmTasks('grunt-jsdoc');
grunt.loadNpmTasks('grunt-jpm');
grunt.loadNpmTasks('grunt-shell');

//custom tasks
grunt.registerTask('dist-cr', ['compress:chrome']);
grunt.registerTask('dist-crx', function() {
grunt.util.spawn({cmd: 'sign-dist/crxmake.sh', args: ['build/chrome', 'cert/crx_signing.pem'], opts: {stdio: 'ignore'}});
});

grunt.registerTask('dist-ff', ['jpm:xpi', 'copy:xpi']);
grunt.registerTask('dist-ff', ['shell:webex_build', 'shell:move_firefox_dist']);
grunt.registerTask('sign-ffa', function() {
grunt.util.spawn({cmd: 'sign-dist/ffa-sign.sh', args: ['cert/ffa-api-credentials.sh', 'dist/e2e-plugin.firefox.xpi']});
grunt.util.spawn({cmd: 'sign-dist/ffa-sign.sh', args: ['cert/ffa-api-credentials.sh', 'dist/e2e-plugin.firefox.zip']});
});
grunt.registerTask('dist-doc', ['jsdoc', 'compress:doc']);

grunt.registerTask('copy_common', ['copy:vendor', 'copy:common', 'replace:bootstrap', 'replace:openpgp_ff']);
grunt.registerTask('final_assembly', ['copy:plugins', 'copy:common_browser', 'copy:locale_firefox', 'copy:dep']);
grunt.registerTask('copy_common', ['copy:vendor', 'copy:common', 'replace:bootstrap']);
grunt.registerTask('final_assembly', ['copy:plugins', 'copy:common_browser', 'copy:dep']);

grunt.registerTask('default', ['clean', 'jshint', 'jscs', 'copy:jquery', 'concat', 'copy_common', 'final_assembly']);
grunt.registerTask('nightly', ['clean', 'jshint', 'jscs', 'copy:jquery', 'concat', 'copy_common', 'final_assembly', 'replace:build_version']);
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "porto",
"version": "3.0.0",
"version": "4.0.0",
"description": "Porto is a browser extension library for Google Chrome,Firefox and Safari that allows to develop cross platform browser extension with ease.",
"license": "ALS",
"private": true,
Expand Down
6 changes: 4 additions & 2 deletions chrome/lib/porto-lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define(function(require, exports, module) {
var porto = require('porto');

porto.crx = true;
porto.ffa = false;
porto.webex = false;
porto.sfx = false;

var dompurify = require('dompurify');
Expand Down Expand Up @@ -55,7 +55,9 @@ define(function(require, exports, module) {
// Code to run if the request succeeds (is done);
// The response is passed to the function
.done(function(data, status, xhr) {
console.log(data);
if (porto.storage.get('debug')) {
console.log(data);
}
resolve({data: data, status: xhr.status, statusText: xhr.statusText});
})
// Code to run if the request fails; the raw request and
Expand Down
5 changes: 3 additions & 2 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_ext_name__",
"version": "3.0.0",
"version_name": "3.0.0",
"version": "4.0.0",
"version_name": "4.0.0",
"description": "__MSG_ext_description__",
"homepage_url":"https://subutai.io",
"manifest_version": 2,
Expand All @@ -23,6 +23,7 @@
"permissions": [
"tabs",
"webRequest",
"downloads",
"*://*/*",
"clipboardWrite"
],
Expand Down
7 changes: 2 additions & 5 deletions common/lib/controller/main.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ define(function(require, exports, module) {
if (request.api_event) {
return;
}
//console.log('main.controller::handleMessageEvent');
//console.log(request);
console.log('main.controller::handleMessageEvent');
console.log(request);
//console.trace();
switch (request.event) {
case 'pgpmodel':
Expand All @@ -60,9 +60,6 @@ define(function(require, exports, module) {
break;
case 'set-watch-list':
model.setWatchList(request.data);
if (porto.ffa) {
reloadFrames(true);
}
specific.initScriptInjection();
break;
case 'get-all-keyring-attr':
Expand Down
9 changes: 2 additions & 7 deletions common/lib/pgpModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,8 @@ define(function(require, exports, module) {
function initOpenPGP() {
openpgp.config.commentstring = 'https://subutai.io/';
openpgp.config.versionstring = 'Subutai v' + defaults.getVersion();
if (porto.crx || porto.sfx) {
if (porto.crx || porto.sfx || porto.webex) {
openpgp.initWorker('dep/openpgp.worker.js');
} else if (porto.ffa) {
var CWorker = porto.util.getWorker();
openpgp.initWorker('', {
worker: new CWorker(porto.data.url('openpgp.worker.min.js'))
});
}
}

Expand Down Expand Up @@ -499,7 +494,7 @@ define(function(require, exports, module) {

function migrate08() {
var prefs = getPreferences();
if (porto.crx && prefs.migrate08 && prefs.migrate08.done) {
if ( (porto.webex || porto.crx) && prefs.migrate08 && prefs.migrate08.done) {
window.localStorage.removeItem("privatekeys");
window.localStorage.removeItem("publickeys");
delete prefs.migrate08;
Expand Down
2 changes: 1 addition & 1 deletion common/res/defaults.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.0.0",
"version": "4.0.0",
"watch_list": [
{
"active": true,
Expand Down
33 changes: 17 additions & 16 deletions common/ui/_popup-export-key.html
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<div class="b-popup" id="js-popup-settings">
<div class="b-popup__header">
<div class="b-title">
Export keys
<a href="#" class="bp-close-modal-button g-right">
<i class="fa fa-times"></i>
</a>
<div class="b-popup__header">
<div class="b-title">
Export keys
<a href="#" class="bp-close-modal-button g-right">
<i class="fa fa-times"></i>
</a>
</div>
</div>
</div>
<div class="b-popup__body">
<div class="b-form-wrapper g-margin-bottom">
<div class="b-popup__body">
<div class="b-form-wrapper g-margin-bottom">
<textarea id="key"
class="b-form-input b-form-input_full b-form-input_textarea bp-export-clipboard"
style="font-size:12px; height: 200px; font-family: monospace; resize: none" tabindex="0">
Paste key text here
</textarea>
</div>
<div>
<input id="export" type="text" class="b-form-input b-form-input_fix-size-2 bp-export-filename" tabindex="1">
<a class="bp-keypair-export hide" data-l10n-id="key_export_download" style="display: none"></a>
<button class="b-btn b-btn_blue confirm g-right" tabindex="2"><i class="fa fa-arrow-up"></i> Export</button>
</div>
</div>
<div>
<input id="export" type="text" class="b-form-input b-form-input_fix-size-2 bp-export-filename" tabindex="1">
<a id="bp-export-certificate-keypair" class="bp-keypair-export hide" data-l10n-id="key_export_download"
style="display: none"></a>
<button class="b-btn b-btn_blue confirm g-right" tabindex="2"><i class="fa fa-arrow-up"></i> Export</button>
</div>

</div>
</div>
</div>
Loading

0 comments on commit 1623d65

Please sign in to comment.