summaryrefslogtreecommitdiff
path: root/ql-ikiwiki-publish
diff options
context:
space:
mode:
Diffstat (limited to 'ql-ikiwiki-publish')
-rw-r--r--ql-ikiwiki-publish58
1 files changed, 58 insertions, 0 deletions
diff --git a/ql-ikiwiki-publish b/ql-ikiwiki-publish
new file mode 100644
index 0000000..1e2e2e6
--- /dev/null
+++ b/ql-ikiwiki-publish
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# Copyright 2016 QvarnLabs Ab
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+import os
+import shutil
+import subprocess
+import sys
+import tempfile
+
+
+def mangle_setup(src, dest, html):
+ with open(src) as f:
+ text = f.read()
+
+ lines = [
+ line
+ for line in text.splitlines()
+ if not line.startswith('destdir:')
+ ]
+
+ lines.append('destdir: {}'.format(html))
+
+ mangled = ''.join(line + '\n' for line in lines)
+
+ with open(dest, 'w') as f:
+ f.write(mangled)
+
+
+static_http = sys.argv[1]
+rsync_target = 'static@{}:/srv/http/www.qvarn.org/.'.format(static_http)
+
+T = tempfile.mkdtemp()
+try:
+ setup = os.path.join(T, 'ikiwiki.setup')
+ html = os.path.join(T, 'html')
+ mangle_setup('ikiwiki.setup', setup, html)
+ subprocess.check_call(['ikiwiki', '--setup', setup])
+ subprocess.check_call(
+ ['rsync', '-ahHSvs', '--delete', html + '/.', rsync_target])
+except BaseException as e:
+ shutil.rmtree(T)
+ raise