This has been broken for many years. I didn't have much motivation to
fix it because I wasn't actively using irc anymore.
Most of the libraries in the time in between have changed. I have to
rewrite the bot from scratch.
Unfortunately, the async ecosystem in rust is split down the middle with
tokio vs async-std. `irc` uses tokio, `rink-sandbox` uses async-std, so
they aren't compatible. I don't have the motivation to fix this yet, so
for now the IRC bot has no sandboxing support.
Makes Rink parse out the links and date strings when using the token
format machinery. This is a new syntax in the definitions file with
`<abc>` for links and `#abc#` for dates.
Replaced ansi_term with nu-ansi-term because the former was
unmaintained. The latter comes with the ability to set hyperlinks.
Adds `to frac` and `to sci` to explicitly force the use of these
representations. Also adds `to eng` which behaves similar to the default
behavior, except rounds to every third power of 10 instead of every
power of 10. I might make the output format configurable and set the
engineering one as the default in a future version.
While working on this I found a bug in the current version of rink.
`surveyfoot to digits` is incorrect by 3 orders of magnitude. I fixed
that in this PR.
This has been annoying me for years. Make rink output bytes by default,
even though bits are the base unit of information.
Only applies when you specifically ask for bytes by itself. Falls back
to bits if you use some other unit like `bit s^-1`, `bit^2`, `bit^-1`,
etc.
```
> 500 floppy
737.28 megabyte (information)
```
Improves #56 but doesn't really fix it.
While researching this I wanted to see if I could add CD and DVD sizes
as well, but it turns out the size of these can depend on how they were
formatted. CDs can vary anywhere from 600-800MB depending on how much
you want to risk read errors.
Implements #79.
The CLI will now load more than the first `definitions.units` file it
finds. It will stick them together and load them as one big
`definitions.units` file. This lets you easily add custom definitions by
adding them to `~/.config/rink/definitions.units`. The format for it is
already documented in the manpage.
Kind of silly that I'm already on the third iteration of the website.
But the previous one was a bit over-engineered and hard to maintain. I
actually can't even get it to compile anymore, it errors out while
trying to build the wasm binary.
So it was either migrate from sapper (which is deprecated and broken) to
svelte-kit (the successor to sapper), or to simplify. I simplified.
The new tech jenga tower is:
- Soupault for building the website
- AsciiDoctor for the pages
- cmark-gfm for processing the markdown in the github releases
- Several plugins and scripts copied from my personal website
- Vite for compiling the javascript
- wasm-pack for building the wasm binary
Rink's website will now be completely static, so operating it is easier.
The javascript and wasm is quarantined to the index page where a rink
repl is active, the other pages are plain html.
The currency fetching is now a totally separate piece of code from the
website. It makes it simpler and requires less code to be loaded during
the regular cron job.
The javascript is way simpler now. It only manipulates the part of the
page that need to be dynamic. It also uses the token format machinery
instead of directly converting rink's output AST to html.
Pros:
- Way lighter, faster page load times.
- Easier to maintain.
- Site contains more information now. An about page, the manual, and a
releases tab with DL links.
- No more URL spam that makes search engines think the site is a content
farm.
- Actually acts as a REPL now so you can run multiple queries, use
`ans`, up/down arrows to re-run previous queries.
- Proper sandboxing - queries that timeout cause the worker to be killed
and restarted.
- Now has a progress indicator on downloading the wasm blob, which is
good on slow connections.
Cons:
- Even more of a custom setup than before.
- It doesn't work offline anymore. At least not until I add a new
service worker, which will be a real pain to debug.
- The interactive parts (the rink REPL) require javascript to work now.
- A lot of the old URLs like `/query/abc` and `/units/meter` are broken.
I think this is fine though. I can add redirects in nginx that point
them to `/?q=abc` and `/?q=meter`.
## Screenshots
### REPL
![image](https://github.com/tiffany352/rink-rs/assets/1254344/7e43fe58-134f-425c-b975-997797fc1af4)
### About page
![image](https://github.com/tiffany352/rink-rs/assets/1254344/d6a34ce5-a357-434c-b7e9-9ddee3884223)
Implements #72.
```
> 1/7
0.[142857]... (dimensionless)
```
Also changes the behavior of `to digits` so that it will attempt to find
long-period recurring digits and show the entire sequence. The new
default for `to digits` is to show up to 1000 recurring digits.
```
> googol/7 to digits
1428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428571428.[571428]... (dimensionless)
> surveyfoot to digits
0.[304800609601219202438404876809753619507239014478028956057912115824231648463296926593853187706375412750825501651003302006604013208026416052832105664211328422656845313690627381254762509525019050038100076200152400, period 210]... millimeter (length)
```
- Set `default-features=false` where applicable
- Use specific num libraries instead of the top-level crate, as some
parts like complex numbers are not used.
- Replace reqwest with curl, which links the system libcurl and libssl
when possible.
- Add `opt-level="z"` and enable LTO for release builds.
All these changes combined, the CLI binary goes from 10.7 megabytes (or
8.7 manually stripped) to 5.4 megabytes.
The wasm binary is unaffected, still around 2.3 megabytes.
Despite being an official SI derived unit, gray is only meant to be used
in the context of ionizing radiation. There is no official SI unit for
specific heat capacity.
Dates have no range checking which makes parsing them slightly
unreliable and causes weird error messages like this:
```
> #25:00#
Most likely pattern `hour12:min[:sec] meridiem[ offset]` failed: Expected ` `, got eof
```
Additionally, large numbers cause a panic:
```
> #9999999999#
Panic: The application panicked (crashed).
Message: called `Result::unwrap()` on an `Err` value: ParseIntError { kind: PosOverflow }
Location: core/src/parsing/datetime.rs:117
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
```
This PR adds range checks. I also cleaned up the code a little.
Fixes "4 bytes -> GB" being an error saying you can't convert to a
timezone.
This timezone can be obtained in better ways, there's no reason it
should be like this.
I want rink to adhere slightly better to conventions on Linux.
- Adds man pages for the CLI and for the config file format, using
asciidoc.
- Updates the bundling functionality. It doesn't make sense to bundle
these files when building a distro package, they should go in
`/usr/share`.
- Adds a makefile with good defaults for distro packages.
The asciidoc files will likely become the new source of truth for rink's
documentation. There is no way to make PRs to github wikis, so this
might be for the best anyway.
Currently rink is packaged on arch, nix, and void linux.
## Changes to `definitions.units`
- Added vim folds repurposing the `!category`/`!endcategory` syntax. There's a modeline at the bottom of the file for this.
- To make the vim folds work better, every single unit now has a category. I also moved them around a little bit so that each category collapses to a single line. This makes the file much easier to navigate. Kind of acts as its own table of contents.
- Rearranged some of the categories, and moved things between categories.
- Adjusted several comments, and added an explanation of the file to the top.
- Deleted some legacy GNU Units directives like !utf8 that Rink will never use. Also several of the function/LUTs that are commented out.
- Uncommented some fractions that apparently GNU Units didn't like. Also uncommented `googol`.
- Moved mercury to the periodic table section.
- Moved the 4 newest elements to be alphabetically sorted.
- Added atomic numbers to every element. (I double checked that the numbers are correct, but I might have still gotten some mixed up...)
- Fixed a few typos and trailing whitespace.
![image](https://github.com/tiffany352/rink-rs/assets/1254344/3d3fbc58-1928-4ded-8612-a84778127c65)
## Changes to rink-core
- Now prints an error on unrecognized directives instead of silently ignoring them.
- Ignores categories for non-units. This may be re-added later but it will require refactoring `Context::categories` to respect namespaces.
- Improved some of the error messages from the units DB loader.
ECB doesn't include HRK anymore because of it being pinned now, now the message will be correct for older versions of Rink.
Also updated the fallback values since they're 2 years old.
Croatia adopted the euro on 2023-01-01, setting a fixed conversion rate of the kuna to euro to 7.53450 kuna per 1 euro. https://www.ecb.europa.eu/euro/changeover/croatia/html/index.en.html
The kuna is still often listed and used as a reference, so not removing it, but instead setting a fixed conversion rate and adding a couple of often used slang names for varied amounts.
Makes quantities occupy a different namespace from units. This means you can no longer write them in expressions as though they were units, which was confusing.
Fixes#12, which is one of the longest standing bugs in Rink.