dec17
This commit is contained in:
parent
623e130a5d
commit
c474268c9b
10 changed files with 194 additions and 12 deletions
|
@ -28,6 +28,28 @@ pub async fn index( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|||
).await
|
||||
}
|
||||
|
||||
|
||||
pub async fn rootwork( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
||||
// if response Ok return HttpResponseBuilder
|
||||
HttpResponse::Ok()
|
||||
// set response content type html
|
||||
.content_type("text/html")
|
||||
// set response body to template context
|
||||
.body(
|
||||
// render template context
|
||||
template::TplRootWork {
|
||||
// lang to value of Accept-Language header
|
||||
lang : &template::get_lang(&req),
|
||||
}
|
||||
// render template context into String
|
||||
.render()
|
||||
.map_err( |e| {
|
||||
eprintln!("error_tplrender : {}", e );
|
||||
error::crash( template::get_lang(&req), "error_tplrender" )
|
||||
})?,
|
||||
).await
|
||||
}
|
||||
|
||||
pub async fn hemp( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
||||
// if response Ok return HttpResponseBuilder
|
||||
HttpResponse::Ok()
|
||||
|
@ -158,6 +180,50 @@ pub async fn robot( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
|||
).await
|
||||
}
|
||||
|
||||
pub async fn app( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
||||
// if response Ok return HttpResponseBuilder
|
||||
HttpResponse::Ok()
|
||||
// set response content type html
|
||||
.content_type("text/html")
|
||||
// set response body to template context
|
||||
.body(
|
||||
// render template context
|
||||
template::TplApp {
|
||||
// lang to value of Accept-Language header
|
||||
lang : &template::get_lang(&req),
|
||||
}
|
||||
|
||||
// render template context into String
|
||||
.render()
|
||||
.map_err( |e| {
|
||||
eprintln!("error_tplrender : {}", e );
|
||||
error::crash( template::get_lang(&req), "error_tplrender" )
|
||||
})?,
|
||||
).await
|
||||
}
|
||||
|
||||
pub async fn business( req: HttpRequest ) -> Result<HttpResponse, Error> {
|
||||
// if response Ok return HttpResponseBuilder
|
||||
HttpResponse::Ok()
|
||||
// set response content type html
|
||||
.content_type("text/html")
|
||||
// set response body to template context
|
||||
.body(
|
||||
// render template context
|
||||
template::TplModel {
|
||||
// lang to value of Accept-Language header
|
||||
lang : &template::get_lang(&req),
|
||||
}
|
||||
|
||||
// render template context into String
|
||||
.render()
|
||||
.map_err( |e| {
|
||||
eprintln!("error_tplrender : {}", e );
|
||||
error::crash( template::get_lang(&req), "error_tplrender" )
|
||||
})?,
|
||||
).await
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -12,6 +12,14 @@ pub struct TplIndex<'a> {
|
|||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
// define path to use template in
|
||||
#[template(path="app.html")]
|
||||
pub struct TplRootWork<'a> {
|
||||
// replace with lang
|
||||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
// define path to use template in
|
||||
#[template(path="hemp.html")]
|
||||
|
@ -52,16 +60,25 @@ pub struct TplOff<'a> {
|
|||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
|
||||
// test
|
||||
// info template within index.html
|
||||
// index info windows
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path="info.html")]
|
||||
#[template(path="tekla.html")]
|
||||
pub struct TplRobot<'a> {
|
||||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path="rootwork.html")]
|
||||
pub struct TplApp<'a> {
|
||||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
#[derive(Template)]
|
||||
#[template(path="virtual.html")]
|
||||
pub struct TplModel<'a> {
|
||||
pub lang: &'a str,
|
||||
}
|
||||
|
||||
|
||||
// linked to error template
|
||||
|
|
|
@ -19,14 +19,15 @@ async fn main() -> std::io::Result<()> {
|
|||
.service( fs::Files::new("/assets", "./templates/assets/").index_file("index.html"))
|
||||
.route("/", web::get().to(route::index))
|
||||
.route("/hemp", web::get().to(route::hemp))
|
||||
.route("/spider", web::get().to(route::spider))
|
||||
.route("/tekla", web::get().to(route::spider))
|
||||
.route("/rootwork", web::get().to(route::rootwork))
|
||||
.route("/kaoscube", web::get().to(route::cube))
|
||||
.route("/cyberpreneur", web::get().to(route::cyber))
|
||||
.route("/offgrid", web::get().to(route::off))
|
||||
|
||||
// test
|
||||
// route of link in svg in index.html
|
||||
// info windows index
|
||||
.route("/robot", web::get().to(route::robot))
|
||||
.route("/app", web::get().to(route::app))
|
||||
.route("/virtual", web::get().to(route::business))
|
||||
})
|
||||
.bind("0.0.0.0:5000")?
|
||||
.run()
|
||||
|
|
5
templates/app.html
Normal file
5
templates/app.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
{% extends "base.html" %}
|
||||
{% block content %}
|
||||
<h1>RootWork</h1>
|
||||
<p>The social network of plants</p>
|
||||
{% endblock %}
|
|
@ -33,6 +33,7 @@
|
|||
width: inherit;
|
||||
display: grid;
|
||||
grid-template-rows: .5fr .25fr 1fr .45fr;
|
||||
max-width: inherit;
|
||||
}
|
||||
|
||||
.content h2 {
|
||||
|
@ -171,6 +172,11 @@ input:hover ~ .close {
|
|||
}
|
||||
}
|
||||
|
||||
#small {
|
||||
font-size: 4.9vh;
|
||||
max-width: inherit;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -61,13 +61,17 @@
|
|||
<path id="edge_6" class="edges" d="m18.277 93.674c38.021-40.006 37.999-40.007 37.999-40.007" stroke-width=".52917"/>
|
||||
<path id="edge_4" class="edges" d="m69.403 85.356c-13.122-31.702-13.127-31.689-13.127-31.689" stroke-width="3.4396"/>
|
||||
<path id="edge_5" class="edges" d="m50.728 121.44c2.3527-71.49 2.3361-71.474 2.3361-71.474" stroke-width=".48836px"/>
|
||||
<circle id="circle_2" class="nodes" cx="60" cy="52" r="13" style="paint-order:fill stroke markers" fill="url(#permapp)"/>
|
||||
<a href="/app">
|
||||
<circle id="circle_2" class="nodes" cx="60" cy="52" r="13" style="paint-order:fill stroke markers" fill="url(#permapp)"/>
|
||||
</a>
|
||||
</g>
|
||||
|
||||
<g class="group_3">
|
||||
<path id="edge_7" class="edges" d="m30.477 64.503c29.347 29.791 29.347 29.774 29.347 29.774" stroke-width=".52917"/>
|
||||
<path id="edge_8" class="edges" d="m23.453 62.106c28.366 67.295 28.374 67.263 28.374 67.263" stroke-width=".55417px"/>
|
||||
<circle id="circle_3" class="nodes" cx="20" cy="60" r="13" style="paint-order: fill stroke markers" fill="url(#cyber)"/>
|
||||
<a href="/virtual">
|
||||
<circle id="circle_3" class="nodes" cx="20" cy="60" r="13" style="paint-order: fill stroke markers" fill="url(#cyber)"/>
|
||||
</a>
|
||||
</g>
|
||||
|
||||
<g class="group_4">
|
||||
|
|
|
@ -9,8 +9,9 @@
|
|||
<div class="hamburger"></div>
|
||||
|
||||
<ul class ="menu">
|
||||
<li><a href="/tekla">Tekla</a></li>
|
||||
<li><a href="/rootwork">Rootwork</a></li>
|
||||
<li><a href="/hemp">{{ "nav_item1"|translate(lang) }}</a></li>
|
||||
<li><a href="/spider">{{ "nav_item2"|translate(lang) }}</a></li>
|
||||
<li><a href="/kaoscube">Kaos Cube</a></li>
|
||||
<li><a href="/cyberpreneur">Cyberpreneur</a></li>
|
||||
<li><a href="/offgrid">Offgrid</a></li>
|
||||
|
|
41
templates/rootwork.html
Normal file
41
templates/rootwork.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
<!-- load into index template -->
|
||||
{% block child %}
|
||||
<div class="mobile_placeholder">
|
||||
<form action="/" method="get">
|
||||
<input type="submit">
|
||||
<svg class="close" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="myGradient" gradientTransform="rotate(90)">
|
||||
<stop offset="5%" stop-color="#8693AB" />
|
||||
<stop offset="95%" stop-color="#BDD4E7" />
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id="myGradient2" gradientTransform="rotate(45)">
|
||||
<stop offset="5%" stop-color="#BDD4E7" />
|
||||
<stop offset="95%" stop-color="#8693AB" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
</form>
|
||||
<div class="open">
|
||||
{# Test Content - add language handling json#}
|
||||
<div class="box">
|
||||
</div>
|
||||
<div class="content">
|
||||
<h2>Root Work</h2>
|
||||
<h3>The Social Network of Plants for Robots and Explorers</h3>
|
||||
<p>The most impressive network on out planet can be found underground.
|
||||
All organisms on earth are related, they are friends and followers.
|
||||
All of them have favorite environments that get them into a good mood.
|
||||
They show it with flowers or sweet fruit.
|
||||
RootWork aims to become a network of optimal conditions for all organisms and serves as a database for Tekla.
|
||||
</p>
|
||||
<a href="/rootwork">MORE</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock%}
|
|
@ -33,7 +33,7 @@
|
|||
All Spiders communicate trough the network the Kaos Cube spins.
|
||||
Tekla monitors the plants and takes care of their needs until it's time for it to harvest the free organic and local crops.
|
||||
</p>
|
||||
<a href="/spider">MORE</a>
|
||||
<a href="/tekla">MORE</a>
|
||||
</div>
|
||||
</div>
|
||||
|
41
templates/virtual.html
Normal file
41
templates/virtual.html
Normal file
|
@ -0,0 +1,41 @@
|
|||
{% extends "index.html" %}
|
||||
|
||||
<!-- load into index template -->
|
||||
{% block child %}
|
||||
<div class="mobile_placeholder">
|
||||
<form action="/" method="get">
|
||||
<input type="submit">
|
||||
<svg class="close" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
||||
<defs>
|
||||
<linearGradient id="myGradient" gradientTransform="rotate(90)">
|
||||
<stop offset="5%" stop-color="#8693AB" />
|
||||
<stop offset="95%" stop-color="#BDD4E7" />
|
||||
</linearGradient>
|
||||
|
||||
<linearGradient id="myGradient2" gradientTransform="rotate(45)">
|
||||
<stop offset="5%" stop-color="#BDD4E7" />
|
||||
<stop offset="95%" stop-color="#8693AB" />
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
||||
</svg>
|
||||
</form>
|
||||
<div class="open">
|
||||
{# Test Content - add language handling json#}
|
||||
<div class="box">
|
||||
</div>
|
||||
<div class="content">
|
||||
<h2 id="small">Cyberpreneur</h2>
|
||||
<h3>Virtual business transparency and customers as entrepreneurs</h3>
|
||||
<p>The most impressive network on out planet can be found underground.
|
||||
All organisms on earth are related, they are friends and followers.
|
||||
All of them have favorite environments that get them into a good mood.
|
||||
They show it with flowers or sweet fruit.
|
||||
RootWork aims to become a network of optimal conditions for all organisms and serves as a database for Tekla.
|
||||
</p>
|
||||
<a href="/cyberpreneur">MORE</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
{% endblock%}
|
Loading…
Reference in a new issue