Created
August 22, 2016 06:18
-
-
Save wolkenschieber/e0f5172a7aaacd8e177c587e73f0b1d9 to your computer and use it in GitHub Desktop.
QML-script to convert markdown from QOwnNotes to MediaWiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQml 2.0 | |
import com.qownnotes.noteapi 1.0 | |
QtObject { | |
function init() { | |
script.registerCustomAction("convertToMediaWiki", "Convert note to MediaWiki", "Convert to MediaWiki" ); | |
} | |
function customActionInvoked(identifier) { | |
script.log("customActionInvoked - " + identifier); | |
switch (identifier) { | |
case "convertToMediaWiki": | |
var note = script.currentNote(); | |
var nodeName = note.name; | |
var currentDate = new Date(); | |
var dateString = currentDate.toLocaleString(Qt.locale(), "yyyy-MM-ddThh:mm:ss.zzz"); | |
var tmpFile = "/tmp/"+nodeName+"-mediawiki-"+dateString+".conv"; | |
var fullFileName = note.fullNoteFilePath; | |
var pandocArgs = [fullFileName, "-f", "markdown", "-t", "mediawiki", "-o", tmpFile]; | |
script.startDetachedProcess("pandoc", pandocArgs); | |
script.startDetachedProcess("kate", [tmpFile]); | |
break; | |
} | |
} | |
} |
From version 16.08.17, buttons can be added to the custon action:
function init() {
script.registerCustomAction("convertToMediaWiki", "Convert note to MediaWiki", "Convert to MediaWiki", "/usr/share/icons/breeze/actions/24/quickopen-file.svg" );
}
I guess you should also be able to just write quickopen-file
for the icon.
Using the icon filename directly also chooses the best matching size.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Looking good!