Skip to content

Commit

Permalink
Add more placeholders for the event URL in the HTML report
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiodsf committed Feb 5, 2025
1 parent aac6977 commit 54f85f7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
9 changes: 7 additions & 2 deletions sourcespec/config_files/configspec.conf
Original file line number Diff line number Diff line change
Expand Up @@ -686,9 +686,14 @@ plot_map_tiles_zoom_level = integer(min=1, max=23, default=None)
# Note: "plot_save_format" (above) must be "png" or "svg"
html_report = boolean(default=False)
# Link to event page. If set, the event ID on the HTML page will be a link to
# the event page. Use $EVENTID to indicate the current event ID.
# Example:
# the event page. You can use the following placeholders:
# - $EVENTID: the event ID
# - $YEAR: the year of the event
# - $MONTH: the month of the event
# - $DAY: the day of the event
# Examples:
# event_url = https://earthquake.usgs.gov/earthquakes/eventpage/$EVENTID/executive
# event_url = http://bbnet.gein.noa.gr/Events/$YEAR/$MONTH/$EVENTID_info.html
event_url = string(default=None)
# -------- HTML REPORT

Expand Down
6 changes: 6 additions & 0 deletions sourcespec/ssp_html_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,12 @@ def _add_event_info_to_html(config, replacements):
event_url = config.event_url
if event_url is not None:
event_url = event_url.replace('$EVENTID', evid)
event_year = hypo.origin_time.year
event_month = hypo.origin_time.month
event_day = hypo.origin_time.day
event_url = event_url.replace('$YEAR', f'{event_year:04d}')
event_url = event_url.replace('$MONTH', f'{event_month:02d}')
event_url = event_url.replace('$DAY', f'{event_day:02d}')
parsed_url = urlparse(event_url)
if not parsed_url.scheme:
logger.warning(
Expand Down

0 comments on commit 54f85f7

Please sign in to comment.