♻️ Simple & Efficient Gemini-to-HTTP Proxy fuwn.net
proxy gemini-protocol protocol gemini http rust
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: CONDENSE_LINKS_AT_HEADINGS configuration option

Fuwn f25e3bef 4c29f506

+33 -2
+1 -1
Cargo.toml
··· 21 21 22 22 [dependencies] 23 23 # Gemini 24 - germ = { version = "0.4.0", features = ["ast", "meta"] } 24 + germ = { version = "0.4.1", features = ["ast", "meta"] } 25 25 26 26 # HTTP 27 27 actix-web = "4.7.0"
+16
Configuration.md
··· 163 163 PRIMARY_COLOUR=red 164 164 PRIMARY_COLOUR=#ff0000 165 165 ``` 166 + 167 + ## `CONDENSE_LINKS_AT_HEADING` 168 + 169 + This configuration option is similar to `CONDENSE_LINKS`, but only condenses 170 + links found under certain headings. 171 + 172 + For instance, I condense the few links I have on my index page under the 173 + "# Fuwn[.me]" heading, and I condense my quick links/navigation panel under the 174 + "## Quick Links" heading. 175 + 176 + This way, I don't accidentally condense say my entire sitemap, which could be 177 + hundreds of links long, but I do condense my quick links on every page. 178 + 179 + ```dotenv 180 + CONDENSE_LINKS_AT_HEADINGS="## Quick Links,# Fuwn[.me]" 181 + ```
+16 -1
src/html.rs
··· 52 52 53 53 links.contains(&url.path().to_string()) || links.contains(&"*".to_string()) 54 54 }; 55 + let mut in_condense_links_flag_trap = true; 56 + let condensible_headings_value = 57 + var("CONDENSE_LINKS_AT_HEADINGS").unwrap_or_default(); 58 + let condensible_headings = 59 + condensible_headings_value.split(',').collect::<Vec<_>>(); 55 60 56 61 for node in ast { 57 - if previous_link && (!matches!(node, Node::Link { .. }) || !condense_links) 62 + if condensible_headings.contains(&node.to_gemtext().as_str()) { 63 + in_condense_links_flag_trap = true; 64 + } 65 + 66 + if previous_link 67 + && (!matches!(node, Node::Link { .. }) 68 + || (!condense_links && !in_condense_links_flag_trap)) 58 69 { 59 70 html.push_str("\n</p>"); 60 71 previous_link = false; ··· 173 184 )); 174 185 } 175 186 Node::Heading { level, text } => { 187 + if !condensible_headings.contains(&node.to_gemtext().as_str()) { 188 + in_condense_links_flag_trap = false; 189 + } 190 + 176 191 if title.is_empty() && *level == 1 { 177 192 title = safe(&text.clone()).to_string(); 178 193 }