Skip to content

Commit 1153277

Browse files
authored
Merge branch 'master' into semvar-checks
2 parents a4f8257 + 08eccfb commit 1153277

24 files changed

Lines changed: 534 additions & 462 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ jobs:
320320
uses: mozilla-actions/sccache-action@v0.0.9
321321

322322
- name: Run cargo check with every combination of features
323-
run: cargo hack check --feature-powerset --exclude-features db --no-dev-deps
323+
run: cargo hack check --feature-powerset --depth 3 --exclude-features db --no-dev-deps
324324

325325
miri:
326326
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event.pull_request.head.repo.full_name != github.repository

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,10 @@ repos:
3838
hooks:
3939
- id: format-justfile
4040
name: "format justfiles"
41+
- repo: https://github.com/djlint/djLint
42+
rev: v1.36.4
43+
hooks:
44+
- id: djlint
45+
name: djLint
46+
files: \.(html|jinja|j2)$
47+
args: ["--reformat", "--lint"]

cot-cli/src/project_template/src/main.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@ use cot::db::migrations::SyncDynMigration;
66
use cot::html::Html;
77
use cot::middleware::{AuthMiddleware, LiveReloadMiddleware, SessionMiddleware};
88
use cot::project::{MiddlewareContext, RegisterAppsContext, RootHandlerBuilder};
9+
use cot::request::extractors::StaticFiles;
910
use cot::router::{Route, Router};
1011
use cot::static_files::{StaticFile, StaticFilesMiddleware};
1112
use cot::{App, AppBuilder, BoxedHandler, Project, static_files};
1213

1314
#[derive(Debug, Template)]
1415
#[template(path = "index.html")]
15-
struct IndexTemplate {}
16+
struct IndexTemplate {
17+
static_files: StaticFiles,
18+
}
1619

17-
async fn index() -> cot::Result<Html> {
18-
let index_template = IndexTemplate {};
20+
async fn index(static_files: StaticFiles) -> cot::Result<Html> {
21+
let index_template = IndexTemplate { static_files };
1922
let rendered = index_template.render()?;
2023

2124
Ok(Html::new(rendered))
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<title>Welcome to Cot!</title>
7-
8-
<link href="/static/css/main.css" rel="stylesheet">
9-
</head>
10-
<body>
11-
12-
<main>
13-
<h1>You have successfully installed Cot!</h1>
14-
15-
<p class="lead">Now, you can start building your web application using Rust and Cot.</p>
16-
17-
<ul>
18-
<li><a href="https://cot.rs/guide/latest/">Read the guide</a></li>
19-
<li><a href="https://docs.rs/cot">See the API reference</a></li>
20-
</ul>
21-
</main>
22-
23-
</body>
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Welcome to Cot!</title>
7+
<link href="{{ static_files.url_for("css/main.css")? }}" rel="stylesheet">
8+
</head>
9+
<body>
10+
<main>
11+
<h1>You have successfully installed Cot!</h1>
12+
<p class="lead">Now, you can start building your web application using Rust and Cot.</p>
13+
<ul>
14+
<li>
15+
<a href="https://cot.rs/guide/latest/">Read the guide</a>
16+
</li>
17+
<li>
18+
<a href="https://docs.rs/cot">See the API reference</a>
19+
</li>
20+
</ul>
21+
</main>
22+
</body>
2423
</html>

cot/templates/404.html

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<title>Not Found</title>
5-
<style>
3+
<head>
4+
<title>Not Found</title>
5+
<style>
66
html {
77
color-scheme: light dark;
88
}
@@ -12,11 +12,11 @@
1212
margin: 0 auto;
1313
font-family: Tahoma, Verdana, Arial, sans-serif;
1414
}
15-
</style>
16-
</head>
17-
<body>
18-
<h1>Not Found</h1>
19-
<p>Sorry, the page you are looking for has not been found.</p>
20-
<p>Try checking if the address you provided is correct and do not contain any typos.</p>
21-
</body>
15+
</style>
16+
</head>
17+
<body>
18+
<h1>Not Found</h1>
19+
<p>Sorry, the page you are looking for has not been found.</p>
20+
<p>Try checking if the address you provided is correct and do not contain any typos.</p>
21+
</body>
2222
</html>

cot/templates/405.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<title>Method Not Allowed</title>
5-
<style>
3+
<head>
4+
<title>Method Not Allowed</title>
5+
<style>
66
html {
77
color-scheme: light dark;
88
}
@@ -12,10 +12,10 @@
1212
margin: 0 auto;
1313
font-family: Tahoma, Verdana, Arial, sans-serif;
1414
}
15-
</style>
16-
</head>
17-
<body>
18-
<h1>Method Not Allowed</h1>
19-
<p>Sorry, the requested HTTP method is not supported by this endpoint.</p>
20-
</body>
15+
</style>
16+
</head>
17+
<body>
18+
<h1>Method Not Allowed</h1>
19+
<p>Sorry, the requested HTTP method is not supported by this endpoint.</p>
20+
</body>
2121
</html>

cot/templates/500.html

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!DOCTYPE html>
22
<html lang="en">
3-
<head>
4-
<title>Server Error</title>
5-
<style>
3+
<head>
4+
<title>Server Error</title>
5+
<style>
66
html {
77
color-scheme: light dark;
88
}
@@ -12,13 +12,18 @@
1212
margin: 0 auto;
1313
font-family: Tahoma, Verdana, Arial, sans-serif;
1414
}
15-
</style>
16-
</head>
17-
<body>
18-
<h1>Server Error</h1>
19-
<p>Sorry, the page you are looking for is currently unavailable.<br/>
20-
Please try again later.</p>
21-
<p>If you are a user, please report this to the website administrator. If you are the website administrator, please look
22-
in the server logs for details.</p>
23-
</body>
15+
</style>
16+
</head>
17+
<body>
18+
<h1>Server Error</h1>
19+
<p>
20+
Sorry, the page you are looking for is currently unavailable.
21+
<br />
22+
Please try again later.
23+
</p>
24+
<p>
25+
If you are a user, please report this to the website administrator. If you are the website administrator, please look
26+
in the server logs for details.
27+
</p>
28+
</body>
2429
</html>

cot/templates/admin/base.html

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
{%- let urls = ctx.urls -%}
22
<!DOCTYPE html>
33
<html lang="en">
4-
<head>
5-
<meta charset="UTF-8">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7-
<meta name="robots" content="NONE,NOARCHIVE">
8-
<title>{% block title %}{% endblock %} | Cot Admin</title>
9-
<link rel="stylesheet" href="{{ ctx.static_files.url_for("admin/admin.css")? }}">
10-
</head>
11-
<body class="{% block body_class %}{% endblock %}">
12-
<header id="header">
13-
<div id="branding"><a href="{{ cot::reverse!(urls, "index")? }}"><h1>Cot Administration</h1></a></div>
14-
</header>
15-
<main>
16-
{% block content %}{% endblock %}
17-
</main>
18-
</body>
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta name="robots" content="NONE,NOARCHIVE">
8+
<title>
9+
{%- block title -%}
10+
{%- endblock title %}
11+
| Cot Admin
12+
</title>
13+
<link rel="stylesheet"
14+
href="{{ ctx.static_files.url_for("admin/admin.css")? }}">
15+
</head>
16+
<body class="{% block body_class %}{% endblock body_class %}">
17+
<header id="header">
18+
<div id="branding">
19+
<a href="{{ cot::reverse!(urls, "index")? }}">
20+
<h1>Cot Administration</h1>
21+
</a>
22+
</div>
23+
</header>
24+
<main>
25+
{%- block content -%}
26+
{%- endblock content -%}
27+
</main>
28+
</body>
1929
</html>

cot/templates/admin/login.html

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,31 @@
11
{% extends "base.html" %}
2-
3-
{% block title %}Sign in{% endblock %}
4-
5-
{% block body_class %}login{% endblock %}
6-
2+
{% block title %}
3+
Sign in
4+
{% endblock title %}
5+
{% block body_class %}
6+
login
7+
{% endblock body_class %}
78
{% block content -%}
8-
<div class="container">
9-
<form action="" method="post">
10-
{% if form.has_errors() %}
11-
<div class="form-errors">
12-
{% for error in form.errors_for(FormErrorTarget::Form) %}
13-
{{ error }}
14-
{% endfor %}
15-
</div>
16-
{% endif %}
17-
18-
<div class="form-row">
19-
<label for="{{ form.username.id() }}">Username:</label>
20-
{{ form.username }}
21-
{% for error in form.errors_for(FormErrorTarget::Field("username")) %}
22-
{{ error }}
23-
{% endfor %}
24-
</div>
25-
26-
<div class="form-row">
27-
<label for="{{ form.password.id() }}">Password:</label>
28-
{{ form.password }}
29-
{% for error in form.errors_for(FormErrorTarget::Field("password")) %}
30-
{{ error }}
31-
{% endfor %}
32-
</div>
33-
34-
<div class="button-box">
35-
<button class="btn primary" type="submit">Sign in</button>
36-
</div>
37-
</form>
38-
</div>
39-
{%- endblock %}
9+
<div class="container">
10+
<form action="" method="post">
11+
{% if form.has_errors() %}
12+
<div class="form-errors">
13+
{% for error in form.errors_for(FormErrorTarget::Form) %}{{ error }}{% endfor %}
14+
</div>
15+
{% endif %}
16+
<div class="form-row">
17+
<label for="{{ form.username.id() }}">Username:</label>
18+
{{ form.username }}
19+
{% for error in form.errors_for(FormErrorTarget::Field("username")) %}{{ error }}{% endfor %}
20+
</div>
21+
<div class="form-row">
22+
<label for="{{ form.password.id() }}">Password:</label>
23+
{{ form.password }}
24+
{% for error in form.errors_for(FormErrorTarget::Field("password")) %}{{ error }}{% endfor %}
25+
</div>
26+
<div class="button-box">
27+
<button class="btn primary" type="submit">Sign in</button>
28+
</div>
29+
</form>
30+
</div>
31+
{%- endblock content %}

0 commit comments

Comments
 (0)