Commit Graph

329 Commits

Author SHA1 Message Date
Damien Elmes
333d0735ff preserve mtime/usn when syncing deck config, and add snake_case names 2020-04-03 19:34:46 +10:00
Damien Elmes
c9da4bc1a6 allow aborting a media sync while http req in flight
The progress handling code needs a rethink, as we now have two separate
ways to flag that the media sync should abort. In the future, it may
make sense to switch to polling the backend for progress, instead of
passing a callback in.
2020-04-01 09:49:25 +10:00
Damien Elmes
35c03af520 split deck config into separate SQL table
- on collection load, the schema is upgraded to 12
- on collection close, the changes are reversed so older clients
can continue to open the collection
- in the future, we could potentially skip the reversal except
when exporting/doing a full sync
- the same approach should work for decks, note types and tags in the
future too
- the deck list code needs updating to cache the deck confs for the
life of the call
2020-03-30 20:01:16 +10:00
Damien Elmes
004cc2b5f8 move deck conf handling to backend 2020-03-30 14:39:46 +10:00
Damien Elmes
84b84ae31c use add_card() 2020-03-27 15:11:07 +10:00
Damien Elmes
7f16f436c3 handle mtime/usn bump in backend, and tweak integer sizes 2020-03-26 20:55:04 +10:00
Damien Elmes
47504245dc update_card() 2020-03-26 18:54:20 +10:00
Damien Elmes
7ddaf93f7a use backend to get card 2020-03-26 17:47:43 +10:00
Damien Elmes
69d8cdd9ed use backend for v1 and v2 cutoff calculations
this should also fix the CI failures, which were happening because
the datetime module wasn't matching the shifted time.time()
2020-03-22 14:28:26 +10:00
Damien Elmes
f28e57a367 add enum for controlling sort order
eg col.find_cards("", order=BuiltinSortKind.CARD_DUE)
2020-03-22 12:59:24 +10:00
Damien Elmes
a5787781d7 add note searching 2020-03-21 09:00:05 +10:00
Damien Elmes
5debd3e0f8 add the ability to provide a custom sort order; use backend for find 2020-03-21 07:55:21 +10:00
Damien Elmes
bca5f2ddff prototype of integration
no ordering yet, and no tests
2020-03-20 21:15:23 +10:00
Damien Elmes
874bc085fe support opening and closing the DB while keeping backend alive
This is safer than just dropping the backend, as .close() will
block if something else is holding the mutex. Also means we can
drop the extra I18nBackend code.

Media syncing still needs fixing.
2020-03-20 21:15:23 +10:00
Damien Elmes
1322d8c617 make the collection optional 2020-03-20 21:15:23 +10:00
Damien Elmes
b51e575a9d drop the protobuf prototype 2020-03-20 21:15:23 +10:00
Damien Elmes
04ca8ec038 initial work on DB handling in Rust
committing the Protobuf implementation for posterity, but will replace
it with json, as Protobuf measures about 6x slower for some workloads
like 'select * from notes'
2020-03-20 21:15:23 +10:00
Damien Elmes
0f4c3ab611 add restore media action 2020-03-10 13:35:09 +10:00
Damien Elmes
6ad2a1f9a3 add empty trash action in aqt 2020-03-10 12:49:40 +10:00
Damien Elmes
3d3fe17132 add missing newline to .proto 2020-03-09 18:58:49 +10:00
Damien Elmes
ba4fe71eba make logging explicit, and support logging to a file 2020-02-29 20:44:01 +10:00
Damien Elmes
b610ff781f info is superfluous 2020-02-27 10:53:49 +10:00
Damien Elmes
644670d0d6 return a localized error for all error kinds
some errors are not yet localized, but now the Python code
doesn't need to think about which property to use
2020-02-27 10:46:24 +10:00
Damien Elmes
71c18a9372 separate out infallible and fallible commands in .proto 2020-02-27 08:46:09 +10:00
Damien Elmes
fbbbbd6a7d tweak rounding
- avoid rounding minutes
- round the seconds taken in the card info screen
- provide different precise and imprecise modes, since we need
to display seconds to multiple decimals in some areas
2020-02-25 17:29:06 +10:00
Damien Elmes
9f7c3a2fcf expand clozes before rendering LaTeX
https://anki.tenderapp.com/discussions/ankidesktop/39071-latex-media-windows-version-2121-683b7983-fail-rendering-latex
2020-02-24 18:34:08 +10:00
Damien Elmes
0e931808c9 translations no longer require an open collection 2020-02-23 14:57:02 +10:00
Damien Elmes
4430c67069 rework Fluent handling
- all .ftl files for a language are concatenated into a single file
at build time
- all languages are included in the binary
- external ftl files placed in the ftl folder can override the
built-in definitions
- constants are automatically generated for each string key
- dropped the separate StringsGroup enum
2020-02-23 13:22:50 +10:00
Damien Elmes
6fd3d1e8b4 add deck config category 2020-02-21 20:53:20 +10:00
Damien Elmes
972aee5f7a add next learning due time + remaining count to congrats screen
https://anki.tenderapp.com/discussions/ankidesktop/38000-v2-scheduler-learning-cards
2020-02-21 19:54:50 +10:00
Damien Elmes
49fe080636 add studied_today(), move to statistics.ftl 2020-02-21 18:01:15 +10:00
Damien Elmes
2fc15d0d3a add non-abbreviated timespan translation; update existing short=True calls
- drop the '5m3s' special casing done in the card stats screen, and
just use decimals
- change alignment of the review log so that the non-abbreviated
spans are easier to read
2020-02-21 15:29:38 +10:00
Damien Elmes
99c07cfdcb move answer_button_time to the backend, split sched into separate module 2020-02-21 15:29:38 +10:00
Damien Elmes
232a8625bf move answer button labels into fluent 2020-02-21 15:29:38 +10:00
Damien Elmes
370bb38b8b update to latest fluent-rs and add basic locale-aware decimals
- git version pinned at the moment until the concurrency fix
lands in 0.10.2
- currently float values are hard-coded at 2 decimal places;
we should switch to using NUMBER() in the future
2020-02-21 15:29:38 +10:00
Damien Elmes
1524e7dcac split "Due" into three different contexts for translators 2020-02-17 14:41:01 +10:00
Damien Elmes
d612aa0945 localize some error messages 2020-02-17 11:38:22 +10:00
Damien Elmes
c395003def expose translations to Python 2020-02-17 08:40:17 +10:00
Damien Elmes
f6a881f950 pass progress back as translated string(s) 2020-02-17 08:40:17 +10:00
Damien Elmes
cc99f221be expose StringsGroup enum in protobuf 2020-02-17 08:40:17 +10:00
Damien Elmes
33367c8edf make template errors translatable 2020-02-17 08:40:17 +10:00
Damien Elmes
5c8e3df612 include report in MediaCheckOutput 2020-02-17 08:40:17 +10:00
Damien Elmes
dc9362d4ed add i18n support to Rust code using Fluent 2020-02-17 08:40:17 +10:00
Damien Elmes
d73fec3280 shorten add_file_to_media_folder 2020-02-17 08:40:17 +10:00
Damien Elmes
4c0f216df2 use media.trash for unused media deletion as well 2020-02-17 08:40:17 +10:00
Damien Elmes
7f365faf3f add extract_latex to backend; use it for latex build 2020-02-17 08:40:17 +10:00
Damien Elmes
6f158c8555 plug new media check in 2020-02-17 08:40:17 +10:00
Damien Elmes
aa832e9117 backend stores media folder/db locations; don't need to pass them in 2020-02-17 08:40:17 +10:00
Damien Elmes
7ae6244f6a log media DB change registration progress, and allow aborting it 2020-02-17 08:40:17 +10:00
Damien Elmes
5fe1bfc5b4 simplify code by accumulating stats at the source 2020-02-17 08:40:17 +10:00
Damien Elmes
98279add15 defer errors on upload to media check 2020-02-17 08:40:17 +10:00
Damien Elmes
6a64c8dfcc use enums for some common errors 2020-02-17 08:40:16 +10:00
Damien Elmes
ea4de9a6de connect media sync progress to Python, add a progress dialog 2020-02-17 08:40:16 +10:00
Damien Elmes
c82cff3836 add progress hook to media sync 2020-02-17 08:40:16 +10:00
Damien Elmes
f20b5b8db6 media sync working, but unpolished 2020-02-17 08:40:16 +10:00
Damien Elmes
01470c4854 backend init can now fail, and update media db when file is added
- Adding files inside Anki now updates the media DB, so a full file
scan at sync time is no longer required if no other changes have been
made.
- Use a protobuf message for backend initialization, and return a
string error if initialization fails.
2020-02-17 08:40:16 +10:00
Damien Elmes
056c2d3fd1 initial rs implementation of media database 2020-02-17 08:40:16 +10:00
Damien Elmes
4096d21c07 add add_file() and write_data() 2020-02-17 08:40:16 +10:00
Damien Elmes
bd96c27096 show which side the template error occurred on 2020-02-08 11:54:08 +10:00
Damien Elmes
c075191697 reuse reveal_cloze_text() for LaTeX cloze expansion 2020-01-28 07:40:44 +10:00
Damien Elmes
21cbb5a766 support speed control in tts tags 2020-01-26 14:31:07 +10:00
Damien Elmes
17ebdfc099 extract and flag AV tags as part of the render process
We can now show replay buttons for the audio contained in {{FrontSide}}
without having to play it again when the answer is shown.

The template code now always defers FrontSide rendering, as it wasn't
a big saving, and meant the logic had to be implemented twice.
2020-01-24 11:06:11 +10:00
Damien Elmes
4fb227ca4c added flag_av_tags() for replay button support 2020-01-21 14:44:27 +10:00
Damien Elmes
c713683f63 add rank handling to TTS; parse TTS args in get_av_tags() 2020-01-21 12:41:37 +10:00
Damien Elmes
0942ffbff6 add a simple TTS field filter
This simply wraps the field in extra text that the frontend will
deal with. Also added some helpers for extracting and stripping
audio and TTS tags from the rendered text.
2020-01-20 19:16:24 +10:00
Damien Elmes
bead03e858 drop plus_one test 2020-01-17 18:54:38 -07:00
Damien Elmes
12c60f20fe _localOffsetForDate() was broken
It was including the elapsed time of day when calculating
the offset, leading to incorrect results
2020-01-17 18:52:36 -07:00
Damien Elmes
9bb0348fdd more template rendering tweaks
- The front and back are rendered in one call now. If the front
side contains no custom filters, we can bake {{FrontSide}} into the
rear side. If it did contain custom filters, we return the partially
complete rear template instead, and the calling code can inject
the FrontSide in after it has been fully rendered.

- Instead of modifying "cloze" into something like "cq-2", the card
ordinal and whether we're rendering the question or answer are now
passed in to the rendering filters as context.

- The Rust code doesn't need to support filter names split on '-'
anymore.

- Drop the "Show" part of hint descriptions so i18n support can be
deferred.

- Ignore blank filter names caused by user using two colons instead
of one.

- Fixed hint field and text transposition.
2020-01-12 21:34:07 +10:00
Damien Elmes
3f724e5c98 replace fields and apply standard filters in rslib
The filters still need to be implemented.
2020-01-10 18:02:26 +10:00
Damien Elmes
f7ff0d1c17 flatten->render; pass field content in
This is paving the way to move the standard filters into Rust.

Non-empty fields are now determined in Rust, using a single regex
instead of the overkill stripHTMLMedia(). The old implementation
has been moved into the Pystache code for now.
2020-01-10 14:59:29 +10:00
Damien Elmes
a5613523ee rework new timezone code
We now store the UTC offset that was in effect at creation time,
and use that to determine the starting date.
2020-01-09 16:58:27 +10:00
Damien Elmes
0087eee6d9 handle conditional replacement in Rust
This extends the existing Rust code to handle conditional
replacement. The replacement of field names and filters to text
remains in Python, so that add-ons can still define their own
field modifiers.

The code is currently running the old Pystache rendering and the
new implementation in parallel, and will print a message to the
console if they don't match. If you notice any problems, please
let me know.
2020-01-08 20:28:04 +10:00
Damien Elmes
8df5f49c52 add some more protobuf messages 2020-01-06 12:18:20 +10:00
Damien Elmes
0bfc90f52f update readme, remove submodule readmes 2020-01-04 12:21:58 +10:00
Damien Elmes
b23b6fbe35 move the separate components back into this monorepo
Earlier today I pushed a change that split this code up into multiple
repos, but that has proved to complicate things too much. So we're
back to a single repo, except the individual submodules are better
separated than they were before.

The README files need updating again; I will push them out soon.

Aside from splitting out the different modules, the sound code has
moved from from anki to aqt.
2020-01-02 19:43:19 +10:00
Damien Elmes
92673c99d8 rework the new scheduler's rollover/day counting code
The previous implementation interpreted the creation date as a local
time, and applied the rollover to that. If the initial creation date
was around midnight local time, even a one hour change due to daylight
savings could result in Anki skipping or doubling up on a day. To
address this, the rollover is now applied to the current time instead
of the creation date.

The new code needs the current time passed into it. This makes it
easier to unit test, and for AnkiWeb to be able to use the user's local
timezone.

The new timezone code is currently disabled, as this code needs to be
ported to all clients before it can be activated.
2019-12-27 21:53:20 +10:00
Damien Elmes
3e1b474dca bridge->backend 2019-12-25 08:59:33 +10:00
Damien Elmes
3ce4d5fd3d compute template requirements in Rust
on a 100 field template, what took ~75 seconds now takes ~3 seconds.
2019-12-24 19:57:54 +10:00
Damien Elmes
252a0cb54f use protobuf for python/rust bridge
If we go ahead with betterproto on the Python side, it will mean
bumping the minimum Python dependency to 3.7.
2019-12-24 19:57:54 +10:00