1
0
Fork 0

Compare commits

...

2 commits

Author SHA1 Message Date
Adrian Hedqvist c7ff1a75b2 post formatting 2023-03-26 13:58:38 +02:00
Adrian Hedqvist 58f199c35f things 2023-03-26 13:44:49 +02:00
6 changed files with 78 additions and 36 deletions

11
README.md Normal file
View file

@ -0,0 +1,11 @@
# <https://tollyx.net>
## My personal website written in rust
Inspired by [fasterthanli.me], [xeiaso.net], and my own curiousity for learning
how to do web-dev stuff in rust, I started working on this thing.
I do not recommend using this for yourself, at most take a peek how I've done
things and use it as an inspiration on how to write your own website in rust.
[fasterthanli.me]: https://fasterthanli.me
[xeiaso.net]: https://xeiaso.net

View file

@ -10,4 +10,4 @@ here have a squid kid miku to test relative paths:
![Squid kid miku](FbHSmoeUUAA2x-m.png)
modified post test, see if docker skips build using
its cache if only a post has changed.
its cache if only a post has changed.

View file

@ -6,6 +6,12 @@ aliases = ["/blog/hello-world/", "/blog/hello-world.html"]
tags = ["hugo", "jekyll"]
+++
So I've yet again remade this website. This time I've moved from [jekyll](https://jekyllrb.com/) to [hugo](https://gohugo.io/), because I've had to reinstall ruby far too many times and there's always some issue with it preventing me from just getting it up and running so I can update this site. Hugo is just a binary, no need to install anything to get it to run. It's far less of a hassle.
So I've yet again remade this website. This time I've moved from
[jekyll](https://jekyllrb.com/) to [hugo](https://gohugo.io/), because I've had
to reinstall ruby far too many times and there's always some issue with it
preventing me from just getting it up and running so I can update this site.
Hugo is just a binary, no need to install anything to get it to run. It's far
less of a hassle.
If you for whatever reason want to see the old posts (which were basically just dev logs required for some of my school courses), you can find them [here.](@/old/_index.md)
If you for whatever reason want to see the old posts (which were basically just
dev logs required for some of my school courses), you can find them [here.](/archive/)

View file

@ -7,15 +7,36 @@ tags = ["hugo", "zola", "roguelike", "spork"]
Oh boy, it's been a while since I wrote anything on this website, over two years ago!
But I've been thinking of starting to write posts more often, try this proggramming-blogging thing out that seems to have had some sort of resurgance. I don't know if I have anything others will find interesting to read, but I've got a few drafts lying around that I'm gonna try finishing up. We'll see how it goes. Just don't expect me to post things too often - maybe once or twice a month, at most.
But I've been thinking of starting to write posts more often, try this
proggramming-blogging thing out that seems to have had some sort of resurgance.
I don't know if I have anything others will find interesting to read, but I've
got a few drafts lying around that I'm gonna try finishing up. We'll see how it
goes. Just don't expect me to post things too often - maybe once or twice a
month, at most.
And with that, I've moved the website to yet another static website generator, this time I'm using [zola]. Why? It's written in rust. That's pretty much all I got. It's actually very similar to [hugo], which I used previously, but I don't know - zola kinda feels nicer to work with when it comes to templates/themes?
And with that, I've moved the website to yet another static website generator,
this time I'm using [zola]. Why? It's written in rust. That's pretty much all I
got. It's actually very similar to [hugo], which I used previously, but I don't
know - zola kinda feels nicer to work with when it comes to templates/themes?
My latest free-time project I've been working on is yet another roguelike - this time, I'm following a tutorial so that I won't get stuck for too long figuring out architecture stuff. It's being written in rust and the tutorial I'm following is [this one][roguelike-tutorial]. It's pretty great - it's using [specs] which I've tried out multiple times but I never really got a good hang of figuring out how to do stuff with an ECS, so learning more about that has been nice. But I did the stupid mistake of not writing down some small errors in the tutorial, so I'll probably go back and try to find them again and open a few PR's for them. I'll try to write a post or two about the roguelike here as well. But for now, [you can find the source code for it over here][roguelike-src].
My latest free-time project I've been working on is yet another roguelike - this
time, I'm following a tutorial so that I won't get stuck for too long figuring
out architecture stuff. It's being written in rust and the tutorial I'm
following is [this one][roguelike-tutorial]. It's pretty great - it's using
[specs] which I've tried out multiple times but I never really got a good hang
of figuring out how to do stuff with an ECS, so learning more about that has
been nice. But I did the stupid mistake of not writing down some small errors
in the tutorial, so I'll probably go back and try to find them again and open a
few PR's for them. I'll try to write a post or two about the roguelike here as
well. But for now, [you can find the source code for it over here][roguelike-src].
In other news, I bought myself an apartment. I'm moving at the start of June, so that's pretty exciting.
In other news, I bought myself an apartment. I'm moving at the start of June, so
that's pretty exciting.
Also, in case someone actually got my rss feed in their reader - sorry, it broke again when I switched to zola, and from what I've read it'll break again in version 0.11 due to a change I agree with. You'll have to fix the feed link, twice. Again, sorry about that.
Also, in case someone actually got my rss feed in their reader - sorry, it broke
again when I switched to zola, and from what I've read it'll break again in
version 0.11 due to a change I agree with. You'll have to fix the feed link,
twice. Again, sorry about that.
[zola]: https://getzola.org
[hugo]: https://gohugo.io

View file

@ -19,38 +19,32 @@ pub fn router() -> Router {
.fallback_service(tower_http::services::ServeDir::new("./posts"))
}
#[derive(Serialize)]
struct IndexContext<'a> {
#[derive(Serialize, Debug)]
struct PageContext<'a> {
title: &'a str,
posts: Vec<&'a Post>,
}
#[instrument(skip(state))]
pub async fn index(Extension(state): Extension<Arc<State>>) -> Result<Html<String>, WebsiteError> {
let mut posts = state
let mut posts: Vec<&Post> = state
.posts
.values()
.filter(|p| p.is_published())
.collect::<Vec<&Post>>();
.collect();
posts.sort_by_key(|p| &p.date);
posts.reverse();
let ctx = IndexContext {
let ctx = PageContext {
title: "Posts",
posts,
};
let res = match state
.tera
.render("posts_index.html", &tera::Context::from_serialize(ctx)?)
{
Ok(r) => r,
Err(e) => {
error!("failed to render posts index: {}", e);
return Err(e.into());
}
};
let mut c = tera::Context::new();
c.insert("page", &ctx);
c.insert("posts", &posts);
let res = state.tera
.render("posts_index.html", &c)?;
HIT_COUNTER.with_label_values(&["/posts/"]).inc();
Ok(Html(res))
@ -81,7 +75,7 @@ mod tests {
use crate::post::Post;
use super::IndexContext;
use super::PageContext;
#[test]
fn render_index() {
@ -97,15 +91,18 @@ mod tests {
date: None,
..Default::default()
}];
let ctx = IndexContext {
let page = PageContext {
title: "Posts",
posts: posts.iter().collect(),
};
let mut ctx = tera::Context::new();
ctx.insert("page", &page);
ctx.insert("posts", &posts);
let tera = tera::Tera::new("templates/**/*").unwrap();
let _res = tera
.render(
"posts_index.html",
&tera::Context::from_serialize(ctx).unwrap(),
&ctx,
)
.unwrap();
}

View file

@ -1,15 +1,22 @@
{% extends "base.html" %}
{% block main %}
<h1>tollyx</h1>
<h1>tollyx.net</h1>
<p>hi hello welcome to my website it's pretty wip right now yeah ok bye</p>
<h2>todo</h2>
<ul>
<li>static content ✅</li>
<li>sass compilation</li>
<li>post metadata (frontmatter) ✅</li>
<li>rss/atom/jsonfeed</li>
<li>proper error handling ✅ (i guess??)</li>
<li>other pages???</li>
<li>✅ static content</li>
<li>✅ template rendering (tera)</li>
<li>✅ markdown rendering (pulldown_cmark)</li>
<li>✅ post metadata (frontmatter, toml)</li>
<li>✅ app metrics</li>
<li>✅ tests</li>
<li>⬜ page aliases (redirects, for back-compat with old routes)</li>
<li>⬜ sass compilation (rsass? grass?)</li>
<li>⬜ rss/atom/jsonfeed</li>
<li>✅ proper error handling (i guess??)</li>
<li>⬜ other pages???</li>
<li>⬜ opentelemetry?</li>
<li>⬜ fancy styling</li>
</ul>
{% endblock main %}