{"id":21302326,"url":"https://github.com/ajatt-tools/anki.koplugin","last_synced_at":"2025-03-31T10:01:57.560Z","repository":{"id":104820040,"uuid":"605311755","full_name":"Ajatt-Tools/anki.koplugin","owner":"Ajatt-Tools","description":"KOReader plugin enabling Anki card generations for words looked up in the internal dictionary.","archived":false,"fork":false,"pushed_at":"2025-03-05T22:10:53.000Z","size":145,"stargazers_count":81,"open_issues_count":5,"forks_count":10,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-23T00:19:32.333Z","etag":null,"topics":["ajatt","anki","ankiconnect","koreader","koreader-plugin"],"latest_commit_sha":null,"homepage":"","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ajatt-Tools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-02-22T22:25:54.000Z","updated_at":"2025-03-21T09:11:30.000Z","dependencies_parsed_at":"2023-05-17T08:47:04.098Z","dependency_job_id":"21603b1e-1d21-4693-ab88-5b20b408d3d1","html_url":"https://github.com/Ajatt-Tools/anki.koplugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajatt-Tools%2Fanki.koplugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajatt-Tools%2Fanki.koplugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajatt-Tools%2Fanki.koplugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ajatt-Tools%2Fanki.koplugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ajatt-Tools","download_url":"https://codeload.github.com/Ajatt-Tools/anki.koplugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246450408,"owners_count":20779406,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ajatt","anki","ankiconnect","koreader","koreader-plugin"],"created_at":"2024-11-21T15:55:46.817Z","updated_at":"2025-03-31T10:01:57.521Z","avatar_url":"https://github.com/Ajatt-Tools.png","language":"Lua","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Anki plugin for KOReader\n\nKOReader plugin enabling Anki note generation for words looked up in the internal dictionary.\n\n## Installation\n\n1) Install [AnkiConnect](https://ankiweb.net/shared/info/2055492159) to enable this plugin to communicate with Anki.\n\n   **NOTE:** as mentioned in the Anki-Connect [documentation](https://foosoft.net/projects/anki-connect/), you will not be able to connect to Anki-Connect from your e-reader without updating the default settings.\n\n   \u003e 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.\n   \u003e If you need to access it over a network, you can change the binding address in the configuration.\n   \u003e Go to Tools-\u003eAdd-ons-\u003eAnkiConnect-\u003eConfig and change the “webBindAddress” value.\n   \u003e 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.\n\n2) 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.\n\n   Alternatively, use KOReader's built in SSH server:\n\n   ```sh\n   git clone \"https://github.com/Ajatt-Tools/anki.koplugin.git\" ./anki.koplugin\n   sshfs -p 2222 root@\u003cIP-address\u003e:/mnt/onboard/.adds/koreader \u003clocal_folder\u003e\n   # be careful to not add a trailing / to the source directory, this creates the folder on your device\n   rsync -Pruv --exclude=\".git/\" ./anki.koplugin \u003clocal_folder\u003e/plugins/\n   ```\n\n## Usage\n\nWhen 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.\n\n\n![image](https://user-images.githubusercontent.com/34285115/228915515-b6d3eef6-d9e3-4899-9922-db040a29f2b3.png)\n\nWhen pressed, the add-on will generate a note for the looked up word.\n\n![image](https://github.com/Ajatt-Tools/anki.koplugin/assets/34285115/641bbb46-d23f-488f-9c1a-72c2e9db4125)\n\n## Features\nThe information extracted from the dictionary and book is sent to separate fields on the note.\n\nBelow is a list of all fields, along with the setting that defines which field on your note it ends up on.\nThese settings are configured via a user profile, see [Profiles](profiles/README.md) for more info.\n\n\u003cdetails\u003e\n  \u003csummary\u003eAvailable fields\u003c/summary\u003e\n  \n  #### Selected word (`word_field`)\n  The word selected in the book.\n  #### Sentence context (`context_field`)\n  The full sentence that the word occured in, extracted from the book.\n  #### Translated Sentence (`translated_context_field`)\n  The translation of the sentence context mentioned above. The target language is inherited from the translation settings in KOReader itself.\n  #### Previous sentence count (`prev_sentence_count`)\n  Define the amount of sentences which should be prepended to the word you looked up. Set this to `1` to have it complete the sentence the word occured in.\n  #### Next sentence count (`next_sentence_count`)\n  Define the amount of sentences which should be appended to the word you looked up. Set this to `1` to have it complete the sentence the word occured in.\n  \n  \n  The exact context stored can be modified by pressing and holding the 'Add to Anki' button, and choosing the 'custom context' entry on the menu that pops up.\n  \n  #### Dictionary definition (`def_field`)\n  The dictionary entry that was selected when pressing the button.\n  #### Audio (`audio_field`)\n  The plugin will query Forvo to get audio for the lookupword. The language used is determined by the dictionary's language, or by the book's language as fallback.\n  #### Metadata (`meta_field`)\n  Some information about the book: author, title and page number.\n  \n  This info is retrieved from the EPUB's metadata, or by parsing the filename with a Lua pattern (`\"^%[([^%]]-)%]_(.-)_%[([^%]]-)%]%.[^%.]+\"`)\n  \n  The pattern expects filenames with the following format: `[Author]_Title_[extra_info].epub`. The extension can be anything.\n\u003c/details\u003e\n\n### Offline usage\nNotes 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. \n\nThis can also be done manually by pressing and holding the 'Add to Anki' button, and choosing the manual sync option.\n\n### Extra options\n\nAs mentioned earlier, when pressing and holding the 'Add to Anki' button, a separate menu is shown:\n\n![image](https://github.com/Ajatt-Tools/anki.koplugin/assets/34285115/932df377-c9fe-4083-8964-8536780b2920)\n\n##### Sync offline notes\nThis option can be used to send the locally stored notes to Anki.\n##### Custom tags\nThis allows the user to allows the user to create a card with custom tags.\n##### Custom context\nBy 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.\n#### Undo latest note\nIt'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.\n#### Change profile\nLink the currently opened document with a different user profile.\n\n## Configuration\n\nConfiguration is done by defining profiles, See [Profiles](profiles/README.md) for more info.\n\n### Edit configuration within KOreader\nThere 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](https://github.com/koreader/koreader/wiki/User-patches).\n\n\u003cdetails\u003e\n  \u003csummary\u003eShow snippet\u003c/summary\u003e\n  Save the code snippet below in a file with the name `2-anki-menu-patch.lua`. This file should be stored in `koreader/patches`.\n  \n  ```lua\n  local FileManagerMenuOrder = require(\"ui/elements/filemanager_menu_order\")\n  local ReaderMenuOrder = require(\"ui/elements/reader_menu_order\")\n  \n  table.insert(FileManagerMenuOrder.search, 5, \"anki_settings\")\n  table.insert(ReaderMenuOrder.search, 5, \"anki_settings\")\n  ```\n    \n\u003c/details\u003e\n\n\nIf everything goes right, this should add an extra option to the search menu:\n![2023-03-30_19-57](https://user-images.githubusercontent.com/34285115/228923486-bc6f87ec-f65a-4789-bcb5-e053ba36aa5c.png)\n\nWhen editing a profile which is *not* the default one, it's possible to 'unset' a setting (meaning it falls back on whatever is present in the `default.lua` profile). This is done by pressing and holding the setting you would like to reset.\n\n## FAQ\n\n\u003cdetails\u003e\n  \u003csummary\u003ePlugin can't detect the language of the word\u003c/summary\u003e \n  When the user has defined a value for the `audio_field` in the config, the plugin needs to know the language of the word you looked up, so it can look for the correct audio file.\n\n\n  It looks for this language in 2 places\n  - Stardict's `.ifo` file\n  \n    Each dictionary installed has its own folder consisting of, among other files, an `.ifo` file with some info about this dictionary, looking something like this:\n    ```\n    StarDict's dict ifo file\n    version=2.4.2\n    wordcount=18244\n    idxfilesize=405703\n    bookname=Dutch-English dictionary\n    date=2009.01.30\n    sametypesequence=x\n    description=Copyright: Converted by swaj under GNU Public License; Version: 1.1\n    ```\n    In this case (Dutch-English), add the following line: `ifo_lang=nl-en` (just `ifo_lang=nl` would work too).\n  \n    This field is parsed by KOReader, and used by this plugin when available. This should already be present for dictionaries downloaded internally.\n  \n  - the language of the document\n  \n    In some documents, like `.epub` files, it is possible to define the language of the text with it. When this info is available, the plugin will use it.\n  \n    KOReader also allows you to edit a document's metadata manually, by opening the top menu \u003e Hamburger menu \u003e Book information \u003e Tap and hold \"Language\" \u003e Set custom.\n  \n    The expected format of this language is, like above, the ISO2 code. For example, to specify French, fill in 'fr'\n  \n  If you don't care about having audio, you can leave the `audio_field` blank. This will cause this step to be skipped completely.\n    \n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajatt-tools%2Fanki.koplugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajatt-tools%2Fanki.koplugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajatt-tools%2Fanki.koplugin/lists"}