Skip to content

Commit 06c42e1

Browse files
add auto changing banner image
1 parent 42e27ef commit 06c42e1

File tree

97 files changed

+410
-186
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+410
-186
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"GISCUS",
88
"iframe",
99
"inlinehilite",
10+
"isinstance",
1011
"kroki",
1112
"longjmp",
1213
"lude",
@@ -22,7 +23,8 @@
2223
"SISC",
2324
"svgbob",
2425
"Tinobsy",
25-
"Unskippables"
26+
"Unskippables",
27+
"yazani"
2628
],
2729
"files.associations": {
2830
"*.tmpl": "jinja-html",

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
build: clean
44
./build.py
5+
cp banner_image.js docs/banner_image.js
56

67
clean:
78
rm -rf docs/

banner_image.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function () {
2+
const tagsEl = /** @type {HTMLMetaElement} */ document.querySelector("meta[name=tags]");
3+
if (!tagsEl) return;
4+
const bannerImage = document.querySelector("#banner-image");
5+
const tags = tagsEl.getAttribute("content").split(",").map(s => s.trim()).sort();
6+
7+
var name;
8+
if (Math.random() < 0.05) name = "chicken";
9+
else if (tags.includes("robotics")) name = "armdroid";
10+
else if (tags.includes("game-design")) name = "gaming";
11+
else if (tags.includes("electronics")) name = "soldering"
12+
else if (tags.includes("reverse-engineering")) name = "microscope";
13+
else {
14+
const a = ["lounging", "lounging", "working", null];
15+
name = a[Math.floor(a.length * Math.random())];
16+
if (name == null) return; // Don't change it
17+
}
18+
bannerImage.src = `/images/yazani/yazani_${name}_extracted.png`;
19+
})();

build.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
SITEURL = "https://dragoncoder047.github.io/blog"
1717
LOGO = "/images/yazani/yazani_1_extracted_bg.png"
1818
LOGO_AREA_HTML = ('<a href="/" class="flex-row"><div class="flex-row">'
19-
f'<img src="{LOGO}" style="max-height:10em" />'
19+
f'<img src="{LOGO}" style="max-height:10em" '
20+
'id="banner-image" />'
2021
'<div id="sitename-text">'
2122
f'<h1>{SITENAME}</h1><h2>{SITESUBTITLE}</h2>'
2223
'</div></div></a>')
@@ -25,7 +26,7 @@
2526
THEME_CSS_FILE = "/static/css/theme.css"
2627
THEME_MAIN_CSS = "/static/css/main.css"
2728
THEME_STATIC_DIR = "static/"
28-
EXTRA_JS = "/static/misc.js"
29+
EXTRA_JS = ("/static/misc.js", "/blog/banner_image.js")
2930

3031
GOOGLE_TAG = "G-XR0F89CCGK" # cSpell: ignore ccgk
3132

docs/2021/updating-python/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2022/airdrop-for-non-apple-users/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2022/almost-no-javascript/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2022/change-of-plans/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2022/debugger-almost/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/2022/first-pull-request/index.html

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy