About Blog Current

Some sort of workflow

After not having time due to me replaying Gothic 1 and being sick with some sort of flu.

I have finally come around to rewrite my python script and create a deployment for markdown files that I upload to my webserver.

The python code now looks like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import glob
import pypandoc
import os
import os.path

def create_file_list():
    """Creates an array of markdown files to be converted"""
    mds = []
    for file in glob.glob("*.md"):
        mds.append(file)
    return mds

def convert_markdown():
    """Convert markdown files to html"""
    for files in create_file_list():
        name = os.path.splitext(files)[0]
        pypandoc.convert_file(files,'html', outputfile=name+'.html',
                extra_args=['--include-in-header=/opt/content_deployment/style.html'])

convert_markdown()

The filename should probably be different, since it does not actually deploy anything.

This is tied in with the actual deployment script written in bash, which is executed once every minute via cron.

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

BLOG_DIRECTORY=/opt/content_deployment
WWW_BLOG_DIRECTORY=/var/www/html/blog
WWW_DIRECTORY=/var/www/html

python3 content_deployment.py

sudo -u www-data rsync $BLOG_DIRECTORY/*.html $WWW_BLOG_DIRECTORY/
rm /var/www/html/index.html
ln -s "`find /var/www/html/blog -type f -iname $(ls -t /var/www/html/blog | head -1 )`" $WWW_DIRECTORY/index.html

This is also the first article published via this system. I just write the file on my notebook and then upload the file via scp.