Skip to content

Commit

Permalink
enh(web-ext): Add protocol handler in extension manifest, for firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
blavenie committed Jan 3, 2024
1 parent fa8b3b7 commit 329de49
Show file tree
Hide file tree
Showing 13 changed files with 350 additions and 215 deletions.
2 changes: 1 addition & 1 deletion dist/desktop
Submodule desktop updated from 70444a to 532bd7
4 changes: 2 additions & 2 deletions doc/build_android.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ After that you should be able to start the application using `npm start`, and to

You can choose to install

- on Linux, install OpenJDK 8:
- on Linux, install OpenJDK 11:

* ``sudo apt-get install openjdk-8-jdk``
* ``sudo apt-get install openjdk-11-jdk``

- or Oracle JDK 8 (all platforms supported):

Expand Down
4 changes: 2 additions & 2 deletions doc/build_web.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cesium can be build as a simple web application, portable and runnable anywhere.

Follow all the steps defined in the [Development guide](./development_guide.md).

After that you should be able to start the application using `npm start`or `yarn run start`, and to test it.
After that you should be able to start the application using `npm start`or `yarn start`, and to test it.

## Build the unhosted web application

Expand All @@ -23,4 +23,4 @@ After that you should be able to start the application using `npm start`or `yarn

## Publishing to a web site

Uncompress the web archive, then open the `ìndex.html` file in your web browser.
Decompress the web archive, then open the `ìndex.html` file in your web browser.
2 changes: 1 addition & 1 deletion ionic.config.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "Cesium",
"type": "ionic1",
"integrations": {
"cordova": {}
},
"type": "ionic1",
"watchPatterns": [
"www/index.html",
"www/api/index.html",
"www/dist/**/*",
"www/css/*.css"
],
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"lint": "gulp lint",
"install-platforms": "ionic cordova prepare",
"start": "ionic serve",
"start:webExt": "gulp webExtCompile && web-ext run --source-dir ./dist/web/ext/",
"start:webExt": "gulp webExtCompile && web-ext run --source-dir ./dist/web/ext/ --devtools",
"start:android": "ionic cordova run android --color",
"docker:build": "sudo docker build . -t cesium/release",
"docker:run": "sudo docker run -ti --rm -p 8100:8100 -p 35729:35729 -v .:/cesium:rw cesium/release",
Expand Down Expand Up @@ -69,7 +69,7 @@
"@bower_components/ionic": "driftyco/ionic-bower#v1.3.5",
"@bower_components/ionic-material": "zachsoft/Ionic-Material#v0.4.2",
"@bower_components/jdenticon": "dmester/jdenticon#3.1.0",
"@bower_components/js-nacl": "tonyg/js-nacl#1.3.2",
"@bower_components/js-nacl": "tonyg/js-nacl#1.4.0",
"@bower_components/js-scrypt": "tonyg/js-scrypt#v1.2.0",
"@bower_components/leaflet": "Leaflet/Leaflet#v0.7.7",
"@bower_components/leaflet-search": "stefanocudini/leaflet-search#v2.7.2",
Expand Down Expand Up @@ -160,7 +160,7 @@
"phonegap-plugin-barcodescanner": "^8.1.0",
"playup": "^1.1.0",
"vinyl-fs": "^3.0.3",
"web-ext": "^7.6.2",
"web-ext": "^7.9.0",
"yargs": "^5.0.0"
},
"peerDependencies": {
Expand Down Expand Up @@ -218,4 +218,4 @@
"node": ">= 16.17.0",
"yarn": ">= 1.22.0"
}
}
}
5 changes: 5 additions & 0 deletions resources/chrome-ext/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Manifest V3 migration

This folder `chrome-ext` has been created in order to prepare to Manifest V3 format.

This is working well for Chrome, but not yet for Firefox.
53 changes: 53 additions & 0 deletions resources/chrome-ext/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Add browser actions, for WebExtension
* (e.g. to open Cesium in a tab, when integrated as a Firefox extension).
*
* See https://forum.duniter.org/t/premiere-version-du-module-cesium-pour-firefox/6944
*
**/
var browser, chrome;

browser = browser || chrome;

var action = browser.browserAction || (chrome && chrome.action);

var browserExtensionRequirements = browser.tabs && action && action.onClicked;

// If integrated as a browser extension
if (browserExtensionRequirements) {
console.debug("[extension] Initializing...");

/**
* Open Cesium in a new browser's tab
*/
function openInTab() {
console.debug("[extension] Opening Cesium...")
browser.tabs.create({
url: "index.html"
});
}

// Adding browser action
action.onClicked.addListener(openInTab);

// FIXME: finish this code
function checkNotifications() {
console.debug("[extension] Checking for notifications...");

action.setBadgeText({
text: '0'
});
action.setBadgeBackgroundColor({
color: '#387EF5' // = $positive color - see the SCSS theme
});

// Loop, after a delay
setTimeout(function() {
checkNotifications();
}, 60 * 1000 /*1min*/);
}
//checkNotifications();
}
else {
console.error("[extension] Cannot init extension: missing some API requirements (action or tabs");
}
41 changes: 41 additions & 0 deletions resources/chrome-ext/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"manifest_version": 2,
"name": "Cesium",
"version": "1.7.12",
"description": "Cesium Wallet for Ğ1 libre currency",
"icons": {
"32": "img/logo_32px.png",
"60": "img/logo_60px.png",
"96": "img/logo_96px.png",
"144": "img/logo_144px.png",
"192": "img/logo.svg"
},
"permissions": [
"storage"
],
"host_permissions": [
"file:///*",
"*://*/*"
],
"background": {
"service_worker": "background.js",
"scripts": ["background.js"]
},
"browser_action" : {
"default_icon": {
"32": "img/logo_32px.png",
"60": "img/logo_60px.png",
"96": "img/logo_96px.png",
"128": "img/logo_128px.png"
}
},
"action": {
"default_icon": {
"32": "img/logo_32px.png",
"60": "img/logo_60px.png",
"96": "img/logo_96px.png",
"144": "img/logo_144px.png",
"192": "img/logo.svg"
}
}
}
22 changes: 13 additions & 9 deletions resources/web-ext/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,13 @@ var browser, chrome;

browser = browser || chrome;

var browserExtensionRequirements = browser.browserAction && browser.browserAction.onClicked && browser.tabs;
var action = browser.browserAction || (chrome && chrome.action);

var browserExtensionRequirements = browser.tabs && action && action.onClicked;

// If integrated as a browser extension
if (browserExtensionRequirements) {
console.debug("[extension] Initializing...");

/**
* Open Cesium in a new browser's tab
Expand All @@ -22,18 +25,19 @@ if (browserExtensionRequirements) {
browser.tabs.create({
url: "index.html"
});


}

// Adding browser action
action.onClicked.addListener(openInTab);

// FIXME: finish this code
function checkNotifications() {
console.debug("[extension] Checking for notifications...");

browser.browserAction.setBadgeText({
action.setBadgeText({
text: '0'
});
browser.browserAction.setBadgeBackgroundColor({
action.setBadgeBackgroundColor({
color: '#387EF5' // = $positive color - see the SCSS theme
});

Expand All @@ -42,8 +46,8 @@ if (browserExtensionRequirements) {
checkNotifications();
}, 60 * 1000 /*1min*/);
}

// Adding browser action
browser.browserAction.onClicked.addListener(openInTab);

//checkNotifications();
}
else {
console.error("[extension] Cannot init extension: missing some API requirements (action or tabs");
}
13 changes: 11 additions & 2 deletions resources/web-ext/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,23 @@
"32": "img/logo_32px.png",
"60": "img/logo_60px.png",
"96": "img/logo_96px.png",
"128": "img/logo_128px.png"
"128": "img/logo_128px.png",
"192": "img/logo.svg"
}
},
"icons": {
"32": "img/logo_32px.png",
"60": "img/logo_60px.png",
"96": "img/logo_96px.png",
"128": "img/logo_128px.png"
"128": "img/logo_128px.png",
"192": "img/logo.svg"
},
"protocol_handlers": [
{
"protocol": "web+june",
"name": "web Ğ1",
"uriTemplate": "index.html#/app/home?uri=%s"
}
],
"manifest_version": 2
}
4 changes: 2 additions & 2 deletions www/js/config-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ angular.module("cesium.config", [])
"defaultCountry": "France"
}
},
"version": "1.7.11",
"build": "2024-01-02T10:24:48.766Z",
"version": "1.7.12",
"build": "2024-01-02T11:33:49.953Z",
"newIssueUrl": "https://git.duniter.org/clients/cesium-grp/cesium/issues/new"
})

Expand Down
55 changes: 32 additions & 23 deletions www/manifest.json
Original file line number Diff line number Diff line change
@@ -1,38 +1,47 @@
{
"manifest_version": 3,
"short_name": "Cesium",
"name": "Cesium",
"manifest_version": 1,
"version": "1.7.12",
"default_locale": "fr",
"description": "Cesium Wallet for Ğ1 libre currency",
"icons": {
"32": "img/logo_32px.png",
"96": "img/logo_96px.png",
"144": "img/logo_144px.png",
"192": "img/logo.svg"
},
"permissions": [
"storage"
],
"host_permissions": [
"file:///*"
],
"theme": {
"colors": {
"frame": "#1a237e",
"toolbar": "#1a237e",
"ntp_background": "#1a237e",
"ntp_text": "#1a237e",
"button_background": "#1a237e"
"icons": [
{
"src": "img/logo_32px.png",
"sizes": "32x32",
"type": "image/png"
},
{
"src": "img/logo_96px.png",
"sizes": "96x96",
"type": "image/png"
},
{
"src": "img/logo_144px.png",
"sizes": "144x144",
"type": "image/png"
},
{
"src": "img/logo.svg",
"sizes": "192x192",
"type": "image/svg"
}
},
],
"background_color": "#1a237e",
"theme_color": "black",
"dir": "ltr",
"start_url": "/#/app/home",
"display": "standalone",
"protocol_handlers": [
{
"protocol": "june",
"uriTemplate": "/#/app/home?uri=%s"
"name": "Ğ1",
"uriTemplate": "#/app/home?uri=%s"
},
{
"protocol": "web+june",
"uriTemplate": "/#/app/home?uri=%s"
"name": "web Ğ1",
"uriTemplate": "#/app/home?uri=%s"
}
]
}
Loading

0 comments on commit 329de49

Please sign in to comment.