improve code, doc, tooling

This commit is contained in:
Thomas Rupprecht 2022-12-24 02:31:56 +01:00
parent e812aa8feb
commit 863315d77c
10 changed files with 70 additions and 1235 deletions

1
.npmrc Normal file
View File

@ -0,0 +1 @@
lockfile-version=3

View File

@ -10,6 +10,8 @@
## Install ## Install
```ssh ```ssh
$ git clone https://gitea.usrspace.at/XimeX/usrspace-browser-addon.git $ git clone https://gitea.usrspace.at/XimeX/usrspace-browser-addon.git
$ npm install -g web-ext
$ npm install
``` ```
- Open `about:debugging` or `about:debugging-new` in Firefox - Open `about:debugging` or `about:debugging-new` in Firefox
@ -20,9 +22,8 @@ $ git clone https://gitea.usrspace.at/XimeX/usrspace-browser-addon.git
## Release ## Release
```ssh ```ssh
$ git commit -m "release vX.Y" $ npm version {major|minor|patch|...}
$ git tag vX.Y $ web-ext build
$ web-ext build -n _usr_space-X.Y.zip
``` ```
## Credits ## Credits

View File

@ -1,10 +1,10 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>/usr/space</title> <title>/usr/space</title>
<script type="application/javascript" src="../browser-polyfill.js"></script> <script type="application/javascript" src="../node_modules/webextension-polyfill/dist/browser-polyfill.js"></script>
<script type="application/javascript" src="../config.js"></script> <script type="application/javascript" src="../config.js"></script>
<script type="application/javascript" src="index.js"></script> <script type="application/javascript" src="index.js"></script>
</head> </head>
</html> </html>

File diff suppressed because it is too large Load Diff

View File

@ -6,19 +6,19 @@ window.Config = {
quickLinks: [ quickLinks: [
{ {
url: 'https://www.usrspace.at/', url: 'https://www.usrspace.at/',
text: 'Homepage' text: 'Homepage',
}, },
{ {
url: 'https://wiki.usrspace.at/', url: 'https://wiki.usrspace.at/',
text: 'Wiki' text: 'Wiki',
}, },
{ {
url: 'https://gitea.usrspace.at/', url: 'https://gitea.usrspace.at/',
text: 'Gitea' text: 'Gitea',
}, },
{ {
url: 'https://cloud.usrspace.at/', url: 'https://cloud.usrspace.at/',
text: 'Nextcloud' text: 'Nextcloud',
} },
] ],
}; };

View File

@ -2,7 +2,7 @@
"manifest_version": 2, "manifest_version": 2,
"name": "/usr/space", "name": "/usr/space",
"version": "0.7", "version": "0.7",
"description": "An Add-on for the Hacker-/Maker-Space /usr/space.", "description": "WebExtension for the Hacker-/Maker-Space /usr/space",
"icons": { "icons": {
"48": "icons/favicon.svg", "48": "icons/favicon.svg",
"96": "icons/favicon.svg" "96": "icons/favicon.svg"

52
package-lock.json generated
View File

@ -1,26 +1,30 @@
{ {
"name": "usrspace-browser-addon", "name": "usrspace-browser-addon",
"lockfileVersion": 2, "version": "0.7.0",
"requires": true, "lockfileVersion": 3,
"packages": { "requires": true,
"": { "packages": {
"devDependencies": { "": {
"web-ext-types": "^3.2.1" "name": "usrspace-browser-addon",
} "version": "0.7.0",
}, "license": "MIT",
"node_modules/web-ext-types": { "dependencies": {
"version": "3.2.1", "webextension-polyfill": "^0.10.0"
"resolved": "https://registry.npmjs.org/web-ext-types/-/web-ext-types-3.2.1.tgz", },
"integrity": "sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew==", "devDependencies": {
"dev": true "web-ext-types": "^3.2.1"
} }
}, },
"dependencies": { "node_modules/web-ext-types": {
"web-ext-types": { "version": "3.2.1",
"version": "3.2.1", "resolved": "https://registry.npmjs.org/web-ext-types/-/web-ext-types-3.2.1.tgz",
"resolved": "https://registry.npmjs.org/web-ext-types/-/web-ext-types-3.2.1.tgz", "integrity": "sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew==",
"integrity": "sha512-oQZYDU3W8X867h8Jmt3129kRVKklz70db40Y6OzoTTuzOJpF/dB2KULJUf0txVPyUUXuyzV8GmT3nVvRHoG+Ew==", "dev": true
"dev": true },
} "node_modules/webextension-polyfill": {
} "version": "0.10.0",
"resolved": "https://registry.npmjs.org/webextension-polyfill/-/webextension-polyfill-0.10.0.tgz",
"integrity": "sha512-c5s35LgVa5tFaHhrZDnr3FpQpjj1BB+RXhLTYUxGqBVN460HkbM8TBtEqdXWbpTKfzwCcjAZVF7zXCYSKtcp9g=="
}
}
} }

View File

@ -1,5 +1,20 @@
{ {
"devDependencies": { "name": "usrspace-browser-addon",
"web-ext-types": "^3.2.1" "description": "WebExtension for the Hacker-/Maker-Space /usr/space",
} "version": "0.7.0",
"dependencies": {
"webextension-polyfill": "^0.10.0"
},
"devDependencies": {
"web-ext-types": "^3.2.1"
},
"repository": {
"type": "git",
"url": "https://gitea.usrspace.at/XimeX/usrspace-browser-addon"
},
"keywords": [
"/usr/space"
],
"author": "Thomas Rupprecht",
"license": "MIT"
} }

View File

@ -1,7 +1,7 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="de"> <html lang="de">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<title>/usr/space</title> <title>/usr/space</title>
<link rel="stylesheet" href="index.css" /> <link rel="stylesheet" href="index.css" />
</head> </head>
@ -63,7 +63,7 @@
</details> </details>
</section> </section>
<script type="application/javascript" src="../browser-polyfill.js"></script> <script type="application/javascript" src="../node_modules/webextension-polyfill/dist/browser-polyfill.js"></script>
<script type="application/javascript" src="../config.js"></script> <script type="application/javascript" src="../config.js"></script>
<script type="application/javascript" src="index.js"></script> <script type="application/javascript" src="index.js"></script>
</body> </body>

View File

@ -17,10 +17,11 @@ const doorOpenSVG = `
</svg> </svg>
`; `;
const dateTimeFormat = Intl.DateTimeFormat([], {dateStyle: "medium", timeStyle: "short"});
async function linkElementClickListener(event) { async function linkElementClickListener(event) {
try { try {
const tab = await browser.tabs.create({url: event.currentTarget.dataset.url}); await browser.tabs.create({url: event.currentTarget.dataset.url});
// console.log(tab);
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
@ -67,7 +68,7 @@ function updateNextEvent(nextEvents) {
const timeElement = document.createElement('time'); const timeElement = document.createElement('time');
strongElement.textContent = nextEventDateEvent.name; strongElement.textContent = nextEventDateEvent.name;
timeElement.datetime = beginDate.toISOString(); timeElement.datetime = beginDate.toISOString();
const dateNode = document.createTextNode(beginDate.toLocaleString([], {dateStyle: "medium", timeStyle: "short"})); const dateNode = document.createTextNode(dateTimeFormat.format(beginDate));
// divElement.innerText = ''; // divElement.innerText = '';
divElement.append(strongElement, ' ', timeElement); divElement.append(strongElement, ' ', timeElement);
timeElement.append(dateNode); timeElement.append(dateNode);
@ -91,7 +92,7 @@ function updateSpaceApiJson(spaceApi) {
function updateState(spaceApi) { function updateState(spaceApi) {
const stateElement = document.getElementById('state'); const stateElement = document.getElementById('state');
const since = new Date(spaceApi.state.lastchange * 1000); const since = new Date(spaceApi.state.lastchange * 1000);
const sinceStr = ` seit <time datetime="${since.toISOString()}">${since.toLocaleString([], {dateStyle: "medium", timeStyle: "short"})}</time>`; const sinceStr = ` seit <time datetime="${since.toISOString()}">${dateTimeFormat.format(since)}</time>`;
if (spaceApi.state.open) { if (spaceApi.state.open) {
stateElement.innerHTML = `${doorOpenSVG}Offen ${sinceStr}`; stateElement.innerHTML = `${doorOpenSVG}Offen ${sinceStr}`;
} else { } else {