- + 'a {
.flat_map(|bytes| b"
".iter().chain(bytes).chain(b"
\n"))
}
+pub fn css_content(buffer: &mut Vec) -> usize {
+ buffer.extend_from_slice(LINK_CSS.as_bytes());
+
+ LINK_CSS.len()
+}
+
pub async fn initial_content(
buf_mut: Vec,
chain: Arc,
@@ -144,7 +152,7 @@ pub async fn footer(
let is_not_root = path != "/";
- buf_mut.extend_from_slice(b"");
+ buf_mut.extend_from_slice(b"");
for _ in 1..=total_links {
buf_mut.extend(
diff --git a/crates/nailgen/src/lib.rs b/crates/nailgen/src/lib.rs
index c9b936f..c722dab 100644
--- a/crates/nailgen/src/lib.rs
+++ b/crates/nailgen/src/lib.rs
@@ -24,7 +24,8 @@ use tokio::time::Sleep;
use crate::{
delay::delay_output,
html_gen::{
- extra, footer, initial_content, main_content, static_content, static_title, text_generator,
+ css_content, extra, footer, initial_content, main_content, static_content, static_title,
+ text_generator,
},
};
@@ -108,11 +109,11 @@ impl Stream for MarkovStream {
) -> Poll> {
let mut this = self.as_mut().project();
- 'outer: loop {
+ 'generator: loop {
let mut buffer = Vec::new();
match this.state.as_mut().project() {
- GeneratorStateProj::Template => 'inner: loop {
+ GeneratorStateProj::Template => 'template: loop {
match this.cursor.write_template(&mut buffer) {
template::TemplateState::Title => {
let title = this.page_title.get_or_insert_with(|| {
@@ -130,7 +131,7 @@ impl Stream for MarkovStream {
buffer.extend_from_slice(title);
- continue 'inner;
+ continue 'template;
}
template::TemplateState::Initial => {
let handle = boxed_future_within(|| {
@@ -147,7 +148,12 @@ impl Stream for MarkovStream {
keep_generating: false,
});
- continue 'outer;
+ continue 'generator;
+ }
+ template::TemplateState::Css => {
+ *this.total_bytes += css_content(&mut buffer);
+
+ continue 'template;
}
template::TemplateState::Main => {
if let Some(content) = this.template.get_static_content() {
@@ -161,11 +167,11 @@ impl Stream for MarkovStream {
*this.total_bytes += len;
- continue 'inner;
+ continue 'template;
} else {
this.state.set(GeneratorState::Content);
- continue 'outer;
+ continue 'generator;
}
}
template::TemplateState::Extra => {
@@ -173,7 +179,7 @@ impl Stream for MarkovStream {
*this.total_bytes += bytes;
- continue 'inner;
+ continue 'template;
}
template::TemplateState::Footer => {
let handle = boxed_future_within(|| {
@@ -191,7 +197,7 @@ impl Stream for MarkovStream {
keep_generating: false,
});
- continue 'outer;
+ continue 'generator;
}
template::TemplateState::Finished => {
let elapsed_time = this.start_time.elapsed().as_micros();
@@ -216,12 +222,12 @@ impl Stream for MarkovStream {
&& this.start_time.elapsed().as_secs() >= time_limit.as_secs()
{
this.state.set(GeneratorState::Template);
- continue 'outer;
+ continue 'generator;
}
if *this.total_bytes >= (this.config.generator.payload_size * 1024) {
this.state.set(GeneratorState::Template);
- continue 'outer;
+ continue 'generator;
}
let handle = boxed_future_within(|| {
diff --git a/crates/nailgen/src/template.rs b/crates/nailgen/src/template.rs
index a4ea233..099b0ef 100644
--- a/crates/nailgen/src/template.rs
+++ b/crates/nailgen/src/template.rs
@@ -25,6 +25,7 @@ fn process_template<'any>(template: &'any mut &str) -> ModalResult<(&'any str, T
let state = alt((
Caseless("title").map(|_| (part, TemplateState::Title)),
+ Caseless("css").map(|_| (part, TemplateState::Css)),
Caseless("initial").map(|_| (part, TemplateState::Initial)),
Caseless("main").map(|_| (part, TemplateState::Main)),
Caseless("extra").map(|_| (part, TemplateState::Extra)),
@@ -88,6 +89,7 @@ impl WarningTemplate {
if cursor.validate(&[
TemplateState::Title,
+ TemplateState::Css,
TemplateState::Main,
TemplateState::Footer,
]) {
@@ -112,6 +114,7 @@ impl GeneratedTemplate {
if cursor.validate(&[
TemplateState::Title,
+ TemplateState::Css,
TemplateState::Initial,
TemplateState::Main,
TemplateState::Extra,
@@ -205,6 +208,7 @@ unsafe impl Sync for TemplateCursor {}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TemplateState {
Title,
+ Css,
Initial,
Main,
Extra,
diff --git a/templates/generated.html b/templates/generated.html
index 8eb99b2..62a28d5 100644
--- a/templates/generated.html
+++ b/templates/generated.html
@@ -1,23 +1,21 @@
-
+
+
+ {{ TITLE }}
+
+
+
+ {{ CSS }}
+
-
- {{ TITLE }}
-
-
-
-
-
-
-
- {{ TITLE }}
- {{ INITIAL }}
- {{ MAIN }}
- {{ EXTRA }}
-
-
-
-
-
\ No newline at end of file
+
+
+ {{ TITLE }}
+ {{ INITIAL }} {{ MAIN }} {{ EXTRA }}
+
+
+
+