-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsite_post.py
More file actions
57 lines (52 loc) · 1.28 KB
/
website_post.py
File metadata and controls
57 lines (52 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from textwrap import dedent
import datetime
import sys
import subprocess
import os
import re # as reeeeeeeee
def to_kebab_case(string):
string = re.sub(r'[^\w\s]', '', string)
string = re.sub('\s+', '-', string)
return string.lower()
def create_announcement_file(post):
post_header = """---
layout: post
title: %s
summary: %s
prompt: Learn More
image: %s
image_description: %s
games: %s
categories: %s
event:
date: %s %s
location: %s
facebook_link: %s
ticket_link: %s
---
%s
""" % (
post['title'],
post['summary'],
post['image'],
post['image_description'],
post['games'],
' '.join(post['categories'].split()),
post['event']['date'].strftime("%Y-%m-%d"),
post['event']['date'].strftime("%H:%M"),
post['event']['location'],
post['event']['facebook_link'],
post['event']['ticket_link'],
post['content']
)
post_header = dedent(post_header)
filename = '../{}/_posts/{}-{}.html'.format(
'website',
datetime.datetime.now().strftime("%Y-%m-%d"),
to_kebab_case(post['title'])
)
md_file = open(filename, 'w')
md_file.write(post_header)
md_file.close()
build = subprocess.Popen('make build'.split(), cwd='../website')
build.wait()