Skip to content

Commit

Permalink
Add about page, self host fonts, update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
agraven committed Apr 8, 2020
1 parent 77af1f5 commit f2cf135
Show file tree
Hide file tree
Showing 12 changed files with 272 additions and 224 deletions.
413 changes: 200 additions & 213 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ lto = true

[dependencies]
askama = "0.9"
base64 = "0.11"
bcrypt = "0.6"
chrono = { version = "0.4.6", features = ["serde"] }
base64 = "0.12"
bcrypt = "0.7"
chrono = { version = "0.4", features = ["serde"] }
comrak = "0.7"
cookie = { version = "0.12", features = ["percent-encode"] }
diesel = { version = "1.4", features = ["chrono", "postgres"] }
Expand Down
19 changes: 17 additions & 2 deletions src/document/index.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use askama::Template;
use cookie::Cookie;
use diesel::PgConnection as Connection;
use gotham::{
helpers::http::response::{create_empty_response, create_temporary_redirect as temp_redirect},
state::{FromState, State},
Expand All @@ -17,7 +16,7 @@ use crate::{
Permission::{CreateArticle, EditArticle, EditForeignArticle},
Session,
},
DbConnection,
Connection, DbConnection,
};

#[derive(Template)]
Expand Down Expand Up @@ -49,6 +48,22 @@ pub fn handler(state: &State) -> DocumentResult {
Ok(reponse)
}

#[derive(Template)]
#[template(path = "about.html")]
pub struct AboutTemplate<'a> {
session: Option<&'a Session>,
connection: &'a Connection,
}

pub fn about(state: &State) -> DocumentResult {
let connection = &DbConnection::borrow_from(state).lock()?;
let template = AboutTemplate {
session: Session::try_borrow_from(state),
connection,
};
Ok(template.to_response(state))
}

#[derive(Template)]
#[template(path = "article.html", escape = "none")]
pub struct ArticleTemplate<'a> {
Expand Down
2 changes: 2 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ fn router(settings: &Settings) -> Router {
.post("/initial-setup")
.to(body_handler!(document::index::init_setup_post));

route.get("/about").to(handler!(document::index::about));

route
.get("/article/:id")
.with_path_extractor::<articles::ArticlePath>()
Expand Down
18 changes: 18 additions & 0 deletions static/fonts/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@font-face {
font-family: 'Merriweather';
font-style: normal;
font-weight: normal;
src: local('Merriweather Regular'), local('Merriweather-Regular'), url('merriweather.woff2');
}
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: normal;
src: local('Roboto Regular'), local('Roboto-Regular'), url('roboto.woff2');
}
@font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: normal;
src: local('Montserrat Regular'), local('Montserrat-Regular'), url('montserrat.woff2');
}
Binary file added static/fonts/merriweather.woff2
Binary file not shown.
Binary file added static/fonts/montserrat.woff2
Binary file not shown.
Binary file added static/fonts/roboto.woff2
Binary file not shown.
15 changes: 10 additions & 5 deletions static/style.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import url('https://fonts.googleapis.com/css?family=Merriweather&display=swap');
@import url('https://fonts.googleapis.com/css?family=Roboto&display=swap');
@import url('https://fonts.googleapis.com/css?family=Montserrat&display=swap');
/* General element styling */
article {
background: #FCE4DE;
Expand All @@ -18,12 +15,20 @@ a[href] {
a:visited {
color: #941c63;
}
h1 {
h1, h2, h3, h4, h5, h6 {
margin: 0;
font-family: "Roboto", sans-serif;
font-size: xx-large;
text-decoration: none !important;
}
h1 {
font-size: xx-large;
}
h2 {
font-size: x-large;
}
h3 {
font-size: large;
}
h1 > a {
color: black!important;
text-decoration: none;
Expand Down
16 changes: 16 additions & 0 deletions templates/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends "root.html" %}

{% block content %}
<article>
<h1>About this site</h1>
Hi. My name is Amanda and this is my website.
<p>

<h2>Licenses</h2>
The source code for this site is released under the <a rel="license" href="https://www.gnu.org/licenses/agpl-3.0.html">GNU Affero General Public License</a>.</p>
<p>The font "Roboto" is licensed under the <a href="https://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
<p>The fonts "Merriweather" and "Montserrat" are licensed under the <a href="https://scripts.sil.org/cms/scripts/page.php?site_id=nrsi&id=OFL">Open Font License</a>.</p>
<p>Other files are licensed under the <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a> unless otherwise is stated.
</article>
{% endblock %}

4 changes: 4 additions & 0 deletions templates/initial-setup.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{% extends "root.html" %}

{% block head %}
<link rel="stylesheet" type="text/css" href="/file/form.css">
{% endblock head %}

{% block content %}
<article>
<header><h1>Create an admin user</h1></header>
Expand Down
3 changes: 2 additions & 1 deletion templates/root.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<meta name="viewport" content="width=device-width, inital-scale=1.0"/>
<link rel="shortcut icon" href="/file/favicon.png" type="image/png">
<link rel="shortcut icon" href="/file/favicon.svg" sizes="any" type="image/svg+xml">
<link rel="stylesheet" href="/file/style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="/file/style.css">
<link rel="stylesheet" type="text/css" href="/file/fonts/fonts.css">
{% block head %}{% endblock %}
</head>
<body>
Expand Down

0 comments on commit f2cf135

Please sign in to comment.