GD7FCQ2KD5YJQ3UDLAWNJQUAUK4LTHMPFVGHMUAWMKNIBYZWK2NAC
E4OBIIUBGNDXK577XK573TLN4DYLS32GJGXY6J7TOWFHESTEZZNAC
TWIZ7QV4GCTQK743IKZSOJCIAEX62GZHFIYGOIFCFGIBOGPSY2WAC
KFVJ3KMWXEGILN4NWIWPPX7AU65M4H4UEAUIAQL2QSXOW3B5RFGQC
FS2NWBVN2SZB2FFPB3JSYT5URTVZEAZWMQ7QW4JUYPNJVDVAJTTQC
F5DMFQAO2IVQXQQ36Z5FRW5WNXKNTY2NAWMRR3VXIOWTPJ5UUDVAC
S6TFYMRGWC4PSRLQ4OAKE2Z3JFEVGF3RZ5Z3MEN5XSA4INPQILOAC
3E77DEMDLYBFJEGS2SLQKLQJQIXG2Y4TBDHAG3UKFLMKQ53CFOKQC
{% extends "base" %}
{% block body %}
<div class="p-5 mb-4 bg-light rounded-3">
<div class="container-fluid py-5">
<h1 class="display-5 fw-bold">{{ project.name }}</h1>
<p class="col-md-8 fs-4">Clone this repository using: <code>pijul clone http://nidobyte.com/{{organisation.name}}/{{project.name}}</code>.</p>
</div>
</div>
{% endblock body %}
{% extends "base" %}
{% block body %}
<table class="table table-borderless">
{% for project in projects %}
<tr>
<td>{{project.organisation.name}}</td>
<td><a href="{{project.uri}}">{{project.name}}</a></td>
</tr>
{% endfor %}
</table>
{% endblock body %}
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DispProject {
pub name: String,
pub organisation: User,
pub uri: String,
}
impl DispProject {
pub async fn new(db: &State<Database>, project: Project) -> Self {
let org = project.organisation(db).await.unwrap();
let uri = rocket::uri!(crate::controllers::projects::show(&org.name, &project.name));
DispProject {
name: project.name,
organisation: org,
uri: uri.to_string(),
}
}
}
/*
// Rank 3 is assigned as project/new and users/new might else collide
#[get("/<org_path>/<proj_path>", rank = 3)]
async fn show_anonymous(
db: &State<Database>,
org_path: String,
proj_path: String,
) -> Result<Template, rocket::http::Status> {
let p = if let Some(p) = projects::find(db, org_path, proj_path).await {
p
} else {
return Err(rocket::http::Status::InternalServerError);
};
Ok(Template::render(
"projects/show",
crate::context! {
project: p.clone(),
organisation: p.organisation(db).await.ok(),
},
))
}
#[get("/<org_path>/<proj_path>", rank = 4)]
repoman: &State<RepoMan>,
user: User,
org_path: String,
proj_path: String,
) -> Result<Template, rocket::http::Status> {
let p = if let Some(p) = projects::find(db, org_path, proj_path).await {
p
} else {
return Err(rocket::http::Status::InternalServerError);
};
Ok(Template::render(
"projects/show",
crate::context! {
current_user: user,
project: p.clone(),
organisation: p.organisation(db).await.ok(),
},
))
}
#[get("/projects/explore")]
async fn explore(
db: &State<Database>,
current_user: Option<User>,
) -> Result<Template, rocket::http::Status> {
let projects = if let Ok(projects) = projects::list(db).await {
projects
} else {
return Err(rocket::http::Status::InternalServerError);
};
let mut disp = Vec::new();
for proj in projects.iter() {
disp.push(projects::DispProject::new(db, proj.clone()).await)