Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Privacy Panel new pull request #25688

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .jshintignore
Expand Up @@ -7,6 +7,7 @@ apps/calendar/build/**
apps/calendar/js/ext/**
apps/camera/js/vendor/**
apps/camera/test/**
apps/privacy-panel/js/vendor/**
apps/system/camera/**
build/r.js
build/csslinter.js
Expand Down
11 changes: 11 additions & 0 deletions apps/privacy-panel/.jshintrc
@@ -0,0 +1,11 @@
{
"extends": "../../.jshintrc",
"predef": [
"define",
"require",
"Promise",
"crypto",
"TextEncoder",
"TextDecoder"
]
}
89 changes: 89 additions & 0 deletions apps/privacy-panel/build/build.js
@@ -0,0 +1,89 @@
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure we can rm -r apps/privacy-panel/build

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, project will work, but build config allow us to combine all files into one file thanks to requirejs optimizer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the gaia build system also does this kind of optimizations, so it might be redundant.
anyway, I'm fine with it if we have make test-perf results showing that it helps, otherwise we shouldn't add the complexity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


/* global require, exports, dump */
var utils = require('utils');

function hasGitCommand() {
return utils.getEnvPath().some(function(path) {
try {
var cmd = utils.getFile(path, 'git');
return cmd.exists();
} catch (e) {
// path not found
}
return false;
});
}

var PrivacyPanelAppBuilder = function() {};

PrivacyPanelAppBuilder.prototype.readVersionFile = function(options) {
var aboutFile = utils.getFile(options.STAGE_APP_DIR, '/resources/about.json');
var aboutFileContent = utils.getFileContent(aboutFile);
return aboutFileContent;
};

PrivacyPanelAppBuilder.prototype.getLastCommit = function(options, callback) {
var gitDir = utils.getFile(options.GAIA_DIR, '.git');
if (gitDir.exists() && hasGitCommand()) {
var git = new utils.Commander('git');
var stderr, stdout;
var args = [
'--git-dir=' + gitDir.path,
'log',
'--format=%H',
'HEAD',
'-1'
];

var cmdOptions = {
stdout: function(data) {
stdout = data;
},
stderr: function(data) {
stderr = data;
},
done: function(data) {
if (data.exitCode === 0) {
utils.log('privacy-panel-app-build', 'Last commit: ' + stdout);
callback(stdout);
}
}
};

git.initPath(utils.getEnvPath());
git.runWithSubprocess(args, cmdOptions);
}
};

PrivacyPanelAppBuilder.prototype.executeRjs = function(options) {
var optimize = 'optimize=' +
(options.GAIA_OPTIMIZE === '1' ? 'uglify2' : 'none');
var configFile = utils.getFile(options.APP_DIR, 'build',
'settings.build.jslike');
var r = require('r-wrapper').get(options.GAIA_DIR);
r.optimize([configFile.path, optimize], function() {
dump('require.js optimize ok\n');
}, function(err) {
dump('require.js optmize failed:\n');
dump(err + '\n');
});
};

PrivacyPanelAppBuilder.prototype.execute = function(options) {
this.executeRjs(options);

this.getLastCommit(options, function(commit) {
var aboutFile = utils
.getFile(options.STAGE_APP_DIR, '/resources/about.json');
var aboutContent = utils
.readJSONFromPath(options.STAGE_APP_DIR + '/resources/about.json');

aboutContent.build = commit.substring(0, 10);
utils.writeContent(aboutFile, JSON.stringify(aboutContent));
});
};

exports.execute = function(options) {
(new PrivacyPanelAppBuilder()).execute(options);
};
55 changes: 55 additions & 0 deletions apps/privacy-panel/build/settings.build.jslike
@@ -0,0 +1,55 @@
{
appDir: '..',
baseUrl: 'js',
mainConfigFile: '../js/app.js',
dir: '../../../build_stage/privacy-panel',

// Set the path to "empty" to prevent the scripts defining global objects
// from being merged or they are removed after the optimization process,
// which makes the objects inaccessible by reference.
// If the inquiries to the object are all performed by requirejs, we can
// remove the path of the object from the following list.
paths: {
'shared/l10n': 'empty:',
'shared/lazy_loader': 'empty:',
'shared/settings_listener': 'empty:',
'shared/settings_url': 'empty:',
'shared/settings_helper': 'empty:',
'shared/async_storage': 'empty:'
},

findNestedDependencies: true,

// Be sure to normalize all define() calls by extracting
// dependencies so Function toString is not needed, and
// lower capability devices like Tarako can optimize
// memory by discarding function sources. This is
// automatically done when an 'optimize' value other than
// 'none' is used. This setting makes sure it happens for
// builds where 'none' is used for 'optimize'.
normalizeDirDefines: 'all',

// optimize is now passed via Makefile's GAIA_SETTINGS_MINIFY
// default is none if not passed at all.
// optimize: 'none',

// Just strip comments, no code compression or mangling.
// Only active if optimize: 'uglify2'
uglify2: {
// Comment out the output section to get rid of line
// returns and tabs spacing.
output: {
beautify: false
},
compress: true,
mangle: true
},

fileExclusionRegExp: /^\.|^test$|^build$/,

// Keeping build dir since Makefile cleans it up and
// preps build dir with the shared directory
keepBuildDir: true,
removeCombined: true,
modules: [{ name: 'app' }]
}
125 changes: 125 additions & 0 deletions apps/privacy-panel/index.html
@@ -0,0 +1,125 @@
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<meta charset="utf-8">

<title>Privacy Panel</title>

<!-- Shared styles -->
<link rel="stylesheet" type="text/css" href="shared/style/headers.css">
<link rel="stylesheet" type="text/css" href="shared/style/switches.css">
<link rel="stylesheet" type="text/css" href="shared/style/buttons.css">
<link rel="stylesheet" type="text/css" href="shared/style/input_areas.css">
<link rel="stylesheet" type="text/css" href="shared/elements/gaia-icons/gaia-icons.css">
<link rel="stylesheet" type="text/css" href="shared/elements/gaia-theme/gaia-theme.css">

<!-- Styles for Privacy Panel -->
<link rel="stylesheet" type="text/css" href="style/lists.css">
<link rel="stylesheet" type="text/css" href="style/menu.css">
<link rel="stylesheet" type="text/css" href="style/main.css">
<link rel="stylesheet" type="text/css" href="style/panels.css">

<!-- Localization -->
<link rel="manifest" href="manifest.webapp">
<link rel="localization" href="locales/countries.{locale}.properties">
<link rel="localization" href="locales/privacypanel.{locale}.properties">

<!-- Templates: Location Accuracy -->
<link rel="import" href="/templates/ala/main.html">
<link rel="import" href="/templates/ala/exceptions.html">
<link rel="import" href="/templates/ala/exception.html">
<link rel="import" href="/templates/ala/custom.html">

<!-- Templates: Remote Privacy Protection -->
<link rel="import" href="/templates/rpp/main.html">
<link rel="import" href="/templates/rpp/change_pass.html">
<link rel="import" href="/templates/rpp/features.html">
<link rel="import" href="/templates/rpp/screenlock.html">
<link rel="import" href="/templates/rpp/passcode.html">

<!-- Templates: Guided Tour -->
<link rel="import" href="/templates/gt/main.html">
<link rel="import" href="/templates/gt/ala_explain.html">
<link rel="import" href="/templates/gt/ala_blur.html">
<link rel="import" href="/templates/gt/ala_custom.html">
<link rel="import" href="/templates/gt/ala_exceptions.html">
<link rel="import" href="/templates/gt/rpp_explain.html">
<link rel="import" href="/templates/gt/rpp_passphrase.html">
<link rel="import" href="/templates/gt/rpp_locate.html">
<link rel="import" href="/templates/gt/rpp_ring.html">
<link rel="import" href="/templates/gt/rpp_lock.html">

<!-- Templates: About -->
<link rel="import" href="/templates/about/main.html">

<!-- Shared JavaScripts -->
<!-- <script src="shared/js/l10n.js"></script> -->
<!-- <script src="shared/js/settings_listener.js"></script> -->
<!-- <script src="shared/js/settings_helper.js"></script> -->
<!-- <script src="shared/js/settings_url.js"></script> -->
<!-- <script src="shared/js/html_imports.js"></script> -->
<!-- <script src="shared/js/lazy_loader.js"></script> -->
<!-- <script src="shared/js/async_storage.js"></script> -->
</head>

<body class="skin-organic theme-settings">

<section role="region" id="root" class="current" data-settings="false">
<header>
<a id="back-to-settings" href="#"><span class="icon gaia-icon-back">back</span></a>
<menu type="toolbar">
<a class="pp-link" href="#about"><span class="icon gaia-icon-about">about</span></a>
</menu>
<h1 data-l10n-id="privacy-panel">Privacy Panel</h1>
</header>
<ul>
<li>
<a id="menu-item-ala" class="menu-item pp-link" data-icon="location" href="#ala-main">
<span data-l10n-id="location-accuracy">Location Accuracy</span>
</a>
</li>
<li>
<a id="menu-item-rpp" class="menu-item pp-link" data-icon="messages" href="#rpp-main">
<span data-l10n-id="remote-privacy-protection">Remote Privacy Protection</span>
</a>
</li>
<li>
<a id="menu-item-gt" class="menu-item pp-link" data-icon="flag" href="#gt-main">
<span data-l10n-id="guided-tour">Guided Tour</span>
</a>
</li>
</ul>
</section>

<!-- Sections: Location Accuracy -->
<section is="ala-main" role="region" id="ala-main" data-section="ala"></section>
<section is="ala-exceptions" role="region" id="ala-exceptions" data-section="ala"></section>
<section is="ala-exception" role="region" id="ala-exception" data-section="ala"></section>
<section is="ala-custom" role="region" id="ala-custom" data-section="ala"></section>

<!-- Sections: Remote Privacy Protection -->
<section is="rpp-main" role="region" id="rpp-main" data-section="rpp"></section>
<section is="rpp-change-pass" role="region" id="rpp-change-pass" data-section="rpp"></section>
<section is="rpp-features" role="region" id="rpp-features" data-section="rpp"></section>
<section is="rpp-screenlock" role="region" id="rpp-screenlock" data-section="rpp"></section>
<section is="rpp-passcode" role="region" id="rpp-passcode" data-section="rpp"></section>

<!-- Sections: Guided Tour -->
<section is="gt-main" role="region" id="gt-main" data-section="gt"></section>
<section is="gt-ala-explain" role="region" id="gt-ala-explain" data-section="gt"></section>
<section is="gt-ala-blur" role="region" id="gt-ala-blur" data-section="gt"></section>
<section is="gt-ala-custom" role="region" id="gt-ala-custom" data-section="gt"></section>
<section is="gt-ala-exceptions" role="region" id="gt-ala-exceptions" data-section="gt"></section>
<section is="gt-rpp-explain" role="region" id="gt-rpp-explain" data-section="gt"></section>
<section is="gt-rpp-passphrase" role="region" id="gt-rpp-passphrase" data-section="gt"></section>
<section is="gt-rpp-locate" role="region" id="gt-rpp-locate" data-section="gt"></section>
<section is="gt-rpp-ring" role="region" id="gt-rpp-ring" data-section="gt"></section>
<section is="gt-rpp-lock" role="region" id="gt-rpp-lock" data-section="gt"></section>

<!-- Sections: About -->
<section is="about" role="region" id="about" data-section="about"></section>

<script data-main="js/app" src="js/vendor/alameda.js"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions apps/privacy-panel/js/about/main.js
@@ -0,0 +1,32 @@
/**
* About page panel
*
* @module About
* @return {Object}
*/
define([
'panels'
],

function(panels) {
'use strict';

var About = {

init: function() {
this.panel = document.getElementById('about');
this.version = this.panel.querySelector('#privacy-panel-version');
this.build = this.panel.querySelector('#privacy-panel-build');

panels.loadJSON('resources/about.json', function(data) {
this.regionsAndCities = data;

this.version.textContent = data.version;
this.build.textContent = data.build;
}.bind(this));
}
};

return About;

});