From 065b39dcb4d3186e1f57d37420bb195300ce14e4 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Tue, 2 May 2017 21:42:13 +0200 Subject: [PATCH] changes to scripts as to be run by hook --- mmdc_modules.py | 2 +- mmdc_wiki2web.py | 6 +++--- post-receive-hook | 10 ++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) create mode 100644 post-receive-hook diff --git a/mmdc_modules.py b/mmdc_modules.py index c685906..93232cd 100644 --- a/mmdc_modules.py +++ b/mmdc_modules.py @@ -102,7 +102,7 @@ def parse_work(site, title, content): def pandoc2html(mw_content): '''convert individual mw sections to html''' mw_content = mw_content.encode('utf-8') - tmpfile = open('tmp_content.mw', 'w') + tmpfile = open('./tmp_content.mw', 'w') tmpfile.write(mw_content) tmpfile.close() args_pandoc = shlex.split( 'pandoc -f mediawiki -t html5 tmp_content.mw' ) diff --git a/mmdc_wiki2web.py b/mmdc_wiki2web.py index 014bcc1..6a29a99 100755 --- a/mmdc_wiki2web.py +++ b/mmdc_wiki2web.py @@ -30,7 +30,7 @@ print year # DEFS: create_page create_index ###### def create_page(memberpages, mode): - page_template = open("{}-template.html".format(year), "r") + page_template = open("./{}-template.html".format(year), "r") indexdict = {} #parent dict: contains articledict instances for member in memberpages: print member @@ -102,7 +102,7 @@ def create_page(memberpages, mode): def create_index(indexdict): - index_template = open("index-template-{}.html".format(year), "r") + index_template = open("./index-template-{}.html".format(year), "r") index_tree = html5lib.parse(index_template, namespaceHTMLElements=False) index_container = index_tree.find(".//div[@class='isotope']") #maybe id is imp keys = indexdict.keys() @@ -118,7 +118,7 @@ def create_index(indexdict): thumbnail=(indexdict[key]['Thumbnail']) ) print '----', indexdict[key]['Title'],indexdict[key]['Path'] - write_html_file(index_tree, 'web/{}.html'.format('index')) + write_html_file(index_tree, './web/{}.html'.format('index')) ##### diff --git a/post-receive-hook b/post-receive-hook new file mode 100644 index 0000000..8bb5864 --- /dev/null +++ b/post-receive-hook @@ -0,0 +1,10 @@ +#!/bin/sh + +git_work_tree_path=/var/www/mmdc-site +GIT_WORK_TREE=$git_work_tree_path git checkout -f + +commitname=`git log -n 1 --pretty=format:%cn` +commitdate=`git log -n 1 --pretty=format:%cd` + +# runs script that converts md to website +python $git_work_tree_path/mmdc_wiki2web.py