Fixes for old version of Anki, cleanup script

This commit is contained in:
Alex Yatskov 2020-03-05 19:29:49 -08:00
parent 385ff2a43e
commit 975c0699b7
3 changed files with 24 additions and 5 deletions

13
link.sh
View File

@ -1,2 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
ln -s $(pwd)/plugin ~/.local/share/Anki2/addons21/AnkiConnectDev
plugin_name=AnkiConnectDev
plugin_path_linux=~/.local/share/Anki2/addons21
plugin_path_mac=~/Library/Application\ Support/Anki2/addons21
if [ -d "$plugin_path_linux" ]; then
ln -s -f $(pwd)/plugin $plugin_path_linux/$plugin_name
fi
if [ -d "$plugin_path_mac" ]; then
ln -s -f $(pwd)/plugin $plugin_path_mac/$plugin_name
fi

View File

@ -1,2 +0,0 @@
#!/usr/bin/env bash
ln -s $(pwd)/plugin ~/Library/Application\ Support/Anki2/addons21/AnkiConnectDev

View File

@ -802,12 +802,22 @@ class AnkiConnect:
name = info['name'] name = info['name']
fields[name] = {'value': note.fields[order], 'order': order} fields[name] = {'value': note.fields[order], 'order': order}
if getattr(card, 'question', None) is None:
question = card._getQA()['q']
else:
question = card.question(),
if getattr(card, 'answer', None) is None:
answer = card._getQA()['a']
else:
answer = card.answer()
result.append({ result.append({
'cardId': card.id, 'cardId': card.id,
'fields': fields, 'fields': fields,
'fieldOrder': card.ord, 'fieldOrder': card.ord,
'question': card.question(), 'question': question,
'answer': card.answer(), 'answer': answer,
'modelName': model['name'], 'modelName': model['name'],
'deckName': self.deckNameFromId(card.did), 'deckName': self.deckNameFromId(card.did),
'css': model['css'], 'css': model['css'],