-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
509 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
CARGO_HOME: cargo/ | ||
|
||
jobs: | ||
check: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/cache@v3 | ||
with: | ||
path: | | ||
cargo/ | ||
target/ | ||
key: ${{ runner.os }}-gen3 | ||
- run: du -sh cargo/ target/ || true | ||
- name: Version | ||
run: rustc --version && cargo --version | ||
- name: Install rustfmt | ||
run: cargo fmt --version || rustup component add rustfmt | ||
- name: Install clippy | ||
run: cargo clippy --version || rustup component add clippy | ||
- run: cargo install cargo-readme | ||
- name: Check | ||
run: ./check.sh | ||
- run: du -sh cargo/ target/ || true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env bash | ||
echo PWD=$PWD | ||
set -e | ||
set -x | ||
time cargo check | ||
time cargo check --all-targets --all-features | ||
time cargo build | ||
time cargo build --all-targets --all-features | ||
time cargo fmt -- --check | ||
time cargo clippy -- -D clippy::pedantic | ||
time cargo clippy --all-targets --all-features -- -D clippy::pedantic | ||
time cargo test --tests | ||
time cargo test --all-targets --all-features | ||
echo "$0 finished" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#![allow(clippy::module_name_repetitions)] | ||
use crate::HOME_PAGE_KEY; | ||
use applin::{ | ||
applin_response, checkbox, form, form_button, nav_button, nav_page, push, replace_all, rpc, | ||
scroll, textfield, user_error, | ||
}; | ||
use safe_regex::{regex, Matcher0}; | ||
use serde::Deserialize; | ||
use servlin::{Error, Request, Response}; | ||
|
||
pub const CREATE_ACCOUNT_KEY: &str = "/create_account"; | ||
pub fn create_account(req: &Request) -> Result<Response, Error> { | ||
#[derive(Deserialize)] | ||
struct Input { | ||
#[serde(default)] | ||
username: String, | ||
#[serde(default)] | ||
agree: bool, | ||
} | ||
let input: Input = req.json()?; | ||
if !input.agree { | ||
return Ok(user_error("You must agree to the terms")); | ||
} | ||
let username = input.username.trim(); | ||
let matcher: Matcher0<_> = regex!(br"[a-z0-9]+"); | ||
if !matcher.is_match(username.as_bytes()) { | ||
return Ok(user_error("Please enter letters and numbers")); | ||
} | ||
Ok(Response::ok_200()) | ||
} | ||
|
||
pub const NEW_ACCOUNT_PAGE_KEY: &str = "/new_account_page"; | ||
pub fn new_account_page() -> Response { | ||
applin_response(nav_page( | ||
"New Account", | ||
scroll(form(( | ||
textfield("username").with_label("Username"), | ||
nav_button("Terms", [push("/terms")]), | ||
nav_button("Privacy", [push("/privacy")]), | ||
checkbox("agree").with_text("I agree"), | ||
form_button( | ||
"Create Account", | ||
[rpc("/create_account"), replace_all(HOME_PAGE_KEY)], | ||
), | ||
))), | ||
)) | ||
.unwrap() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.