Implement HTML block type

This commit is contained in:
Evie Viau-Chow-Stuart 2023-02-05 05:44:02 -08:00
parent 2359581c22
commit fb6ba0dd50
Signed by: evie
GPG key ID: 928652CDFCEC8099
7 changed files with 25 additions and 14 deletions

View file

@ -24,3 +24,6 @@ podman run -d --name kyanite -p 3621:3621 -e DATABASE_URL=postgres://xxx:xxx@xxx
| HOST | Optional. The IP that Kyanite will listen on. | 0.0.0.0 |
| PORT | Optional. The port that Kyanite will listen on. | 3621 |
| RUST_LOG | Optional. Sets the logging level. | INFO |
## Features

View file

@ -12,6 +12,9 @@ pub enum BlockTypes {
MARKDOWN {
content: String,
},
HTML {
content: String,
},
UNSUPPORTED
}

View file

@ -90,7 +90,8 @@ pub(crate) async fn root(
let deserde: block_types::Header = serde_json::from_str(&f.content.as_str()).expect("Incorrect HEADER formatting");
BlockTypes::HEADER { text: deserde.text, size: deserde.size }
}
},
"HTML" => BlockTypes::HTML { content: f.content },
_ => {
warn!("Unsupported block type! ({})", f.r#type.as_str());
BlockTypes::UNSUPPORTED

View file

@ -68,13 +68,13 @@ pub(crate) async fn resolver(
"HEADER" => {
let deserde: block_types::Header = serde_json::from_str(&f.content.as_str()).expect("Incorrect HEADER formatting");
BlockTypes::HEADER { text: deserde.text, size: deserde.size
}
}
BlockTypes::HEADER { text: deserde.text, size: deserde.size }
},
"HTML" => BlockTypes::HTML { content: f.content },
_ => {
warn!("Unsupported block type! ({})", f.r#type.as_str());
BlockTypes::UNSUPPORTED
}
warn!("Unsupported block type! ({})", f.r#type.as_str());
BlockTypes::UNSUPPORTED
}
}
).collect();

View file

@ -68,13 +68,13 @@ pub(crate) async fn resolver(
"HEADER" => {
let deserde: block_types::Header = serde_json::from_str(&f.content.as_str()).expect("Incorrect HEADER formatting");
BlockTypes::HEADER { text: deserde.text, size: deserde.size
}
}
BlockTypes::HEADER { text: deserde.text, size: deserde.size }
},
"HTML" => BlockTypes::HTML { content: f.content },
_ => {
warn!("Unsupported block type! ({})", f.r#type.as_str());
BlockTypes::UNSUPPORTED
}
warn!("Unsupported block type! ({})", f.r#type.as_str());
BlockTypes::UNSUPPORTED
}
}
).collect();

View file

@ -30,6 +30,8 @@
<p>{{ text }}</p>
{% when BlockTypes::MARKDOWN { content } %}
{{ content|markdown }}
{% when BlockTypes::HTML { content } %}
{{ content|safe }}
{% when BlockTypes::HEADER { text, size } %}
<h{{size}}>{{text}}</h{{size}}>
{% else %}

View file

@ -41,6 +41,8 @@
<p>{{ text }}</p>
{% when BlockTypes::MARKDOWN { content } %}
{{ content|markdown }}
{% when BlockTypes::HTML { content } %}
{{ content|safe }}
{% when BlockTypes::HEADER { text, size } %}
<h{{size}}>{{text}}</h{{size}}>
{% else %}