Dan's Website


2024-10-13

Well I didn't expect it to take this much, but I guess it was going to happen sooner or later. I set up a Droplet on DigialOcean to host the webapp. I also figured out how to use Tera with Rocket, which is a template engine for HTML. It apparently stiches together HTML at request time, which can be very powerful for reading databases or other file-based data. For now, I'm just using it to re-use HTML blocks, like the navigation and heading bar and the first blog post for the about page. Still haven't done the calculator yet hah.

It took me awhile to figure out how to set up the webapp correctly; logging, deployment, file and directory structure. I set up a Docker image for the webapp, copying the resulting release binary and website contents into a working directory in the Docker image. I also wrote a script to deploy it to the Droplet server. It builds the webapp, stops the existing contianer, loads the new one then starts the container again. I save the container ID into a file so its easy to stop for the next deployment.

I store the key for the admin on my local machine but check everything else in. I assume there are better, more secure ways to do all of these things, but it works for now. This felt lot a big leap to go from hosting static pages on github to running my own webapp on a VPS. I will say that I think this will provide a pretty solid base for future features and potentially apps ran off the website, if I ever get there.

2024-09-25

Houston, we have liftoff... 🚀

My first pass at the web application server is complete. It uses Rocket, which seems to be the de-facto framework for server-side programming in Rust. I initially set up a simple file server that also sent the "Content-Type" header field in the HTTP response. I quickly changed that to use the segment of the URL passed by the user to return content.

Initially, it still just grabs the location passed by the user (everything after danielali.com), adds ".html" and attempts to read that file. If it doesn't exist, you get 404'd, if it does, you get some fresh website content. So now you should be able to go to danielali.com/blog/ and you'll get the contents of what used to be blog.html.

I'm sure all this will change once I start actually attempting to serve dynamic HTML content, like I described in my last post. That's all I have steam for right now. Lots to do. I should really go back and edit old posts.

2024-09-24

I have a few ideas in mind for what next to program. They include writing a 4-function calculator and an "About" page. For the "About" page I want it to show the content from my first post. I'm not a D.R.Y. principal zealot, but I'd rather not copy/paste that content, I'd rather it just source it from the same place. We have technology. It can be done.

Additionally, I noticed when switching between the pages I have, the navigation must be represented in each page. This is another minor peice of code I'd rather not copy/paste everywhere. I'm sure I'll run through five or six different "themes" for the navigation bar in a given day, depending on how much caffine I've had. ☕

In my humble opinion the navigation portion seems like the most important feature to get right first. This will also help craft the about page. While I'm sure everyone is constantly hitting refresh to use the calculator but I'm afraid it will have to wait.

Some time later...

Holy moly, creating re-usable HTML is not a simple thing. I learned that I would probably have to server a dynamic HTML page. This means setting up a web application in addition to a web server (two processes already???). The web application will piece together the request page and send it to the web server to return to the user. This means diving into server-side programming almost right away, which I did not anticipate.

Rust has always been something I've flirted with, but never actually dated in a professional sense. I want to use Rust as my back-end language, even though MSDN recommends Python + Django because its cool. After flippantly deciding which language I wanted to focus on, I asked Perplexity AI to write a Rust-based web application for a blogging website. To me, what is useful about this is knowning what a code base that does this generally looks like. I learned in its response that it anticipated using a HTML template engine called Tera. Now we're cutting through all that other stuff to get to what I really wanted; dynamic HTML pages.

As an aside, I wonder too if this means I can't just use GitHub Pages to serve up some static webpages 🙁. My guess is GitHub would probably not host a bunch of custom binaries serving files from their servers. So long free hosting...

I installed Rust on my Windows 11 laptop and started putting an application together. I will update on my progress, but it won't be reflected until I can figure out what I have to do for hosting. Running my own server would be cool though.

2024-09-13

Hello, I am a computer engineer that typically works on embedded Linux devices. I have wanted to learn how to build a website for some time now. I believe the best way to learn is to do, so I will be attempting to document my progress and make various features around this content. Something of a self-licking ice cream cone.

I am aware of a myriad of web development frameworks, node.js, databases, dynamic content, etc. that all help speed up the development of building a website and its features, but I'm just beginning on my understanding of web development. I plan on learning as much as I can about each of these, but I also want to do this the right way and start from the ground up. As far as I can tell, the web is built on HTML and CSS, so I thought that would be a good place to start. I am dating myself here, but I also have some experience with HTML from customizing my MySpace page back in the day. My online friends had to know which Alient Ant Farm lyrics best represented my current mood.

My goal is to eventually get OK and somewhat bored of writing my own HTML/CSS and find something that can do most of this work for me. I'm assuming there are tools out there to help you get formatting right for different devices (or something called a ViewPort?). So for now, I will be writing a lot of HTML/CSS and experimenting on how best utilize it. I also think it means faster load times compared to websites that utilize lots of third-party libraries for fast feature development. Nothing against those websites, but this is something I plan on keeping in mind during my progress, least I end up creating a real chonk of a website.