Commit Graph

640 Commits

Author SHA1 Message Date
oakkitten
8d507908c7 Add GitHub workflows tests 2022-04-11 02:28:25 +01:00
oakkitten
8aa5fdd1de Add api method guiEditNote 2022-04-11 02:28:25 +01:00
oakkitten
2313b8ba65 Add tox.ini, remove test.sh
The tests can be run now using `tox` against multiple Anki versions;
see instructions in `tox.ini`.

The tests depend on `pytest-anki` that had to be slightly modified
to remove the upper constraint on Anki version, as well as
to remove a few dependencies that are not essential to using it.
2022-04-11 02:28:25 +01:00
oakkitten
fb892d330a Add tests for the Edit dialog 2022-04-11 02:28:03 +01:00
oakkitten
8f1a2cc5fd Convert all tests to pytest
Previously, tests were run against Anki launched by user.

Now,
 * most tests run against isolated Anki in current process;
 * tests in `test_server.py` launch another Anki in a separate process
   and run a few commands to test the server;
 * nearly all tests were preserved in the sense that
   what was being tested is tested still.
   A few tests in `test_graphical.py` are skipped due to
   a problem with the method tests, see the comments;
 * tests can be run:
   * In a single profile, using --no-tear-down-profile-after-each-test;
   * In a single app instance, but with the profile being torn down
     after each test--default;
   * In separate processes, using --forked.
2022-04-11 02:26:44 +01:00
oakkitten
ddad426563 Do not wrap api methods with a lambda
Makes Pycharm happy
2022-04-11 02:26:44 +01:00
oakkitten
cfc6b0d012 Move configuration defaults dict to module level
So that it is importable by tests
2022-04-11 02:26:44 +01:00
oakkitten
f7d5cbbd04 Edit dialog: refactor
* make previewer use a more generic Adapter to flip through cards;
* return Previewer from `show_preview()` for testing,
* as well as Edit dialog from `open_dialog_and_show_note_with_id`;
* disable/enable `Edit` editor buttons more reliably;
* a few minor changes
2022-04-11 02:26:35 +01:00
oakkitten
748310def4 Make plugin importable
Don't start the web server if imported not from inside Anki

Make sure Anki Connect instance is not garbage collected.
This kills the timer that's responsible for the web server.
2022-04-07 09:48:37 +01:00
oakkitten
d6061affad Remove api method updateCompleteDeck
This method was broken and there are no issues regarding it on GitHub.
2022-04-07 09:48:37 +01:00
oakkitten
eac658716a Fix api method findAndReplaceInModels
I think this was a typo?
2022-04-07 09:48:37 +01:00
oakkitten
baed642489 Fix api method deleteDecks
The method was failing due to Anki API changes.

Also, make it mandatory to call the method with `cardsToo=True`,
since deleting decks on Anki >= 2.1.28 without cards is
no longer supported, and the deprecated `decks.rem()` method
on Anki >= 2.1.45 ignores keyword arguments.
2022-04-07 09:48:37 +01:00
oakkitten
0fdc93abc6 Add Edit dialog
Like Edit Current, but:
  * has a Preview button to preview all cards for this note
  * has a Browse button to open the browser with these
  * has Previous/Back buttons to navigate the history of the dialog
  * has no Close button bar
2022-04-07 09:48:37 +01:00
thiswillbeyourgithub
54a7105bf9
implement setSpecificValueOfCard for user @TobiasWehrum (#303)
Co-authored-by: thiswillbeyourgithub <github@32mail.33mail.comm>
2022-02-22 18:31:43 -08:00
Raphael-Joel Lim
a5aecfceee
Explicitly allow requests from public websites via new header (#302)
- Chrome now enforces that servers on private networks explicitly
  grant access to public websites using a new header
  "Access-Control-Allow-Private-Network" that should be sent in
  responses to preflight OPTIONS requests.
- This change implements special handling for OPTIONS requests by
  sending all the existing CORS headers along with the new
  Access-Control-Allow-Private-Network header if private network
  access is being requested.
- See https://developer.chrome.com/blog/private-network-access-preflight/
  for more info.
2022-02-18 23:08:44 -08:00
Jone Wang
7136a15ade
Allow safari-web-extension to access Aniki Connect. (#297)
* Allow safari-web-extension to access Aniki Connect.

* Fix typo.
2022-01-08 20:01:00 -08:00
Ren Tatsumoto
418ebcb0de
Fix updateModelTemplates and updateModelStyling functionality on Anki 2.1.45 and later (#296)
* fix update functionality on anki 2.1.45+

* delete trailing semicolon in the statement
2021-12-26 22:21:21 -08:00
1db646c13e Update README 2021-12-16 08:51:35 -08:00
ed324caf16 Update README 2021-12-15 18:01:09 -08:00
1d35bdbbc0 Add site metadata 2021-12-14 16:57:05 -08:00
penginsan
064fbef413
Add guiSelectedNotes action (#292) 2021-12-06 08:59:10 -08:00
introt
ca60bf6c61
Clean up curl example (#289) 2021-09-26 10:41:04 -07:00
Marcel Graber
335de469c3
Save note after field update (#287)
Signed-off-by: Marcel Graber <marcel@clever.design>
2021-09-15 17:55:46 -07:00
Ripose
5bb02e7d21
guibrowse: fixes mockmodel error on new anki versions (#288)
Anki deprecated access to the model from the API and the new MockModel
contained no attribute 'cards' leading to an error message being thrown
instead of card ids being returned. This change uses findCards to find
card ids instead of the model so no error is thrown while keeping
guiBrowse functionally equivalent to the previous version.
Closes #277.
2021-09-14 20:30:36 -07:00
Jeff
ea35fe549a
Fix typo in readme (#285) 2021-09-06 11:44:07 -07:00
Twinov
b880463f52
Update README.md (#281)
The searching documentation seems to have moved.
2021-08-24 20:55:45 -07:00
thiswillbeyourgithub
2d08fdd5e5
feat: cardsInfo now also returns the modification time (#279)
* feat: cardsInfo now also returns the modification time

* minor: wrong indentation

* new method: get modification time of cards

* docs: mentions new method cardsModTime

* docs: readme now mentions that modification time is in the result from cardsInfo

Co-authored-by: thiswillbeyourgithub <github@32mail.33mail.comm>
2021-08-24 20:55:23 -07:00
Andreas
9e4d590aa0
Update README.md (#274) 2021-07-15 23:08:39 -07:00
NSBum
4e41429165
Fixed deck config id actions (#273)
The follow deck configuration actions were updated to conform to Anki’s current deck configuration access. Specifically, `decks.conf` is no longer available.

setDeckConfigId no longer check for existence of configuration id, because the access to the list of config id’s appears to be only through decks; and the config may theoretically be orphaned.
2021-07-14 18:22:10 -07:00
a34c1de0b4 Minor tweaks to readme 2021-07-13 17:58:27 -07:00
NSBum
8404bd782d
Added guiCheckDatabase action and fix #202 in saveDeckConfig (#271)
* Added guiCheckDatabase action

This action initiates a check database action in Anki but doesn’t wait for the action to complete before returning.

* Fixed #202 no dconf attribute in saveDeckConfig

Anki manages access to deck configuration differently now. This adapts saveDeckConfig to new style of access.
2021-07-13 17:55:22 -07:00
toasted-nutbread
2150940c7e
More create note duplicate options (#269)
* Simplify access to note['options']

* Add checkAllModels option

* Update documentation
2021-07-12 19:46:22 -07:00
Jason Won
591ac06aa3
allow guiAddCards to add media (#266)
* add media to editing note

* update readme
2021-06-20 20:35:09 -07:00
9c6a62d20b Remove old action docs 2021-06-08 22:58:05 -07:00
689cbf2d86 Update README 2021-06-08 20:50:53 -07:00
c9f0cc61c3 Update README 2021-06-08 20:42:38 -07:00
grepmew
a6406107e4
Resolves #223 by removing unnecessary image markup (#260) 2021-06-03 14:36:04 -07:00
abdo
f8ff7c0c38
storeMediaFile: Add option to keep file with the same name (#257) 2021-05-22 12:21:12 -07:00
DegrangeM
9fec86f7fe
Add requestPermission API method (#255)
* Add requestPermission Api Method

* Add documentation about requestPermission method

* Update version documentation
2021-05-07 20:33:06 -07:00
Kirill Salnikov
17d8ecf60f
Update createModel method to create Cloze models (#250) 2021-05-06 19:11:03 -07:00
DegrangeM
1a08d79454
Fix documentation (#253) 2021-05-05 22:31:26 -07:00
DegrangeM
9472ac4401
Fix vulnerability (#252)
* Improve and simplify code handling CORS

* Don't execute request when origin not allowed

Fix vulnerability

* Remove webCorsOrigin legacy option

It's confusing (and potentially insecure as removing webCorsOrigin in configuration would still set it to localhost)

* Allow 127.0.0.1 and browser extension if localhost allowed
2021-05-05 22:31:11 -07:00
Konstantin Sukovatij
929716c7b1
Added "getMediaFilesNames" action (#247) 2021-04-11 21:26:03 -07:00
abdo
2081330c35
Compare field names in a case-insensitive manner (#242) 2021-03-13 16:10:58 -08:00
9a18ae0b11 Better compat with old versions of Anki 2021-03-06 21:16:19 -08:00
Quentin Harscoët
27a8678f88
added getNumCardsReviewedByDay action (#239)
* added getNumCardsReviewedByDay action

* added sample in statistics.md

* fix bad quotes and add basic test
2021-03-06 09:58:40 -08:00
Kirill Salnikov
b8a7151ed0
Fix handling of errors in several methods (#238)
* Fix error message in updateNoteFields method

* Fix error handling in cardsInfo, notesInfo methods

* Add more tests for updateNoteFields, notesInfo

* Fix error handling in several methods

Also fixed obvious bugs in replaceTags and replaceTagsInAllNotes
methods.

* Add more tests for cards methods

* Add more tests for notes methods

* Update documentation on cards methods
2021-03-04 20:06:25 -08:00
Tsung-Po Sun(Munehiro)
a4d723de3e
Add "forgetCards" and "relearnCards" (#234)
* Add "forgetCards" and "relearnCards"

* Add unit tests

Co-authored-by: Tsung-Po Sun <tsungpo.sun@smartnews.com>
2021-03-04 20:02:57 -08:00
Venkata Ramana
131a1c7cfc
Added findAndReplaceInModels (#228)
* added findAndReplaceInModels api call

* added documentation for findAndReplaceInModels

* added findAndReplaceInModels api call

* updatd findAndReplaceInModels function

* added unit test for findAndReplaceInModels in models

* updated findAndReplaceInModels

* added unit test for findAndReplaceInModels

* removed 'all_models' in findAndReplaceInModels
2021-02-26 21:17:51 -08:00
ripose-jp
aaf6b3a55b
Fixed bug where hash was calculated using the wrong variable (#235) 2021-02-26 21:16:39 -08:00