Skip to content
Snippets Groups Projects
Commit 46a49b33 authored by Nikos Roussos's avatar Nikos Roussos
Browse files

Add image support

parent ef2d07f6
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -19,6 +19,7 @@ from os import path, listdir, makedirs, mkdir
import sys
import yaml
import time
from glob import glob
 
from markdown import Markdown
from jinja2 import Environment, FileSystemLoader
Loading
Loading
@@ -51,12 +52,12 @@ def generate_posts():
env = Environment()
env.loader = FileSystemLoader('templates')
 
for post in listdir('posts'):
orig = path.join('posts', post)
listing = glob('posts/*md')
for post in listing:
 
print('Generating {0}...'.format(orig))
print('Generating {0}...'.format(post))
 
raw = open(orig, 'r').read()
raw = open(post, 'r').read()
headers, content = raw.split('---', 1)
headers = yaml.load(headers)
tags = headers['tags'].split(', ')
Loading
Loading
@@ -80,6 +81,13 @@ def generate_posts():
makedirs(postpath)
except OSError:
pass
if 'images' in headers:
import shutil
images = headers['images'].split(', ')
for image in images:
shutil.copy2(path.join('posts', image), postpath)
filename = '{0}/{1}.html'.format(postpath, headers['slug'])
 
print('Generating HTML blog post at {0}...'.format(filename))
Loading
Loading
@@ -135,7 +143,7 @@ def generate_archive(posts, tag_set):
tpl = env.get_template('blog.html')
html = tpl.render(dict(
sitename=cfg['sitename'],
title='blog: {0}'.format(tag),
title='blog: #{0}'.format(tag),
posts=post_list
))
tagpath = path.join('tag', tag)
Loading
Loading
Loading
Loading
@@ -2,8 +2,11 @@ title: Hello World
slug: hello-world
date: 2015-04-13 18:00:00
tags: opensource, python
images: tor-people.jpg
---
 
_Welcome to monopati!_
 
This is a sample blog post.
![Keep walking](tor-people.jpg)
posts/tor-people.jpg

22.9 KiB

Jinja2==2.7.3
Markdown==2.5.2
Markdown==2.6.1
PyYAML==3.11
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment