Commit graph

5093 commits

Author SHA1 Message Date
Aleksa Sarai
21769bfa68 rust: switch to stable compilers
The only dependency which required nightly compilers was pyo3, which
supports stable Rust (1.39.0 and later) since version 0.11.0. Supporting
stable Rust makes it easier to package Anki for distributions. No other
code changes were required.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:39:51 +10:00
Aleksa Sarai
da040372da rslib: disable bzip2 feature
We can't link against libzip2.so.1 when building manylinux wheels, but
the only dependency which required this was "zip" and we don't appear to
make use of bzip2 in Anki.

This fixes the following "make build" error on Linux:

  x maturin failed
    Caused by: Failed to ensure manylinux compliance
    Caused by: Your library is not manylinux compliant because it links the following forbidden libraries: ["libbz2.so.1"]

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:39:11 +10:00
Aleksa Sarai
96da137314 rs: remove most &mut references in BackendService
The previous implementation had some slightly questionable memory safety
properties (older versions of PyO3 didn't uphold the Rust aliasing rules
and would thus create multiple &mut references to #[pyclass] objects).
This explains why Backend has internal Mutex<T>s even though all of its
methods took &mut self.

The solution is to simply make all methods take &self, which luckily
doesn't pose too make issues -- most of the code inside Backend already
has sufficient locking. The only two things which needed to be
explicitly handled where:

1. "self.runtime" which was fairly easy to handle. All usages of
   the Runtime only require an immutable reference to create a new
   Handle, so we could switch to OnceCell which provides
   lazy-initialisation semantics without needing a more heavy-handed
   Mutex<tokio::runtime::Handle>.

2. "self.sync_abort" was simply wrapped in a Mutex<>, though some of the
   odd semantics of sync_abort (not being able to handle multiple
   processes synchronising at the same time) become pretty obvious with
   this change (for now we just log a warning in that case). In
   addition, switch to an RAII-style guard to make sure we don't forget
   to clear the abort_handle.

As a result, we now no longer break Rust's aliasing rules and we can
build with newer versions of PyO3 which have runtime checks for these
things (and build on stable Rust).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-05 19:37:59 +10:00
Aleksa Sarai
1f95cb3139 rslib: auto-format protobuf code
prost-build doesn't generate rustfmt-safe code, so we had to add it to
the ignore list for rustfmt on "make check". However, the ignore list
isn't supported by stable rustfmt, so we have to work around this some
other way -- in this case, just do "rustfmt" on the generated file in
"build.rs" (this way, formatting errors in checked-in source code are
still caught but generated code doesn't cause spurrious errors).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2020-09-04 16:30:06 +10:00
Damien Elmes
32f5bc96a8 another showDupes fix from ANH
https://forums.ankiweb.net/t/show-duplicates-not-working/2883/10
2020-09-04 10:13:30 +10:00
Damien Elmes
a5955f0206 sound tags need filename html escaped
https://forums.ankiweb.net/t/unable-to-play-longer-audio-on-cards/1313/30
2020-09-04 09:36:38 +10:00
Damien Elmes
cce0ee2b03 handle quoted html chars in media check
https://forums.ankiweb.net/t/unable-to-play-longer-audio-on-cards/1313/30
2020-09-04 09:36:38 +10:00
Damien Elmes
d81251676d Revert "Merge pull request #749 from ANH25/editor-media-autoplay"
This reverts commit 373402ed0a, reversing
changes made to 35c59cb899.

https://github.com/ankitects/anki/pull/749#issuecomment-686385112
2020-09-04 08:34:26 +10:00
Damien Elmes
dff3644875 fix custom study link being shown in filtered deck
https://forums.ankiweb.net/t/crashing-after-custom-study-learn-forgotten-cards/3013
2020-09-04 08:31:33 +10:00
Damien Elmes
bc60d233e5 rebuild_filtered_deck() and new_filtered() 2020-09-03 18:02:47 +10:00
Damien Elmes
6f7f5686e8 empty_filtered_deck() 2020-09-03 17:43:07 +10:00
Damien Elmes
f32d773e25 set_deck() 2020-09-03 17:42:46 +10:00
Damien Elmes
f7d4bf8489 support did:[deck id] search 2020-09-03 16:43:22 +10:00
Damien Elmes
32759a55e4 log 0 day interval as 1 day
Allows distinguishing it from resetting to new, and is treated as
a one day delay when answering anyway.
2020-09-03 16:00:06 +10:00
Damien Elmes
7c169daa95 move card sorting and resetting to backend 2020-09-03 15:54:15 +10:00
Damien Elmes
72142d51c4 set local offset when saving preferences 2020-09-03 12:43:18 +10:00
Damien Elmes
366c5c4774 log manual reschedule, but ignore the log entry in the stats 2020-09-02 17:56:23 +10:00
Damien Elmes
31b7d7d645 move reschedCards() to backend 2020-09-02 17:56:23 +10:00
Damien Elmes
396081d329 move filtered deck empty/fill to backend
emptying of individual card ids still to be done
2020-09-02 17:56:23 +10:00
Damien Elmes
0f6840596b fix night mode on old graphs 2020-09-02 17:56:12 +10:00
Damien Elmes
52425a9851 ensure background override works in night mode 2020-09-01 12:20:45 +10:00
Damien Elmes
efccdf6bf6 add a small default margin 2020-09-01 10:24:38 +10:00
Damien Elmes
7f42500e53 rename some card+note fields in backend 2020-09-01 10:24:38 +10:00
Damien Elmes
9f51347e1e move bury/suspend into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
a8f84c1264 formatting fixes for latest black 2020-09-01 10:24:38 +10:00
Damien Elmes
988b3c00c1 move unbury/unsuspend routines into backend 2020-09-01 10:24:38 +10:00
Damien Elmes
130f99fe44 fix some lints 2020-09-01 10:24:38 +10:00
Damien Elmes
4894025cfc add separate sched/user bury searches, and fix bury enums 2020-09-01 10:24:38 +10:00
Damien Elmes
b234a92d8b default to true in want_release_gil() 2020-09-01 10:24:38 +10:00
Damien Elmes
fcf63205b6 add a hook to support extending external .html files 2020-09-01 10:24:38 +10:00
Damien Elmes
2a6206be91 handle null return from sum() in other columns 2020-09-01 10:24:38 +10:00
Damien Elmes
6f585a1e5a remove debug statement from graphs 2020-09-01 10:24:38 +10:00
Damien Elmes
5536969f29 add load_ts_page() & avoid duplicate call 2020-09-01 10:24:38 +10:00
Damien Elmes
9a3a81012a update ts deps to fix svelte-vscode 2020-09-01 10:24:38 +10:00
Damien Elmes
999b659c3a reimplement congrats screen in Rust+Typescript 2020-09-01 10:24:38 +10:00
Damien Elmes
a629e1acf2 apply standard zoom and background to graphs; prevent FOUC 2020-09-01 10:24:38 +10:00
Damien Elmes
7d84954f53 use css vars for graph styling as well; base webview.scss off core.scss 2020-09-01 10:24:38 +10:00
Damien Elmes
3b1a4d029c most of the .nightMode redefinitions are no longer required 2020-09-01 10:24:38 +10:00
Damien Elmes
2411e944e4 drop the old sass vars and define the properties directly 2020-09-01 10:24:38 +10:00
Damien Elmes
514409d86f migrate the majority of the sass vars to css variables
Allows add-ons to easily override the theme, and allows us to apply
styling to elements outside of the normal document flow (like applying
the normal background colour to a position: fixed element).
2020-09-01 10:24:38 +10:00
Damien Elmes
a6aaaf8691 move _vars to outer ts folder
First step in sharing styling with graphs + future .html files
2020-09-01 10:24:38 +10:00
Damien Elmes
00bba4d3cc disable pyenv cache on Linux
https://github.com/ankitects/anki/pull/681
2020-09-01 09:11:07 +10:00
Damien Elmes
a126485e27 Merge pull request #746 from hgiesel/modelsbuttons
Create a gui_hook for initializing buttons in Models
2020-09-01 08:36:03 +10:00
Henrik Giesel
87bcc39a77 Some minor reformatting to satisfy black 2020-08-31 13:50:59 +02:00
Henrik Giesel
f32dc05daf Address broken translations and increase readibility of button insertion 2020-08-31 13:40:42 +02:00
Henrik Giesel
c87d60ea4c Remove unnecessary import 2020-08-31 13:35:18 +02:00
Henrik Giesel
31b2d46247 Fix type signature: models is passed because it's a method 2020-08-31 13:35:18 +02:00
Henrik Giesel
b9e26ae052 Remove duplicated buttons 2020-08-31 13:35:18 +02:00
Henrik Giesel
2a4f0edfe7 Don't import models in gui_hooks to avoid circular import 2020-08-31 13:35:18 +02:00
Henrik Giesel
14a33cb2ce Fix uninitialized buttons object 2020-08-31 13:35:18 +02:00