conf: move html_filter to PagerSettings
html_filter was in Account settings, but it makes more sense for it to be in PagerSettingsembed
parent
ee9ffffa12
commit
9a3b9b1409
|
@ -70,6 +70,7 @@ identity="username@hostname.local"
|
||||||
|
|
||||||
[pager]
|
[pager]
|
||||||
filter = "/usr/bin/pygmentize"
|
filter = "/usr/bin/pygmentize"
|
||||||
|
html_filter = "w3m -I utf-8 -T text/html"
|
||||||
|
|
||||||
[notifications]
|
[notifications]
|
||||||
script = "notify-send"
|
script = "notify-send"
|
||||||
|
@ -113,8 +114,6 @@ shows one row per thread
|
||||||
.It Cm display_name Ar String
|
.It Cm display_name Ar String
|
||||||
(optional) a name which can be combined with your address:
|
(optional) a name which can be combined with your address:
|
||||||
"Name <email@address.tld>"
|
"Name <email@address.tld>"
|
||||||
.It Cm html_filter Ar String
|
|
||||||
(optional) pipe html attachments through this filter before display
|
|
||||||
.It Cm read_only Ar boolean
|
.It Cm read_only Ar boolean
|
||||||
attempt to not make any changes to this account.
|
attempt to not make any changes to this account.
|
||||||
.Pq Em false
|
.Pq Em false
|
||||||
|
@ -273,6 +272,10 @@ enable freedesktop-spec notifications. this is usually what you want
|
||||||
(optional) always show headers when scrolling.
|
(optional) always show headers when scrolling.
|
||||||
.\" default value
|
.\" default value
|
||||||
.Pq Em false
|
.Pq Em false
|
||||||
|
.It Cm html_filter Ar String
|
||||||
|
(optional) pipe html attachments through this filter before display
|
||||||
|
.\" default value
|
||||||
|
.Pq Em none
|
||||||
.It Cm filter Ar String
|
.It Cm filter Ar String
|
||||||
(optional) a command to pipe mail output through for viewing in pager.
|
(optional) a command to pipe mail output through for viewing in pager.
|
||||||
.\" default value
|
.\" default value
|
||||||
|
|
|
@ -134,9 +134,9 @@ impl MailView {
|
||||||
Some(Box::new(move |a: &'closure Attachment, v: &mut Vec<u8>| {
|
Some(Box::new(move |a: &'closure Attachment, v: &mut Vec<u8>| {
|
||||||
if a.content_type().is_text_html() {
|
if a.content_type().is_text_html() {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let settings = context.accounts[self.coordinates.0].runtime_settings.conf();
|
let settings = &context.settings;
|
||||||
/* FIXME: duplication with view/html.rs */
|
/* FIXME: duplication with view/html.rs */
|
||||||
if let Some(filter_invocation) = settings.html_filter() {
|
if let Some(filter_invocation) = settings.pager.html_filter.as_ref() {
|
||||||
let parts = split_command!(filter_invocation);
|
let parts = split_command!(filter_invocation);
|
||||||
let (cmd, args) = (parts[0], &parts[1..]);
|
let (cmd, args) = (parts[0], &parts[1..]);
|
||||||
let command_obj = Command::new(cmd)
|
let command_obj = Command::new(cmd)
|
||||||
|
@ -576,16 +576,11 @@ impl Component for MailView {
|
||||||
ViewMode::Attachment(aidx) if body.attachments()[aidx].is_html() => {
|
ViewMode::Attachment(aidx) if body.attachments()[aidx].is_html() => {
|
||||||
self.pager = None;
|
self.pager = None;
|
||||||
let attachment = &body.attachments()[aidx];
|
let attachment = &body.attachments()[aidx];
|
||||||
self.subview = Some(Box::new(HtmlView::new(
|
self.subview = Some(Box::new(HtmlView::new(&attachment, context)));
|
||||||
&attachment,
|
|
||||||
context,
|
|
||||||
self.coordinates.0,
|
|
||||||
)));
|
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
}
|
}
|
||||||
ViewMode::Normal if body.is_html() => {
|
ViewMode::Normal if body.is_html() => {
|
||||||
self.subview =
|
self.subview = Some(Box::new(HtmlView::new(&body, context)));
|
||||||
Some(Box::new(HtmlView::new(&body, context, self.coordinates.0)));
|
|
||||||
self.pager = None;
|
self.pager = None;
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,8 +96,8 @@ impl EnvelopeView {
|
||||||
Some(Box::new(|a: &Attachment, v: &mut Vec<u8>| {
|
Some(Box::new(|a: &Attachment, v: &mut Vec<u8>| {
|
||||||
if a.content_type().is_text_html() {
|
if a.content_type().is_text_html() {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
let settings = context.accounts[self.account_pos].runtime_settings.conf();
|
let settings = &context.settings;
|
||||||
if let Some(filter_invocation) = settings.html_filter() {
|
if let Some(filter_invocation) = settings.pager.html_filter.as_ref() {
|
||||||
let parts = split_command!(filter_invocation);
|
let parts = split_command!(filter_invocation);
|
||||||
let (cmd, args) = (parts[0], &parts[1..]);
|
let (cmd, args) = (parts[0], &parts[1..]);
|
||||||
let command_obj = Command::new(cmd)
|
let command_obj = Command::new(cmd)
|
||||||
|
@ -319,14 +319,10 @@ impl Component for EnvelopeView {
|
||||||
match self.mode {
|
match self.mode {
|
||||||
ViewMode::Attachment(aidx) if body.attachments()[aidx].is_html() => {
|
ViewMode::Attachment(aidx) if body.attachments()[aidx].is_html() => {
|
||||||
let attachment = &body.attachments()[aidx];
|
let attachment = &body.attachments()[aidx];
|
||||||
self.subview = Some(Box::new(HtmlView::new(
|
self.subview = Some(Box::new(HtmlView::new(&attachment, context)));
|
||||||
&attachment,
|
|
||||||
context,
|
|
||||||
self.account_pos,
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
ViewMode::Normal if body.is_html() => {
|
ViewMode::Normal if body.is_html() => {
|
||||||
self.subview = Some(Box::new(HtmlView::new(&body, context, self.account_pos)));
|
self.subview = Some(Box::new(HtmlView::new(&body, context)));
|
||||||
self.mode = ViewMode::Subview;
|
self.mode = ViewMode::Subview;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
|
|
|
@ -31,12 +31,13 @@ pub struct HtmlView {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HtmlView {
|
impl HtmlView {
|
||||||
pub fn new(body: &Attachment, context: &mut Context, account_pos: usize) -> Self {
|
pub fn new(body: &Attachment, context: &mut Context) -> Self {
|
||||||
let id = ComponentId::new_v4();
|
let id = ComponentId::new_v4();
|
||||||
let bytes: Vec<u8> = decode_rec(body, None);
|
let bytes: Vec<u8> = decode_rec(body, None);
|
||||||
|
|
||||||
let settings = context.accounts[account_pos].runtime_settings.conf();
|
let settings = &context.settings;
|
||||||
let mut display_text = if let Some(filter_invocation) = settings.html_filter() {
|
let mut display_text = if let Some(filter_invocation) = settings.pager.html_filter.as_ref()
|
||||||
|
{
|
||||||
let parts = split_command!(filter_invocation);
|
let parts = split_command!(filter_invocation);
|
||||||
let (cmd, args) = (parts[0], &parts[1..]);
|
let (cmd, args) = (parts[0], &parts[1..]);
|
||||||
let command_obj = Command::new(cmd)
|
let command_obj = Command::new(cmd)
|
||||||
|
|
|
@ -157,11 +157,6 @@ pub struct FileAccount {
|
||||||
display_name: Option<String>,
|
display_name: Option<String>,
|
||||||
index_style: IndexStyle,
|
index_style: IndexStyle,
|
||||||
|
|
||||||
/// A command to pipe html output before displaying it in a pager
|
|
||||||
/// Default: None
|
|
||||||
#[serde(default = "none", deserialize_with = "non_empty_string")]
|
|
||||||
html_filter: Option<String>,
|
|
||||||
|
|
||||||
#[serde(default = "false_val")]
|
#[serde(default = "false_val")]
|
||||||
read_only: bool,
|
read_only: bool,
|
||||||
subscribed_folders: Vec<String>,
|
subscribed_folders: Vec<String>,
|
||||||
|
@ -268,10 +263,6 @@ impl FileAccount {
|
||||||
pub fn index_style(&self) -> IndexStyle {
|
pub fn index_style(&self) -> IndexStyle {
|
||||||
self.index_style
|
self.index_style
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn html_filter(&self) -> Option<&str> {
|
|
||||||
self.html_filter.as_ref().map(String::as_str)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||||
|
@ -421,18 +412,6 @@ impl Default for IndexStyle {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn non_empty_string<'de, D>(deserializer: D) -> std::result::Result<Option<String>, D::Error>
|
|
||||||
where
|
|
||||||
D: Deserializer<'de>,
|
|
||||||
{
|
|
||||||
let s = <String>::deserialize(deserializer)?;
|
|
||||||
if s.is_empty() {
|
|
||||||
Ok(None)
|
|
||||||
} else {
|
|
||||||
Ok(Some(s))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn toggleflag_de<'de, D>(deserializer: D) -> std::result::Result<ToggleFlag, D::Error>
|
fn toggleflag_de<'de, D>(deserializer: D) -> std::result::Result<ToggleFlag, D::Error>
|
||||||
where
|
where
|
||||||
D: Deserializer<'de>,
|
D: Deserializer<'de>,
|
||||||
|
@ -488,6 +467,23 @@ mod default_vals {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mod deserializers {
|
||||||
|
use serde::{Deserialize, Deserializer};
|
||||||
|
pub(in crate::conf) fn non_empty_string<'de, D>(
|
||||||
|
deserializer: D,
|
||||||
|
) -> std::result::Result<Option<String>, D::Error>
|
||||||
|
where
|
||||||
|
D: Deserializer<'de>,
|
||||||
|
{
|
||||||
|
let s = <String>::deserialize(deserializer)?;
|
||||||
|
if s.is_empty() {
|
||||||
|
Ok(None)
|
||||||
|
} else {
|
||||||
|
Ok(Some(s))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for IndexStyle {
|
impl<'de> Deserialize<'de> for IndexStyle {
|
||||||
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> std::result::Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use super::default_vals::*;
|
use super::default_vals::*;
|
||||||
|
use super::deserializers::*;
|
||||||
/// Settings for the pager function.
|
/// Settings for the pager function.
|
||||||
#[derive(Debug, Deserialize, Clone, Default, Serialize)]
|
#[derive(Debug, Deserialize, Clone, Default, Serialize)]
|
||||||
pub struct PagerSettings {
|
pub struct PagerSettings {
|
||||||
|
@ -45,9 +46,14 @@ pub struct PagerSettings {
|
||||||
|
|
||||||
/// A command to pipe mail output through for viewing in pager.
|
/// A command to pipe mail output through for viewing in pager.
|
||||||
/// Default: None
|
/// Default: None
|
||||||
#[serde(default = "none")]
|
#[serde(default = "none", deserialize_with = "non_empty_string")]
|
||||||
pub filter: Option<String>,
|
pub filter: Option<String>,
|
||||||
|
|
||||||
|
/// A command to pipe html output before displaying it in a pager
|
||||||
|
/// Default: None
|
||||||
|
#[serde(default = "none", deserialize_with = "non_empty_string")]
|
||||||
|
pub html_filter: Option<String>,
|
||||||
|
|
||||||
/// Respect "format=flowed"
|
/// Respect "format=flowed"
|
||||||
/// Default: true
|
/// Default: true
|
||||||
#[serde(default = "true_val")]
|
#[serde(default = "true_val")]
|
||||||
|
|
Loading…
Reference in New Issue