Skip to content

Commit

Permalink
add attribution to devicePictures
Browse files Browse the repository at this point in the history
Text is translatable in different languages with configurable source and license
  • Loading branch information
maurerle authored and MyIgel committed Oct 20, 2023
1 parent eabafaa commit 35a9eef
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
4 changes: 3 additions & 1 deletion config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@
"title": "Bild der Wochenstatistik"
}
],
"hwImg": "https://map.aachen.freifunk.net/router-images/{MODEL_NORMALIZED}.svg",
"devicePictures": "https://map.aachen.freifunk.net/pictures-svg/{MODEL_NORMALIZED}.svg",
"devicePicturesSource": "<a href='https://github.com/freifunk/device-pictures'>https://github.com/freifunk/device-pictures</a>",
"devicePicturesLicense": "CC-BY-NC-SA 4.0",
"node_custom": "/[^a-z0-9\\-\\.]/ig",
"deprecation_text": "Hier kann ein eigener Text für die Deprecation Warning (inkl. HTML) stehen!",
"deprecation_enabled": true
Expand Down
8 changes: 7 additions & 1 deletion lib/about.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const About = function () {
export const About = function (picturesSource, picturesLicense) {
this.render = function render(d) {
d.innerHTML =
_.t("sidebar.aboutInfo") +
Expand Down Expand Up @@ -29,6 +29,12 @@ export const About = function () {
_.t("others") +
"</span>" +
"</p>" +
(picturesSource
? _.t("sidebar.devicePicturesAttribution", {
pictures_source: picturesSource,
pictures_license: picturesLicense,
})
: "") +
"<h3>Feel free to contribute!</h3>" +
"<p>Please support this meshviewer-fork by opening issues or sending pull requests!</p>" +
'<p><a href="https://github.com/freifunk/meshviewer">' +
Expand Down
2 changes: 1 addition & 1 deletion lib/gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export const Gui = function (language) {
var nodelist = new Nodelist();
var linklist = new Linklist(linkScale);
var statistics = new Proportions(fanout);
var about = new About();
var about = new About(config.devicePicturesSource, config.devicePicturesLicense);

fanoutUnfiltered.add(legend);
fanoutUnfiltered.add(newnodeslist);
Expand Down
17 changes: 10 additions & 7 deletions lib/infobox/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function showStatImg(o, d) {
return helper.showStat(V, o, subst);
}

function showHwImg(o, d) {
function showDevicePictures(o, d) {
if (!d.model) {
return null;
}
Expand All @@ -32,7 +32,7 @@ function showHwImg(o, d) {
.replace(/^-+/, "")
.replace(/-+$/, ""),
};
return helper.showHwImg(V, o, subst);
return helper.showDevicePicture(V, o, subst);
}

export function Node(el, d, linkScale, nodeDict) {
Expand Down Expand Up @@ -118,7 +118,7 @@ export function Node(el, d, linkScale, nodeDict) {

var self = this;
var header = document.createElement("h2");
var hwImage = document.createElement("div");
var devicePicture = document.createElement("div");
var table = document.createElement("table");
var images = document.createElement("div");
var neighbours = document.createElement("h3");
Expand Down Expand Up @@ -173,7 +173,7 @@ export function Node(el, d, linkScale, nodeDict) {
deprecation.innerHTML = "<div>" + (config.deprecation_text || _.t("deprecation")) + "</div>";

el.appendChild(header);
el.appendChild(hwImage);
el.appendChild(devicePicture);
el.appendChild(deprecation);
el.appendChild(table);
el.appendChild(neighbours);
Expand All @@ -183,13 +183,16 @@ export function Node(el, d, linkScale, nodeDict) {
self.render = function render() {
V.patch(header, V.h("h2", d.hostname));

var hwImg = showHwImg(config.hwImg, d);
var hwImgContainerData = {
var devicePictures = showDevicePictures(config.devicePictures, d);
var devicePicturesContainerData = {
attrs: {
class: "hw-img-container",
},
};
hwImage = V.patch(hwImage, hwImg ? V.h("div", hwImgContainerData, hwImg) : V.h("div"));
devicePicture = V.patch(
devicePicture,
devicePictures ? V.h("div", devicePicturesContainerData, devicePictures) : V.h("div"),
);

var children = [];

Expand Down
2 changes: 1 addition & 1 deletion lib/utils/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const showStat = function showStat(V, o, subst) {
return V.h("div", content);
};

export const showHwImg = function showHwImg(V, o, subst) {
export const showDevicePicture = function showDevicePicture(V, o, subst) {
if (!o) {
return null;
}
Expand Down
1 change: 1 addition & 0 deletions public/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"nodeOffline": "offline",
"nodeUplink": "uplink",
"aboutInfo": "<h2>Über Meshviewer</h2><p>Mit Doppelklick kann man in die Karte hinein zoomen und Shift+Doppelklick heraus zoomen.</p>",
"devicePicturesAttribution": "<h3>Hardware-Bilder Attribution</h3><p>Die Hardware Bilder sind unter %{pictures_source} lizensiert unter %{pictures_license} verfügbar</p>",
"actual": "Aktuell",
"stats": "Statistiken",
"about": "Über",
Expand Down
1 change: 1 addition & 0 deletions public/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"nodeOffline": "offline",
"nodeUplink": "uplink",
"aboutInfo": "<h2>About Meshviewer</h2> <p>You can zoom in with double-click and zoom out with shift+double-click</p>",
"devicePicturesAttribution": "<h3>Device Pictures Attribution</h3><p>The hardware pictures are available at %{pictures_source} licensed under %{pictures_license}</p>",
"actual": "Current",
"stats": "Statistics",
"about": "About",
Expand Down

0 comments on commit 35a9eef

Please sign in to comment.