diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/TODO | 1 | ||||
-rw-r--r-- | backend/ikiwiki.setup | 27 | ||||
-rw-r--r-- | backend/resilient/__init__.py | 39 |
3 files changed, 58 insertions, 9 deletions
diff --git a/backend/TODO b/backend/TODO index 3544369..1d9e4d5 100644 --- a/backend/TODO +++ b/backend/TODO @@ -10,6 +10,7 @@ [x] zeronet 8/27/16 [ ] zeronet public gateway [ ] ipfs + [ ] ipfs needs a server running. let's run only the private server get automatically if not present: (submodule or gpg) [x] DO ONE: [ ] ikiwiki diff --git a/backend/ikiwiki.setup b/backend/ikiwiki.setup index 0d71995..0153c4c 100644 --- a/backend/ikiwiki.setup +++ b/backend/ikiwiki.setup @@ -36,11 +36,13 @@ cgi_overload_message: '' # enable optimization of only refreshing committed changes? only_committed_changes: 0 # rcs backend to use -rcs: '' +rcs: git # plugins to add to the default configuration add_plugins: - ikistrap - repolist +- ikistrap +- repolist # plugins to disable disable_plugins: [] # additional directory to search for template files @@ -105,9 +107,30 @@ useragent: ikiwiki/3.20141016.3 ###################################################################### # core plugins -# (editpage, htmlscrubber, inline, link, meta, parentlinks, templatebody) +# (editpage, git, htmlscrubber, inline, link, meta, parentlinks, +# templatebody) ###################################################################### +# git plugin +# git hook to generate +#git_wrapper: /git/wiki.git/hooks/post-update +# shell command for git_wrapper to run, in the background +#git_wrapper_background_command: git push github +# mode for git_wrapper (can safely be made suid) +#git_wrappermode: 06755 +# git pre-receive hook to generate +#git_test_receive_wrapper: /git/wiki.git/hooks/pre-receive +# unix users whose commits should be checked by the pre-receive hook +#untrusted_committers: [] +# gitweb url to show file history ([[file]] substituted) +#historyurl: http://git.example.com/gitweb.cgi?p=wiki.git;a=history;f=[[file]];hb=HEAD +# gitweb url to show a diff ([[file]], [[sha1_to]], [[sha1_from]], [[sha1_commit]], and [[sha1_parent]] substituted) +#diffurl: http://git.example.com/gitweb.cgi?p=wiki.git;a=blobdiff;f=[[file]];h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_commit]];hpb=[[sha1_parent]] +# where to pull and push changes (set to empty string to disable) +gitorigin_branch: origin +# branch that the wiki is stored in +gitmaster_branch: master + # htmlscrubber plugin # PageSpec specifying pages not to scrub #htmlscrubber_skip: '!*/Discussion' diff --git a/backend/resilient/__init__.py b/backend/resilient/__init__.py index 424c73c..c42b5d1 100644 --- a/backend/resilient/__init__.py +++ b/backend/resilient/__init__.py @@ -1,7 +1,9 @@ import fileinput import os +import shlex import shutil import subprocess +import sys import tempfile import time import urllib @@ -9,13 +11,14 @@ import urllib __all__ = ["freenet"] backend_path = os.path.normpath(os.path.join(os.path.dirname(__file__), '..')) +root_path = os.path.normpath(os.path.join(backend_path, '..')) auth_path = os.path.join(backend_path, 'auth') dep_path = os.path.join(backend_path, 'dep') -html_path = os.path.normpath(os.path.join(backend_path, '../html')) -wiki_src_path = os.path.normpath(os.path.join(backend_path, '../wiki')) ikiwiki_setup_path = os.path.join(backend_path, 'ikiwiki.setup') -git_path = os.path.normpath(os.path.join(backend_path, '../.git')) +html_path = os.path.normpath(os.path.join(root_path, 'html')) +wiki_src_path = os.path.normpath(os.path.join(root_path, 'wiki')) +git_path = os.path.normpath(os.path.join(root_path, '.git')) ssh_config_path = os.path.join(auth_path, "ssh-config") @@ -36,9 +39,31 @@ class git: if not found: print("ERROR: git not found") exit(1) - else: - os.system("git submodule init") - os.system("git submodule update") + + os.system("git submodule init") + os.system("git submodule update") + + # http://stackoverflow.com/questions/1964470/whats-the-equivalent-of-use-commit-times-for-git + # sets mtimes to last commit time, for ikiwiki 'last edited by' time + filelist = set() + for root, subdirs, files in os.walk(wiki_src_path): + for file in files: + filelist.add(os.path.relpath(os.path.join(root, file), root_path)) + mtime = 0 + gitobj = subprocess.Popen(shlex.split('git whatchanged --pretty=%at'), stdout=subprocess.PIPE) + for line in gitobj.stdout: + line = line.strip() + if not line: continue + if line.startswith(':'): + file = line.split('\t')[-1] + if file in filelist: + filelist.remove(file) + #print mtime, file + os.utime(os.path.join(root_path,file), (mtime, mtime)) + else: + mtime = long(line) + if not filelist: + break def __init__(self, remote, push_remote = ""): self.remote = remote @@ -80,7 +105,7 @@ class ikiwiki: shutil.rmtree(html_path) os.mkdir(html_path) - status = os.system("ikiwiki --rcs git --setup '%s' '%s' '%s'" % (ikiwiki_setup_path, wiki_src_path, html_path)) + status = os.system("ikiwiki --setup '%s' '%s' '%s'" % (ikiwiki_setup_path, wiki_src_path, html_path)) # workaround for ikistrap overwriting custom css files, which are included for freenet's filter os.system("git checkout -- '%s'/css" % html_path) |