From e168aebdb5df3e9216d117d08a13603ff5435fe1 Mon Sep 17 00:00:00 2001 From: Midgard Date: Sat, 23 Nov 2024 20:49:26 +0100 Subject: [PATCH] Okay, done! --- footer.html | 5 ++- gen.sh | 82 +++++++++++++++++++++++++++---------- go_to_channel.png | Bin 0 -> 592 bytes header.html | 15 +++---- main.css | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+), 33 deletions(-) create mode 100644 go_to_channel.png create mode 100644 main.css diff --git a/footer.html b/footer.html index fdeaaf2..9b44319 100644 --- a/footer.html +++ b/footer.html @@ -1,6 +1,7 @@ + diff --git a/gen.sh b/gen.sh index f9163f0..b04e59b 100755 --- a/gen.sh +++ b/gen.sh @@ -1,7 +1,10 @@ #!/bin/sh set -euo pipefail -export MM_SERVER=zeus.mattermost.gent +if [ -z "$MM_SERVER" ]; then + echo "Set environment variable MM_SERVER to e.g. mattermost.example.com" + exit 1 +fi mattermost_name="Zeus Mattermost" team_name="zeus" @@ -10,6 +13,9 @@ dir="$(dirname "$0")" out="$dir/dist/channels/index.html" mkdir -p "$(dirname "$out")" +cp go_to_channel.png dist/ +cp main.css dist/ + custom_emoji_file="$(mktemp --tmpdir custom_emoji.XXXXXXXXXX.json)" mmcli listcustomemoji | jq -s > "$custom_emoji_file" @@ -30,11 +36,20 @@ emoji() { markdown() { htmlescape | \ - { pandoc --from=markdown --to=html || printf "Markdown conversion failed\n" >&2; } | \ - sed 's/src="\(.*\)"/src=""/g' | \ + { pandoc --from=markdown+autolink_bare_uris+emoji --to=html || printf "Markdown conversion failed\n" >&2; } | \ + sed -E ' + s|<(h[0-6])[^>]*>|
|g + s||
|g + s/src="\(.*\)"/src=""/g + ' | \ + sed -f "$channels_sed_file" | \ emoji } +format_number() { + awk '{printf "%'\''d\n", $1}' +} + format_timestamp() { format_str="$1" xargs -Ixxx date --date "@xxx" "+$format_str" @@ -42,6 +57,9 @@ format_timestamp() { channels="$(mmcli ls "$team_name" | jq -cs 'sort_by(- .last_post_at) | .[]')" channel_count="$(jqo "$channels" -s 'length')" +channels_sed_file="$(mktemp --tmpdir "mattermost_channels.XXXXXXXXX.sed")" +jqo "$channels" -s 'map(.name) | sort_by(length) | reverse | .[]' | sed 's|.*|s/~&/CHANNEL[&]<\\/a>/g|' > "$channels_sed_file" +printf 's/CHANNEL\\[\\([^]]*\\)\\]/~\\1/g\n' >> "$channels_sed_file" substitute_vars() { sed ' @@ -63,28 +81,48 @@ printf '%s\n' "$channels" | while IFS="" read -r chan || [ -n "$chan" ]; do header="$(jqo "$chan" '.header' | markdown)" create_at="$(jqo "$chan" '.create_at / 1000' | format_timestamp '%Y-%m-%d')" last_post_at="$(jqo "$chan" '.last_post_at / 1000' | format_timestamp '%Y-%m-%d %H:%M')" - total_msg_count="$(jqo "$chan" '.total_msg_count')" + total_msg_count="$(jqo "$chan" '.total_msg_count' | format_number)" cat >> "$out" < -

$display_name

-
-
Channel purpose
-
$purpose
- -
Channel header
-
$header
- -
Channel created on
-
$create_at
- -
Last message
-
$last_post_at
- -
Total amount of messages
-
$total_msg_count
-
+
+

$display_name Go to channel

+
+HERE + if [ -n "$purpose" ]; then + cat >> "$out" < +
Purpose
+
$purpose
+ +HERE + fi + if [ -n "$header" ]; then + cat >> "$out" < +
Header
+
$header
+ + +HERE + fi + cat >> "$out" < +
+
Created on
+
$create_at
+
+
+
Last message
+
$last_post_at
+
+
+
Amount of messages
+
$total_msg_count
+
+ + + HERE done diff --git a/go_to_channel.png b/go_to_channel.png new file mode 100644 index 0000000000000000000000000000000000000000..9d525a4da05e730402ec8d5010ba8c7f747b382b GIT binary patch literal 592 zcmV-W0EX>4Tx04R}tkv&MmKpe$iQ$?v2hZYoZ$WR@`E-K;vxAeOi*kx9=Jhl#~v2g@DIN`^{2O&n2Fjq-)8 z%L?Z$&T6H`TKD8H4Cb|!Wv~|dLJA^e)KEqR7NWFjq?kz4e%!-9?D$jUlF3yD zBgX=&P$4;f@IUz7ty!3wbd!Q{p!>zPKSqI`U7%UF?eAmTZk_=CXW&X}`>PFL_LKB_ zTZC)opGBTZEw?lk6k>Nu6xEMopPI>Y;WdnW|1HH5(GgI e1i@GwLGTCt9vFJH=+3PG0000 literal 0 HcmV?d00001 diff --git a/header.html b/header.html index f922a93..6b18910 100644 --- a/header.html +++ b/header.html @@ -4,14 +4,11 @@ $mattermost_name channels - + -

$mattermost_name channels

-

A list of all $channel_count public channels in the team $team_name on $mattermost_name, as of $lastupdated

+
+

$mattermost_name channels

+

A list of all $channel_count public channels in the team $team_name on $mattermost_name, as of $lastupdated

+
+
diff --git a/main.css b/main.css new file mode 100644 index 0000000..013ccb9 --- /dev/null +++ b/main.css @@ -0,0 +1,102 @@ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: sans-serif; + background-color: #121212; /* Dark background */ + color: #c9c2c0; /* Light text color */ + line-height: 1.6; + padding: 20px; +} + +@media (max-width: 600px) { + body { + padding: 10px; + } +} + +h1 { font-size: 125%; } + +h2 { font-size: 110%; } + +h3 { font-size: 105%; } + +.h1, .h2, .h3, .h4, .h5, .h6 { + font-weight: bold; +} + +a { + color: #ff7000; + text-decoration: none; + transition: color 0.3s; +} +a:hover { + color: #efa76f; +} + +dl { + margin-left: 0.4em; +} + +dt { + font-weight: bold; + color: #8f6254; + margin-top: 0.625em; + text-transform: uppercase; + font-size: 75%; +} + +dd { + margin-left: 0.4em; +} + +@media (min-width: 590px) { + .stats { + display: flex; + } + .stats > * { + flex-grow: 1; + } +} + +header, footer { + text-align: center; + margin: 1em 0; +} + +/* Card Style */ +.channel { + background-color: #1E1E1E; /* Card background */ + border-radius: 1em; + padding: 0.7em 1em 1em; + margin: 1em auto; + max-width: 75em; + box-shadow: 0 0.3em 0.5em rgba(0, 0, 0, 1); +} + +@media (min-width: 1000px) { + header, footer { + margin: 3em 0; + font-size: 125%; + } + + .channel { + margin-bottom: 2em; + } +} + +img.emoji { + width: 1em; + height: 1em; + vertical-align: text-bottom; +} + +img.go_to_channel { + margin-left: 0.3em; + width: 0.8em; + height: 0.8em; + vertical-align: baseline; +}