Compare commits
No commits in common. "5ad31a8ca432d070563477acdef22cf1fdf1c923" and "64c821387d264a9b0581e026eb47ffb0545b5f41" have entirely different histories.
5ad31a8ca4
...
64c821387d
28
src/main.rs
28
src/main.rs
|
@ -23,29 +23,16 @@ struct HelloTemplate<'a> {
|
||||||
name: &'a str,
|
name: &'a str,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct User {
|
|
||||||
name : String,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Owner {
|
|
||||||
name : String,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct Repository {
|
|
||||||
name : String,
|
|
||||||
owner : Owner,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
#[template(path = "git.html")]
|
#[template(path = "git.html")]
|
||||||
struct GitMainTemplate<TS, ROOT>
|
struct GitMainTemplate<TS, ROOT>
|
||||||
where for <'a> &'a TS : IntoIterator<Item = &'a GitBrowseEntry>,
|
where for <'a> &'a TS : IntoIterator<Item = &'a GitBrowseEntry>,
|
||||||
for <'a> &'a ROOT : IntoIterator<Item = &'a (String, String)>,
|
for <'a> &'a ROOT : IntoIterator<Item = &'a (String, String)>,
|
||||||
{
|
{
|
||||||
repo : Repository,
|
user: String,
|
||||||
|
repo : String,
|
||||||
browse : TS,
|
browse : TS,
|
||||||
root : ROOT,
|
root : ROOT,
|
||||||
user_opt : Option<User>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/")]
|
#[get("/")]
|
||||||
|
@ -82,20 +69,17 @@ async fn hello_auth(req : HttpRequest) -> impl Responder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[get("/git/{owner}/{repo}/{commit}/{path:.*}")]
|
#[get("/git/{user}/{repo}/{commit}/{path:.*}")]
|
||||||
async fn git_main(web::Path((owner, reponame, commitname, rootname)): web::Path<(String, String, String, String)>) -> impl Responder {
|
async fn git_main(web::Path((user, reponame, commitname, rootname)): web::Path<(String, String, String, String)>) -> impl Responder {
|
||||||
let repo = GitRepo::new();
|
let repo = GitRepo::new();
|
||||||
let path : Vec<(String, String)> = rootname.split("/").map_accum("/git/".to_string() + &owner + "/" + &reponame + "/" + &commitname, |str_ref, b| {
|
let path : Vec<(String, String)> = rootname.split("/").map_accum("/git/".to_string() + &user + "/" + &reponame + "/" + &commitname, |str_ref, b| {
|
||||||
let href = b + "/" + str_ref;
|
let href = b + "/" + str_ref;
|
||||||
((str_ref.to_string(), href.clone()), href)
|
((str_ref.to_string(), href.clone()), href)
|
||||||
}).collect();
|
}).collect();
|
||||||
let commit = GitCommit::new(commitname);
|
let commit = GitCommit::new(commitname);
|
||||||
let root = GitBrowseDir::new(rootname);
|
let root = GitBrowseDir::new(rootname);
|
||||||
let browse = repo.browse(&commit, &root).await;
|
let browse = repo.browse(&commit, &root).await;
|
||||||
let owner = Owner { name : owner};
|
GitMainTemplate { user, repo : reponame, browse : browse, root : path}
|
||||||
let repo = Repository {name : reponame, owner};
|
|
||||||
let user = User { name : "Hubert".to_string()};
|
|
||||||
GitMainTemplate { repo, browse : browse, root : path, user_opt : Some(user)}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/echo")]
|
#[post("/echo")]
|
||||||
|
|
|
@ -3,31 +3,9 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
<link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css">
|
||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
<title>{{repo}}</title>
|
||||||
<title>{{repo.name}}</title>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="w3-container">
|
|
||||||
<div class="w3-bar w3-border w3-light-grey">
|
|
||||||
<a href="#" class="w3-bar-item w3-button w3-green"><i class="fa fa-home"></i> Home</a>
|
|
||||||
<a href="#" class="w3-bar-item w3-button">Link 1</a>
|
|
||||||
<a href="#" class="w3-bar-item w3-button">Link 2</a>
|
|
||||||
{% match user_opt %}
|
|
||||||
{% when Some with (user) %}
|
|
||||||
<div class="w3-dropdown-hover w3-right">
|
|
||||||
<button class="w3-button">{{user.name}} <i class="fa fa-caret-down"></i></button>
|
|
||||||
<div class="w3-dropdown-content w3-bar-block w3-card-4" style="right:0">
|
|
||||||
<a href="#" class="w3-bar-item w3-button">Link 1</a>
|
|
||||||
<a href="#" class="w3-bar-item w3-button">Link 2</a>
|
|
||||||
<a href="#" class="w3-bar-item w3-button">Link 3 lkj lkj lkj lkj lkj </a>
|
|
||||||
<a href="#" class="w3-bar-item w3-button"><i class="fa fa-sign-out"></i> Log out</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% when None %}
|
|
||||||
<a href="#" class="w3-bar-item w3-button w3-right"><i class="fa fa-sign-in"></i> Log in</a>
|
|
||||||
{% endmatch %}
|
|
||||||
</div>
|
|
||||||
{% block content %}{% endblock %}
|
{% block content %}{% endblock %}
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -13,7 +13,7 @@
|
||||||
<div class="w3-col m3 w3-center"><p></p></div>
|
<div class="w3-col m3 w3-center"><p></p></div>
|
||||||
<div class="w3-col m6 w3-left-align">
|
<div class="w3-col m6 w3-left-align">
|
||||||
<div class="w3-container w3-amber w3-round w3-margin">
|
<div class="w3-container w3-amber w3-round w3-margin">
|
||||||
<h1>{{repo.owner.name}}/{{repo.name}}</h1>
|
<h1>{{user}}/{{repo}}</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue