Different base icon & setting

(cherry picked from commit dc61b61)
This commit is contained in:
Gina Häußge committed 2018-06-25 12:47:31 +02:00
1 parent f69718b060
commit 2a67772f46
8 files changed
+112 -31

No files matched your search

+2
View File
@@ -90,6 +90,7 @@ def getSettings():
"name": s.get(["appearance", "name"]),
"color": s.get(["appearance", "color"]),
"colorTransparent": s.getBoolean(["appearance", "colorTransparent"]),
"colorIcon": s.getBoolean(["appearance", "colorIcon"]),
"defaultLanguage": s.get(["appearance", "defaultLanguage"]),
"showFahrenheitAlso": s.getBoolean(["appearance", "showFahrenheitAlso"])
},
@@ -371,6 +372,7 @@ def _saveSettings(data):
if "name" in data["appearance"]: s.set(["appearance", "name"], data["appearance"]["name"])
if "color" in data["appearance"]: s.set(["appearance", "color"], data["appearance"]["color"])
if "colorTransparent" in data["appearance"]: s.setBoolean(["appearance", "colorTransparent"], data["appearance"]["colorTransparent"])
if "colorIcon" in data["appearance"]: s.setBoolean(["appearance", "colorIcon"], data["appearance"]["colorIcon"])
if "defaultLanguage" in data["appearance"]: s.set(["appearance", "defaultLanguage"], data["appearance"]["defaultLanguage"])
if "showFahrenheitAlso" in data["appearance"]: s.setBoolean(["appearance", "showFahrenheitAlso"], data["appearance"]["showFahrenheitAlso"])
+1
View File
@@ -278,6 +278,7 @@ default_settings = {
"name": "",
"color": "default",
"colorTransparent": False,
"colorIcon": True,
"defaultLanguage": "_default",
"showFahrenheitAlso": False,
"components": {
+30
View File
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="svg8868" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 107.1 107.1" style="enable-background:new 0 0 107.1 107.1;" xml:space="preserve">
<style type="text/css">
.st0{fill:#13C100;}
.st1{fill:#169300;}
</style>
<title>mask-theme</title>
<g id="g19353">
<g id="g19426">
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6c-0.9-1.5-1.8-2.9-2.6-4.3c-7.6-11.2-7-20.8,2-29c2.7-2.2,5.8-4,9.1-5.3
c2.2-0.9,4.4-1.6,6.7-2.2c15.8-2.1,29.8,3.2,41.8,15.7c-0.7-1-1.4-2.1-2.2-3.2c-0.3-0.3-0.5-0.5-0.8-0.8
c-0.3-0.7-0.8-1.4-1.5-1.7c-1.5-2-2.6-3.5-3.4-4.5c-0.4-0.7-0.9-1.4-1.5-2c-2.4-2.7-5.2-5.2-8.2-7.3c-3.3-2.1-6.8-3.7-10.6-4.6
C74.3,18.9,71.2,18.4,68,18.2z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

@@ -1,44 +1,73 @@
$(function() {
var save = [];
var save = {};
// Using the theme color (for the top bar), also recolor the favicon tentacle.
function ThemeFavicon(colorname) {
function themeFavicon(colorname) {
save.colorName = colorname;
// the following is from an Apache licensed snippet:
// http://blog.roomanna.com/09-24-2011/dynamically-coloring-a-favicon
var link = document.querySelector("link[rel~='icon']");
var link = document.querySelector("link[rel='shortcut icon']");
if (!link) {
link = document.createElement("link");
link.setAttribute("rel", "shortcut icon");
document.head.appendChild(link);
link = document.createElement("link");
link.setAttribute("rel", "shortcut icon");
document.head.appendChild(link);
}
// try to get the best quality ico possible; prefer svg, the apple-touch pngs are more difficult,
// but all three of the others give a high-quality ico.
var faviconUrl =
// document.querySelector("link[rel~='apple-touch-icon'][sizes~='144x144']").href ||
document.querySelector("link[rel~='mask-icon']").href ||
link.href ||
window.location.origin + "/favicon.ico";
var faviconUrl = document.querySelector("link[rel~='mask-icon-theme']").href
|| link.href
|| window.location.origin + "/favicon.ico";
function onImageLoaded() {
var icosize = 256; // example was 16
// svgs don't really have width
//var icosize = img.width;
var canvas = document.createElement("canvas");
canvas.width = icosize;
canvas.height = icosize;
var context = canvas.getContext("2d");
context.drawImage(img, 0, 0, icosize, icosize);
// https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/globalCompositeOperation
context.globalCompositeOperation = "source-in";
//context.fillStyle = "#d00";
context.fillStyle = save.colorName;
context.fillRect(0, 0, icosize, icosize/1);
context.fill();
link.type = "image/x-icon";
link.href = canvas.toDataURL();
};
var icosize = 256;
var canvas = document.createElement("canvas");
canvas.width = icosize;
canvas.height = icosize;
var context = canvas.getContext("2d");
function grayscale() {
var imageData = context.getImageData(0, 0, canvas.width, canvas.height),
pixels = imageData.data,
i, l, r, g, b, a, luma;
for (i = 0, l = pixels.length; i < l; i += 4) {
a = pixels[i + 3];
if (a === 0) { continue; }
r = pixels[i];
g = pixels[i + 1];
b = pixels[i + 2];
luma = r * 0.2126 + g * 0.7152 + b * 0.0722;
pixels[i] = pixels[i + 1] = pixels[i + 2] = luma;
}
context.putImageData(imageData, 0, 0);
}
function colorize(color, alpha) {
context.globalCompositeOperation = "source-atop";
context.globalAlpha = alpha;
context.fillStyle = color;
context.fillRect(0, 0, canvas.width, canvas.height);
context.globalCompositeOperation = "source-over";
context.globalAlpha = 1.0;
}
context.drawImage(img, 0, 0, canvas.width, canvas.height);
if (save.colorName !== "default") {
grayscale();
colorize(save.colorName, .3);
}
link.type = "image/x-icon";
link.href = canvas.toDataURL();
}
var img = document.createElement("img");
img.addEventListener("load", onImageLoaded);
img.src = faviconUrl;
@@ -50,8 +79,18 @@ $(function() {
self.name = parameters[0].appearance_name;
self.color = parameters[0].appearance_color;
self.colorTransparent = parameters[0].appearance_colorTransparent;
self.colorIcon = parameters[0].appearance_colorIcon;
ThemeFavicon(self.name);
function updateIcon() {
if (self.colorIcon()) {
themeFavicon(self.color());
} else {
themeFavicon("default");
}
}
self.color.subscribe(updateIcon);
self.colorIcon.subscribe(updateIcon);
updateIcon();
self.brand = ko.pureComputed(function() {
if (self.name())
@@ -111,6 +111,7 @@ $(function() {
self.appearance_name = ko.observable(undefined);
self.appearance_color = ko.observable(undefined);
self.appearance_colorTransparent = ko.observable();
self.appearance_colorIcon = ko.observable();
self.appearance_defaultLanguage = ko.observable();
self.appearance_showFahrenheitAlso = ko.observable(undefined);
@@ -15,7 +15,14 @@
<div class="control-group" title="{{ _('For acrylic printers ;)') }}">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: appearance_colorTransparent"> {{ _('Transparent Color') }}
<input type="checkbox" data-bind="checked: appearance_colorTransparent"> {{ _('Transparent color') }}
</label>
</div>
</div>
<div class="control-group" title="{{ _('Also personalize the icon of the browser tab') }}">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: appearance_colorIcon"> {{ _('Colorize favicon (in supported browsers)') }}
</label>
</div>
</div>
+2 -1
View File
@@ -4,7 +4,8 @@
<title data-bind="text: title">OctoPrint</title>
<link rel="shortcut icon" href="{{ url_for('static', filename='img/tentacle-32x32.png') }}">
<link rel="mask-icon" href="{{ url_for('static', filename='img/favicon.svg') }}" color="#56BE37">
<link rel="mask-icon" href="{{ url_for('static', filename='img/mask.svg') }}" color="#56BE37">
<link rel="mask-icon-theme" href="{{ url_for('static', filename='img/mask-theme.svg') }}" color="#56BE37">
<link rel="apple-touch-icon" sizes="114x114" href="{{ url_for('static', filename='img/apple-touch-icon-114x114.png') }}">
<link rel="apple-touch-icon" sizes="144x144" href="{{ url_for('static', filename='img/apple-touch-icon-144x144.png') }}">