Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

jdenticon: Patch to add CLI options to configure lightness range.

Prakhar Pratyushed70609737e2
diff --git a/package.json b/package.json
index fd4fd880d52..04756e543ef 100644
--- a/package.json
+++ b/package.json
@@ -186,7 +186,8 @@
"svgicons2svgfont": "patches/svgicons2svgfont.patch",
- "autosize": "patches/autosize.patch"
+ "autosize": "patches/autosize.patch",
+ "jdenticon": "patches/jdenticon.patch"
}
},
"nyc": {
diff --git a/patches/jdenticon.patch b/patches/jdenticon.patch
new file mode 100644
index 00000000000..3295806ea92
--- /dev/null
+++ b/patches/jdenticon.patch
@@ -0,0 +1,93 @@
+diff --git a/bin/jdenticon.js b/bin/jdenticon.js
+index 752f5f6277b204928751b555216a1e2655e47289..d5e4b536b1c20c6ecf6eac1575c050cc88794467 100755
+--- a/bin/jdenticon.js
++++ b/bin/jdenticon.js
+@@ -50,6 +50,8 @@ function writeHelp() {
+ console.log(" -f, --format <svg|png> Format of generated icon. Otherwise detected from output path. (default: png)");
+ console.log(" -b, --back-color <value> Background color on format #rgb, #rgba, #rrggbb or #rrggbbaa. (default: transparent)");
+ console.log(" -p, --padding <value> Padding in percent in range 0 to 0.5. (default: 0.08)");
++ console.log(" --lightness-color <min,max> Lightness range of colored shapes in [0,1]. (default: 0.4,0.8)");
++ console.log(" --lightness-grayscale <min,max> Lightness range of grayscale shapes in [0,1]. (default: 0.3,0.9)");
+ console.log(" -v, --version Gets the version of Jdenticon.");
+ console.log(" -h, --help Show this help information.");
+ console.log("");
+@@ -117,10 +119,33 @@ function parseArgs(args) {
+ format: consume(["-f", "--format"], true),
+ padding: consume(["-p", "--padding"], true),
+ backColor: consume(["-b", "--back-color"], true),
++ lightnessColor: consume(["--lightness-color"], true),
++ lightnessGrayscale: consume(["--lightness-grayscale"], true),
+ value: args
+ };
+ }
+
++function parseLightnessRange(value) {
++ var parts = value.split(",");
++ if (parts.length !== 2) {
++ return;
++ }
++
++ var min = Number(parts[0]);
++ var max = Number(parts[1]);
++
++ if (
++ isNaN(min) || isNaN(max) ||
++ min < 0 || min > 1 ||
++ max < 0 || max > 1 ||
++ min > max
++ ) {
++ return;
++ }
++
++ return [min, max];
++}
++
+ function validateArgs(args) {
+ if (args.value.length) {
+
+@@ -153,7 +178,34 @@ function validateArgs(args) {
+ console.warn("WARN Invalid background color specified. Defaults to transparent.");
+ }
+ }
+-
++
++ // Lightness
++ var lightnessColor;
++ if (args.lightnessColor != null) {
++ lightnessColor = parseLightnessRange(args.lightnessColor);
++ if (!lightnessColor) {
++ lightnessColor = [0.4, 0.8];
++ console.warn("WARN Invalid lightness range of colored shapes specified. Defaults to 0.4,0.8.");
++ }
++ }
++
++ var lightnessGrayscale;
++ if (args.lightnessGrayscale != null) {
++ lightnessGrayscale = parseLightnessRange(args.lightnessGrayscale);
++ if (!lightnessGrayscale) {
++ lightnessGrayscale = [0.3, 0.9];
++ console.warn("WARN Invalid lightness range of grayscale shapes specified. Defaults to 0.3,0.9.");
++ }
++ }
++
++ var lightness;
++ if (lightnessColor || lightnessGrayscale) {
++ lightness = {
++ color: lightnessColor,
++ grayscale: lightnessGrayscale
++ };
++ }
++
+ // Format
+ var generateSvg =
+ args.format ? /^svg$/i.test(args.format) :
+@@ -166,7 +218,8 @@ function validateArgs(args) {
+ return {
+ config: {
+ padding: padding,
+- backColor: backColor
++ backColor: backColor,
++ lightness: lightness
+ },
+ output: args.output,
+ size: size,
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index eacb8fef4e5..8b7013d4de3 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -15,6 +15,9 @@ patchedDependencies:
handlebars:
hash: 53ad8d748fa2ca3a7a0502c46f2ed1236eef8162efec84c06849dc83ad9e28e9
path: patches/handlebars.patch
+ jdenticon:
+ hash: 3c1dcb92454760777e96759a0fb26bd5ab8998d0b4ebba771bc38f2c714c36ec
+ path: patches/jdenticon.patch
jquery-caret-plugin:
hash: 1afee996e4f991b021b9432ad558cacb8d078cdd828444dbd39836726b3ba6ad
path: patches/jquery-caret-plugin.patch
@@ -181,7 +184,7 @@ importers:
version: 1.2.4
jdenticon:
specifier: ^3.3.0
- version: 3.3.0
+ version: 3.3.0(patch_hash=3c1dcb92454760777e96759a0fb26bd5ab8998d0b4ebba771bc38f2c714c36ec)
jquery:
specifier: ^4.0.0
version: 4.0.0
@@ -16543,7 +16546,7 @@ snapshots:
optionalDependencies:
'@pkgjs/parseargs': 0.11.0
+ [email protected](patch_hash=3c1dcb92454760777e96759a0fb26bd5ab8998d0b4ebba771bc38f2c714c36ec):
dependencies:
canvas-renderer: 2.2.1
diff --git a/version.py b/version.py
index f4474c2d729..39aabea267e 100644
--- a/version.py
+++ b/version.py
@@ -48,4 +48,4 @@ API_FEATURE_LEVEL = 468
# historical commits sharing the same major version, in which case a
# minor version bump suffices.
-PROVISION_VERSION = (370, 0) # bumped 2026-02-23 to upgrade Python requirements
+PROVISION_VERSION = (370, 1) # bumped 2026-02-24 to patch jdenticon