This was flawed - while non-Latin text is now acceptable
in an IRI, we still need to be concerned with reserved characters
such as spaces, and Anki unfortunately has been storing the filenames
in unencoded form in the DB, meaning we must encode them at display
time. We won't be able to move away from this until existing notes
are rewritten, and it will probably require breaking compatibility with
older clients.
https://en.wikipedia.org/wiki/Internationalized_Resource_Identifier
This reverts commit 14110add55.
Will allow importing the Protobuf without pulling in the rest of
the library. This is not a full PEP420 namespace, and the wheel still
bundles everything - it just makes things easier in a Bazel workspace.
I originally tried with PEP420, but it required more invasive changes,
and I ran into issues with mypy.
In order to split backend.proto into a more manageable size, the protobuf
handling needed to be updated. This took more time than I would have
liked, as each language handles protobuf differently:
- The Python Protobuf code ignores "package" directives, and relies
solely on how the files are laid out on disk. While it would have been
nice to keep the generated files in a private subpackage, Protobuf gets
confused if the files are located in a location that does not match
their original .proto layout, so the old approach of storing them in
_backend/ will not work. They now clutter up pylib/anki instead. I'm
rather annoyed by that, but alternatives seem to be having to add an extra
level to the Protobuf path, making the other languages suffer, or trying
to hack around the issue by munging sys.modules.
- Protobufjs fails to expose packages if they don't start with a capital
letter, despite the fact that lowercase packages are the norm in most
languages :-( This required a patch to fix.
- Rust was the easiest, as Prost is relatively straightforward compared
to Google's tools.
The Protobuf files are now stored in /proto/anki, with a separate package
for each file. I've split backend.proto into a few files as a test, but
the majority of that work is still to come.
The Python Protobuf building is a bit of a hack at the moment, hard-coding
"proto" as the top level folder, but it seems to get the job done for now.
Also changed the workspace name, as there seems to be a number of Bazel
repos moving away from the more awkward reverse DNS naming style.
I mourn the time lost trying to track this down :-(
https://github.com/protobufjs/protobuf.js/issues/1014
We can't patch the minified file in dist without essentially duplicating
it, so this change also switches from the external file to including
the src file as part of the bundle.
Back in the WebKit days, images with Unicode filenames would fail to
appear if they weren't percent-escaped. This no longer seems to be the
case - with this patch, images appear correctly on the Mac and Windows
platforms I tested with.
Fixes https://forums.ankiweb.net/t/anki-2-1-45-beta/10664/96Fixes#1219
'FlagManager' allows cached access to the flag objects, takes care of
renaming flags and notifies GUI components with the hook
'flag_label_did_change'.
An example of how we can start migrating the codebase to PEP8:
- enable invalid-name at the top
- use bazel run pylib:pylint to identify names that need renaming
- use PyCharm or similar to rename the functions/variables
- in the cases where the conversion is not just snake_case, use
.register_deprecated_aliases()
+ removed the __repr__() definition, it dumps all the note content
and obscures the error message
including the following changes:
- rename "_getWindowColor" to "get_window_bg_color" to follow PEP8
- add "night_mode" argument to "get_window_bg_color"
- make it possible to get the correct colors regardless of the current theme
Currently there's a nasty blink when revealing the answer if the answer
has images on it, as the entire card is hidden, and not shown again until
the images have loaded. This patch removes the wait, so text should appear
more quickly, but it will mean the images may pop in.
We still wait for images before scrolling, to avoid a scroll to the wrong
location.
There's plenty of scope to improve this further - preloading images,
rendering MathJax in advance, etc, but those changes will need to wait
for now. #1120 has some related discussion.
mypy's move to external types-* packages is a PITA, as it requires them
to be installed in site-packages, and provides no way to specify a custom
site-packages folder, necessitating extra scripts to mock the
site-packages path, and copy+rename the stub packages into a separate
folder.
- changes can now be undone
- the same field can now be mapped to multiple target fields, allowing
fields to be cloned
- the old Qt dialog has been removed
- the old col.models.change() API calls the new code, to avoid
breaking existing consumers. It requires the field map to always
be passed in, but that appears to have been the common case.
- closes#1175