diff --git a/docs/source/configuration.rst b/docs/source/configuration.rst
index d3ea7e79..34dfef26 100644
--- a/docs/source/configuration.rst
+++ b/docs/source/configuration.rst
@@ -102,9 +102,11 @@ output in color, as well as HTML e-mail using ``sendmail``:
report:
text:
details: true
+ title_format: location
footer: true
line_length: 75
html:
+ title_format: pretty
diff: unified
separate: true
email:
diff --git a/docs/source/reporters.rst b/docs/source/reporters.rst
index f4f4b750..8eaef207 100644
--- a/docs/source/reporters.rst
+++ b/docs/source/reporters.rst
@@ -313,6 +313,7 @@ public Matrix room, as the messages quickly become noisy:
markdown:
details: false
+ title_format: pretty
footer: false
minimal: true
enabled: true
diff --git a/lib/urlwatch/reporters.py b/lib/urlwatch/reporters.py
index 43a19cde..57bb990c 100644
--- a/lib/urlwatch/reporters.py
+++ b/lib/urlwatch/reporters.py
@@ -177,8 +177,6 @@ def submit(self):
yield from (str(part) for part in self._parts())
def _parts(self):
- cfg = self.get_base_config(self.report)
-
yield SafeHtml("""
urlwatch
@@ -217,15 +215,27 @@ def _parts(self):
""")
+ cfg = self.get_base_config(self.report)
+ title_format = cfg.get('title_format', 'default')
+
+ if title_format not in ("default", "location", "pretty"):
+ logger.warn(f'Invalid title format {title_format!r}, falling back to "default".')
+ title_format = "default"
+
for job_state in self.report.get_filtered_job_states(self.job_states):
job = job_state.job
if job.location_is_url():
title = '{pretty_name}'
- elif job.pretty_name() != job.get_location():
- title = '{pretty_name}'
- else:
+ elif title_format == "location":
title = '{location}'
+ elif title_format == "pretty":
+ title = '{pretty_name}'
+ else: # default
+ if job.pretty_name() != job.get_location():
+ title = '{pretty_name}'
+ else:
+ title = '{location}'
title = '{verb}: ' + title + '
'
yield SafeHtml(title).format(verb=job_state.verb,
@@ -292,14 +302,24 @@ def submit(self):
line_length = cfg['line_length']
show_details = cfg['details']
show_footer = cfg['footer']
+ title_format = cfg.get('title_format', 'default')
+
+ if title_format not in ("default", "location", "pretty"):
+ logger.warn(f'Invalid title format {title_format!r}, falling back to "default".')
+ title_format = "default"
if cfg['minimal']:
for job_state in self.report.get_filtered_job_states(self.job_states):
pretty_name = job_state.job.pretty_name()
location = job_state.job.get_location()
- if pretty_name != location:
- location = '%s ( %s )' % (pretty_name, location)
- yield ': '.join((job_state.verb.upper(), location))
+ if title_format == "location":
+ title = location
+ elif title_format == "pretty":
+ title = pretty_name
+ else: # default
+ if pretty_name != location:
+ title = '%s ( %s )' % (pretty_name, location)
+ yield ': '.join((job_state.verb.upper(), title))
return
summary = []
@@ -337,16 +357,24 @@ def _format_content(self, job_state):
return job_state.get_diff()
def _format_output(self, job_state, line_length):
+ cfg = self.get_base_config(self.report)
+ title_format = cfg.get('title_format', 'default')
+
summary_part = []
details_part = []
pretty_name = job_state.job.pretty_name()
location = job_state.job.get_location()
- if pretty_name != location:
- location = '%s ( %s )' % (pretty_name, location)
+ if title_format == "location":
+ title = location
+ elif title_format == "pretty":
+ title = pretty_name
+ else: # default
+ if pretty_name != location:
+ title = '%s ( %s )' % (pretty_name, location)
pretty_summary = ': '.join((job_state.verb.upper(), pretty_name))
- summary = ': '.join((job_state.verb.upper(), location))
+ summary = ': '.join((job_state.verb.upper(), title))
content = self._format_content(job_state)
summary_part.append(pretty_summary)
@@ -798,14 +826,24 @@ def submit(self, max_length=None):
cfg = self.get_base_config(self.report)
show_details = cfg['details']
show_footer = cfg['footer']
+ title_format = cfg.get('title_format', 'default')
+
+ if title_format not in ("default", "location", "pretty"):
+ logger.warn(f'Invalid title format {title_format!r}, falling back to "default".')
+ title_format = "default"
if cfg['minimal']:
for job_state in self.report.get_filtered_job_states(self.job_states):
pretty_name = job_state.job.pretty_name()
location = job_state.job.get_location()
- if pretty_name != location:
- location = '%s (%s)' % (pretty_name, location)
- yield '* ' + ': '.join((job_state.verb.upper(), location))
+ if title_format == "location":
+ title = location
+ elif title_format == "pretty":
+ title = pretty_name
+ else: # default
+ if pretty_name != location:
+ title = '%s (%s)' % (pretty_name, location)
+ yield '* ' + ': '.join((job_state.verb.upper(), title))
return
summary = []
@@ -964,16 +1002,24 @@ def _format_content(self, job_state):
return job_state.get_diff()
def _format_output(self, job_state):
+ cfg = self.get_base_config(self.report)
+ title_format = cfg.get('title_format', 'default')
+
summary_part = []
details_part = []
pretty_name = job_state.job.pretty_name()
location = job_state.job.get_location()
- if pretty_name != location:
- location = '%s (%s)' % (pretty_name, location)
+ if title_format == "location":
+ title = location
+ elif title_format == "pretty":
+ title = pretty_name
+ else: # default
+ if pretty_name != location:
+ title = '%s (%s)' % (pretty_name, location)
pretty_summary = ': '.join((job_state.verb.upper(), pretty_name))
- summary = ': '.join((job_state.verb.upper(), location))
+ summary = ': '.join((job_state.verb.upper(), title))
content = self._format_content(job_state)
summary_part.append(pretty_summary)
diff --git a/lib/urlwatch/storage.py b/lib/urlwatch/storage.py
index 12090441..aa7b4d8c 100644
--- a/lib/urlwatch/storage.py
+++ b/lib/urlwatch/storage.py
@@ -76,6 +76,7 @@
'footer': True,
'minimal': False,
'separate': False,
+ 'title_format': 'default',
},
'markdown': {
@@ -83,11 +84,13 @@
'footer': True,
'minimal': False,
'separate': False,
+ 'title_format': 'default',
},
'html': {
'diff': 'unified', # "unified" or "table"
'separate': False,
+ 'title_format': 'default',
},
'stdout': {