Skip to content

Commit

Permalink
🧅 HTML üreticileri es6 modüle çevir (bun sayesinde)
Browse files Browse the repository at this point in the history
  • Loading branch information
KimlikDAO-bot committed Jan 26, 2024
1 parent b932ece commit 9f2fd8b
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 92 deletions.
2 changes: 1 addition & 1 deletion ana/ağ/Makefile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ana/ağ.birim: ana/ağ/birim.html ana/ağ/*.cjs
ana/ağ.birim: ana/ağ/birim.html ana/ağ/düğümler.js
6 changes: 4 additions & 2 deletions ana/ağ/düğümler.cjs → ana/ağ/düğümler.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const NODES = [
*/
const h = (renk) => (renk.startsWith("#") ? renk : "#" + renk).toUpperCase();

exports.üret = (d) => {
const üret = (d) => {
/** @const {number} */
const n = NODES.length;
const cx = d.width / 2;
Expand All @@ -35,4 +35,6 @@ exports.üret = (d) => {
out += `<text x="${x}" y="${y + 23}" text-anchor="middle" fill="#444">${NODES[i][1]}</text>`;
}
return out;
}
};

export { üret };
2 changes: 1 addition & 1 deletion birim/ağlar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ AĞLAR_INLINE_SVGS := $(addsuffix .isvg,$(addprefix build/birim/ağlar/, $(AĞLA

build/birim/ağlar/birim.keymap: $(call compressions, $(AĞLAR_REQUEST_SVGS))
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(AĞLAR_REQUEST_SVGS)
bun lib/birimler/hasher.js $@ $(AĞLAR_REQUEST_SVGS)

birim/ağlar.birim: build/birim/ağlar/birim.keymap $(AĞLAR_INLINE_SVGS)
3 changes: 2 additions & 1 deletion birim/ağlar/birim.cjs → birim/ağlar/adlar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
exports.Ağlar = {
/** @const {!Object<string, string>} */
export const Adlar = {
"0x1": "Ethereum",
"0xa86a": "Avalanche",
"0x89": "Polygon",
Expand Down
2 changes: 1 addition & 1 deletion birim/blog/2023.12/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/birim/blog/2023.12/banner.webp: birim/blog/2023.12/banner.png

build/birim/blog/2023.12/birim.keymap: build/birim/blog/2023.12/banner.webp
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $<
bun lib/birimler/hasher.js $@ $<
sed -i.bak 's#banner.webp#banner.png#' $@

birim/blog/2023.12.birim: birim/blog/2023.12/birim.html \
Expand Down
2 changes: 1 addition & 1 deletion birim/blog/2024.01/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build/birim/blog/2024.01/banner.webp: birim/blog/2024.01/banner.png

build/birim/blog/2024.01/birim.keymap: build/birim/blog/2024.01/banner.webp
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $<
bun lib/birimler/hasher.js $@ $<
sed -i.bak 's#banner.webp#banner.png#' $@

birim/blog/2024.01.birim: birim/blog/2024.01/birim.html \
Expand Down
2 changes: 1 addition & 1 deletion birim/blog/eliptik-egriler/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ build/birim/blog/eliptik-egriler/banner.webp: birim/blog/eliptik-egriler/banner.
build/birim/blog/eliptik-egriler/birim.keymap: build/birim/blog/eliptik-egriler/banner.webp \
build/birim/paralar/DOBBY.webp
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $^
bun lib/birimler/hasher.js $@ $^
sed -i.bak 's#banner.webp#banner.png#' $@
sed -i.bak 's#DOBBY.webp#DOBBY.png#' $@

Expand Down
2 changes: 1 addition & 1 deletion birim/cüzdan/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ CÜZDAN_REQUEST_SVG_OUT := $(addprefix build/birim/cüzdan/img/, $(CÜZDAN_REQUE
build/birim/cüzdan/birim.keymap: build/birim/ağlar/birim.keymap \
$(call compressions, $(CÜZDAN_REQUEST_SVG_OUT))
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(CÜZDAN_REQUEST_SVG_OUT)
bun lib/birimler/hasher.js $@ $(CÜZDAN_REQUEST_SVG_OUT)
cat $< >> $@

birim/cüzdan.birim: birim/cüzdan/birim.html \
Expand Down
61 changes: 0 additions & 61 deletions birim/cüzdan/ağDüğmesi.cjs

This file was deleted.

25 changes: 25 additions & 0 deletions birim/cüzdan/ağDüğmesi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { readFileSync } from "fs";
import { optimize } from "svgo";
import svgoConfig from "../../lib/birimler/svgoInlineConfig";
import { Adlar } from "../ağlar/adlar";

let out = "";

export const üret = (değerler) => {
if (!("chains" in değerler)) return "";
/** @const {!Array<string>} */
const chains = değerler.chains.split("|");

if (out) return out;

for (const chain of chains) {
const parts = chain.split(",");
if (parts.length > 3) {
return out = optimize(
readFileSync(`birim/ağlar/${Adlar[parts[0]].replaceAll(" ", "").toLowerCase()}.svg`),
svgoConfig
).data;
}
}
return out;
}
10 changes: 5 additions & 5 deletions birim/cüzdan/ağListesi.cjs → birim/cüzdan/ağListesi.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { Ağlar } = require("../ağlar/birim.cjs");
import { Adlar } from "../ağlar/adlar";

exports.üret = (değerler) => {
export const üret = (değerler) => {
if (!("chains" in değerler)) return "";
/** @const {!Array<string>} */
const chains = değerler.chains.split("|");
Expand All @@ -12,10 +12,10 @@ exports.üret = (değerler) => {
return `\n<li id="cud${parts[0]}"${selected ? ' class=sel' : ""}>` +
(selected
? "<span></span>"
: `<img src="/birim/ağlar/${Ağlar[parts[0]].toLowerCase().replaceAll(" ", "")}.svg" width="32" height="32">`) +
: `<img src="/birim/ağlar/${Adlar[parts[0]].toLowerCase().replaceAll(" ", "")}.svg" width="32" height="32">`) +
(parts.length > 1
? ` <div>${Ağlar[parts[0]]}<div class=cuo>${parts[1 + (değerler.dil == "en")]}</div></div>`
: ` ${Ağlar[parts[0]]}`) +
? ` <div>${Adlar[parts[0]]}<div class=cuo>${parts[1 + (değerler.dil == "en")]}</div></div>`
: ` ${Adlar[parts[0]]}`) +
"</li>"
}).join("");
}
2 changes: 1 addition & 1 deletion birim/dil/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ DİL_REQUEST_SVG_OUT := $(addprefix build/birim/dil/, $(DİL_REQUEST_SVG))

build/birim/dil/birim.keymap: $(call compressions, $(DİL_REQUEST_SVG_OUT))
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(DİL_REQUEST_SVG_OUT)
bun lib/birimler/hasher.js $@ $(DİL_REQUEST_SVG_OUT)

birim/dil.birim: birim/dil/birim.html \
build/birim/dil/birim.keymap
2 changes: 1 addition & 1 deletion birim/favicon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ build/favicon.ico: \
build/birim/favicon/birim.keymap: $(call compressions, build/birim/favicon/icon.svg) \
build/birim/favicon/icon32.png
mkdir -p $(dir $@)
node lib/birimler/hasher $@ build/birim/favicon/icon.svg build/birim/favicon/icon32.png
bun lib/birimler/hasher.js $@ build/birim/favicon/icon.svg build/birim/favicon/icon32.png

birim/favicon.birim: birim/favicon/birim.html \
build/birim/favicon/birim.keymap
8 changes: 4 additions & 4 deletions birim/lato/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,24 @@ l400Files = $(addprefix build/birim/lato/,$(addsuffix .$(1), l400))
build/birim/lato/l400.css: birim/lato/l400.css \
build/birim/lato/birim.keymap
mkdir -p $(dir $@)
node lib/birimler/değiştirici $^ -o $@
bun lib/birimler/değiştirici.js $^ -o $@

build/birim/lato/l700-%.css: birim/lato/l700.css \
build/birim/lato/birim-%.keymap
mkdir -p $(dir $@)
node lib/birimler/değiştirici $^ -o $@
bun lib/birimler/değiştirici.js $^ -o $@

build/birim/lato/birim.keymap: \
$(call compressions, $(call l400Files,ttf)) \
$(call l400Files,woff2)
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(call l400Files,ttf) $(call l400Files,woff2)
bun lib/birimler/hasher.js $@ $(call l400Files,ttf) $(call l400Files,woff2)

build/birim/lato/birim-%.keymap: \
$(call compressions, $(call l700Files,%,ttf)) \
$(call l700Files,%,woff2)
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(call l700Files,$*,ttf) $(call l700Files,$*,woff2)
bun lib/birimler/hasher.js $@ $(call l700Files,$*,ttf) $(call l700Files,$*,woff2)

build/birim/lato/%.ttf: birim/lato/%.txt
mkdir -p $(dir $@)
Expand Down
2 changes: 1 addition & 1 deletion birim/paralar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build/birim/paralar/DOBBY.webp: birim/paralar/DOBBY.png
build/birim/paralar/birim.keymap: build/birim/paralar/DOBBY.webp \
$(call compressions, $(BIRIM_PARALAR_SVG_OUT))
mkdir -p $(dir $@)
node lib/birimler/hasher $@ $(BIRIM_PARALAR_SVG_OUT) $<
bun lib/birimler/hasher.js $@ $(BIRIM_PARALAR_SVG_OUT) $<
sed -i.bak 's#.webp#.png#' $@

birim/paralar.birim: build/birim/paralar/birim.keymap
1 change: 1 addition & 0 deletions birim/tckt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ build/TCKT.webp: build/TCKT.png
cwebp -m 6 -pass 10 -q 80 $^ -o $@

birim/tckt.birim: birim/tckt/birim.html \
birim/tckt/üret/*.js \
build/birim/tckt/birim.keymap \
$(BIRIM_TCKT_ASSETS)

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { SVGPathData } = require("svg-pathdata");
import { SVGPathData } from "svg-pathdata";

/**
* Sol alt ve sağ üstte birer halka içeren 2x2 grid ve bu iki halkanın
Expand Down Expand Up @@ -301,10 +301,10 @@ const ŞekilKod = {

let out = "";

exports.üret = () => {
export const üret = () => {
if (!out) {
for (const kod in ŞekilKod)
out += `<path id="${kod}" d="${ŞekilKod[kod].encode()}" />\n `;
}
return out
}
};
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"type": "module",
"scripts": {
"build": "make build",
"start": "make dev",
"test": "bun vitest"
"start": "make dev"
},
"devDependencies": {
"csso-cli": "^4.0.2",
Expand All @@ -25,4 +24,4 @@
"vite": "^5.0.11",
"wrangler": "^3.23.0"
}
}
}

0 comments on commit 9f2fd8b

Please sign in to comment.