Package: vimoku
vimokuEdit pages of a dokuwiki instance with your favorite editor.Use theRPC-XML interfaceof dokuwiki, accessed usingdokuwikixmlrpc.Tested with python 3.8. Should work with 3.6. Will not with 3.5 (sorry, f-strings are the best).Installationsetup (manual)Install vimoku.py somewhere, make it executable. You probably want to rename it justvimoku, or create aliases in your dot files.Create a new repository withgit init, and, in thegit/configfile, add the following section:
You need to create the file$XDG_CONFIG_HOME/vimoku/vimoku.ini(Your$XDG_CONFIG_HOMEis probably equal to~/.config) as follow:[wiki:default]
url = https://yourwiki.url.net
user = john
password = yourpasswordThe url is the url of your wiki. User and password are the login for the account you will use to publish your editions on the wiki.
It therefore must be an existing dokuwiki user allowed touse RTC calls.Other options are available, notablyeditorto set the editor to choose its options. Seeeditor options sectionfor an example. This readme explains more options and features.setup (semi-manual)pip install vimoku  # don't forget to verify version of pip, python, OS, timeline, blahblahPython dependencies are automatically installed, but you still need to install avimoku.iniin your config directory. Only now, you have vimoku ready to fire withpython -m vimoku.dependenciesOnly one, really :dokuwikixmlrpc.
If you are to browse it, there is no documentation, butthe codeis short and understandable. You probably look for theDokuWikiClient object.pip install dokuwikixmlrpcshould be enough, probably with--user.
You could also copy paste in place of the imports thesingle source file of dokuwikixmlrpcin vimoku.py. Don't forget to remove the (call to) main function.UsageEditionUsevimoku --helpfor help.Basic usage:vimoku pageidYou can edit multiple pages, using standard dokuwiki naming conventions for categories:vimoku categ1:page1 page2 categ2:categ3:page3And you may set a commit message (by default, it'sundocumented remote modification):vimoku page2 -m "guess from where i edit that page ??"Your editor will fire a first time, letting you modify the pages you requested. It will fire a second time to let you modify, for each page, the commit message.
And, if you opened other files, it will be fired a third time to ask you if they are wiki pages to retrieve and edit (seecycling).Move and copyUsing flags--move-toand--copy-to, you can modify your wiki structure easily !
The only difference between the two is that moving deletes the page after copy.
Note the existence of specific flags, such as--redirectand--fix-backlinks. See the below examples.Change the name of a page, if the new name is not an existing page:vimoku categ:pageid --move-to othercateg:newpageidChange the name of a page, if the new name is not an existing page, with a redirection in the old page to the new one:vimoku categ:pageid --move-to othercateg:newpageid --redirectCopy the categorybarinto another (note the:that indicate that thecategory, not the page, is to be considered):vimoku bar: --copy-to bazMove all content of a categorybarintobaz, and put a redirection message in the moved pages:vimoku bar:* --move-to baz --redirectRename a page, and fix all links that were linking to it before the renaming:vimoku page --move-to movedpage --fix-backlinksVimoku will try to detect any possible fault with what you provided,
then will ask you to review the move with your editor. There, you can go wild and erase entire pages by not paying attention to what you do.Categories selectionThe next example shows some advanced details regarding categories.
Let's consider the wiki containing the following pages:a
b
b:d:e
b:f
c
c:gThe following command:vimoku a b: c --move-to h --redirectShould move the pages to obtain:b
c:g
h:a
h:b:d:e
h:b:f
h:cIf you also wanted to movebandc:g, you should indicate that you want to movebandc:, thus:vimoku a b b: c c: --move-to h --redirectEdit on different dokuwiki instancesVimoku supports the existence of many wikis in the configuration file. This is achieved by populating yourvimoku.iniwith different wikis.
This also allows you to handle multiple identities on a single wiki.
The following ini file provides an example of three different accounts on two different wikis, setting one of them as the default:[wiki:default]
url = https://wiki.one.example.net
user = john
password = passwordone
[wiki:second]
url = https://wiki.two.example.net
user = john
password = passwordtwo
[wiki:alt]
url = https://wiki.one.example.net
user = mysteriousguy
password = mysteriouspasswordNow, you can specify explicitely which wiki to consider when using the CLI. For instance, you could edit a page using your alternative identity on the first wiki:vimoku categ:page alt:::page second/pageThis will enable you to editcateg:pageon thedefaultwiki,pagewith your alternative identity on the same wiki, andpageon thesecondwiki.
Slash or triple colons means the same thing.You can also copy from one instance to another, here copying all meeting reports from wiki one to wiki two:vimoku one/meeting:* --copy-to two/meeting:More details:slashes are accepted in input as wiki separator, but internally the token triple colon:::is used.before the slash/triple colon is the wiki name, as defined in the configuration file. After the slash/triple colon is the page name in the remote wiki.when no wiki name is given,defaultis used. You canchange this.tipscyclingOnce in your editor, if you create more files in the temporary directory containing the files you asked for edition, they will not be removed.
Instead, you will be prompted (using your $EDITOR) about which files you want to edit properly.The whole program will run again, this time retrieving the new files you asked for.NB: if you wrote things in those manually opened files, you will loose your data. Even if the page doesn't exists on the wiki. Yes, that sucks. Help me.editor optionsYourvimoku.iniaccept the optioneditor, to explicitely set the editor command if you don't trust your$EDITORenvironment variable or wants to provide options to your editor.It is formated with the variables{cwd}, the path to the directory holding the files you will be editing, and{pages}, that list the pages to be edited. If{pages}is not given, files to open are fed at the end of the command.For instance, using vim, i ended up with the following value:[options]
editor=/usr/bin/vim -c ":cd {cwd}" -pThis ensures that vim opens each file in its own tab (-p), and uses the temporary directory containing all files as working dir so opening more files is easy (-c ":cd {cwd}", where{cwd}will be substituted by the path to current working directory).Note that since pages are added by default after the command, i didn't have to explicitely add{pages}after the-poption. I could have. I didn't.Set a different default wikiWhen setting multiple wikis in your ini file, you may use the optiondefault_wikito provide which wiki to use when no name is given. Example:[options]
default_wiki = second
[wiki:first]
url = https://wiki.one.example.net
user = john
password = passwordone
[wiki:second]
url = https://wiki.two.example.net
user = john
password = passwordtwoAliasesAny good system offers user-defined aliases, but keep in mind the converse error.Your aliases are set, under the[option]header (support for per-wiki aliases would be awesome, wouldn't it ?),
as in the following example:[options]
aliases = pp: c1:c2, aaaaaaa: a:a:aThis allows you to open pagec1:c2withvimoku pp, pagec1:c2:pwithvimoku pp:p, or pagea:a:a:stayingalivewithaaaaaaa:stayingalive.
Note that this last alias is not really helpful. Choose better aliases, kids.Aliases substitution only occur at thebeginningof the pagename. Hence,vimoku a:pp:awill happily opena:pp:a, nota:c1:c2:a.This is an arbitrary choice that, to me, seems to limit the number of unexpected behaviors when you are editing pages with long and weird names. Maybe that risk is worth the gain ?
This i do not know. Tell me if you know something about that.Work to be donefix the data loss problem when writing a new file and asking the program to upload it.what about using a watchdog to automatically download and lock the newly opened file ? Or provide a vim plugin ?use the CLI's--minorflagusetmpfileinstead of flooding.config/vimokuis it possible to upload a media ? yes, it is. seeclient.put_filethere is few TODOs in the code.aliases in config file, where writingaliases = pp: c1:c2makes commandvimoku pp:aedit pagec1:c2:a