anki/cargo
RumovZ 6da5e5b042
CSV import/export fixes and features (#1898)
* Fix footer moving upwards

* Fix column detection

Was broken because escaped line breaks were not considered.
Also removes delimiter detection on `#columns:` line. User must use tabs
or set delimiter beforehand.

* Add CSV preview

* Parse `#tags column:`

* Optionally export deck and notetype with CSV

* Avoid clones in CSV export

* Prevent bottom of page appearing under footer (dae)

* Increase padding to 1em (dae)

With 0.5em, when a vertical scrollbar is shown, it sits right next to
the right edge of the content, making it look like there's no right
margin.

* Experimental changes to make table fit+scroll (dae)

- limit individual cells to 15em, and show ellipses when truncated
- limit total table width to body width, so that inner table is shown
with scrollbar
- use class rather than id - ids are bad practice in Svelte components,
as more than one may be displayed on a single page

* Skip importing foreign notes with filtered decks

Were implicitly imported into the default deck before.
Also some refactoring to fetch deck ids and names beforehand.

* Hide spacer below hidden field mapping

* Fix guid being replaced when updating note

* Fix dupe identity check

Canonify tags before checking if dupe is identical, but only add update
tags later if appropriate.

* Fix deck export for notes with missing card 1

* Fix note lines starting with `#`

csv crate doesn't support escaping a leading comment char. :(

* Support import/export of guids

* Strip HTML from preview rows

* Fix initially set deck if current is filtered

* Make isHtml toggle reactive

* Fix `html_to_text_line()` stripping sound names

* Tweak export option labels

* Switch to patched rust-csv fork

Fixes writing lines starting with `#`, so revert 5ece10ad05f331.

* List column options with first column field

* Fix flag for exports with HTML stripped
2022-06-09 10:28:01 +10:00
..
remote CSV import/export fixes and features (#1898) 2022-06-09 10:28:01 +10:00
BUILD.bazel Update regex crate for CVE 2022-06-07 08:39:07 +10:00
BUILD.reqwest.native.bazel Update Rust deps 2022-03-15 16:51:52 +10:00
BUILD.reqwest.rustls.bazel Update Rust deps 2022-03-15 16:51:52 +10:00
BUILD.term-0.7.0.bazel update Rust deps 2022-01-15 14:59:43 +10:00
crates.bzl CSV import/export fixes and features (#1898) 2022-06-09 10:28:01 +10:00
licenses.json Update regex crate for CVE 2022-06-07 08:39:07 +10:00
README.md updates to the build process and binary bundles 2022-02-10 19:23:07 +10:00
update.py CSV import/export fixes and features (#1898) 2022-06-09 10:28:01 +10:00

This folder integrates Rust crates.io fetching into Bazel.

To add or update dependencies, ensure a local Rust environment is available (eg source tools/cargo-env), then install cargo-raze:

cargo install cargo-raze --version 0.14.1
cargo install cargo-license

After adding/updating dependencies in ../rslib/Cargo.toml, change to this folder and run:

$ python update.py

or

$ REPIN=1 python update.py

The former will apply added crates and adjusted version numbers, while leaving most crate versions alone. The latter will also update pinned dependencies to their latest compatible versions.

Note: cargo-raze does not currently work when run from Windows, and nobody has investigated why yet. For now, you'll need a Mac or Linux machine, or will need to run update.py from within WSL.

A couple of crates need extra work to build with Bazel, and are listed in ../Cargo.toml. For example:

[package.metadata.raze.crates.pyo3.'*']
compile_data_attr = "glob([\"**\"])"

With minor version updates, you should not normally need to modify the entries in that file.

Because update.py modifies a lot of files in remote/, it makes it difficult to review in a PR, and the changes can sometimes break platforms like Windows. For this reason, please don't submit PRs that do minor version bumps - those will typically be done after stable releases. If you need a new crate for a feature you're working on, please raise it in an issue first.

Reqwest

Things are complicated with reqwest at the moment, because:

  • we're using a fork to implement better timeouts for syncing
  • we want to build it with different features on Linux (where we can't build a wheel that links to OpenSSL), and on other platforms.

For minor version bumps, update.py should take care of updating the versions of reqwest dependencies.

After making a big update to reqwest via an updated fork, the vendored BUILD.reqwest.* files may need updating. To do that, comment native-tls from the features in rslib/Cargo.toml and run update.py, and copy the file in remote/ over the old vendored file. Then comment the other two deps out, add native-tls back, and repeat the process.