# making of blessfrey.me

october 15, 2020
#bottle #css #html #simpletemplate #webdesign #webdevelopment
Blessfrey.me is a personal website I use to showcase projects and blog my process. It was originally written in PHP, but now it uses Bottle, a Python web framework.

## why not use a premade blogging platform like WordPress?

Blessfrey.me's needs are fairly simple - some static pages and a blog page. Generalized blogging platforms are overkill for my purposes. I don't need support for multiple authors, comments, localization, e-commerce, and so on. Unused features bog down the website at best and contribute to security vulnerabilities at worst.
Also, it's fun to write my own platform. I'm learning a lot as I take my website from initial sketches, to Hello World, to various prototypes, to something polished enough to show my friends. Regardless, since it can be considered my programming portfolio, it makes sense that it itself should be something I programmed.

## why Bottle?

I originally wrote Blessfrey.me in PHP. I switched to Bottle after looking for a templating engine. Bottle comes with SimpleTemplate and can do everything PHP can do but faster and with less verbosity. Plus, I get to write in Python, a much more enjoyable language.

## how does blessfrey.me work?

### SimpleTemplate

Instead of existing as a static collection of HTML pages on my server, Blessfrey.me's pages are constructed upon request by the website's Bottle script from SimpleTemplate templates.
Every page uses the frame template pictured below, so the basic skeleton is consistent without requiring copy-pasted code. Each page is individualize through bringing in a new template within `{{!base}}`. (Double curly brackets refer to variables, and exclamation marks disable escaping.)
(The code can be found on Pastebin.)
The header template below (brought in at `% include('header.tpl')`) has some variables, too, which are supplied by the Bottle script. If Bottle doesn't provide a title, it defaults to 'blessfrey.me.' Variables can also be used in paths and URLs.
(The code can be found on Pastebin.)
You can insert Python code into the templates for dynamic pages. Below is an excerpt of the template for the diary page. This code fills the page with diary entry previews using a for loop. Not shown is the first line `% rebase('frame.tpl')`, which tells SimpleTemplate to insert this content at the `{{!base}}` variable in the frame template.
(The code can be found on Pastebin.)
The Bottle script sends the max number of snippets per page (the `limit`) and a list of lists containing all the diary snippets. It receives the page number from the URL. For the snippets that will appear on the given page, it converts the list data into HTML code to be displayed in the browser.

### Bottle

Bottle takes URLs and generates the corresponding web page upon request. Each URL is tied to a method, which returns a template and a dictionary of data to be used in the template. Since Bottle is a Python framework, you have access to all the Python libraries you need.
(The code can be found on Pastebin.)
This is what the methods for specific routes look like. So every time you go to Blessfrey.me/diary, one of the above methods is called, depending on whether also you supplied an integer. To generate the page content, it calls a lot of Python functions to find my diary entries, convert them into previews for the snippets section and headlines for the sidebar, and get the current time for the footer.

### CSS

The website is styled using CSS, heavily relying on the CSS Grid and a bit of Flexbox. CSS Grids can be used inside CSS Grids, so my pages are generally blocked out, with smaller internal grids managing specific content.
The projects page is an example of nested grids. Almost every page uses the yellow general layout. The content unique to the projects page is mapped out in green, with a section for the header, featured projects, and other projects. The other projects use a 2-column grid in blue to evenly space out all the little thumbnails.
The CSS code for project's general grid and the nested unfeatured grid are shown below.
(The code can be found on Pastebin, but you can always see a web page's CSS by right-clicking and viewing the source.)
Last updated June 8, 2021