Skip to content

Commit 35a9eef

Browse files
maurerleMyIgel
authored andcommitted
add attribution to devicePictures
Text is translatable in different languages with configurable source and license
1 parent eabafaa commit 35a9eef

File tree

7 files changed

+24
-11
lines changed

7 files changed

+24
-11
lines changed

config.example.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,9 @@
6666
"title": "Bild der Wochenstatistik"
6767
}
6868
],
69-
"hwImg": "https://map.aachen.freifunk.net/router-images/{MODEL_NORMALIZED}.svg",
69+
"devicePictures": "https://map.aachen.freifunk.net/pictures-svg/{MODEL_NORMALIZED}.svg",
70+
"devicePicturesSource": "<a href='https://github.com/freifunk/device-pictures'>https://github.com/freifunk/device-pictures</a>",
71+
"devicePicturesLicense": "CC-BY-NC-SA 4.0",
7072
"node_custom": "/[^a-z0-9\\-\\.]/ig",
7173
"deprecation_text": "Hier kann ein eigener Text für die Deprecation Warning (inkl. HTML) stehen!",
7274
"deprecation_enabled": true

lib/about.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const About = function () {
1+
export const About = function (picturesSource, picturesLicense) {
22
this.render = function render(d) {
33
d.innerHTML =
44
_.t("sidebar.aboutInfo") +
@@ -29,6 +29,12 @@ export const About = function () {
2929
_.t("others") +
3030
"</span>" +
3131
"</p>" +
32+
(picturesSource
33+
? _.t("sidebar.devicePicturesAttribution", {
34+
pictures_source: picturesSource,
35+
pictures_license: picturesLicense,
36+
})
37+
: "") +
3238
"<h3>Feel free to contribute!</h3>" +
3339
"<p>Please support this meshviewer-fork by opening issues or sending pull requests!</p>" +
3440
'<p><a href="https://github.com/freifunk/meshviewer">' +

lib/gui.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const Gui = function (language) {
111111
var nodelist = new Nodelist();
112112
var linklist = new Linklist(linkScale);
113113
var statistics = new Proportions(fanout);
114-
var about = new About();
114+
var about = new About(config.devicePicturesSource, config.devicePicturesLicense);
115115

116116
fanoutUnfiltered.add(legend);
117117
fanoutUnfiltered.add(newnodeslist);

lib/infobox/node.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function showStatImg(o, d) {
1515
return helper.showStat(V, o, subst);
1616
}
1717

18-
function showHwImg(o, d) {
18+
function showDevicePictures(o, d) {
1919
if (!d.model) {
2020
return null;
2121
}
@@ -32,7 +32,7 @@ function showHwImg(o, d) {
3232
.replace(/^-+/, "")
3333
.replace(/-+$/, ""),
3434
};
35-
return helper.showHwImg(V, o, subst);
35+
return helper.showDevicePicture(V, o, subst);
3636
}
3737

3838
export function Node(el, d, linkScale, nodeDict) {
@@ -118,7 +118,7 @@ export function Node(el, d, linkScale, nodeDict) {
118118

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

175175
el.appendChild(header);
176-
el.appendChild(hwImage);
176+
el.appendChild(devicePicture);
177177
el.appendChild(deprecation);
178178
el.appendChild(table);
179179
el.appendChild(neighbours);
@@ -183,13 +183,16 @@ export function Node(el, d, linkScale, nodeDict) {
183183
self.render = function render() {
184184
V.patch(header, V.h("h2", d.hostname));
185185

186-
var hwImg = showHwImg(config.hwImg, d);
187-
var hwImgContainerData = {
186+
var devicePictures = showDevicePictures(config.devicePictures, d);
187+
var devicePicturesContainerData = {
188188
attrs: {
189189
class: "hw-img-container",
190190
},
191191
};
192-
hwImage = V.patch(hwImage, hwImg ? V.h("div", hwImgContainerData, hwImg) : V.h("div"));
192+
devicePicture = V.patch(
193+
devicePicture,
194+
devicePictures ? V.h("div", devicePicturesContainerData, devicePictures) : V.h("div"),
195+
);
193196

194197
var children = [];
195198

lib/utils/helper.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const showStat = function showStat(V, o, subst) {
151151
return V.h("div", content);
152152
};
153153

154-
export const showHwImg = function showHwImg(V, o, subst) {
154+
export const showDevicePicture = function showDevicePicture(V, o, subst) {
155155
if (!o) {
156156
return null;
157157
}

public/locale/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"nodeOffline": "offline",
5656
"nodeUplink": "uplink",
5757
"aboutInfo": "<h2>Über Meshviewer</h2><p>Mit Doppelklick kann man in die Karte hinein zoomen und Shift+Doppelklick heraus zoomen.</p>",
58+
"devicePicturesAttribution": "<h3>Hardware-Bilder Attribution</h3><p>Die Hardware Bilder sind unter %{pictures_source} lizensiert unter %{pictures_license} verfügbar</p>",
5859
"actual": "Aktuell",
5960
"stats": "Statistiken",
6061
"about": "Über",

public/locale/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"nodeOffline": "offline",
5656
"nodeUplink": "uplink",
5757
"aboutInfo": "<h2>About Meshviewer</h2> <p>You can zoom in with double-click and zoom out with shift+double-click</p>",
58+
"devicePicturesAttribution": "<h3>Device Pictures Attribution</h3><p>The hardware pictures are available at %{pictures_source} licensed under %{pictures_license}</p>",
5859
"actual": "Current",
5960
"stats": "Statistics",
6061
"about": "About",

0 commit comments

Comments
 (0)