Check-in [d13f0cd032]

Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Contributed index generation script from Jeff Rogers. Thanks!
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | evilotto-index
Files: files | file ages | folders
SHA3-256: d13f0cd032bf5351c6eca02909957bbf811a08213fe6a49d5c9cc3608cb03bb8
User & Date: dkf 2019-04-12 10:25:10
Context
2019-04-12
10:25
Updated the index check-in: 4db101a6ea user: dkf tags: evilotto-index
10:25
Contributed index generation script from Jeff Rogers. Thanks! check-in: d13f0cd032 user: dkf tags: evilotto-index
2019-04-11
12:29
Tab check-in: dc6a1e6865 user: kevin_walzer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to scripts/mkhtmlindex.tcl.

7
8
9
10
11
12
13
14





15
16
17

18
19
20
21
22
23
24
..
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
..
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113








114
115
116
117
118
119
120
121
122
123
124
125
126
127
128

129
130
131
132
133
134
135
...
150
151
152
153
154
155
156
157


158
159
160
161
162
163
164
165
166
167
168
...
183
184
185
186
187
188
189
190
191
192
193
194
195

196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226






227
228

229
230
231
232
233
234
235
236

237
238
239
240
241
242


243
244
245
246
247
248
249
...
282
283
284
285
286
287
288


289
290
291
292
293
294
295
...
299
300
301
302
303
304
305























306
307
308
309
    BR {^[-\w]+$}
    TKT {^[a-f0-9]+$}
    URL {^(?:https?|ftp)://[-\w.]+/[^\s""`']*$}
}

# Some TIPs are jokes
set jests {131 263 365}






proc writeHeader {} {
    global index json
    puts $index \

{# TIP Index

<div>
Welcome to the Tcl Improvement Proposals repository. For information on how to raise a new TIP see <a href="./doc/help.md">Help</a>
<p>
</div>
<form method='GET' action='../../search'>
................................................................................
<option value='d'>Docs</option>
<option value='t'>Tickets</option>
</select>
<input type="submit" value="Search">
</div></form>
<p>

<div><div>
Filter Toggles:
</div>
<div>
<input type="checkbox" id="click_projectdraft">Drafts</button>
<input type="checkbox" id="click_projectfinal">Finals</button>
<input type="checkbox" id="click_project">Projects</button>
(<input type="checkbox" id="click_project84">8.4</button>
 <input type="checkbox" id="click_project85">8.5</button>
 <input type="checkbox" id="click_project86">8.6</button>
 <input type="checkbox" id="click_project87">8.7</button>
 <input type="checkbox" id="click_project90">9.0</button>)
<input type="checkbox" id="click_informational">Informationals</button>
<input type="checkbox" id="click_process">Processes</button>
<br>
<input type="checkbox" id="click_rejected">Rejected</button>
<input type="checkbox" id="click_withdrawn">Withdrawn</button>
<input type="checkbox" id="click_obsoleted">Obsoleted</button>
<input type="checkbox" id="click_deferred">Deferred</button>
<input type="checkbox" id="click_jest">Jokes</button>
</div></div>
<style title="filtering">
/*
 * DO NOT MANUALLY PUT ANY STYLES IN HERE!
 *
 * This is manipulated by JS and it makes a lot of assumptions about the
 * structure of this stylesheet. Use a different stylesheet instead!
 */
................................................................................
                return;
            }
        }
    }
    console.log("adding hide rule for " + cls);
    sheet.insertRule(cls + " {display:none;}", 0);
}
document.addEventListener("DOMContentLoaded", function() {
    var TAGS = {
        "informational": 0, "process": 0,
        "projectdraft": 0, "projectfinal": 0, "project": 0,
        "project84": 0, "project85": 0, "project86": 0, "project87": 0,
        "project90": 0,
        "rejected": 1, "withdrawn": 1, "obsoleted": 1, "deferred": 1, "jest": 1
    };
    function toggler(selector) {
	return function() {
	    toggleClass(selector);
	}
    }
    for (var tag of Object.keys(TAGS)) {
        var id = "click_" + tag;
        var selector = "." + tag;
        document.getElementById(id).addEventListener("click", toggler(selector));
        if (TAGS[tag]) {
            document.getElementById(id).checked = true;
            toggleClass(selector);
        }
    }
});
</script>








<p>

<div style="float:right; font-size:10pt" class="key">
<table border="1" cellpadding="2" cellspacing="0">
<thead><tr><th>Key</th</tr></thead><tbody>
<tr class="projectdraft"><td>Draft Project</td></tr>
<tr class="projectdraft project86 projectdraft86"><td>Draft Project (8.6)</td></tr>
<tr class="invote"><td>In Current Vote</td></tr>
<tr class="projectaccepted"><td>Accepted Project</td></tr>
<tr class="rejected"><td>Rejected Project</td></tr>
<tr class="withdrawn"><td>Withdrawn Project</td></tr>
<tr class="projectfinal"><td>Final Project</td></tr>
<tr class="process"><td>Process TIP</td></tr>
<tr class="informational"><td>Informational TIP</td></tr>
</tbody></table></div>

<div class="index">
<table border="1" cellpadding="2" cellspacing="0" class="sortable" id="tipTable">
<thead><tr>
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
................................................................................
proc encodeHTML {string} {
    return [string map {< &lt; > &gt; \" &quot; & &amp; ' &apos;} $string]
}

proc encodeJSON {string} {
    return [string cat \" [string map {\" \\\" \\ {\\}} $string] \"]
}



proc writeRow {number varName} {
    global index json jests RE
    upvar 1 $varName fields
    set titlecolumnspan ""

    set state $fields(state)
    if {[info exists fields(obsoleted-by)]} {
	set state "Obsoleted"
    }
    set type $fields(type)
    if {[string match -nocase "info*" $type]} {
................................................................................
	if {$class eq "project"} {
	    append class " [string tolower $type$state]"
	    if {[info exists fields(tcl-version)]} {
		regexp {(\d+)(?:\.(\d+))?} $fields(tcl-version) -> v1 v2
		set version $v1$v2
		append class " [string tolower $type$state$version]"
		append class " project$version"
	    }
	}
    }

    # Decode links to branches and tickets with implementations
    if {[info exists fields(tcl-branch)]} {

	if {[regexp $RE(BR) $fields(tcl-branch)]} {
	    set link [format "/tcl/timeline?r=%s" $fields(tcl-branch)]
	} else {
	    puts stderr "WARNING: $number has invalid Tcl-Branch field"
	}
    } elseif {[info exists fields(tk-branch)]} {
	if {[regexp $RE(BR) $fields(tk-branch)]} {
	    set link [format "/tk/timeline?r=%s" $fields(tk-branch)]
	} else {
	    puts stderr "WARNING: $number has invalid Tk-Branch field"
	}
    } elseif {[info exists fields(tcl-ticket)]} {
	if {[regexp $RE(TKT) $fields(tcl-ticket)]} {
	    set link [format "/tcl/tktview/%s" $fields(tcl-ticket)]
	} else {
	    puts stderr "WARNING: $number has invalid Tcl-Ticket field"
	}
    } elseif {[info exists fields(tk-ticket)]} {
	if {[regexp $RE(TKT) $fields(tk-ticket)]} {
	    set link [format "/tk/tktview/%s" $fields(tk-ticket)]
	} else {
	    puts stderr "WARNING: $number has invalid Tk-Ticket field"
	}
    } elseif {[info exists fields(implementation-url)]} {
	if {[regexp $RE(URL) $fields(implementation-url)]} {
	    set link $fields(implementation-url)
	} else {
	    puts stderr "WARNING: $number has invalid Implementation-URL field"
	}
    }







    puts $index "<tr class='$class'>"
    puts $index "<td valign='top'><a href='./tip/$number.md'>$number</a></td>"

    if {[info exists fields(tcl-version)]} {
	puts $index "<td valign='top'>[encodeHTML $type]</td>"
	puts $index "<td valign='top'>[encodeHTML $fields(tcl-version)]</td>"
    } else {
	puts $index "<td valign='top' colspan=2>[encodeHTML $type]</td>"
    }
    puts $index "<td valign='top'>[encodeHTML $state]</td>"
    puts $index "<td valign='top'$titlecolumnspan>[encodeHTML $fields(title)]</td>"

    if {[info exist link]} {
	puts $index "<td valign='top'><a href='$link'>Link</a></td>"
    } elseif {$titlecolumnspan eq ""} {
	puts $index "<td></td>"
    }
    puts $index "</tr>"



    puts -nonewline $json "\n\t\"$number\":\{\"url\":[encodeJSON ./tip/$number.md],"
    foreach f [array names fields] {
	if {$f eq "author"} {
	    puts -nonewline $json "[encodeJSON $f]:\[[join [lmap a $fields($f) {encodeJSON $a}] ,]\],"
	} else {
	    puts -nonewline $json \
................................................................................

set dir [file join [file dirname [info script]] ..]
set index [open [file join $dir index.md] w+]
set json [open [file join $dir index.json] w+]
fconfigure $index -translation lf -encoding utf-8
fconfigure $json -translation lf -encoding utf-8



writeHeader

set max 0
foreach tip [lsort -decreasing -dictionary [glob [file join $dir tip/*.md]]] {
    set number [file tail [file rootname $tip]]
    if {![string is integer -strict $number]} {
	puts stderr "WARNING: skipping non-standard filename: $tip"
................................................................................
    unset -nocomplain fields
    set lines [loadTIPPreamble $number]

    parsePreamble $lines fields
    writeRow $number fields
}
























writeFooter

close $index
close $json







>
>
>
>
>

|
<
>







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>





|
|
|
|
|
|
|
|
|

>







 








>
>

|

|







 







|





>
|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|

|
|
|
|
|
|

>
>
>
>
>
>
|
|
>

|
|

|

|
|
>

|

|
|
<
>
>







 







>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
..
35
36
37
38
39
40
41





















42
43
44
45
46
47
48
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
...
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245

246
247
248
249
250
251
252
253
254
...
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
...
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
    BR {^[-\w]+$}
    TKT {^[a-f0-9]+$}
    URL {^(?:https?|ftp)://[-\w.]+/[^\s""`']*$}
}

# Some TIPs are jokes
set jests {131 263 365}

proc appendn {var str} {
    upvar 1 $var vbuf
    append vbuf $str\n
}

proc writeHeader {} {
    global indexbuf json

    appendn indexbuf \
{# TIP Index

<div>
Welcome to the Tcl Improvement Proposals repository. For information on how to raise a new TIP see <a href="./doc/help.md">Help</a>
<p>
</div>
<form method='GET' action='../../search'>
................................................................................
<option value='d'>Docs</option>
<option value='t'>Tickets</option>
</select>
<input type="submit" value="Search">
</div></form>
<p>






















<style title="filtering">
/*
 * DO NOT MANUALLY PUT ANY STYLES IN HERE!
 *
 * This is manipulated by JS and it makes a lot of assumptions about the
 * structure of this stylesheet. Use a different stylesheet instead!
 */
................................................................................
                return;
            }
        }
    }
    console.log("adding hide rule for " + cls);
    sheet.insertRule(cls + " {display:none;}", 0);
}
function toggleFacet(f) {
    r = sheet.cssRules;
    if (!r) return
    boxes = document.getElementsByClassName("toggler-"+f);
    none = true;
    for (i=0; i<boxes.length; i++) {
        if (boxes[i].checked) {
            none=false;
            break;
        }
    }
    console.log("NONE:"+none);
    var i = r.length;
    while (i--) {
        if (r[i].selectorText && r[i].selectorText.substr(1,f.length).toLowerCase() === f) {
            sheet.deleteRule(i);
        }
    }
    if (!none) {
        for (i=0; i<boxes.length; i++) {
            console.log(boxes[i]);
            if (!boxes[i].checked) {
                sheet.insertRule("."+f+"-"+boxes[i].dataset.value + " {display:none;}", 0);
            }
        }
    }
}
</script>

#TOGGLES#

</div>
<p>

<div style="float:right; font-size:10pt" class="key">
<table border="1" cellpadding="2" cellspacing="0">
<thead><tr><th>Key</th</tr></thead><tbody>
<tr class="state-draft"><td>Draft Project</td></tr>
<tr class="state-draft version-86"><td>Draft Project (8.6)</td></tr>
<tr class="state-voting"><td>In Current Vote</td></tr>
<tr class="state-accepted"><td>Accepted Project</td></tr>
<tr class="state-rejected"><td>Rejected Project</td></tr>
<tr class="state-withdrawn"><td>Withdrawn Project</td></tr>
<tr class="state-final"><td>Final Project</td></tr>
<tr class="type-process"><td>Process TIP</td></tr>
<tr class="type-informational"><td>Informational TIP</td></tr>
</tbody></table></div>

<div class="index">
<table border="1" cellpadding="2" cellspacing="0" class="sortable" id="tipTable">
<thead><tr>
<th>#</th>
<th>Type</th>
<th>Tcl Version</th>
<th>Status</th>
................................................................................
proc encodeHTML {string} {
    return [string map {< &lt; > &gt; \" &quot; & &amp; ' &apos;} $string]
}

proc encodeJSON {string} {
    return [string cat \" [string map {\" \\\" \\ {\\}} $string] \"]
}

set toggles {}

proc writeRow {number varName} {
    global indexbuf json jests RE
    upvar 1 $varName fields
    set titlecolumnspan "" 

    set state $fields(state)
    if {[info exists fields(obsoleted-by)]} {
	set state "Obsoleted"
    }
    set type $fields(type)
    if {[string match -nocase "info*" $type]} {
................................................................................
	if {$class eq "project"} {
	    append class " [string tolower $type$state]"
	    if {[info exists fields(tcl-version)]} {
		regexp {(\d+)(?:\.(\d+))?} $fields(tcl-version) -> v1 v2
		set version $v1$v2
		append class " [string tolower $type$state$version]"
		append class " project$version"
            }
	}
    }

    # Decode links to branches and tickets with implementations
    if {[info exists fields(tcl-branch)]} {

        if {[regexp $RE(BR) $fields(tcl-branch)]} {
            set link [format "/tcl/timeline?r=%s" $fields(tcl-branch)]
        } else {
            puts stderr "WARNING: $number has invalid Tcl-Branch field"
        }
    } elseif {[info exists fields(tk-branch)]} {
        if {[regexp $RE(BR) $fields(tk-branch)]} {
            set link [format "/tk/timeline?r=%s" $fields(tk-branch)]
        } else {
            puts stderr "WARNING: $number has invalid Tk-Branch field"
        }
    } elseif {[info exists fields(tcl-ticket)]} {
        if {[regexp $RE(TKT) $fields(tcl-ticket)]} {
            set link [format "/tcl/tktview/%s" $fields(tcl-ticket)]
        } else {
            puts stderr "WARNING: $number has invalid Tcl-Ticket field"
        }
    } elseif {[info exists fields(tk-ticket)]} {
        if {[regexp $RE(TKT) $fields(tk-ticket)]} {
            set link [format "/tk/tktview/%s" $fields(tk-ticket)]
        } else {
            puts stderr "WARNING: $number has invalid Tk-Ticket field"
        }
    } elseif {[info exists fields(implementation-url)]} {
        if {[regexp $RE(URL) $fields(implementation-url)]} {
            set link $fields(implementation-url)
        } else {
            puts stderr "WARNING: $number has invalid Implementation-URL field"
        }
    } 

    set class [join [lmap axis {state type version} {
        if {![info exists $axis]} continue
        dict set ::toggles $axis [set $axis] 1
        string cat $axis-[string tolower [set $axis]]
    }] " "]

    appendn indexbuf "<tr class='$class'>"
    appendn indexbuf "<td valign='top'><a href='./tip/$number.md'>$number</a></td>"

    if {[info exists fields(tcl-version)]} {
	appendn indexbuf "<td valign='top'>[encodeHTML $type]</td>"
	appendn indexbuf "<td valign='top'>[encodeHTML $fields(tcl-version)]</td>"
    } else {
	appendn indexbuf "<td valign='top' colspan=2>[encodeHTML $type]</td>"
    }
    appendn indexbuf "<td valign='top'>[encodeHTML $state]</td>"
    appendn indexbuf "<td valign='top'>[encodeHTML $fields(title)]</td>"

    if {[info exist link]} {
        appendn indexbuf  "<td valign='top'><a href='$link'>Link</a></td>"
    } elseif {$titlecolumnspan eq ""} {
        appendn indexbuf "<td></td>"
    } 


    appendn indexbuf "</tr>"

    puts -nonewline $json "\n\t\"$number\":\{\"url\":[encodeJSON ./tip/$number.md],"
    foreach f [array names fields] {
	if {$f eq "author"} {
	    puts -nonewline $json "[encodeJSON $f]:\[[join [lmap a $fields($f) {encodeJSON $a}] ,]\],"
	} else {
	    puts -nonewline $json \
................................................................................

set dir [file join [file dirname [info script]] ..]
set index [open [file join $dir index.md] w+]
set json [open [file join $dir index.json] w+]
fconfigure $index -translation lf -encoding utf-8
fconfigure $json -translation lf -encoding utf-8

set indexbuf ""

writeHeader

set max 0
foreach tip [lsort -decreasing -dictionary [glob [file join $dir tip/*.md]]] {
    set number [file tail [file rootname $tip]]
    if {![string is integer -strict $number]} {
	puts stderr "WARNING: skipping non-standard filename: $tip"
................................................................................
    unset -nocomplain fields
    set lines [loadTIPPreamble $number]

    parsePreamble $lines fields
    writeRow $number fields
}

set button {
    <input class="toggler-#FACET#"
        data-value="#VALUE#"
        type="checkbox"
        onclick="toggleFacet('#FACET#')">#TITLE#</button>
}
set TOGGLES ""
set STYLES ""
dict for {axis values} $toggles {
    appendn TOGGLES "[string totitle $axis]: "
    foreach val [dict keys $values] {
        set map [list]
        lappend map #FACET# $axis
        lappend map #VALUE# [string tolower $val]
        lappend map #TITLE# [string totitle $val]
        appendn TOGGLES [string map $map $button]
        appendn STYLES ".$axis-[string tolower $val] {display: table-row }"
    }
    appendn TOGGLES "<br>"
}

puts $index [string map [list #TOGGLES# $TOGGLES #STYLES# "<style title=\"filtering\">$STYLES</style>"] $indexbuf]

writeFooter

close $index
close $json