KOReader plugin enabling Anki note generation for words looked up in the internal dictionary.
1) Install AnkiConnect to enable this plugin to communicate with Anki.
NOTE: as mentioned in the Anki-Connect documentation, you will not be able to connect to Anki-Connect from your e-reader without updating the default settings.
By default, Anki-Connect will only bind the HTTP server to the 127.0.0.1 IP address, so that you will only be able to access it from the same host on which it is running. If you need to access it over a network, you can change the binding address in the configuration. Go to Tools->Add-ons->AnkiConnect->Config and change the “webBindAddress” value. For example, you can set it to 0.0.0.0 in order to bind it to all network interfaces on your host. This also requires a restart for Anki.
2) Download the plugin, unzip it in the koreader/plugins
directory, make sure the folder is named anki.koplugin
, this is necessary for KOReader to load it.
Alternatively, use KOReader's built in SSH server:
git clone "https://github.com/Ajatt-Tools/anki.koplugin.git" ./anki.koplugin
ssh -p 2222 root@<IP-address>:/mnt/onboard/.adds/koreader <local_folder>
# be careful to not add a trailing / to the source directory, this creates the folder on your device
rsync -Pruv --exclude=".git/" ./anki.koplugin <local_folder>/plugins/
When the plugin has been installed succesfully, there will be an extra button present on the reader's dictionary popup window, allowing the user to create an Anki note.
When pressed, the add-on will generate a note for the looked up word.
The information extracted from the dictionary and book is sent to separate fields on the note.
Below is a list of all fields, along with the configuration option that defines which field on your note it ends up on.
The configuration options are stored in config.lua
. Each key mentioned below (e.g. word_field
, def_field
) is defined in this file.
Notes are saved locally on the device when the remotely running Anki isn't available. When it becomes available again, the user will be reminded they have unsynced notes.
This can also be done manually by pressing and holding the 'Add to Anki' button, and choosing the manual sync option.
As mentioned earlier, when pressing and holding the 'Add to Anki' button, a separate menu is shown:
This option can be used to send the locally stored notes to Anki.
This allows the user to allows the user to create a card with custom tags, which are defined in config.lua
By default, the complete sentence the word occured in is stored on the note. In cases where this is too little or too much context, the user can modify it by pressing this button. This pops up a menu where the exact amount of text can be selected.
It's also possible to undo the creation of the latest card, which can be handy when deciding you want to add some extra context to the note.
User configuration is stored in the config.lua
file. Take care not to break the Lua syntax!
Do not remove any entries which are marked as REQUIRED in the explanatory comment. Doing so will cause the plugin to fail to load. Other entries can be safely omitted, any missing fields will not be generated.
There is code in place to create a menu, with which some of the fields can be edited on the reader itself. Adding an option in the KOreader's menu isn't possible from within a standalone plugin, but it can be done with a user patch.
If everything goes right, this should add an extra option to the search menu:
NOTE
When updating one of the settings on the reader itself, this setting will be stored in KOreader's settings
folder, under the name ankiconnect.lua
.
This means that the value in config.lua
may not be the one that's used by the plugin. KOreader's settings folder takes precedence.
This ankiconnect.lua
file can safely be deleted, in which case the 'default' settings from config.lua
will be used again.