Go to file
2020-09-02 18:53:24 +02:00
config Add ankisyncd environment variables to .env.example 2020-07-30 23:06:50 +01:00
docs Generate mkdocs markdown documentation 2020-07-30 20:20:24 +01:00
notebooks Add notebook to read collections 2020-06-27 00:48:50 +01:00
scripts Add script to lock and export requirements 2020-07-30 21:49:34 +01:00
src Fix parent initialization of SyncCollectionHandler 2020-09-02 18:53:24 +02:00
tests mock_servers test helper works with new syncer code 2020-09-02 18:53:24 +02:00
.gitignore Add gitignore for python and jupyter notebooks 2020-06-27 00:46:47 +01:00
.readthedocs.yml Add .readthedocs.yml to specify mkdocs.yml path 2020-07-30 20:50:50 +01:00
COPYING Renamed LICENSE.txt to COPYING 2013-10-13 16:10:00 -05:00
Makefile Add jupyter lab and notebook as a dependency 2020-07-30 21:47:36 +01:00
poetry.lock Add webob as a dependency to pyproject 2020-07-30 22:18:52 +01:00
pyproject.toml Add webob as a dependency to pyproject 2020-07-30 22:18:52 +01:00
README.md updated readme to reflect latest changes 2020-09-02 18:53:24 +02:00

ankisyncd

Documentation Status Gitter

Anki is a powerful open source flashcard application, which helps you quickly and easily memorize facts over the long term utilizing a spaced repetition algorithm. Anki's main form is a desktop application (for Windows, Linux and macOS) which can sync to a web version (AnkiWeb) and mobile versions for Android and iOS.

This is a personal Anki server, which you can sync against instead of AnkiWeb. It was originally developed by David Snopek to support the flashcard functionality on Bibliobird, a web application for language learning.

This version is a fork of jdoe0/ankisyncd. It supports Python 3 and Anki 2.1.

Contents

Installing

  1. Install the current version of Anki.

  2. Install the dependencies:

     $ pip install webob
    
  3. Modify ankisyncd.conf according to your needs

  4. Create user:

     $ ./ankisyncctl.py adduser <username>
    
  5. Setup a proxy to unchunk the requests. Webob does not support the header "Transfer-Encoding: chunked" used by Anki and therefore ankisyncd sees chunked requests as empty. To solve this problem setup Nginx (or any other webserver of your choice) and configure it to "unchunk" the requests to ankisyncd:

    server { listen 27701; server_name default;

     location / {
         proxy_http_version 1.0;
         proxy_pass         http://ankisyncd:27701/;
     }
    

    }

  6. Run ankisyncd:

     $ python -m ankisyncd
    

Installing (Docker)

Follow these instructions.

Setting up Anki

Anki 2.1.28 and above

Create a new directory in the add-ons folder (name it something like ankisyncd), create a file named __init__.py containing the code below and put it in the ankisyncd directory.

import os

addr = "http://127.0.0.1:27701/" # put your server address here
os.environ["SYNC_ENDPOINT"] = addr + "sync/"
os.environ["SYNC_ENDPOINT_MEDIA"] = addr + "msync/"

Anki 2.1

Create a new directory in the add-ons folder (name it something like ankisyncd), create a file named __init__.py containing the code below and put it in the ankisyncd directory.

import anki.sync, anki.hooks, aqt

addr = "http://127.0.0.1:27701/" # put your server address here
anki.sync.SYNC_BASE = "%s" + addr
def resetHostNum():
    aqt.mw.pm.profile['hostNum'] = None
anki.hooks.addHook("profileLoaded", resetHostNum)

Anki 2.0

Create a file (name it something like ankisyncd.py) containing the code below and put it in ~/Anki/addons.

import anki.sync

addr = "http://127.0.0.1:27701/" # put your server address here
anki.sync.SYNC_BASE = addr
anki.sync.SYNC_MEDIA_BASE = addr + "msync/"

AnkiDroid

Advanced → Custom sync server

Unless you have set up a reverse proxy to handle encrypted connections, use http as the protocol. The port will be either the default, 27701, or whatever you have specified in ankisyncd.conf (or, if using a reverse proxy, whatever port you configured to accept the front-end connection).

Even though the AnkiDroid interface will request an email address, this is not required; it will simply be the username you configured with ankisyncctl.py adduser.

Running ankisyncd without pyaudio

ankisyncd doesn't use the audio recording feature of Anki, so if you don't want to install PortAudio, you can edit some files in the anki-bundled directory to exclude pyaudio:

ENVVAR configuration overrides

Configuration values can be set via environment variables using ANKISYNCD_ prepended to the uppercase form of the configuration value. E.g. the environment variable, ANKISYNCD_AUTH_DB_PATH will set the configuration value auth_db_path

Environment variables override the values set in the ankisyncd.conf.

Support for other database backends

sqlite3 is used by default for user data, authentication and session persistence.

ankisyncd supports loading classes defined via config that manage most persistence requirements (the media DB and files are being worked on). All that is required is to extend one of the existing manager classes and then reference those classes in the config file. See ankisyncd.conf for example config.