More verbose urls
This commit is contained in:
27
src/main.rs
Normal file
27
src/main.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use anyhow::{
|
||||
Result,
|
||||
};
|
||||
use clap::{
|
||||
Parser,
|
||||
};
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about, long_about = None)]
|
||||
struct Cli {
|
||||
/// Path to config file
|
||||
#[arg(long, default_value_t = String::from("flake-tracker.json"))]
|
||||
config: String,
|
||||
/// Address to bind web server to
|
||||
#[arg(long, default_value_t = String::from("[::1]:3000"))]
|
||||
listen: String,
|
||||
/// Path to database file
|
||||
#[arg(long, default_value_t = String::from("flake-tracker.db"))]
|
||||
database: String,
|
||||
}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cli = Cli::parse();
|
||||
|
||||
Ok(())
|
||||
}
|
@@ -223,12 +223,12 @@ pub struct RevisionRow {
|
||||
|
||||
impl RevisionRow {
|
||||
pub fn revision_link(&self) -> String {
|
||||
format!("/r/{}", urlencode(&self.revision_uri))
|
||||
format!("/revisions/{}", urlencode(&self.revision_uri))
|
||||
}
|
||||
|
||||
pub fn flake_link(&self) -> String {
|
||||
match &self.flake_uri {
|
||||
Some(flake_uri) => format!("/f/{}", urlencode(&flake_uri)),
|
||||
Some(flake_uri) => format!("/flakes/{}", urlencode(&flake_uri)),
|
||||
None => String::from("#"),
|
||||
}
|
||||
}
|
||||
@@ -253,19 +253,19 @@ pub struct InputRow {
|
||||
|
||||
impl InputRow {
|
||||
pub fn revision_link(&self) -> String {
|
||||
format!("/r/{}", urlencode(&self.revision_uri))
|
||||
format!("/revisions/{}", urlencode(&self.revision_uri))
|
||||
}
|
||||
|
||||
pub fn locked_revision_link(&self) -> String {
|
||||
match &self.locked_revision_uri {
|
||||
Some(locked_revision_uri) => format!("/r/{}", urlencode(&locked_revision_uri)),
|
||||
Some(locked_revision_uri) => format!("/revisions/{}", urlencode(&locked_revision_uri)),
|
||||
None => String::from("#"),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn locked_flake_link(&self) -> String {
|
||||
match &self.locked_flake_uri {
|
||||
Some(locked_flake_uri) => format!("/f/{}", urlencode(&locked_flake_uri)),
|
||||
Some(locked_flake_uri) => format!("/flakes/{}", urlencode(&locked_flake_uri)),
|
||||
None => String::from("#"),
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ pub struct FlakeRow {
|
||||
|
||||
impl FlakeRow {
|
||||
pub fn flake_link(&self ) -> String {
|
||||
format!("/f/{}", urlencode(&self.flake_uri))
|
||||
format!("/flakes/{}", urlencode(&self.flake_uri))
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -86,8 +86,8 @@ pub fn make_router(storage: Storage) -> anyhow::Result<Router> {
|
||||
let app = Router::new()
|
||||
.route("/", get(route_index))
|
||||
.route("/flakes", get(route_flakes))
|
||||
.route("/f/{uri}", get(route_flake))
|
||||
.route("/r/{revision_uri}", get(route_revision))
|
||||
.route("/flakes/{uri}", get(route_flake))
|
||||
.route("/revisions/{revision_uri}", get(route_revision))
|
||||
.with_state(state);
|
||||
|
||||
Ok(app)
|
||||
|
Reference in New Issue
Block a user