tangled
alpha
login
or
join now
kokirigla.de
/
nara
0
fork
atom
online Minecraft written book viewer
0
fork
atom
overview
issues
pulls
pipelines
feat(web): pass version when grabbing assets
kokirigla.de
3 weeks ago
982ec075
2976c5a4
verified
This commit was signed with the committer's
known signature
.
kokirigla.de
SSH Key Fingerprint:
SHA256:BlSEtD3ZoKT3iKveofI8gba+lZ9CEolKRM1Pzy3pAwg=
+28
-21
6 changed files
expand all
collapse all
unified
split
src
main.rs
web
assets
stylesheet.css
assets.rs
templates
base.html
book.html
index.html
+2
src/main.rs
···
13
13
pub mod library;
14
14
pub mod web;
15
15
16
16
+
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
17
17
+
16
18
#[tokio::main]
17
19
async fn main() -> anyhow::Result<()> {
18
20
tracing_subscriber::fmt::init();
+6
-2
src/web/assets.rs
···
1
1
+
use std::sync::LazyLock;
2
2
+
1
3
use axum::{
2
4
Router, body::Bytes, http::header, response::IntoResponse, routing::get,
3
5
};
···
16
18
const FONT_BOLD_ITALIC: &[u8; 43716] =
17
19
include_bytes!("assets/font/bold_italic.woff2");
18
20
19
19
-
const CSS_STYLES: &str = include_str!("assets/stylesheet.css");
21
21
+
const CSS_STYLES_TEMPLATE: &str = include_str!("assets/stylesheet.css");
22
22
+
static CSS_STYLES: LazyLock<String> =
23
23
+
LazyLock::new(|| CSS_STYLES_TEMPLATE.replace("__NARA_ASSET_VERSION__", crate::VERSION));
20
24
21
25
const WEBP_MIME_TYPE: &str = "image/webp";
22
26
const WOFF2_MIME_TYPE: &str = "font/woff2";
···
88
92
(header::CONTENT_TYPE, CSS_MIME_TYPE),
89
93
(header::CACHE_CONTROL, CACHE_CONTROL_HEADER),
90
94
],
91
91
-
CSS_STYLES,
95
95
+
CSS_STYLES.as_str(),
92
96
)
93
97
}
94
98
+6
-6
src/web/assets/stylesheet.css
···
1
1
@font-face {
2
2
font-family: "Minecraft";
3
3
-
src: url("/assets/font/regular.woff2") format("woff2");
3
3
+
src: url("/assets/font/regular.woff2?v=__NARA_ASSET_VERSION__") format("woff2");
4
4
font-weight: 400;
5
5
font-style: normal;
6
6
font-display: swap;
···
8
8
9
9
@font-face {
10
10
font-family: "Minecraft";
11
11
-
src: url("/assets/font/bold.woff2") format("woff2");
11
11
+
src: url("/assets/font/bold.woff2?v=__NARA_ASSET_VERSION__") format("woff2");
12
12
font-weight: 700;
13
13
font-style: normal;
14
14
font-display: swap;
···
16
16
17
17
@font-face {
18
18
font-family: "Minecraft";
19
19
-
src: url("/assets/font/italic.woff2") format("woff2");
19
19
+
src: url("/assets/font/italic.woff2?v=__NARA_ASSET_VERSION__") format("woff2");
20
20
font-weight: 400;
21
21
font-style: italic;
22
22
font-display: swap;
···
24
24
25
25
@font-face {
26
26
font-family: "Minecraft";
27
27
-
src: url("/assets/font/bold_italic.woff2") format("woff2");
27
27
+
src: url("/assets/font/bold_italic.woff2?v=__NARA_ASSET_VERSION__") format("woff2");
28
28
font-weight: 700;
29
29
font-style: italic;
30
30
font-display: swap;
···
588
588
width: var(--book-sprite-width);
589
589
height: var(--book-sprite-height);
590
590
position: relative;
591
591
-
background-image: url("/assets/image/book_background.webp");
591
591
+
background-image: url("/assets/image/book_background.webp?v=__NARA_ASSET_VERSION__");
592
592
background-size: 100% 100%;
593
593
background-repeat: no-repeat;
594
594
image-rendering: pixelated;
···
651
651
inset: 0;
652
652
pointer-events: none;
653
653
opacity: 0.6;
654
654
-
background-image: url("/assets/image/glint.webp");
654
654
+
background-image: url("/assets/image/glint.webp?v=__NARA_ASSET_VERSION__");
655
655
background-repeat: repeat;
656
656
background-size: 4rem 4rem;
657
657
background-position: 0 0;
+2
-2
templates/base.html
···
5
5
<meta charset="utf-8" />
6
6
<meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
<meta name="color-scheme" content="light" />
8
8
-
<link rel="stylesheet" href="/assets/stylesheet.css" />
8
8
+
<link rel="stylesheet" href="/assets/stylesheet.css?v={{ crate::VERSION }}" />
9
9
<title>{% block title %}nara{% endblock %}</title>
10
10
{% block head %}{% endblock %}
11
11
</head>
···
22
22
</main>
23
23
</body>
24
24
25
25
-
</html>
25
25
+
</html>
+4
-4
templates/book.html
···
2
2
3
3
{% block title %}{{ book.title }} - nara{% endblock %}
4
4
{% block head %}
5
5
-
<link rel="icon" type="image/webp" href="/assets/image/{{ texture_kind }}/written_book.webp" />
5
5
+
<link rel="icon" type="image/webp" href="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" />
6
6
<meta property="og:site_name" content="nara" />
7
7
<meta property="og:type" content="article" />
8
8
<meta property="og:title" content="{{ book.title }} - nara" />
···
13
13
{% endblock %}
14
14
15
15
{% block page_class %}page detail{% endblock %}
16
16
-
{% block page_attrs %} style="--book-mask: url('/assets/image/{{ texture_kind }}/written_book.webp')"{% endblock %}
16
16
+
{% block page_attrs %} style="--book-mask: url('/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}')"{% endblock %}
17
17
18
18
{% block body %}
19
19
<header class="hero detail-hero">
20
20
<div class="brand">
21
21
<span class="enchanted book-badge">
22
22
-
<img class="item" src="/assets/image/{{ texture_kind }}/written_book.webp" alt="">
22
22
+
<img class="item" src="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" alt="">
23
23
</span>
24
24
<div>
25
25
<p class="eyebrow">Book Detail</p>
···
53
53
{% endfor %}
54
54
</div>
55
55
</section>
56
56
-
{% endblock %}
56
56
+
{% endblock %}
+8
-7
templates/index.html
···
2
2
3
3
{% block title %}nara{% endblock %}
4
4
{% block head %}
5
5
-
<link rel="icon" type="image/webp" href="/assets/image/{{ texture_kind }}/written_book.webp" />
5
5
+
<link rel="icon" type="image/webp" href="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" />
6
6
<meta property="og:site_name" content="nara" />
7
7
<meta property="og:type" content="website" />
8
8
<meta property="og:title" content="nara - Book Archive" />
9
9
<meta property="og:description" content="Browse and search an archive of Minecraft books." />
10
10
-
<meta property="og:image" content="/assets/image/{{ texture_kind }}/written_book.webp" />
10
10
+
<meta property="og:image" content="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" />
11
11
<meta property="og:image:alt" content="Minecraft written book icon" />
12
12
<meta name="twitter:card" content="summary" />
13
13
<meta name="twitter:title" content="nara - Book Archive" />
14
14
<meta name="twitter:description" content="Browse and search an archive of Minecraft books." />
15
15
-
<meta name="twitter:image" content="/assets/image/{{ texture_kind }}/written_book.webp" />
15
15
+
<meta name="twitter:image" content="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" />
16
16
{% endblock %}
17
17
18
18
-
{% block page_attrs %} style="--book-mask: url('/assets/image/{{ texture_kind }}/written_book.webp')"{% endblock %}
18
18
+
{% block page_attrs %} style="--book-mask: url('/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}')"{% endblock %}
19
19
20
20
{% block body %}
21
21
<header class="hero">
22
22
<div class="brand">
23
23
<span class="enchanted book-badge">
24
24
-
<img class="item" src="/assets/image/{{ texture_kind }}/written_book.webp" alt="">
24
24
+
<img class="item" src="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" alt="">
25
25
</span>
26
26
<div>
27
27
<p class="eyebrow">nara</p>
···
137
137
<article class="book-tile">
138
138
<a class="book-icon" href="{{ book.detail_href }}" aria-label="Open {{ book.title }}">
139
139
<span class="enchanted">
140
140
-
<img class="item" src="/assets/image/{{ texture_kind }}/written_book.webp" alt="">
140
140
+
<img class="item"
141
141
+
src="/assets/image/{{ texture_kind }}/written_book.webp?v={{ crate::VERSION }}" alt="">
141
142
</span>
142
143
</a>
143
144
<h3 class="font-minecraft">{{ book.title }}</h3>
···
159
160
{% endif %}
160
161
</section>
161
162
</section>
162
162
-
{% endblock %}
163
163
+
{% endblock %}