From e5ed1d3455b0f7aa2015c47ab79231afdda2f9a9 Mon Sep 17 00:00:00 2001
From: Lena Schimmel
Date: Sun, 16 Jun 2019 20:24:53 +0200
Subject: [PATCH] Actually runable as cmd or in the browser, using different
main files.
---
node/server/server.js | 1 +
node/tool/browser.js | 9 +++++++
node/tool/cmd.js | 18 +++++++++++++
node/tool/compile.sh | 3 ++-
node/tool/package.json | 6 +++--
node/tool/{queerallyear.js => recolor.js} | 31 +++--------------------
web/index.html | 3 +--
web/js/main.js | 4 ---
8 files changed, 38 insertions(+), 37 deletions(-)
create mode 100644 node/tool/browser.js
create mode 100644 node/tool/cmd.js
rename node/tool/{queerallyear.js => recolor.js} (82%)
delete mode 100755 web/js/main.js
diff --git a/node/server/server.js b/node/server/server.js
index b8063af..71ff416 100644
--- a/node/server/server.js
+++ b/node/server/server.js
@@ -6,6 +6,7 @@ var app = express();
var index = fs.readFileSync("../../web/index.html").toString();
var logo = fs.readFileSync("../../web/img/logo.svg").toString();
+logo = logo.replace('', logo);
app.get('/', function (req, res) {
diff --git a/node/tool/browser.js b/node/tool/browser.js
new file mode 100644
index 0000000..10d6971
--- /dev/null
+++ b/node/tool/browser.js
@@ -0,0 +1,9 @@
+const recolor = require('./recolor.js');
+const flags = require('./flags.js');
+
+var gradients = window.document.getElementsByTagName("defs").item(0);
+recolor.processGradients(gradients, flags.ace);
+
+window.showflag = function(flagname) {
+ recolor.processGradients(gradients, flags[flagname]);
+}
\ No newline at end of file
diff --git a/node/tool/cmd.js b/node/tool/cmd.js
new file mode 100644
index 0000000..4b77a72
--- /dev/null
+++ b/node/tool/cmd.js
@@ -0,0 +1,18 @@
+const jsdom = require("jsdom");
+const { JSDOM } = jsdom;
+const fs = require('fs');
+
+const recolor = require('./recolor.js');
+const flags = require('./flags.js');
+
+function processSvgFile() {
+ JSDOM.fromFile("../../web/img/logo.svg", {} ).then(dom => {
+ var doc = dom.window.document;
+ //var gradients = dom.window.document.querySelector("defs");
+ var gradients = doc.getElementsByTagName("defs").item(0);
+ recolor.processGradients(gradients, flags.pan);
+ fs.writeFileSync("../output.svg", dom.serialize());
+ });
+}
+
+processSvgFile();
\ No newline at end of file
diff --git a/node/tool/compile.sh b/node/tool/compile.sh
index 2bcdc5b..6188cea 100755
--- a/node/tool/compile.sh
+++ b/node/tool/compile.sh
@@ -1 +1,2 @@
-browserify queerallyear.js > ../../web/js/modules.js
\ No newline at end of file
+browserify browser.js > ../../web/js/modules.js
+ls -l ../../web/js/modules.js
\ No newline at end of file
diff --git a/node/tool/package.json b/node/tool/package.json
index 809197e..f905b4c 100644
--- a/node/tool/package.json
+++ b/node/tool/package.json
@@ -6,6 +6,8 @@
"jsdom": " ^15.1.1"
},
"scripts": {
- "start": "node queerallyear.js"
- }
+ "start": "node cmd.js"
+ },
+ "main" : "cmd.js",
+ "browser" : "browser.js"
}
diff --git a/node/tool/queerallyear.js b/node/tool/recolor.js
similarity index 82%
rename from node/tool/queerallyear.js
rename to node/tool/recolor.js
index 702fcc7..d948afd 100644
--- a/node/tool/queerallyear.js
+++ b/node/tool/recolor.js
@@ -1,27 +1,5 @@
var util = require('util');
-var fs = require('fs');
var color = require('color');
-var flags = require('./flags.js');
-const jsdom = require("jsdom");
-const { JSDOM } = jsdom;
-
-function processSvgFile() {
- JSDOM.fromFile("../../web/img/logo.svg", {} ).then(dom => {
- var doc = dom.window.document;
- //var gradients = dom.window.document.querySelector("defs");
- var gradients = doc.getElementsByTagName("defs").item(0);
- processGradients(gradients);
- fs.writeFileSync("../output.svg", dom.serialize());
- });
-}
-
-function processSvgInline() {
- // TODO find element
- // TODO process
- // DONE, nothing to "output" because we work inplace
-}
-
-processSvgFile();
var rangesL = {};
var rangesS = {};
@@ -30,7 +8,7 @@ composedRangesL = {};
composedRangesS = {};
// the parameter "gradients" must be the DOM element with tag "defs" from the SVG file.
-function processGradients(gradients) {
+exports.processGradients = function(gradients, flag) {
for (let i = 0; i < gradients.children.length; i++) {
const gradient = gradients.children.item(i);
var id = gradient.id;
@@ -62,15 +40,13 @@ function processGradients(gradients) {
}
}
- targetColors = flags.ace;
-
for (let i = 0; i < gradients.children.length; i++) {
const gradient = gradients.children.item(i);
var id = gradient.id;
if (id.length == 3) {
var letter = id.substring(0,2);
- var targetColor = targetColors[letter];
+ var targetColor = flag[letter];
var [th, ts, tl] = color(targetColor).hsl().color;
var stops = gradient.children;
var diffLightness = adaptRange(composedRangesL[letter], tl);
@@ -148,5 +124,4 @@ function getRange(stops, index) {
"mid": (min + max) / 2,
"width": max - min
};
-}
-
+}
\ No newline at end of file
diff --git a/web/index.html b/web/index.html
index a64fa41..f36d6c9 100755
--- a/web/index.html
+++ b/web/index.html
@@ -46,7 +46,7 @@
Wir nehmen diese Einladung gerne an.
- Denn wir sind nicht nur gay, sondern auch lesbisch, bi, pan, asexuell,
+ Denn wir sind nicht nur gay, sondern auch lesbisch, bi , pan , asexuell,
trans, polyamor, oder auch einfach: queer.
@@ -63,7 +63,6 @@
-