Blog of Sara Jakša

I updated the blog

If you had been on my blog previously, you can see that my blog now looks different. I used to use htmly, but now I am generating a static site with nikola and then just serve the html files generated. It is not that I was unsatisfied with the htmly, it is just that I could not figure out, how to update my site without having to log in every time. Because login requires cookies (only session cookie) and they needed to be set for everybody and so on and I tried to make it work for my case.

Actually, my site still sets a session cookie ("PH_HPXY_CHECK") for some reason, but I no longer have any code, which would set it. I don't get this cookie, when I am running a site on my own computer. I have no idea, how to eliminate this one as well.

The other thing was, that it required tag for every single blogs. I do have tags for some of my work (mostly my material that I had originally posted on other websites), but not for most of them. I guess these were the two things, that I wanted to deal with. I would still recommend htmly as a simple blog platform, it just was not for me.

Then I read on the internet a bit about the static sites generators. I don't have any kind of interaction on my site. Even if in the future I realize that I needed the interaction, I still think that most of the sites will be static. So this works well.

I have spend around a day (if measured as time frame of 24 hours) putting everything in the new system and changing the css a bit. This is why some details may not be that well made yet. But I like, that this made the page size smaller for around 60%, which is always a good think. To take care of the environment (and make pages faster, but this version is no faster than the previous one).

On the other hand, I am currently working on the app for researching experience. And I am at the user experience part of it. And I realized that I had no idea, how a good user experience no mobile app looks like (since I don't really use my phone and tablet enough to get a feeling). On the other side, I do know what user experience do I like at websites, so this is like having a practice before the real part.

Hope this will make the blog more and not less readable.

If anybody came here searching for how to migrate from htmly to nikola, I appologize that I am not writting about it. But I will add the code that I used to change the htmly blogposts to nikola blog posts.

import os
import re

re_title = r"<!--t[\S\s]*t-->"
re_tag = r"<!--tag[\S\s]*tag-->"
re_desc = r"<!--d[\S\s]*d-->"

all_files = os.listdir("post/")

for current_file in all_files:
    time = ":".join(current_file.split("_")[0].split("-")[3:])
    date = "-".join(current_file.split("_")[0].split("-")[:3])
    datetime = date + " " + time + " UTC"
    filename = current_file.split("_")[2][:-3]
    tags = current_file.split("_")[1]
    if tags == "none":
        tags = ""
    with open(os.path.join("post/", current_file)) as f:
        lines = f.readlines()
    lines = "".join(lines)
    title = re.search(re_title, lines).group(0)
    lines = lines.replace(title, "")
    title = title.replace("<!--t", "").replace("t-->", "").strip()
    lines = lines.replace(re.search(re_tag, lines).group(0), "")
    desc = re.search(re_desc, lines).group(0)
    lines = lines.replace(desc, "")
    desc = desc.replace("<!--d", "").replace("d-->", "").strip()
    with open(os.path.join("trypost2/", filename + ".rst"), "w") as f:
        f.write(".. title: " + title + "\n")
        f.write(".. slug: " + filename + "\n")
        f.write(".. date: " + datetime + "\n")
        f.write(".. tags: " + tags + "\n")
        f.write(".. description: " + desc + "\n")
        f.write("\n\n")
        f.write(lines)

You can also donwload the code here: htmly2static.py