from os.path import *
WIKIDPAD_PLUGIN = (("hooks", 1),)
def startup(wikidPad):
"""
Called when application starts
"""
import os
import sys
global wikid_plugins
wikid_plugins = {}
dir = join(wikidPad.wikiAppDir, u'user_extensions')
sys.path.append(dir)
files = [f for f in os.listdir(dir) if f[:6] == "plugin"]
for file in files:
[fn,ext] = os.path.splitext(file)
mod = __import__(fn)
[hook,fun] = mod.plugin_init()
if not wikid_plugins.has_key(hook):
wikid_plugins[hook] = []
wikid_plugins[hook].append(fun)
pass
def newWiki(wikidPad, wikiName, wikiDir):
"""
Called when a new wiki is about to be created.
wikiName -- name of the wiki (already checked to be a proper CamelCase word)
wikiDir -- directory to create the wiki in (more precisely the .wiki config
file). This directory may already exist
"""
global wikid_plugins
if wikid_plugins.has_key('newWiki'):
for plugin in wikid_plugins['newWiki']:
(plugin)(wikidPad, wikiName, wikiDir)
def createdWiki(wikidPad, wikiName, wikiDir):
"""
Called when creation of a new wiki was done successfully.
The home wiki word (equals name of the wiki) is not yet loaded.
wikiName -- name of the wiki
wikiDir -- directory the wiki was created in
"""
global wikid_plugins
if wikid_plugins.has_key('createdWiki'):
for plugin in wikid_plugins['createdWiki']:
(plugin)(wikidPad, wikiName, wikiDir)
def openWiki(wikidPad, wikiConfig):
"""
Called when an existing wiki is about to be opened.
wikiConfig -- path to the .wiki config file
"""
global wikid_plugins
if wikid_plugins.has_key('openWiki'):
for plugin in wikid_plugins['openWiki']:
(plugin)(wikidPad, wikiConfig)
def openedWiki(wikidPad, wikiName, wikiConfig):
"""
Called when an existing wiki was opened successfully
wikiName -- name of the wiki
wikiConfig -- path to the .wiki config file
"""
global wikid_plugins
if wikid_plugins.has_key('openedWiki'):
for plugin in wikid_plugins['openedWiki']:
(plugin)(wikidPad, wikiName, wikiConfig)
def openWikiWord(wikidPad, wikiWord):
"""
Called when a new or existing wiki word is about to be opened.
The previous active page is already saved, new one is not yet loaded.
wikiWord -- name of the wiki word to open
"""
global wikid_plugins
if wikid_plugins.has_key('openWikiWord'):
for plugin in wikid_plugins['openWikiWord']:
(plugin)(wikidPad, wikiWord)
def newWikiWord(wikidPad, wikiWord):
"""
Called when a new wiki word is about to be created.
The wikidPad.currentwikidPage of the new word is already available
wikiWord -- name of the wiki word to create
"""
global wikid_plugins
if wikid_plugins.has_key('newWikiWord'):
for plugin in wikid_plugins['newWikiWord']:
(plugin)(wikidPad,wikiWord)
def openedWikiWord(wikidPad, wikiWord):
"""
Called when a new or existing wiki word was opened successfully.
wikiWord -- name of the wiki word to create
"""
global wikid_plugins
if wikid_plugins.has_key('openedWikiWord'):
for plugin in wikid_plugins['openedWikiWord']:
(plugin)(wikidPad,wikiWord)
def savingWikiWord(wikidPad, wikiWord):
"""
Called when a new or existing wiki word is about to be saved
wikiWord -- name of the wiki word to create
"""
global wikid_plugins
if wikid_plugins.has_key('savingWikiWord'):
for plugin in wikid_plugins['savingWikiWord']:
(plugin)(wikidPad, wikiWord)
def savedWikiWord(wikidPad, wikiWord):
"""
Called when a wiki word was saved successfully
wikiWord -- name of the wiki word to create
"""
global wikid_plugins
if wikid_plugins.has_key('savedWikiWord'):
for plugin in wikid_plugins['savedWikiWord']:
(plugin)(wikidPad, wikiWord)
def renamedWikiWord(wikidPad, fromWord, toWord):
"""
Called when a wiki word was renamed successfully.
The changed data is already saved in the fileset,
the GUI is not updated yet, the renamed page is not yet loaded.
fromWord -- name of the wiki word before renaming
toWord -- name of the wiki word after renaming
"""
global wikid_plugins
if wikid_plugins.has_key('renamedWikiWord'):
for plugin in wikid_plugins['renamedWikiWord']:
(plugin)(wikidPad, fromWord, toWord)
def deletedWikiWord(wikidPad, wikiWord):
"""
Called when a wiki word was deleted successfully.
The changed data is already saved in the fileset,
the GUI is not updated yet, another page (normally
the last in history before the deleted one) is not yet loaded.
wikiWord -- name of the deleted wiki word
"""
global wikid_plugins
if wikid_plugins.has_key('deletedWikiWord'):
for plugin in wikid_plugins['deletedWikiWord']:
(plugin)(wikidPad, wikiWord)
def exit(wikidPad):
"""
Called when the application is about to exit.
The global and the wiki configuration (if any) are saved already,
the current wiki page (if any) is saved already.
"""
global wikid_plugins
if wikid_plugins.has_key('exit'):
for plugin in wikid_plugins['exit']:
(plugin)(wikidPad)