Implement HTML block type
This commit is contained in:
parent
2359581c22
commit
fb6ba0dd50
7 changed files with 25 additions and 14 deletions
|
@ -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 |
|
| HOST | Optional. The IP that Kyanite will listen on. | 0.0.0.0 |
|
||||||
| PORT | Optional. The port that Kyanite will listen on. | 3621 |
|
| PORT | Optional. The port that Kyanite will listen on. | 3621 |
|
||||||
| RUST_LOG | Optional. Sets the logging level. | INFO |
|
| RUST_LOG | Optional. Sets the logging level. | INFO |
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ pub enum BlockTypes {
|
||||||
MARKDOWN {
|
MARKDOWN {
|
||||||
content: String,
|
content: String,
|
||||||
},
|
},
|
||||||
|
HTML {
|
||||||
|
content: String,
|
||||||
|
},
|
||||||
UNSUPPORTED
|
UNSUPPORTED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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");
|
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());
|
warn!("Unsupported block type! ({})", f.r#type.as_str());
|
||||||
BlockTypes::UNSUPPORTED
|
BlockTypes::UNSUPPORTED
|
||||||
|
|
|
@ -68,13 +68,13 @@ pub(crate) async fn resolver(
|
||||||
"HEADER" => {
|
"HEADER" => {
|
||||||
let deserde: block_types::Header = serde_json::from_str(&f.content.as_str()).expect("Incorrect HEADER formatting");
|
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());
|
warn!("Unsupported block type! ({})", f.r#type.as_str());
|
||||||
BlockTypes::UNSUPPORTED
|
BlockTypes::UNSUPPORTED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
).collect();
|
).collect();
|
||||||
|
|
|
@ -68,13 +68,13 @@ pub(crate) async fn resolver(
|
||||||
"HEADER" => {
|
"HEADER" => {
|
||||||
let deserde: block_types::Header = serde_json::from_str(&f.content.as_str()).expect("Incorrect HEADER formatting");
|
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());
|
warn!("Unsupported block type! ({})", f.r#type.as_str());
|
||||||
BlockTypes::UNSUPPORTED
|
BlockTypes::UNSUPPORTED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
).collect();
|
).collect();
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
<p>{{ text }}</p>
|
<p>{{ text }}</p>
|
||||||
{% when BlockTypes::MARKDOWN { content } %}
|
{% when BlockTypes::MARKDOWN { content } %}
|
||||||
{{ content|markdown }}
|
{{ content|markdown }}
|
||||||
|
{% when BlockTypes::HTML { content } %}
|
||||||
|
{{ content|safe }}
|
||||||
{% when BlockTypes::HEADER { text, size } %}
|
{% when BlockTypes::HEADER { text, size } %}
|
||||||
<h{{size}}>{{text}}</h{{size}}>
|
<h{{size}}>{{text}}</h{{size}}>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
|
@ -41,6 +41,8 @@
|
||||||
<p>{{ text }}</p>
|
<p>{{ text }}</p>
|
||||||
{% when BlockTypes::MARKDOWN { content } %}
|
{% when BlockTypes::MARKDOWN { content } %}
|
||||||
{{ content|markdown }}
|
{{ content|markdown }}
|
||||||
|
{% when BlockTypes::HTML { content } %}
|
||||||
|
{{ content|safe }}
|
||||||
{% when BlockTypes::HEADER { text, size } %}
|
{% when BlockTypes::HEADER { text, size } %}
|
||||||
<h{{size}}>{{text}}</h{{size}}>
|
<h{{size}}>{{text}}</h{{size}}>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
Reference in a new issue