This uses directory ~/.leo/dump to store version history of leo nodes
that you "dump" there explicitly. It's a git repository with gnx'es as
the file name (because git is fast and popular. It doesn't really
matter what vcs is used). I've attached the thin node if anyone is
interested, but the only interesting part is this script:
QQQ
wb.require('flatleo_setup')
for n in wb.match_h('.*'):
name, date, num = n.p.t.fileIndex
fname = '%s/%s%s%s' % (flatroot, name, date, num)
open(fname,'w').write(n.b)
print "wrote", fname
print "committing to git"
cd $flatroot
git add *
git commit -m "leo autocommit"
print "committed"
QQQ
That's it! It won't be hard to implement something that will allow you
to go back / forward (revert) in history, now you just need to use
normal git commands and copy/paste ;-). Even now something like this
can make sense as a backup of your data. This would make most sense as
a @button.
--
Ville M. Vainio
http://tinyurl.com/vainio
This uses directory ~/.leo/dump to store version history of leo nodes
that you "dump" there explicitly.
> Yet another trivial ILeo hack that needs extreme polish ;-).
>
> This uses directory ~/.leo/dump to store version history of leo nodes
> that you "dump" there explicitly. It's a git repository with gnx'es as
> the file name (because git is fast and popular. It doesn't really
> matter what vcs is used). I've attached the thin node if anyone is
> interested, but the only interesting part is this script:
Here is a snippet you can add to "@button git-dump" node:
QQQ
""" Dump nodes to ~/.leo/dump git repository.
Before using this, you need to:
mkdir ~/.leo/dump; cd ~/.leo/dump; git init
"""
import os
flatroot = os.path.expanduser('~/.leo/dump')
assert os.path.isdir(flatroot)
hl = []
def dump_nodes():
for p in c.all_positions_with_unique_tnodes_iter():
name, date, num = p.t.fileIndex
gnx = '%s%s%s' % (name, date, num)
hl.append('<a href="%s">%s%s</a><br/>' % (gnx, '-' * p.level(), p.h))
fname = gnx
open(fname,'w').write(p.b)
print "wrote", fname
os.chdir(flatroot)
dump_nodes()
lis = "\n".join(hl)
html = "<body>\n<tt>\n" + lis + "\n</tt></body>"
#titlename = c.frame.getTitle() + '.html'
titlename = 'index.html'
open(titlename,'w').write(html)
g.es("committing to " + flatroot)
os.system('git add *')
os.system('git commit -m "Leo autocommit"')
g.es("committed")
QQQ
It stores the outline structure as browseable html.
I will push this to scripts.leo as an example.
Here is a snippet you can add to "@button git-dump" node:
QQQ
""" Dump nodes to ~/.leo/dump git repository.