Overview
Comment:refactor(tag-page): factor out [pages-with-contents]. Use semantic [list] and [dict create] for new values.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: cccd50fa76e62eebe8d6dabdd3e7edd74d7c00caa92efe5c96c03744266462f8
User & Date: dbohdan on 2020-06-05 18:12:27
Other Links: manifest | tags
Context
2020-07-04
16:24
feat(skin): add syntax highlighting for code via highlight.js. This requires escaping the dollar signs in highlight.pack.js for TH1. check-in: 2041b54a18 user: dbohdan tags: trunk
2020-06-05
18:12
refactor(tag-page): factor out [pages-with-contents]. Use semantic [list] and [dict create] for new values. check-in: cccd50fa76 user: dbohdan tags: trunk
17:40
feat(tag-page): print the page text to stdout if the page name is "" or "-" check-in: ea68498dd6 user: dbohdan tags: trunk
Changes

Modified tag-page/tag-page.tcl from [cf9edca8d8] to [212fb93f08].

    13     13       } else {
    14     14           return {}
    15     15       }
    16     16   }
    17     17   
    18     18   
    19     19   proc group-by-tag pages {
    20         -    set grouped {}
           20  +    set grouped [dict create]
    21     21   
    22     22       foreach {name contents} $pages {
    23     23           if {$contents in {{} \n}} continue
    24     24   
    25     25           foreach tag [page-tags $contents] {
    26     26               dict lappend grouped $tag $name
    27     27           }
................................................................................
    39     39           \" "
    40     40           ' '
    41     41       } $text]
    42     42   }
    43     43   
    44     44   
    45     45   proc markdown-list {grouped prefix} {
    46         -    set markdown {}
           46  +    set markdown [list]
    47     47   
    48     48       foreach {tag pages} $grouped {
    49     49           set section [list "$prefix [entities $tag]"]
    50     50   
    51     51           foreach page $pages {
    52     52               set link [expr {
    53     53                   [regexp {[\(\)\[\]<>"'&]} $page]
................................................................................
    72     72   proc update-page {name contents} {
    73     73       set old [fossil wiki export $name]
    74     74       if {$contents eq $old} return
    75     75       fossil wiki commit $name << $contents
    76     76   }
    77     77   
    78     78   
    79         -proc tag-page repo {
    80         -    set lines {}
           79  +proc pages-with-contents repo {
           80  +    set pages [dict create]
    81     81   
    82         -    lappend lines {# Pages by tag} {## Contents} {## Tags}
    83         -
    84         -    set pages {}
    85     82       foreach name [split [fossil wiki ls $repo] \n] {
    86         -        lappend pages $name [fossil wiki export $name]
           83  +        dict set pages $name [fossil wiki export $name]
    87     84       }
    88     85   
           86  +    return $pages
           87  +}
           88  +
           89  +
           90  +proc tag-page repo {
           91  +    set pages [pages-with-contents $repo]
           92  +
           93  +    set lines [list]
           94  +    lappend lines {# Pages by tag} {## Contents}
           95  +
    89     96       set grouped [group-by-tag $pages]
    90     97       set sorted [lsort -stride 2 -index 0 -nocase $grouped]
    91         -    lappend lines [markdown-list $sorted ###]
           98  +    lappend lines {## Tags} [markdown-list $sorted ###]
    92     99   
    93    100       return [join $lines \n]
    94    101   }
    95    102   
    96    103   
    97    104   proc main {repo {page-name {}}} {
    98    105       set contents [tag-page $repo]