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

Add this to your global scripts page and add an import statement to the pages you want to use this on.

Output

+++ Log
track.log.2007.May.03.MyCurrentProject: () 

Code

<%
1:
###############################
#  Add the track.log.YEAR.MONTH.DAY.WIKIPAGE: () time stamp under the +++ Log heading.
#  If there is no heading, it will be created at the end of the document and the 
#  timestamp appended on the next line.
###############################
editor.SetTargetStart(1)
editor.SetTargetEnd(editor.GetLength())

logPos = int(editor.SearchInTarget("+++ Log"))


def AddLogStamp():
    editor.AddText("track.log.")
    editor.AddText(lib.strftime("%Y"))
    editor.AddText(".")
    editor.AddText(lib.strftime("%b"))
    editor.AddText(".")
    editor.AddText(lib.strftime("%d"))
    editor.AddText(".")
    editor.AddText(pwiki.getCurrentWikiWord().replace(" ","_"))
    editor.AddText(": () ")

if logPos == -1:
    editor.GotoPos(editor.GetLength())
    editor.AddText("\n\n+++ Log\n")
    AddLogStamp()  
else:
    editor.GotoLine(editor.LineFromPosition(editor.SearchInTarget("+++ Log")+1))
    editor.SetCurrentPos(editor.GetLineEndPosition(editor.GetCurrentLine()))
    editor.AddText("\n")
    AddLogStamp()
    curPos = editor.GetLineEndPosition(editor.GetCurrentLine())
    editor.AddText("\n")
    editor.GotoPos(curPos)
%>
Clone this wiki locally