aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2018-11-09layout.hcss: Give names to coloursTeddy Wing
2018-11-09main.hcss: Move `layout.hcss` include to bottomTeddy Wing
The typography and link styles should be defined closer to the top.
2018-11-09links.hcss: Replace colours with variablesTeddy Wing
2018-11-09Add `links.hcss`Teddy Wing
Set basic link colours. Other colours under consideration were: #0758d2 #0e7680
2018-11-09Purchaser::insert(): Commit the transactionTeddy Wing
I had forgotten to commit the transaction, so the record I was trying to insert wouldn't get persisted in the database.
2018-11-09main(): Create a test purchaserTeddy Wing
Manually check that our purchaser creation and database persistence works. Make `purchaser` entities public in order to call them.
2018-11-09Purchaser::new(): Generate a secret in this methodTeddy Wing
Realised that when we want a new purchaser, we always want to generate a secret. This way we can call `new()` without having to call `generate_secret()` at the call site.
2018-11-09.env.sample: Add `LOG_FILE` variableTeddy Wing
2018-11-09Set up a file loggerTeddy Wing
Get a file path from the `LOG_FILE` environment variable and use it for log output. Call `database::get_database_connection()` and log the error if it fails. Worried about exiting early from the FastCGI program, as DreamHost says this causes problems (https://help.dreamhost.com/hc/en-us/articles/217298967). But I don't see how the program can continue without a database connection. Return a `Result` from `main()` because it's easier to use the `?` operator for errors that happen before logging is initialised.
2018-11-09Add `get_database_connection()`Teddy Wing
Function to establish a database connection using a connection pool. Update `Purchaser::insert()` to take a `PooledConn` instead of a simple `Conn`.
2018-11-09.env.sample: Add `DATABASE_URL` variableTeddy Wing
Add a new variable for the regular database URL, and move the existing one, which includes the `tcp(hostname)` format to `GO_DATABASE_URL`. We need to keep the existing one for use with the 'migrate' command, but I want a regular database URL to be able to use inside the main web program.
2018-11-09Extract code in `lib.rs` to `errors.rs` and `purchaser.rs`Teddy Wing
Split up the code to get things a bit more organised. I want a function to create a connection to the MySQL database and I don't want to lump it in with the rest.
2018-11-09Purchaser: Remove `with_secret()` functionTeddy Wing
I don't see myself using this since I have the `generate_secret()` function now.
2018-11-09Purchaser::generate_secret(): Use a larger random number poolTeddy Wing
The `random()` function I was using will sample a value from "the full representable range" (https://docs.rs/rand/0.5.5/rand/#the-two-step-process-to-get-a-random-value). We should really be using longer numbers, so set the sample range to integers above and including 1 billion.
2018-11-09Purchaser: Add `generate_secret()` methodTeddy Wing
This new method generates a secret, which is a SHA1 digest of the purchaser's name, email, and a random integer. In order to use the `hexdigest()` method in the 'sha1' crate, I needed to add the feature `std` (https://docs.rs/sha1/0.6.0/sha1/struct.Sha1.html#method.hexdigest). Needed to change the `secret` field to a `String` because otherwise the generated digest string doesn't have a long enough lifetime to assign to it. Update `with_secret()` to use the new `String` type. Update `insert()` to correctly handle the `Option` in `secret`.
2018-11-09Purchaser: Implement `insert()`Teddy Wing
Haven't tested this at all so I have no idea if it works. Just getting a draft committed.
2018-11-09Remove Migrant.tomlTeddy Wing
No longer used after switching migration runners.
2018-11-09Add `lib.rs`Teddy Wing
Starting to set up database interactions. We need a way to insert purchasers into the database.
2018-11-09Add 'error-chain' crateTeddy Wing
2018-11-09Cargo: Add 'mysql' crateTeddy Wing
2018-11-09Add setup scriptsTeddy Wing
Add a script to install dependencies and perform initial application setup. Another script sources the environment file.
2018-11-0920181109031633_create_purchasers.up.sql: Remove `DELIMITER` linesTeddy Wing
Running $ mysql -u user dome_key < 20181109031633_create_purchasers.up.sql worked just fine, but running the migration through 'migrate' produced this error: (details: Error 1064: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'DELIMITER $$ CREATE TRIGGER purchasers_updated_at BEFORE UPDATE ON purchasers FO' at line 1) Probably the same problem that 'migrant' had, but it just didn't give me an error message. After having to fiddle and mess around with different parts of the migration for a while, it finally turned out that the `DELIMITER` seemed to be the problem. Got rid of it as well as the `BEGIN`/`END` that depended on it. Looks like our timestamp updater still works even without `BEGIN`, though, so that's good. When I had first written the code, I figured I should use `BEGIN` because that was how it was written in a couple examples I had seen.
2018-11-09Move 'migrant' migrations to 'migrate' formatTeddy Wing
Switched migration runners from https://crates.io/crates/migrant to https://github.com/golang-migrate/migrate .
2018-11-09.env.sample: Add `migrate` wrapper functionsTeddy Wing
Wrap all `migrate` subcommands. Turns out we do need the `-path` argument for the other commands. Doesn't appear to work correctly for `create`, but for the others it works fine.
2018-11-09.env.sample: Add `migrate` functionTeddy Wing
Wraps the `migrate` command (https://github.com/golang-migrate/migrate). The command requires you to pass in a bunch of shell options that should be constant for an application. Encode those constants in this wrapper function. Now all you need to do is run: $ migrate migration_name and the correct migrations will be generated. The migrations get created in the current directory. I tried passing -source file://migrations , -source file://./migrations , and -path migrations but no combination seemed to put the generated migration files in the migrations/ directory. Settled on moving the files manually in the helper function.
2018-11-09Add migrations for `purchasers` tableTeddy Wing
A database table to hold purchaser information so we can re-generate licenses in case purchasers lose their license keys. Needed to use a trigger to update the `updated_at` field on `UPDATE` as you can't do `ON UPDATE UTC_TIMESTAMP()` in the column definition > You can not specify UTC_TIMESTAMP as default to specify automatic > properties (https://dba.stackexchange.com/questions/20217/mysql-set-utc-time-as-default-timestamp/21619#21619) Weirdly, the trigger isn't working when applying the migration with $ migrant apply but it is working when running $ mysql -u user dome_key < migrations/20181108234653_create-purchasers/up.sql Not sure what's going on there, but 'migrant' appears to have trouble realising there are errors coming back from MySQL and executes the migrations regardless. It also doesn't print syntax error messages from MySQL which is very inconvenient. Migrant seemed to be the most advanced migration CLI on crates.io, and I was hoping to use a Rust program for this, but for simplicity, I'm thinking I'll have to go with a different migration runner. Considering https://github.com/golang-migrate/migrate.
2018-11-09Add database configTeddy Wing
Use 'migrant' for migrations (https://crates.io/crates/migrant). TOML config file generated and modified from `migrant init`. Database connection parameters should be passed in though environment variables, hence the '.env.sample'.
2018-11-08Add system requirements sectionTeddy Wing
2018-11-08Mention free trialTeddy Wing
2018-11-08Add some more descriptive copy to the websiteTeddy Wing
Describe the program, high-level features. Add styles: * Fix leading * Add list bullets that were removed by the reset
2018-11-08Make code block background colour darkerTeddy Wing
Increase contrast for improved readability.
2018-11-08Increase `line-height` of code blocksTeddy Wing
Make them a bit easier to read.
2018-11-08Use a smaller font size for mapping examplesTeddy Wing
2018-11-08Add lighttpd.confTeddy Wing
Allows us to test the FastCGI script locally. Thanks to this article for describing how to set up a local FastCGI server with Lighttpd: http://yaikhom.com/2014/12/18/handling-requests-c-fast-cgi-and-lighttpd.html Found out how to get the current config directory using `var.CWD` from: https://stackoverflow.com/questions/11702989/lighttpd-conf-document-root-as-directory-containing-config-file/12435777#12435777
2018-11-08Update logo alt textTeddy Wing
Clearer explanation of what the image is.
2018-11-08Adjust logo and content marginsTeddy Wing
* Add margins to the top & bottom of the page * Align the logo relative to the content area, and move it left a bit, outside of the column
2018-11-08Add margins to headers and blocksTeddy Wing
2018-11-08Add a few mapping examplesTeddy Wing
2018-11-08Makefile: Remove empty lines from 'styles.css'Teddy Wing
There were a bunch of useless empty lines in the Hasp output. Would rather have had a single newline between each CSS rule, but this is close enough. At least it looks better.
2018-11-08Split CSS into separate filesTeddy Wing
For better organisation. Use the 'hasp' CSS preprocessor (https://github.com/djanowski/hasp).
2018-11-08Add CSS resetTeddy Wing
2018-11-08Add header stylesTeddy Wing
2018-11-08Add a code block styleTeddy Wing
2018-11-08Initial homepage experimentTeddy Wing
A rough setup for the website layout. * Muted yellow background * Logo set in Superclarendon by Typodermic
2018-11-08aquatic-prime: Move 'base64' and 'serde_derive' crates to dev depsTeddy Wing
As these crates are only used in tests, move them to the `dev-dependencies` section, and add `cfg(test)` to 'base64'.
2018-11-08paddle: Require that input `Iterator`s also be `PartialOrd`Teddy Wing
In order to properly verify the signature, dictionary entries must be serialized in sorted order. Seems simpler to put the onus on the caller to ensure the entries can be sorted rather than having to deal with that myself.
2018-11-08verify_signature(): Add input signature argumentTeddy Wing
Hoping this is how to set up the verifier to verify the signature.
2018-11-08paddle: Add rough implementation of `verify_signature()`Teddy Wing
Not sure if this works yet as I haven't tested it, but it follows most of the examples in various languages on: https://paddle.com/docs/reference-verifying-webhooks/ Just need to add in the comparison to the input signature.
2018-11-08paddle::php_serialize(): Take an `IntoIterator` argumentTeddy Wing
Replace the `ExactSizeIterator` with an `IntoIterator`, as I wasn't able to pass in a `HashMap` with `ExactSizeIterator`. While we lose the convenience of the `len()` method, it's easy enough to just count the length of the iterator while we're serializing the entries within it.
2018-11-08paddle: Add a test for `php_serialize()`Teddy Wing
The expected value was generated with the following PHP code, some of which was reproduced from the PHP example on https://paddle.com/docs/reference-verifying-webhooks/ : <?php $fields = array( 'checkout_id' => '1234asdfjkl', 'currency' => 'USD', 'customer_name' => 'Senjougahara', ); ksort($fields); foreach($fields as $k => $v) { if(!in_array(gettype($v), array('object', 'array'))) { $fields[$k] = "$v"; } } $data = serialize($fields); echo "Data: ", $data;