diff options
author | bill-auger <mr.j.spam.me@gmail.com> | 2018-09-06 13:15:11 +0000 |
---|---|---|
committer | bill-auger <mr.j.spam.me@gmail.com> | 2018-10-02 19:02:24 -0400 |
commit | a078b33e4cb6c251cf87c667b3c4b5799cd716fa (patch) | |
tree | 8fc6458fc4ba97f96a83b735203c7f8cce9fc8ff | |
parent | df3f14887705dc1a8d46c49ced1423c16089cfb2 (diff) |
format cgit page titles - (allow backslashes)
-rw-r--r-- | process_event | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/process_event b/process_event index adff835..72511ea 100644 --- a/process_event +++ b/process_event @@ -4,7 +4,16 @@ function rdom { local IFS=\> - read -d \< element content + read -r -d \< element content +} + +function format_cgit_title +{ + if [[ "${url_to_get}" =~ /git.parabola.nu/([^/]+\.git)/tree/ ]] + then + repo="${BASH_REMATCH[1]}" + title=$(sed 's|\\.* - '${repo}'| - '${repo}'|' <<< ${title}) + fi } function tell_fact # thing channel @@ -252,14 +261,17 @@ function process_event do if [[ ${element} = title ]] || [[ ${element} = TITLE ]] then - sed 's/ / /g' <<< "${content}" | replace_wierd_html_chars + title="${content}" + [[ "${url_to_get}" =~ /git.parabola.nu/ ]] && format_cgit_title + + sed 's/ / /g' <<< "${title}" | replace_wierd_html_chars fi done ) if ! [[ -z ${the_title} ]] then - send_msg "${channel_it_came_from}" "Page title: \`${the_title}'" + send_msg "${channel_it_came_from}" "Page title: '${the_title}'" fi fi |