diff options
| author | Tom Smeding <tom@tomsmeding.com> | 2026-08-09 20:56:40 +0200 |
|---|---|---|
| committer | Tom Smeding <tom@tomsmeding.com> | 2026-08-09 20:56:40 +0200 |
| commit | ad70b2b31ac9ecf78d9b909380c54fd5826b54d8 (patch) | |
| tree | a9664238d0ff714ccbd925e1da3c9994847e5ecf | |
| parent | 4b8960ce83d29a63c71ea39b4376d5d9b78b5cdf (diff) | |
Allow channel notes
| -rw-r--r-- | config.txt | 1 | ||||
| -rw-r--r-- | pages/log.mustache | 3 | ||||
| -rw-r--r-- | src/Config.hs | 11 | ||||
| -rw-r--r-- | src/Main.hs | 1 | ||||
| -rw-r--r-- | src/Pages.hs | 1 |
5 files changed, 17 insertions, 0 deletions
@@ -4,4 +4,5 @@ channel liberachat #haskell haskell channel liberachat #kmonad kmonad channel liberachat #xmonad xmonad channel freenode #haskell fn-haskell +note fn-haskell This is a <b>freenode</b> channel! And this is its note. channel freenode #xmonad fn-xmonad diff --git a/pages/log.mustache b/pages/log.mustache index 8e3d800..fdde44c 100644 --- a/pages/log.mustache +++ b/pages/log.mustache @@ -10,6 +10,9 @@ {{> header}} <main> <h1>Logs: {{network}}/{{channel}}</h1> + {{#note}} + <p>{{&.}}</p> + {{/note}} <div class="pagepicker"> {{#picker}} {{#prevpage}}<a href="?page={{.}}">{{/prevpage}}←Prev{{#prevpage}}</a>{{/prevpage}} diff --git a/src/Config.hs b/src/Config.hs index 15ce791..3c897f6 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -26,6 +26,7 @@ import Util -- channel freenode #haskell fn-haskell -- channel liberachat #haskell haskell -- channel liberachat #xmonad xmonad +-- note fn-haskell Extracted from <i>old</i> logs! -- ``` -- -- Lines starting with '#' are ignored. @@ -45,6 +46,8 @@ data Config' (stage :: ConfigStage) = Config , confLogsDir :: FilePath , confPort :: Int -- ^ Port at which to host the HTTP server + , confNotes :: Map Text Text + -- ^ alias => note; user-facing note about the logs for this channel , econfChannels :: IfFull stage [Channel] -- ^ Network-channel pairs, in user-specified order @@ -90,6 +93,7 @@ initConfig = Config { uconfChannels = SnocNil , confLogsDir = error "config: Log directory not set with 'logs'" , confPort = 8000 + , confNotes = mempty , econfChannels = () , econfChan2Alias = () , econfAlias2Chan = () @@ -120,6 +124,13 @@ parseLine conf line = | all (not . null) [network, chan, alias] -> conf { uconfChannels = uconfChannels conf `Snoc` (T.pack network, T.pack chan, T.pack alias) } _ -> error $ "config: Invalid channel spec: " ++ trim rest + "note" -> + case break (== ' ') (dropWhile isSpace rest) of + (alias, ' ' : note) -> + conf { confNotes = + Map.insertWith (error ("config: Duplicate note for '" ++ alias ++ "'")) + (T.pack alias) (T.pack note) (confNotes conf) } + _ -> error "config: Invalid note line, no note" _ -> error $ "config: Invalid line with command '" ++ cmd ++ "'" where trim :: String -> String diff --git a/src/Main.hs b/src/Main.hs index 1bd6496..c4d4460 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -93,6 +93,7 @@ pageLog conf index req alias = { network = chanNetwork chan , channel = chanChannel chan , alias = alias + , note = Map.lookup alias (confNotes conf) , totalevents = renderLargeNumber numEvents , efAll = kind == CKAll , efCompr = kind == CKCompressed diff --git a/src/Pages.hs b/src/Pages.hs index fa7660b..9b65de2 100644 --- a/src/Pages.hs +++ b/src/Pages.hs @@ -61,6 +61,7 @@ data LogData = LogData { network :: Text , channel :: Text , alias :: Text + , note :: Maybe Text , totalevents :: Text , efAll :: Bool , efCompr :: Bool |
