UBA Startup Plugins - eliranwong/UniqueBible GitHub Wiki

UBA Startup Plugins

UBA startup plugins are plugins files executed when UBA starts.

With UBA startup plugins, you can automate a feature, a command or a batch of commands when UBA starts.

A valid plugin file should be written in python file extension ".py".

Read https://github.com/eliranwong/UniqueBible/wiki/UBA-Plugins for other types of UBA plugins.

File Location

All UBA context plugins are placed in folder "plugins/startup/" inside UniqueBible home directory.

Enable Plugins

You need to have "enablePlugins" checked on "Set Config Flags" window.

Automate a Menu Plugin on Startup

You can automate an UBA menu plugin on startup

e.g. https://github.com/eliranwong/UniqueBible/wiki/Notes-Backup-with-Google-Drive#automate-restoration-on-startup

Write you own startup plugins

You may make use of the following variables below to write your own plugins.

Remarks: The more startup plugins you use, the longer the time UBA starts.

config.mainWindow

config.mainWindow points to the mainWindow of UBA. This gives you an access point of UBA built-in functions.

e.g. use config.mainWindow.runTextCommand() to run a UBA command.

config.actionsRightAfterLoadingHistoryRecords

A container of functions to be run after UBA loaded history records on startup

All startup plugins are loaded before UBA loads history records

A startup plugin can place code(s) in config.actionsRightAfterLoadingHistoryRecords so that they are run after history records being loaded.

e.g.

def runThisFunctionLater():     print("hello")

config.actionsRightAfterLoadingHistoryRecords.append(runThisFunctionLater)

config.bibleWindowContentTransformers

config.bibleWindowContentTransformers points to a list of functions, which are used to transform content to be displayed on Bible Window.

e.g. https://github.com/eliranwong/UniqueBible/blob/master/plugins/startup/addHoverFeatureToBibleLinks.py

config.studyWindowContentTransformers

config.studyWindowContentTransformers points to a list of functions, which are used to transform content to be displayed on Study Window.

e.g. https://github.com/eliranwong/UniqueBible/blob/master/plugins/startup/addHoverFeatureToBibleLinks.py

config.customCommandShortcuts

This applies to web version http-server ONLY!

config.customCommandShortcuts is an empty dictionary when http-server starts running.

Users can add entries to it via a startup plugin to customise command shortcuts for http-server operations.

e.g. create a startup plugin and add the following line, to open Chinese Union Version, by simply typing .cuv command.

config.customCommandShortcuts[".cuv"] = "TEXT:::CUV"

ATTENTION! You can use customised command shortcuts in config.customCommandShortcuts to overrides a built-in shortcut.

e.g. Http-server has a built-in command ".bible". Adding the following line in a startup plugin overrides the built-in command ".bible".

config.customCommandShortcuts[".bible"] = "TEXT:::CUV"

An Example

A startup plugin could be as simple as below.

import config

config.mainWindow.runTextCommand("SPEAK:::Hello!")

Example on adding a new command keyword

import config

def newFunction(command, source):     print(command)     return ("study", command, {})

config.mainWindow.textCommandParser.interpreters["mynewkeyword"] = (newFunction, "documentation")

With this example script placed in folder "plugins/startup/", when you enter in command field "mynewkeyword:::test", you will see "test" is displayed on study window.

More examples

https://github.com/eliranwong/UniqueBible/tree/master/plugins/startup