Skip to content

Commit d30c9d0

Browse files
fix default templates and stripp any trailing dashes from copyed posts
1 parent 651dd0c commit d30c9d0

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

src/commands.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -512,8 +512,16 @@ pub fn handle_ui_command(cmd: UiCommand, ctx: &mut UiCommandContext<'_>) {
512512
options.boost_template = strip_stats(&options.boost_template);
513513
options.quote_template = strip_stats(&options.quote_template);
514514
let is_expanded = state.cw_expanded.contains(entry.id());
515-
let text = entry.display_text(&options, is_expanded);
516-
if text.trim().is_empty() {
515+
let mut text = entry.display_text(&options, is_expanded).trim().to_string();
516+
while text.ends_with(" -") || text.ends_with(',') {
517+
if text.ends_with(" -") {
518+
text.truncate(text.len() - 2);
519+
} else if text.ends_with(',') {
520+
text.pop();
521+
}
522+
text = text.trim().to_string();
523+
}
524+
if text.is_empty() {
517525
live_region.announce("Post has no text");
518526
return;
519527
}

src/template.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use minijinja::{Environment, context};
22

3-
pub const DEFAULT_POST_TEMPLATE: &str = "{{ author }}: {{ content }} - {{ media }}{{ poll }} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
4-
pub const DEFAULT_BOOST_TEMPLATE: &str = "{{ booster }} boosted {{ author }}: {{ content }} - {{ media }}{{ poll }}{% if quote_author %} - Quoting {{ quote_author }} ({{ quote_username }}): {{ quote_content }}{{ quote_media }}{{ quote_poll }}{% endif %} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
5-
pub const DEFAULT_QUOTE_TEMPLATE: &str = "{{ author }}: {{ content }} - Quoting {{ quote_author }} ({{ quote_username }}): {{ quote_content }} - {{ quote_media }}{{ quote_poll }} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
3+
pub const DEFAULT_POST_TEMPLATE: &str = "{{ author }}: {{ content }}{% if media or poll %} - {{ media }}{{ poll }}{% endif %} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
4+
pub const DEFAULT_BOOST_TEMPLATE: &str = "{{ booster }} boosted {{ author }}: {{ content }}{% if media or poll %} - {{ media }}{{ poll }}{% endif %}{% if quote_author %} - Quoting {{ quote_author }} ({{ quote_username }}): {{ quote_content }}{% if quote_media or quote_poll %} - {{ quote_media }}{{ quote_poll }}{% endif %}{% endif %} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
5+
pub const DEFAULT_QUOTE_TEMPLATE: &str = "{{ author }}: {{ content }}{% if media or poll %} - {{ media }}{{ poll }}{% endif %} - Quoting {{ quote_author }} ({{ quote_username }}): {{ quote_content }}{% if quote_media or quote_poll %} - {{ quote_media }}{{ quote_poll }}{% endif %} - {{ relative_time }}, {{ visibility }}{% if reply_count %}, {{ reply_count }}{% endif %}{% if boost_count %}, {{ boost_count }}{% endif %}{% if favorite_count %}, {{ favorite_count }}{% endif %}{% if client %}, via {{ client }}{% endif %}";
66
pub const DEFAULT_WINDOW_TITLE_TEMPLATE: &str = "Fedra - {{ account }}";
77

88
pub struct WindowTitleTemplateVars {

0 commit comments

Comments
 (0)