Commit graph

48 commits

Author SHA1 Message Date
Tiffany Bennett
e34e126258 v0.8.0 2024-04-20 19:35:30 -07:00
Tiffany Bennett
a0ddd52bdb
Rink-web 3 (#165)
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)
2024-04-20 18:46:50 -07:00
Tiffany Bennett
1512265d46
Trig function improvements (#164)
Implements #148.
2024-04-13 14:48:18 -07:00
Tiffany Bennett
92c58488d4
Display recurring digits (#162)
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)
```
2024-04-13 14:21:56 -07:00
Tiffany Bennett
6ce8d91b97
Dependencies cleanup (#163)
- 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.
2024-03-31 14:34:09 -07:00
Tiffany Bennett
70ad6fb6b4 Don't use gray for unit decompositions (#13)
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.
2024-03-30 12:50:14 -07:00
Tiffany Bennett
311b9928ce
Add new operators (#161)
`<<`, `>>`, `mod`, `and`, `or`, `xor`. Implements #99.
2024-03-29 23:22:26 -07:00
Tiffany Bennett
01be58b5cb
Date range checking (#160)
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.
2024-03-29 21:30:21 -07:00
Tiffany Bennett
ba3a17d452 Don't interpret GB as a timezone name (#129)
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.
2024-03-29 19:31:23 -07:00
Tiffany Bennett
bf3b960307
Better packaging (#158)
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.
2024-03-29 19:15:53 -07:00
Tiffany Bennett
c33040c746
Run cargo update and fix resulting warnings (#159)
There were compile errors on nightly builds that should be fixed by
this.
2024-03-27 21:28:54 -07:00
Tiffany Bennett
73998b3c47
New SI (#157)
Updating the units database based on Resolution 1 of the 26th CGPM
(2018), aka New SI.

Sources used:

- https://www.bipm.org/en/committees/cg/cgpm/26-2018/resolution-1 - New
SI. Note that the authoritative document is in French.
- https://www.bipm.org/en/cgpm-2022/resolution-3 - Extending SI prefixes
- https://www.bipm.org/en/publications/si-brochure - SI Brochure, 9th
edition
- https://physics.nist.gov/cuu/Constants/index.html - CODATA 2018
- https://syrte.obspm.fr/IAU_resolutions/Res_IAU2012_B2.pdf - 2012 IAU
definition of AU
- https://arxiv.org/abs/1510.06262 - 2015 IAU definition of parsec
- Wikipedia for the info about the IEC standards (the actual standards
are paywalled).

Todo:

- [x] Find remaining 2014 CODATA constants in the file and get them
updated to 2018.
- [x] Find any remaining constants that used to be exact but aren't
anymore.
- [x] Fix parsec definition (not new SI, but might as well)
- [x] Review changes to make sure they are correct
2024-03-23 20:29:24 -07:00
Tiffany Bennett
1f5f636442
Reorganize definitions.units (#156)
## 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.
2024-03-15 19:08:13 -07:00
Tiffany Bennett
a2bb73c2db Release v0.7.0 2024-01-06 19:58:04 -08:00
Stipe Kotarac
2b91f2c169
adjust croatian kuna after euro adoption (#152)
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.
2024-01-06 18:29:56 -08:00
Tiffany Bennett
fb3098aa65 cargo fmt 2023-11-22 21:03:10 -08:00
Tiffany Bennett
2c49c5f1aa Fix #151 2023-11-22 20:58:08 -08:00
Tiffany Bennett
dd866eeb4e Comment out tests failing because of fp precision 2022-12-13 18:10:16 -08:00
Tiffany Bennett
07bdee9eb8
Add more tests (#127) 2022-04-15 23:04:51 -07:00
Tiffany Bennett
aedcb26f40 Fix clippy warning 2022-04-15 21:51:56 -07:00
Tiffany Bennett
8f5700110a
Quantity namespacing (#125)
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.
2022-04-10 12:27:10 -07:00
Tiffany Bennett
1ae832a2ba Propagate errors instead of printing them 2022-04-10 11:03:58 -07:00
Tiffany Bennett
b921d7a68d
Context refactor (#124)
Yet another giant refactor PR. I'm trying to clean up the Context internals. I moved a lot of the fields into a new Registry object with the hopes of making future refactors to it easier.

A lot of things are poorly named, and I've been going through and updating those. Some of these fields I didn't even know what they did until I studied them carefully, since I'd forgotten over time.

This makes some breaking changes to the Defs serialization format, but I didn't touch Unit or Substance which are the only ones that are used by the backend currently.

Some other refactors I did:
- Updated quantities to no longer reference units, only base units and other quantities.
- Added a debug dump option to the CLI for showing the contents of the Context.
- Merged Def::BaseUnit & Canonicalization.
- Merged Def::Prefix & SPrefix. I don't actually know what SPrefix stood for originally (standalone? definitely not short).
- Prefixes are now required to be dimensionless.
- Added missing tests for the Def serialization format.

I'm not entirely done yet though. There's still one dependency on Context from the loader, which is on the eval() method, used by units and substances. I'm still thinking about how I can reduce that coupling.
2022-04-10 10:37:56 -07:00
Tiffany Bennett
4c1d138b2a Make clippy happy 2022-04-03 21:21:50 -07:00
Tiffany Bennett
d7e497815f
Code reorganization (#123)
Much of the code organization and architecture of Rink has been the same since I hacked this project together in 2016. In this PR, I spent about a day moving files around and refactoring code.

I'm hoping that cleaning up the codebase like this will help make it easier to change going forwards. There's a lot of duplicated code, few abstractions are used.

In order to make this not break everything I did it in tiny steps, verifying the test suite each time. The original branch has >30 commits in it as a result.
2022-04-03 21:04:47 -07:00
Tiffany Bennett
6e3fecff57 Version 0.6.2 2021-10-31 15:10:02 -07:00
Tiffany Bennett
aa303062f9 Better reciprocal unit formatting (Fixes #91) 2021-10-31 15:00:53 -07:00
Tiffany Bennett
61814eeb72 Add updated element names (Fixes #105) 2021-10-31 14:48:35 -07:00
Tiffany Bennett
11a04b89b2 Fix missing whitespace in to_spans impl 2021-10-31 14:30:04 -07:00
Tiffany Bennett
0b9991333e Make previous result configurable 2021-10-31 14:18:52 -07:00
Adrian
474c407d15
Provide access to result of previous calculation (#107) 2021-08-20 20:44:37 -07:00
V
c36a666174
Make "now" respect system timezone (#101)
Most users probably want to manipulate time relative to the present in
their local timezone. This brings rink's functionality closer to similar
tools.

In date(1):

	> date -d 'now + 1 hour'
	Fri 23 Jul 09:54:02 CEST 2021

Before:

	> now
	2021-07-23 06:54:05.699222874 +00:00 (now)
	> now + 1 hour
	2021-07-23 07:54:10.940110380 +00:00 (in an hour)

After:

	> now
	2021-07-23 08:54:13.219044877 +02:00 (now)
	> now + 1 hour
	2021-07-23 09:54:15.555096329 +02:00 (in an hour)
2021-07-23 00:14:19 -07:00
Tiffany Bennett
ffd31b320e Fix clippy warnings 2021-05-30 16:46:27 -07:00
Tiffany Bennett
2ffe164f60 Fix warnings 2021-05-30 16:18:53 -07:00
Tiffany Bennett
af49f5d8b1 Release v0.6.0 2021-04-05 17:31:39 -07:00
Tiffany Bennett
709b5d01b4
Output highlighting (#90)
Adds a token tree based representation for Rink's output, allowing it to be colored. Adds support for this to Rink CLI to get improved appearance.
2021-04-05 16:04:46 -07:00
Tiffany Bennett
c453dfdeb9
Update dependencies (#89) 2021-04-01 16:13:17 -07:00
Tiffany Bennett
622dd31901
CLI improvements (#86) 2021-02-14 20:25:27 -08:00
Tiffany Bennett
b1fad6be3c
Use unified currency API endpoint (#76) 2020-09-20 20:45:22 -07:00
Tiffany Bennett
dbe6a45a0d Rink 0.5.1 2020-08-29 21:57:47 -07:00
Tiffany Bennett
451671da8e Add more tests for digits control 2020-08-29 21:07:33 -07:00
Tiffany Bennett
e4f9fc99c5
Remove custom logic for float to rational (#70) 2020-08-29 19:09:14 -07:00
Tiffany Bennett
bd33ab05e9
Fix crash caused by NaN (#69) 2020-08-29 18:49:59 -07:00
Tiffany Bennett
bf1a66ca84
Rink Web 2 (#62)
* Start over with the web interface

* Add initial stuff

* Extract file+network IO out of rink-core

* Fix cargo warning

* Add tests for rink-web

* Add Serialize to AST types

* Refactor AST

* Split up ast module

* BinOp -> BinOpExpr

* Split out UnaryOpExpr

* Remove Deserialize bound from AST

* Clean up Serialize impl for Numeric

* Convert Expr::Const to struct variant

* Make datetime handling deterministic

* Changes to js API

* Rename rink-web to rink-js

* Add initial npm project

* Add lit-element

* Parse textbox inputs

* Make Expr::Error a variant struct

* Convert Expr::Unit to struct variant

* Don't cache when running npm start

* Convert Expr::Mul to struct variant

* Convert Expr::Date to struct variant

* Convert Expr::Quote to struct variant

* Pretty print json

* Fix warnings

* Switch to svelte

* Remove web components polyfill

* Switch to sapper

* Only load wasm once

* Result component

* Update chrono

* `Utc::now` panics on wasm builds

* Hook up eval

* Disable humanize since it panics in wasm

* SSR test page

* Factor out wasm code into new file

* Make json output better

* Improve json output

* Better json for QueryError

* Add TS definitions for QueryReply

* Render some reply types

* Add proper font

* Add PWA manifest

* Add basic favicon

* Initial styling pass

* Include AST in replies

* Expr component

* Make Numeric json repr more useful

* Indicate approximate values

* Remove duplicate information in definitions

* Split up Result into smaller components

* Search reply

* Add UnitsForReply

* Add UnitListReply

* Add SubstanceReply

* Show dates

* Add DurationReply

* Hook up basic routing

* UI polishing

* Add links to unit pages

* Quantity links

* Split ExprNode and fix whitespace issues

* Fix whitespace issues in NumberParts

* Fix Binop component

* Precedence fixes

* Fix imports

* NumberParts.svelte -> Number.svelte

* Remove App + debug prints

* Fix whitespace in parentheses

* Allow division slash for fractions

* Add home button

* Add aria info

* Improve units for page

* Add links to errors

* Remove rink-irc from workspace

So that cargo test --workspace will work.

* Run all workspace tests in CI

* Remove legacy argument
2020-08-06 16:25:12 -07:00
Tiffany Bennett
1f709eb97e Rename several types via automated refactor 2020-07-18 12:35:06 -07:00
Tiffany Bennett
d8b519c067 Add readme 2020-07-18 02:24:37 -07:00
Tiffany Bennett
8bcd316068 Move files to make cargo publish happy 2020-07-18 02:20:39 -07:00
Tiffany Bennett
a6246ab3c4
Revamp CLI (#59)
* Refactor: Change Dim to struct with named fields

* Move files into `core`, leaving `rink` as the CLI

* Split out completer into separate module

* Clean up cargo files

* Move repl to separate file

* Use clap for rink CLI

* More ways to exit the CLI

* Serde doesn't require nightly for derive anymore

* Hopefully better caching behavior for requests
2020-07-18 02:11:41 -07:00