Initial commit

This commit is contained in:
apio 2023-01-24 19:37:35 +01:00
commit 09be3b0bd9
Signed by: apio
GPG Key ID: B8A7D06E42258954
8 changed files with 2409 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

2300
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

10
Cargo.toml Normal file
View File

@ -0,0 +1,10 @@
[package]
name = "bff-challenge"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
rocket = "0.5.0-rc.2"
rocket_dyn_templates = {version = "0.1.0-rc.2", features = [ "tera" ]}

2
Rocket.toml Normal file
View File

@ -0,0 +1,2 @@
[global]
template_dir = "templates"

29
src/main.rs Normal file
View File

@ -0,0 +1,29 @@
#![feature(decl_macro)]
use rocket::*;
use rocket_dyn_templates::{Template, context};
#[get("/create")]
fn create() -> &'static str
{
"Hello, world!"
}
#[get("/about")]
fn about() -> Template
{
Template::render("about", context!{})
}
#[get("/")]
fn index() -> Template
{
Template::render("index", context! {
create_uri: uri!(create())
})
}
#[launch]
fn rocket() -> _ {
rocket::build().mount("/", routes![create, index, about]).attach(Template::fairing())
}

15
templates/about.html.tera Normal file
View File

@ -0,0 +1,15 @@
{% extends "base" %}
{% block title %}{% endblock %}
{% block body %}
<div class="flex flex-col w-full h-fit content-center justify-center">
<div class="card w-96 h-48 flex-initial bg-base-300 shadow-xl self-center m-48">
<div class="card-body">
<h2 class="card-title">Info</h2>
<p>Una versión creativa y libre de estos sitios con "desafíos del mejor amigo".</p>
<div class="card-actions justify-end">
<a class="btn btn-primary" href="https://git.cloudapio.eu/apio/bff-challenge">Código</a>
</div>
</div>
</div>
</div>
{% endblock %}

43
templates/base.html.tera Normal file
View File

@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en" data-theme="luxury" class="h-screen">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="https://cdn.jsdelivr.net/npm/daisyui@2.47.0/dist/full.css" rel="stylesheet" type="text/css" />
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@2.2/dist/tailwind.min.css" rel="stylesheet" type="text/css" />
<title>{% block title %}{% endblock %}</title>
</head>
<body class="h-full">
<div class="navbar bg-base-200">
<div class="navbar-start">
<div class="dropdown">
<label tabindex="0" class="btn btn-ghost lg:hidden">
<svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 12h8m-8 6h16" /></svg>
</label>
<ul tabindex="0" class="menu menu-compact dropdown-content mt-3 p-2 shadow bg-base-300 rounded-box w-52">
<li><a href="/">Página principal</a></li>
<li><a href="/about">Info</a></li>
</ul>
</div>
<a class="btn btn-ghost normal-case text-xl year-data" href="#">Desafío del mejor amigo $year</a>
</div>
<div class="navbar-end hidden lg:flex">
<ul class="menu menu-horizontal px-1">
<li><a href="/">Página principal</a></li>
<li><a href="/about">Info</a></li>
</ul>
</div>
</div>
{% block body %}
{% endblock %}
<script>
const year = new Date().getFullYear().toString();
// Set everything to the current year
document.querySelectorAll(".year-data").forEach((element) => {
element.innerText = element.innerText.replace('$year', year);
})
document.title = `Desafío del mejor amigo ${year}${document.title}`;
</script>
</body>
</html>

View File

@ -0,0 +1,9 @@
{% extends "base" %}
{% block title %}{% endblock %}
{% block body %}
<div class="flex flex-col w-full h-fit content-center justify-center">
<a class="btn btn-ghost normal-case w-96 h-20 flex-initial bg-base-300 shadow-xl self-center m-48" href="/create">
Crea tu propio test AHORA!
</a>
</div>
{% endblock %}