Skip to content
Michael Butscher edited this page Jan 23, 2021 · 1 revision
"""
SimpleStatusBar

Usage from WikidPad:
To create the status bar add a [:status:current_status] in the page content where the marker is desired.
current_status must be an integer between 0 and 6.

Licence: cc0
"""
WIKIDPAD_PLUGIN = (('InsertionByKey', 1),)
COLORLIST = ['#FFFFFF','#FF0000','#FF5500','#FFAA00','#FFFF00','#88FF00','#00FF00']
BASESTRING = "="
STARTSTRING = "{"
ENDSTRING = "}"

def describeInsertionKeys(ver, app):
    return ((u'status', ('wikidpad_language',), StatusHandler),)

class StatusHandler(object):
    def __init__(self, app):
        self.app = app

    def taskStart(self, exporter, exportType):
        pass

    def taskEnd(self):
        pass
    
    def getExtraFeatures(self):
        return ()

    def createContent(self, exporter, exportType, insToken):
        status = int(insToken.getString()[9:-1])
        if status > 6:
            status = 6
        text = BASESTRING*status + " "*(6-status)
        return '''<small><code>%s<b><font color=%s>%s</font></b>%s</code></small>'''%(STARTSTRING,COLORLIST[status],text,ENDSTRING)
Clone this wiki locally