Compare commits
24 Commits
33094f897d
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 5848b7360c | |||
| d0a4b0f6a6 | |||
| 59a6205a1e | |||
| 4bfce7c928 | |||
| d95d764c4a | |||
| ab494f8381 | |||
| 35331ef076 | |||
| d7e4f91740 | |||
| a477b43f1c | |||
| 450c6d137b | |||
| f7b850d62a | |||
| cb6e666a6e | |||
| 892b2082c1 | |||
| 2740bd8c6f | |||
| 66dcbdc93a | |||
| 46c1edafa0 | |||
| 1789cb261f | |||
| d6f16fe65e | |||
| 725a77318a | |||
| 244cddd966 | |||
| 6e9c280542 | |||
| 8c5d5553c5 | |||
| ff12f2c7b4 | |||
| 114dc25235 |
@@ -3,3 +3,4 @@
|
||||
.env
|
||||
*.db*
|
||||
key
|
||||
.DS_Store
|
||||
|
||||
Generated
+366
-332
File diff suppressed because it is too large
Load Diff
@@ -75,6 +75,19 @@ impl BlogDb {
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
/// Delete post by id
|
||||
pub async fn set_post_date<S, T>(&self, id: S, date: T) -> anyhow::Result<()>
|
||||
where
|
||||
S: AsRef<str>,
|
||||
T: AsRef<str>,
|
||||
{
|
||||
sqlx::query("UPDATE posts SET date=? WHERE id=?")
|
||||
.bind(date.as_ref())
|
||||
.bind(id.as_ref())
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -3,6 +3,10 @@ name = "server"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[[bin]]
|
||||
name = "evie"
|
||||
path = "./src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
blogdb = { path = "../blogdb/" }
|
||||
anyhow = "1.0.89"
|
||||
@@ -42,6 +46,7 @@ tracing-subscriber = { version = "0.3.18", features = [
|
||||
"std",
|
||||
] }
|
||||
phf = "0.11.2"
|
||||
chrono = { version = "0.4.39", features = ["alloc"] }
|
||||
|
||||
[build-dependencies]
|
||||
dotenvy = "0.15.7"
|
||||
|
||||
+18
-2
@@ -17,7 +17,7 @@ fn main() {
|
||||
println!("cargo:rustc-env={key}={value}");
|
||||
}
|
||||
let path = Path::new(&env::var("OUT_DIR").unwrap()).join("codegen.rs");
|
||||
let mut file = BufWriter::new(File::create(&path).unwrap());
|
||||
let mut outfile = BufWriter::new(File::create(&path).unwrap());
|
||||
let template_dir = [&env::var("CARGO_MANIFEST_DIR").unwrap(), "/src/templates"].concat();
|
||||
println!("cargo:rerun-if-changed={}", template_dir);
|
||||
let pattern = [&template_dir, "/**/*.html"].concat();
|
||||
@@ -47,8 +47,24 @@ fn main() {
|
||||
Err(_) => todo!(),
|
||||
}
|
||||
}
|
||||
// this is all a mess cause i'm lazy lol
|
||||
let feed_template_path = [&template_dir, "/feed.xml"].concat();
|
||||
let mut feed_file = File::open(feed_template_path).unwrap();
|
||||
let mut content = "r####\"".to_string();
|
||||
feed_file.read_to_string(&mut content).unwrap();
|
||||
content.push_str("\"####");
|
||||
let feed_template = content;
|
||||
map.entry("feed".to_string(), &feed_template);
|
||||
let item_template_path = [&template_dir, "/item.xml"].concat();
|
||||
let mut item_file = File::open(item_template_path).unwrap();
|
||||
let mut content = "r####\"".to_string();
|
||||
item_file.read_to_string(&mut content).unwrap();
|
||||
content.push_str("\"####");
|
||||
let item_template = content;
|
||||
map.entry("item".to_string(), &item_template);
|
||||
|
||||
writeln!(
|
||||
&mut file,
|
||||
&mut outfile,
|
||||
"static TEMPLATES: phf::Map<&'static str, &'static str> = {};",
|
||||
map.build()
|
||||
)
|
||||
|
||||
@@ -6,6 +6,7 @@ main {
|
||||
gap: var(--default-padding);
|
||||
margin-block-end: 40svb;
|
||||
padding: 0;
|
||||
min-block-size: unset;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 60rem) {
|
||||
@@ -21,6 +22,10 @@ main {
|
||||
flex-wrap: nowrap !important;
|
||||
}
|
||||
|
||||
.admin-widget:not(.admin-widget-user) {
|
||||
max-inline-size: calc(50% - (0.5 * var(--default-padding)));
|
||||
}
|
||||
|
||||
.admin-widget-user {
|
||||
flex-direction: row !important;
|
||||
justify-content: space-between;
|
||||
@@ -117,8 +122,8 @@ main {
|
||||
.blog-admin {
|
||||
box-sizing: border-box;
|
||||
display: flex;
|
||||
gap: var(--default-padding);
|
||||
flex-wrap: wrap;
|
||||
gap: var(--default-padding);
|
||||
box-sizing: border-box;
|
||||
min-block-size: 0;
|
||||
flex: 1;
|
||||
@@ -198,6 +203,7 @@ main {
|
||||
min-block-size: 0;
|
||||
border: var(--border);
|
||||
display: flex;
|
||||
max-inline-size: 100%;
|
||||
|
||||
&>*:not(form, a) {
|
||||
padding-inline: var(--default-padding);
|
||||
@@ -212,6 +218,7 @@ main {
|
||||
|
||||
li {
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
@@ -239,10 +246,17 @@ main {
|
||||
a.entry-content {
|
||||
color: inherit;
|
||||
text-decoration: inherit;
|
||||
inline-size: 90%;
|
||||
max-inline-size: 90%;
|
||||
|
||||
transition: all 0.3s ease;
|
||||
|
||||
& :is(p, h2) {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
inline-size: 100%;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
transform: translateX(1ch);
|
||||
|
||||
@@ -8,6 +8,7 @@ h1 {
|
||||
|
||||
.blog-roll-entry {
|
||||
margin-block: 1rem;
|
||||
overflow: visible;
|
||||
|
||||
a {
|
||||
border: var(--border);
|
||||
@@ -21,7 +22,9 @@ h1 {
|
||||
|
||||
.entry-content {
|
||||
padding: var(--content-padding);
|
||||
transition: padding-inline-start 0.3s ease, box-shadow 0.3s ease;
|
||||
transition: padding 0.3s ease, box-shadow 0.3s ease;
|
||||
overflow: hidden;
|
||||
|
||||
|
||||
* {
|
||||
margin-block: 0;
|
||||
@@ -32,6 +35,7 @@ h1 {
|
||||
&:focus-visible {
|
||||
.entry-content {
|
||||
padding-inline-start: calc(var(--content-padding) * 2);
|
||||
padding-inline-end: 0;
|
||||
box-shadow: inset 3px 0px 0px var(--color-text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ main {
|
||||
|
||||
@media all and (max-width: 650px) {
|
||||
.ce-toolbar__actions {
|
||||
|
||||
&>*:nth-child(1),
|
||||
&>*:nth-child(2) {
|
||||
border-radius: 0;
|
||||
@@ -141,7 +142,7 @@ main {
|
||||
}
|
||||
|
||||
* {
|
||||
border-radius: 0 !important;
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.ce-block__content {
|
||||
@@ -192,6 +193,11 @@ main {
|
||||
background-color: var(--color-selection) !important;
|
||||
}
|
||||
|
||||
.cdx-quote__text {
|
||||
border-block-end: none !important;
|
||||
margin-block-end: 0 !important;
|
||||
}
|
||||
|
||||
.embed-tool__caption {
|
||||
display: none;
|
||||
}
|
||||
|
||||
@@ -3,13 +3,8 @@ body {
|
||||
flex-wrap: wrap;
|
||||
justify-content: stretch;
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 50rem) {
|
||||
body {
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
flex-direction: column;
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
body>div {
|
||||
@@ -39,7 +34,6 @@ main {
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
/* block-size: 100%; */
|
||||
max-block-size: 100%;
|
||||
|
||||
&>:first-child {
|
||||
@@ -71,3 +65,13 @@ form {
|
||||
max-inline-size: 40ch;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 50rem) {
|
||||
body {
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
main {
|
||||
margin-block: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
|
||||
--font-size: 1rem;
|
||||
font-size: var(--font-size);
|
||||
line-height: 1.15;
|
||||
/* 1. Correct the line height in all browsers. */
|
||||
-webkit-text-size-adjust: 100%;
|
||||
/* 2. Prevent adjustments of font size after orientation changes in iOS. */
|
||||
@@ -71,10 +70,12 @@ input,
|
||||
label,
|
||||
a,
|
||||
blockquote,
|
||||
figcaption,
|
||||
aside,
|
||||
ol,
|
||||
ul {
|
||||
font-size: calc(var(--font-size) * 1.33);
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
h1,
|
||||
@@ -87,26 +88,22 @@ h6 {
|
||||
}
|
||||
|
||||
aside,
|
||||
blockquote {
|
||||
border: var(--border);
|
||||
}
|
||||
|
||||
blockquote,
|
||||
aside {
|
||||
figure {
|
||||
padding: var(--default-padding) calc(var(--default-padding) * 2);
|
||||
border: var(--border);
|
||||
max-inline-size: 100%;
|
||||
margin-inline: 0;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
&::before {
|
||||
content: '“';
|
||||
font-weight: 600;
|
||||
}
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
&::after {
|
||||
content: '”';
|
||||
font-weight: 600;
|
||||
figure {
|
||||
& figcaption {
|
||||
font-style: italic;
|
||||
margin-inline-start: var(--default-padding);
|
||||
margin-block-start: var(--default-padding);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,6 +116,29 @@ ul {
|
||||
a {
|
||||
color: unset;
|
||||
text-decoration: unset;
|
||||
|
||||
&:not(:has(time)):is([href^="http"], [href^="mailto"]) {
|
||||
padding-inline-end: 0.9em;
|
||||
|
||||
&::after {
|
||||
transition: all 0.3s ease;
|
||||
position: absolute;
|
||||
content: '';
|
||||
display: inline-block;
|
||||
width: 1em;
|
||||
height: 1em;
|
||||
margin-inline-start: -0.05em;
|
||||
margin-block-start: 0.23em;
|
||||
background-size: 100%;
|
||||
transform: scale(0.8);
|
||||
background-image: url("/assets/images/external.svg");
|
||||
}
|
||||
|
||||
&:is(:hover, :active, :focus-visible)::after {
|
||||
filter: invert(100%);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
@@ -135,7 +155,7 @@ input {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
input:is([type="text"], [type="password"], [type="search"]) {
|
||||
input:is([type="text"], [type="password"], [type="search"], [type="email"], ) {
|
||||
padding: 0.5ch 1ch;
|
||||
|
||||
&:focus,
|
||||
@@ -269,7 +289,7 @@ header {
|
||||
background: var(--color-bg);
|
||||
|
||||
&>:first-child {
|
||||
margin: unset;
|
||||
margin-block-end: var(--default-padding);
|
||||
}
|
||||
|
||||
h1 {
|
||||
@@ -347,9 +367,66 @@ header {
|
||||
|
||||
}
|
||||
|
||||
iframe {
|
||||
max-inline-size: 100%;
|
||||
appearance: unset;
|
||||
border: var(--border);
|
||||
}
|
||||
|
||||
footer {
|
||||
border-block-start: var(--border);
|
||||
margin-block-start: calc(var(--default-padding) * 6);
|
||||
display: flex;
|
||||
min-block-size: calc(var(--header-size) * 2.5);
|
||||
padding: calc(1.5 * var(--default-padding)) var(--default-padding);
|
||||
gap: calc(2 * var(--default-padding));
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
|
||||
&>* {
|
||||
max-inline-size: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: start;
|
||||
}
|
||||
|
||||
|
||||
form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
& div {
|
||||
display: flex;
|
||||
max-inline-size: 100%;
|
||||
|
||||
&>* {
|
||||
min-inline-size: 0;
|
||||
}
|
||||
|
||||
input[type="submit"] {
|
||||
min-inline-size: min-content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
h1,
|
||||
ul {
|
||||
margin-block: 0 1rem;
|
||||
}
|
||||
|
||||
p,
|
||||
li,
|
||||
input {
|
||||
margin-block: 0.3rem;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
main {
|
||||
margin-block: var(--default-padding) 40svb;
|
||||
margin-inline: auto;
|
||||
min-block-size: 100svb;
|
||||
margin: var(--default-padding) auto;
|
||||
max-inline-size: min(60ch, 80%);
|
||||
padding-block: var(--default-padding);
|
||||
gap: var(--default-padding);
|
||||
@@ -416,12 +493,26 @@ main {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
|
||||
&>:first-child {
|
||||
margin-block-end: unset;
|
||||
}
|
||||
|
||||
nav {
|
||||
|
||||
justify-content: flex-end;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
flex-direction: row;
|
||||
|
||||
&>* {
|
||||
max-inline-size: 40ch;
|
||||
min-inline-size: 30ch;
|
||||
}
|
||||
}
|
||||
|
||||
main {
|
||||
margin-block: var(--default-padding);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
|
||||
<svg fill="#000000" width="800px" height="800px" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg"><path d="M 5 5 L 5 27 L 27 27 L 27 5 Z M 7 7 L 25 7 L 25 25 L 7 25 Z M 13 10 L 13 12 L 18.5625 12 L 9.28125 21.28125 L 10.71875 22.71875 L 20 13.4375 L 20 19 L 22 19 L 22 10 Z"/></svg>
|
||||
|
After Width: | Height: | Size: 407 B |
@@ -0,0 +1,11 @@
|
||||
const editDateButton = document.getElementById("date-update");
|
||||
const postActions = document.getElementById("post-actions");
|
||||
const children = postActions.innerHTML;
|
||||
|
||||
dateInput = `<button class="form-action" formaction="/admin" formmethod="get" formnovalidate>✕</button><input class="form-action" type="date" name="date" placeholder="Enter Date" autocomplete="off" aria-label="New Date" required /> <button class="form-action" type="submit" formaction="/api/posts/date">Update Date</button>`;
|
||||
|
||||
editDateButton.addEventListener("click", (ev) => {
|
||||
ev.preventDefault();
|
||||
console.log(ev, postActions, dateInput);
|
||||
postActions.innerHTML = dateInput;
|
||||
});
|
||||
@@ -1776,13 +1776,13 @@
|
||||
(this.settings = [
|
||||
{
|
||||
name: "unordered",
|
||||
label: this.api.i18n.t("Unordered"),
|
||||
label: this.api.i18n.t("Bulleted"),
|
||||
icon: n,
|
||||
default: t.defaultStyle === "unordered" || !1,
|
||||
},
|
||||
{
|
||||
name: "ordered",
|
||||
label: this.api.i18n.t("Ordered"),
|
||||
label: this.api.i18n.t("Numbered"),
|
||||
icon: l,
|
||||
default: t.defaultStyle === "ordered" || !0,
|
||||
},
|
||||
@@ -3239,16 +3239,6 @@
|
||||
static get sanitize() {
|
||||
return { text: { br: !0 }, caption: { br: !0 }, alignment: {} };
|
||||
}
|
||||
renderSettings() {
|
||||
const t = (n) => n && n[0].toUpperCase() + n.slice(1);
|
||||
return this.settings.map((n) => ({
|
||||
icon: n.icon,
|
||||
label: this.api.i18n.t(`Align ${t(n.name)}`),
|
||||
onActivate: () => this._toggleTune(n.name),
|
||||
isActive: this._data.alignment === n.name,
|
||||
closeOnActivate: !0,
|
||||
}));
|
||||
}
|
||||
_toggleTune(t) {
|
||||
(this._data.alignment = t), this._block.dispatchChange();
|
||||
}
|
||||
@@ -13662,7 +13652,7 @@ var editor = new EditorJS({
|
||||
inlineToolbar: true,
|
||||
config: {
|
||||
quotePlaceholder: "Enter a quote",
|
||||
captionPlaceholder: "Quote's author",
|
||||
captionPlaceholder: "Add author or a caption, leave blank to hide",
|
||||
},
|
||||
shortcut: "CMD+SHIFT+O",
|
||||
},
|
||||
|
||||
+142
-15
@@ -1,3 +1,4 @@
|
||||
use chrono::prelude::*;
|
||||
use std::{env, vec};
|
||||
|
||||
use blogdb::posts::Post;
|
||||
@@ -72,6 +73,12 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}),
|
||||
element!("site-footer", |site_footer| {
|
||||
if settings.site_footer {
|
||||
site_footer.replace(template!("site-footer"), ContentType::Html);
|
||||
}
|
||||
Ok(())
|
||||
}),
|
||||
element!("br", |br| {
|
||||
br.remove();
|
||||
Ok(())
|
||||
@@ -187,7 +194,7 @@ where
|
||||
.unwrap_or_default();
|
||||
make_page(
|
||||
html,
|
||||
PageSettings::new("Editor", Some(vec!["/assets/css/editor.css"]), true),
|
||||
PageSettings::new("Editor", Some(vec!["/assets/css/editor.css"]), true, false),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -229,7 +236,7 @@ pub(crate) fn login_status(next: &str, success: bool) -> String {
|
||||
.unwrap_or_default();
|
||||
make_page(
|
||||
html,
|
||||
PageSettings::new("Login", Some(vec!["/assets/css/login.css"]), false),
|
||||
PageSettings::new("Login", Some(vec!["/assets/css/login.css"]), false, false),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -237,7 +244,7 @@ pub(crate) async fn admin_page(session_id: i64, db: &BlogDb) -> String {
|
||||
let content = admin_widgets(template!("admin"), session_id, db).await;
|
||||
make_page(
|
||||
&content,
|
||||
PageSettings::new("Admin", Some(vec!["/assets/css/admin.css"]), true),
|
||||
PageSettings::new("Admin", Some(vec!["/assets/css/admin.css"]), true, false),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -288,8 +295,7 @@ async fn admin_entries(entry_type: EntryType, session_id: i64, db: &BlogDb) -> S
|
||||
let is_empty: bool;
|
||||
let entries_html = match entry_type {
|
||||
EntryType::Post => {
|
||||
let mut entries = db.get_posts().await.unwrap_or(vec![]);
|
||||
entries.reverse();
|
||||
let entries = db.get_posts().await.unwrap_or(vec![]);
|
||||
let mut entry_list_html = String::new();
|
||||
is_empty = entries.is_empty();
|
||||
if !is_empty {
|
||||
@@ -441,14 +447,30 @@ where
|
||||
element_content_handlers: vec![element!("meta", |meta| {
|
||||
if let Some(attr) = meta.get_attribute("property") {
|
||||
let content = match attr.as_str() {
|
||||
"og:url" => &[env!("DOMAIN"), slug.as_ref()].concat(),
|
||||
"og:url" => {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
&["http://localhost", slug.as_ref()].concat()
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN"), slug.as_ref()].concat()
|
||||
}
|
||||
}
|
||||
"og:type" => "article",
|
||||
"og:title" => title.as_ref(),
|
||||
"og:description" => description.as_ref(),
|
||||
"og:image" => {
|
||||
let image = image.as_ref();
|
||||
if !image.is_empty() {
|
||||
image
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
&["http://localhost", image].concat()
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN"), image].concat()
|
||||
}
|
||||
} else {
|
||||
meta.remove();
|
||||
""
|
||||
@@ -476,7 +498,7 @@ where
|
||||
let html = make_page(template, PageSettings::title("Blog"));
|
||||
|
||||
let post = db.get_post(id).await.unwrap_or_default();
|
||||
let head = head::<_, _, [String; 0]>(post.title, []);
|
||||
let head_content = head::<_, _, [String; 0]>(post.title, []);
|
||||
let post_content: Blocks = serde_json::from_str(&post.content).unwrap_or_default();
|
||||
let post_html: String = post_content.to_html();
|
||||
let image = if let Some(url) = post_content.image() {
|
||||
@@ -498,8 +520,17 @@ where
|
||||
time.after(&post_html, ContentType::Html);
|
||||
time.replace(
|
||||
&[
|
||||
r#"<a class="animated-link" style="align-self: flex-start; margin-block-end: 0" href="https://"#,
|
||||
env!("DOMAIN"),
|
||||
r#"<a class="animated-link" style="align-self: flex-start; margin-block-end: 0" href=""#,
|
||||
{
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
"http://localhost"
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN")].concat()
|
||||
}
|
||||
},
|
||||
"/blog/",
|
||||
&post.id,
|
||||
r#""><time>"#,
|
||||
@@ -510,8 +541,11 @@ where
|
||||
ContentType::Html,
|
||||
);
|
||||
Ok(())
|
||||
}), element!("head", |head| {
|
||||
head.replace(&head_content, ContentType::Html);
|
||||
head.append(&meta, ContentType::Html);
|
||||
Ok(())
|
||||
})],
|
||||
|
||||
..RewriteStrSettings::new()
|
||||
},
|
||||
)
|
||||
@@ -558,7 +592,7 @@ pub(crate) async fn blog_roll(db: &BlogDb) -> String {
|
||||
|
||||
make_page(
|
||||
blog_roll_html,
|
||||
PageSettings::new("Blog", Some(vec!["/assets/css/blog.css"]), true),
|
||||
PageSettings::new("Blog", Some(vec!["/assets/css/blog.css"]), true, true),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -653,6 +687,7 @@ pub(crate) async fn search_page(
|
||||
["Results for “", &query, "”"].concat(),
|
||||
Some(vec!["/assets/css/blog.css"]),
|
||||
true,
|
||||
true,
|
||||
),
|
||||
)
|
||||
}
|
||||
@@ -694,6 +729,7 @@ pub(crate) struct PageSettings {
|
||||
title: String,
|
||||
stylesheets: Option<Vec<String>>,
|
||||
site_header: bool,
|
||||
site_footer: bool,
|
||||
}
|
||||
|
||||
impl PageSettings {
|
||||
@@ -705,9 +741,15 @@ impl PageSettings {
|
||||
title: title.to_string(),
|
||||
stylesheets: None,
|
||||
site_header: true,
|
||||
site_footer: true,
|
||||
}
|
||||
}
|
||||
pub(crate) fn new<S, T>(title: S, stylesheets: Option<Vec<T>>, site_header: bool) -> Self
|
||||
pub(crate) fn new<S, T>(
|
||||
title: S,
|
||||
stylesheets: Option<Vec<T>>,
|
||||
site_header: bool,
|
||||
site_footer: bool,
|
||||
) -> Self
|
||||
where
|
||||
S: ToString,
|
||||
T: ToString,
|
||||
@@ -718,6 +760,7 @@ impl PageSettings {
|
||||
title: title.to_string(),
|
||||
stylesheets,
|
||||
site_header,
|
||||
site_footer,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -729,7 +772,7 @@ where
|
||||
make_page(message, PageSettings::title("Not found"))
|
||||
}
|
||||
|
||||
pub(crate) fn animate_anchors<S>(input: S) -> String
|
||||
pub(crate) fn zhuzh_anchors<S>(input: S) -> String
|
||||
where
|
||||
S: AsRef<str>,
|
||||
{
|
||||
@@ -737,9 +780,14 @@ where
|
||||
input.as_ref(),
|
||||
RewriteStrSettings {
|
||||
element_content_handlers: vec![element!("a", move |t| {
|
||||
if let Some(href) = t.get_attribute("href") {
|
||||
if !href.starts_with("/") {
|
||||
t.set_attribute("target", "_blank").unwrap_or_default();
|
||||
}
|
||||
}
|
||||
match t.get_attribute("class") {
|
||||
Some(class) => t
|
||||
.set_attribute("class", &[&class, "animated-link-underline"].concat())
|
||||
.set_attribute("class", &[&class, " animated-link-underline"].concat())
|
||||
.unwrap_or_default(),
|
||||
None => {
|
||||
t.set_attribute("class", "animated-link-underline")
|
||||
@@ -767,3 +815,82 @@ pub(crate) fn sanitize<S: AsRef<str>>(input: S) -> String {
|
||||
)
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub(crate) async fn rss(db: &BlogDb) -> String {
|
||||
let posts = db.get_posts().await.unwrap_or_default();
|
||||
let mut items = String::new();
|
||||
for post in posts {
|
||||
let url = {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
["http://localhost/blog/", &post.id].concat()
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
["https://", env!("DOMAIN"), "/blog/", &post.id].concat()
|
||||
}
|
||||
};
|
||||
let item = rewrite_str(
|
||||
template!("item"),
|
||||
RewriteStrSettings {
|
||||
element_content_handlers: vec![
|
||||
element!("title", |title| {
|
||||
title.set_inner_content(&post.title, ContentType::Text);
|
||||
Ok(())
|
||||
}),
|
||||
element!("link", |link| {
|
||||
link.replace(&["<link>", &url, "</link>"].concat(), ContentType::Html); // slight hack to get around lol_html weirdness
|
||||
Ok(())
|
||||
}),
|
||||
element!("guid", |guid| {
|
||||
guid.set_inner_content(&url, ContentType::Text);
|
||||
Ok(())
|
||||
}),
|
||||
element!("pubDate", |pub_date| {
|
||||
let date = {
|
||||
let date: [u32; 3] = post
|
||||
.date
|
||||
.splitn(3, "-")
|
||||
.map(|d| d.parse::<u32>().unwrap_or_default())
|
||||
.collect::<Vec<u32>>()
|
||||
.try_into()
|
||||
.unwrap_or_default();
|
||||
let date_time: DateTime<FixedOffset> =
|
||||
FixedOffset::west_opt(5 * 3600) // New York City
|
||||
.unwrap()
|
||||
.with_ymd_and_hms(date[0] as i32, date[1], date[2], 0, 0, 0)
|
||||
.unwrap();
|
||||
date_time.to_rfc2822()
|
||||
};
|
||||
pub_date.set_inner_content(&date, ContentType::Text);
|
||||
Ok(())
|
||||
}),
|
||||
element!("description", |description| {
|
||||
let post_content: Blocks =
|
||||
serde_json::from_str(&post.content).unwrap_or_default();
|
||||
let desc = ["<![CDATA[", &post_content.to_html(), "]]>"].concat();
|
||||
description.set_inner_content(&desc, ContentType::Html);
|
||||
Ok(())
|
||||
}),
|
||||
],
|
||||
..RewriteStrSettings::new()
|
||||
},
|
||||
)
|
||||
.unwrap_or_default();
|
||||
items.push_str(&item);
|
||||
}
|
||||
|
||||
let feed = rewrite_str(
|
||||
template!("feed"),
|
||||
RewriteStrSettings {
|
||||
element_content_handlers: vec![element!("channel", move |channel| {
|
||||
channel.append(&items, ContentType::Html);
|
||||
Ok(())
|
||||
})],
|
||||
..RewriteStrSettings::new()
|
||||
},
|
||||
)
|
||||
.unwrap_or_default();
|
||||
|
||||
feed
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ pub(crate) enum Block {
|
||||
},
|
||||
quote {
|
||||
text: String,
|
||||
caption: String,
|
||||
},
|
||||
embed {
|
||||
service: String,
|
||||
@@ -78,7 +79,13 @@ impl Block {
|
||||
}
|
||||
},
|
||||
Block::warning { title } => ["<aside>", title, "</aside>"].concat(),
|
||||
Block::quote { text } => ["<blockquote>", text, "</blockquote>"].concat(),
|
||||
Block::quote { text, caption } => {
|
||||
if caption.is_empty() {
|
||||
["<figure><blockquote>“", text, "”</blockquote></figure>"].concat()
|
||||
} else {
|
||||
["<figure><blockquote>“", text, "”</blockquote><figcaption>— ", caption,"</figcaption></figure>"].concat()
|
||||
}
|
||||
},
|
||||
Block::embed {
|
||||
embed,
|
||||
width,
|
||||
@@ -91,16 +98,27 @@ impl Block {
|
||||
&height.to_string(),
|
||||
"\" src=\"",
|
||||
embed,
|
||||
"\"></iframe>",
|
||||
"\" allowfullscreen></iframe>",
|
||||
]
|
||||
.concat(),
|
||||
Block::image { file, caption } => {
|
||||
["<img src=\"", &file.url, "\" alt=\"", caption, "\"/>"].concat()
|
||||
let src = {
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
&file.url
|
||||
}
|
||||
#[cfg(not(debug_assertions))]
|
||||
{
|
||||
&["https://", env!("DOMAIN"), &file.url].concat()
|
||||
}
|
||||
};
|
||||
["<img src=\"", src, "\" alt=\"", &caption.replace(r#"""#, """).replace("<br>", ""), "\"/>"].concat()
|
||||
}
|
||||
Block::delimiter {} => "<div style=\"inline-size: 100%; block-size: 1px; background: var(--color-text)\"></div>".to_string(),
|
||||
|
||||
};
|
||||
html::animate_anchors(html::remove_el(&text, "br"))
|
||||
html::zhuzh_anchors(html::remove_el(&text, "br"))
|
||||
}
|
||||
|
||||
fn to_plaintext(&self) -> String {
|
||||
@@ -109,7 +127,7 @@ impl Block {
|
||||
Block::header { text, level: _ } => text,
|
||||
Block::list { style: _, items } => &items.join("\n"),
|
||||
Block::warning { title } => title,
|
||||
Block::quote { text } => text,
|
||||
Block::quote { text, caption } => &[text, caption.as_str()].concat(),
|
||||
_ => &"".to_string(),
|
||||
};
|
||||
let text = [text, "\n"].concat();
|
||||
@@ -241,14 +259,17 @@ impl Blocks {
|
||||
Block::paragraph { text: _ } => true,
|
||||
Block::header { text: _, level } => *level > 1,
|
||||
Block::warning { title: _ } => true,
|
||||
Block::quote { text: _ } => true,
|
||||
Block::quote {
|
||||
text: _,
|
||||
caption: _,
|
||||
} => true,
|
||||
_ => false,
|
||||
})
|
||||
.map(|block| match block {
|
||||
Block::paragraph { text } => text,
|
||||
Block::header { text, level: _ } => text,
|
||||
Block::warning { title } => title,
|
||||
Block::quote { text } => text,
|
||||
Block::quote { text, caption: _ } => text,
|
||||
_ => "...",
|
||||
})
|
||||
.unwrap_or("No description"),
|
||||
|
||||
@@ -38,6 +38,7 @@ pub(super) fn api(state: BlogState) -> Router {
|
||||
struct Entries {
|
||||
#[serde(default)]
|
||||
item: Vec<String>,
|
||||
date: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize)]
|
||||
@@ -45,6 +46,7 @@ struct Entries {
|
||||
enum PostsEndpoints {
|
||||
delete,
|
||||
unpublish,
|
||||
date,
|
||||
}
|
||||
|
||||
async fn posts(
|
||||
@@ -71,6 +73,12 @@ async fn posts(
|
||||
state.index_delete(term);
|
||||
}
|
||||
}
|
||||
PostsEndpoints::date => {
|
||||
let date = &data.date.clone().unwrap_or("1970-01-01".to_string());
|
||||
for post_id in data.item.iter() {
|
||||
let _ = db.set_post_date(post_id, &date).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
state.index_commit();
|
||||
let mut headers = HeaderMap::new();
|
||||
|
||||
@@ -62,6 +62,7 @@ pub(super) async fn make_router(state: BlogState) -> Router {
|
||||
.nest("/api", api(state.clone()))
|
||||
.nest("/login", login(State(state.clone())))
|
||||
.route("/", get(pages).with_state(state.clone()))
|
||||
.route("/feed.xml", get(rss).with_state(state.clone()))
|
||||
.route("/*path", get(pages).with_state(state.clone()))
|
||||
.route("/search", get(search_empty))
|
||||
.route("/search/*query", get(search).with_state(state.clone()))
|
||||
@@ -308,6 +309,15 @@ async fn admin(jar: PrivateCookieJar, State(state): State<BlogState>) -> Respons
|
||||
(headers, Html(page)).into_response()
|
||||
}
|
||||
|
||||
async fn rss(State(state): State<BlogState>) -> Response {
|
||||
let mut headers = HeaderMap::new();
|
||||
headers.append(
|
||||
CONTENT_TYPE,
|
||||
HeaderValue::from_str("application/xml").unwrap(),
|
||||
);
|
||||
(headers, html::rss(state.db()).await).into_response()
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Default, Debug)]
|
||||
pub(crate) struct SearchResponse(Vec<SearchResponseEntry>);
|
||||
impl SearchResponse {
|
||||
|
||||
@@ -3,11 +3,14 @@
|
||||
<h1>Published Posts</h1>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="form-actions">
|
||||
<div class="form-actions" id="post-actions">
|
||||
<button class="form-action" type="submit" formaction="/api/posts/delete">Delete posts
|
||||
</button>
|
||||
<button class=" form-action" type="submit" formaction="/api/posts/unpublish">Unpublish Posts
|
||||
</button>
|
||||
<button id="date-update" class="form-action" type="submit" formaction="#update-date" formmethod="get">Edit
|
||||
Date
|
||||
</button>
|
||||
</div>
|
||||
<ul tabindex="-1">
|
||||
</ul>
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
<admin-widget type="drafts"></admin-widget>
|
||||
<admin-widget type="posts"></admin-widget>
|
||||
</div>
|
||||
<script src="/assets/js/admin.js"></script>
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="/assets/css/style.css" />
|
||||
</head>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<site-header></site-header>
|
||||
<main>
|
||||
</main>
|
||||
<site-footer></site-footer>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||
<channel>
|
||||
<title>Evie Ippolito's Blog</title>
|
||||
<link>https://evieippolito.com/blog</link>
|
||||
<atom:link href="https://evieippolito.com/feed.xml" rel="self" type="application/rss+xml" />
|
||||
<description>Evie's blog!</description>
|
||||
<language>en-us</language>
|
||||
<ttl>720</ttl>
|
||||
<managingEditor>evieippolito@duck.com (Evie Ippolito)</managingEditor>
|
||||
<webMaster>me@augustkline.com (august kline)</webMaster>
|
||||
</channel>
|
||||
</rss>
|
||||
@@ -0,0 +1,7 @@
|
||||
<item>
|
||||
<title></title>
|
||||
<link>
|
||||
<guid isPermaLink="true"></guid>
|
||||
<pubDate></pubDate>
|
||||
<description></description>
|
||||
</item>
|
||||
@@ -0,0 +1,56 @@
|
||||
<footer>
|
||||
<div>
|
||||
<h1>keep in touch</h1>
|
||||
<div>
|
||||
<form action="https://buttondown.com/api/emails/embed-subscribe/eviewrites" method="post"
|
||||
target="popupwindow" onsubmit="window.open('https://buttondown.com/eviewrites', 'popupwindow')"
|
||||
class="embeddable-buttondown-form">
|
||||
<label for="bd-email">
|
||||
<p>Subscribe to my newsletter for updates <3</p>
|
||||
</label>
|
||||
<div>
|
||||
<input type="email" name="email" id="bd-email" required />
|
||||
<input type="submit" value="Subscribe" style="border-inline-start: none;" />
|
||||
</div>
|
||||
</form>
|
||||
<p>Or subscribe to my <a class="animated-link-underline" href="/feed.xml">RSS feed</a>! RSS rules, you can
|
||||
learn more
|
||||
about
|
||||
it <a href="https://guides.library.yale.edu/keepingup/basics" class="animated-link-underline"
|
||||
target="_blank" rel="noreferrer">here</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h1>credits</h1>
|
||||
<div>
|
||||
<p><a href="https://augustkline.com" class="animated-link-underline" target="_blank" rel="noreferrer">august
|
||||
kline</a>
|
||||
made this website. <a href="mailto:inquiries@augustkline.com" class="animated-link-underline">give her
|
||||
money</a> and she will make you
|
||||
one too.</p>
|
||||
<p><a href="https://www.redaction.us/" class="animated-link-underline" target="_blank"
|
||||
rel="noreferrer">Redaction</a> and <a href="https://www.brailleinstitute.org/freefont/"
|
||||
class="animated-link-underline" target="_blank" rel="noreferrer">Atkinson Hyperlegible</a> are used
|
||||
as display and text typefaces,
|
||||
respectively.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h1>elsewhere</h1>
|
||||
<nav>
|
||||
<ul>
|
||||
<li>
|
||||
<ul>
|
||||
<li>
|
||||
<a href="https://www.instagram.com/everzines/" class="animated-link" target="_blank"
|
||||
rel="noreferrer">insta</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="mailto:evieippolito@duck.com" class="animated-link">email</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</footer>
|
||||
@@ -6,7 +6,7 @@ set -e
|
||||
|
||||
cargo update;
|
||||
|
||||
DOMAIN=evieippolito.com CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc cargo build --release --target x86_64-unknown-linux-gnu;
|
||||
DOMAIN=staging.evieippolito.com CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=x86_64-linux-gnu-gcc cargo build --release --target x86_64-unknown-linux-gnu;
|
||||
|
||||
scp target/x86_64-unknown-linux-gnu/release/evie kline@augustkline.com:/home/kline/;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user