On Wednesday, September 28, 2011, Jaap Karssenberg wrote: > If you want to plug into zim you could have a look at the "print to browser" > plugin, which adds a button to the tasklist dialog for html export. If you > want to make it a background script, try re-using the code of the tasklist > plugin for accessing the index.
It's just two functions in my script that runs whenever I synchronize my flat files with the Web server. It's actually rather stupid, just pulling the text out of the txt files. I've attached it below though I doubt it would be of use to others, but perhaps an expire plugin that moves [x] tasks to a journal/calendar might be. > No zim's "@" syntax does not predate the twitter convention. But you will > find there are older systems using "@" for tags as well. Main reason I > choose this syntax is that in HTML "#" is used for anchors, which is a > feature we still want to add to zim. OK. > Actually work is ongoing to make zim support multiple syntaxes. No need to > have one-size-fits all in this respect. See previous discussion on this > list, as well as various syntax related feature requests in the bug tracker. Yes, I saw some discussion of that a month or so ago, but I didn't know it was being actively developed. (My fingers are crossed.) BTW: no bugs are listed here: https://bugs.launchpad.net/~zim-wiki ~~~~~~~~~~~~~~~~~~~`` def log2work(done_tasks): ''' Log completed zim tasks to work microblog ''' import hashlib log_items = [] for activity, task in done_tasks: # zim syntax for href/em to HTML task = re.sub('\[\[(.*?)\|(.*)\]\]', ur'<a href="\1">\2</a>', task) task = re.sub('\/\/(.*?)\/\/', ur'<em>\1</em>', task) date_token = get_Now_YMD() digest = hashlib.md5(task.encode('utf-8', 'replace')).hexdigest() uid = "e" + date_token + "-" + digest[:4] log_item = '<li class="event" id="%s">%s: %s] %s</li>\n' % \ (uid, date_token, activity, task) log_items.append(log_item) OUT_FILE = HOME+'/data/2web/reagle.org/joseph/plan/plans/index.html' fd = codecs.open(OUT_FILE, 'r', 'utf-8', 'replace') content = fd.read() fd.close() insertion_regexp = re.compile('(<h2>Done Work</h2>\s*<ol>)') newcontent = insertion_regexp.sub(u'\\1 \n %s' % ''.join(log_items), content, re.DOTALL|re.IGNORECASE) if newcontent: fd = codecs.open(OUT_FILE, 'w', 'utf-8', 'replace') fd.write(newcontent) fd.close() else: print_usage("Sorry, output regexp subsitution failed.") def retire_tasks(directory): ''' Removes completed '[x]' zim tasks form zim ''' if 'zim' in check_output(["ps", "axw"]): print("Zim is presently running; tasks not retired.") return else: zim_files = locate('*.txt', directory) for zim_filename in zim_files: info(zim_filename) done_tasks =[] activity = 'misc' new_wiki_page = [] with open(zim_filename, 'r') as wiki_page: for line in wiki_page: label = re.search('@\w+', line) if label: activity = label.group(0).strip()[1:] if '[x]' in line: item = line.split(']',1)[1].strip() done_tasks.append((activity, item)) else: new_wiki_page.append(line) if done_tasks: new_wiki_page_fd = open(zim_filename, 'w') new_wiki_page_fd.writelines("%s" % line for line in new_wiki_page) new_wiki_page_fd.close() log2work(done_tasks)
_______________________________________________ Mailing list: https://launchpad.net/~zim-wiki Post to : [email protected] Unsubscribe : https://launchpad.net/~zim-wiki More help : https://help.launchpad.net/ListHelp

