Mandaris Moore


Two Cautions signs.

I spent some time going down a rabbit hole this evening. I've been putting the time in so that I can learn how to program with SwiftUI when I came up with the idea of putting things on my site so that I could show the world my progress.

When I thought about that, I was reminded that I wanted to spruce up the css on the site so that it would look nice.

So, I took some time to load up the static version of my site so that I can see what changes would look like when I update it without regenerating the whole thing with a build of pelican.

I notice that I didn't have an example of several blocks of text (like what you see now).

Sooo...

I spent 5 minutes getting a copy of lorem ipsum because I always think "This is going to be the last time that I'm going to need that. I spent 5 more minutes adding emphasis, bold, links and code to it when I realized that I should have something a little more familiar.

That's when I looked up alternatives to "The quick brown fox".

I created a new paragraph using it and then placed that in both my test information and my static site.

Whew...

Ultimately, I spent more time just setting up this demo information for the site then posting about my iOS development.


The first thing I did with this site this year other that work on a plugin that I'm not ready to release to the world is update the meta data. I don't know if you - the reader- will see a difference but I'm pretty proud of what I did.

The next thing is to update all the catefory tags to make them more consistent.


So, I spent about 3 hours working on getting Open Graph tags to work in the theme that I created. I've got mixed feeling about it because I started off by adding the tags to the base html template using an if statement and it seemed a little clunky.

{% if OPEN_GRAPH %}
<meta property="og:title" content="{{ SITENAME }}"/>
<meta property="og:type" content="website"/>
<meta property="og:description" content="{{ SITE_DESCRIPTION }}"/>
<meta property="og:url" content="{% SITE_URL %}"/>
{% endif OPEN_GRAPH %}

This worked for the site in general but doesn't translate to all the articles and this caused me to go into a some what deep dive into how Pelican and Jinja parses blocks and if statements. I started off with putting all the tags into the base and then doing individual changes to tags that need to be changed for.

BAH!!!

So, took a step back and looked into what plugins were already available. And there is was! Pelican-open_graph! I was home free! Or so I thought, until I tried to use it. The plugin has three problems.

It doesn't account for when someone does not have a modified date on their articles.

Luckily, someone had put a solution up. The change was forked about 7 months ago today and it looks like whoever created the open graph plugin has taken a break to work on other things.

It's a year old and hasn't made the changes for pelican regarding summaries of articles.

So, I had to do some debugging to find out that the code needed to be changed in the following way1.

ogtags.append(('og:description', instance.metadata.get('og_description',
                                                           instance.metadata.get('summary',
                                                                                 instance.summary))))

It also assumed that every article has some kind of tag.

I've decided to just punt this problem and add the tags to the 6 articles that don't have them, but than I took a second look at the problem because the perfectionist in me doesn't like to leave problems unsolved and I didn't want to track down what the particular articles were.

So, I just wrapped the code in a try block to make sure that I got this particular exception.

try:
        for tag in instance.tags:
            ogtags.append(('article:tag', tag.name))
    except AttributeError:
            ogtags.append(('article:tag', 'untagged'))

Results

Ultimately, I got to learn a little bit more about using pelican and knocked off a major milestone on getting this blog to where I'd like it to be.


  1. I've got to branch and push this fix. I don't know how many other people are using pelican or this plugin but if I can save them or future me some time...