Documentation Source Text

Check-in [41933da084]
Login

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

Overview
Comment:Fixes to the checklist CGI so that it works better as a Fossil CGI extension.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 41933da08487706d42072b483ce2613c3f789e242baa1409a14c183dd119efc8
User & Date: drh 2019-07-27 15:13:20.633
Context
2019-07-27
15:28
In the checklist application, add a /self method and make the magic database name "top" refer to the lexically largest database file. (check-in: 752d433361 user: drh tags: trunk)
15:13
Fixes to the checklist CGI so that it works better as a Fossil CGI extension. (check-in: 41933da084 user: drh tags: trunk)
2019-07-26
20:22
Update the checklist.tcl script to align with the latest code on the website. (check-in: ef7dae4ce8 user: drh tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to misc/checklist.tcl.
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# List all available checklists.
#
proc wapp-page-listing {} {
  global DATADIR
  wapp-trim {
    <div class='fossil-doc' data-title='Available Checklists'>
  }
  wapp-subst {<ol>\n}
  foreach dbfile [lsort -decreasing [glob -nocomplain $DATADIR/*.db]] {
    set name [file rootname [file tail $dbfile]]
    set url [wapp-param BASE_URL]/$name/index
    wapp-subst {<li><a href='%url($url)'>%html($name)</a>\n}
  }
  wapp-subst {</ol>\n</html>\n}
}

# Show the CGI environment for testing purposes.
#
proc wapp-page-env {} {
  sqlite3 db :memory:
  set v [db one {SELECT sqlite_source_id()}]







|





|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# List all available checklists.
#
proc wapp-page-listing {} {
  global DATADIR
  wapp-trim {
    <div class='fossil-doc' data-title='Available Checklists'>
  }
  wapp-subst {<div><ol style='column-width: 20ex;'>\n}
  foreach dbfile [lsort -decreasing [glob -nocomplain $DATADIR/*.db]] {
    set name [file rootname [file tail $dbfile]]
    set url [wapp-param BASE_URL]/$name/index
    wapp-subst {<li><a href='%url($url)'>%html($name)</a>\n}
  }
  wapp-subst {</ol></div>\n</html>\n}
}

# Show the CGI environment for testing purposes.
#
proc wapp-page-env {} {
  sqlite3 db :memory:
  set v [db one {SELECT sqlite_source_id()}]
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
136
137
138
139
140
141
142
143
144
145
146


147
148
149
150



151
152


153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168

169
170
171
172
173
174
175
  }
  sqlite3 db $dbfile -create 0
  db timeout 1000
  db eval BEGIN
  set title [db one {SELECT value FROM config WHERE name='title'}]
  wapp-trim {
    <div class='fossil-doc' data-title='%html($title)'>



















  }
  checklist-verify-login
  wapp-subst {<div class="submenu">\n}
  set base [wapp-param BASE]
  set this [wapp-param PATH_HEAD]
  if {$this!="index"} {
    wapp-subst {<a href='%html($base/index)'>checklist</a>\n}
  }
  set admin [wapp-param CKLIST_ADMIN 0]
  if {$admin} {
    if {$this!="sql"} {
      wapp-subst {<a href='%html($base/sql)'>sql</a>\n}
    }
    if {$this!="cklistedit"} {
      wapp-subst {<a href='%html($base/cklistedit)'>edit-checklist</a>\n}
    }
  }

  wapp-subst {<a href='%html([file dir $base]/listing)'>catalog</a>\n}
  wapp-subst {</div>\n}
  return 0
}

# Close out a web page.  Close the database connection that was opened
# by checklist-common-header.
#
proc checklist-common-footer {} {
  wapp-subst {</div>}
  catch {db close}
}

# Show the main checklist page
#
proc wapp-page-index {} {
  if {[checklist-common-header]} return
  set level 0


  db eval {SELECT seq, printf('%016llx',itemid) AS itemid, txt
           FROM checklist ORDER BY seq} {
    if {$seq%100==0} {
      set newlevel 1



    } else {
      set newlevel 2


    }
    while {$newlevel>$level} {
      if {$level==0} {
        wapp-subst {<ol id="mainCklist" type='1'>\n}
      } else {
        wapp-subst {<p><ol type='a'>\n}
      }
      incr level
    }
    while {$newlevel<$level} {
      wapp-subst {</ol>\n}
      incr level -1
    }
    if {$level==1} {wapp-subst {<p>}}
    wapp-trim {
      <li class='ckitem' id='item-%unsafe($itemid)'><span>%unsafe($txt)</span>

      <span class='ckuid' id='stat-%unsafe($itemid)'></span>
      <div class='ckcom' id='com-%unsafe($itemid)'></div></li>\n
    }
  }
  while {$level>0} {
    wapp-subst {</ol>\n}
    incr level -1







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

















>
|

















>
>




>
>
>


>
>















|
>







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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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
  }
  sqlite3 db $dbfile -create 0
  db timeout 1000
  db eval BEGIN
  set title [db one {SELECT value FROM config WHERE name='title'}]
  wapp-trim {
    <div class='fossil-doc' data-title='%html($title)'>
    <style>
    div.ckcom {
      font-size: 80%;
      font-style: italic;
      white-space: pre;
    }
    span.ckuid {
      font-size: 80%;
      cursor: pointer;
    }
    p.error {
      font-weight: bold;
      color: red;
    }
    #editBox {
      display: none;
      border: 1px solid black;
    }
    </style>
  }
  checklist-verify-login
  wapp-subst {<div class="submenu">\n}
  set base [wapp-param BASE]
  set this [wapp-param PATH_HEAD]
  if {$this!="index"} {
    wapp-subst {<a href='%html($base/index)'>checklist</a>\n}
  }
  set admin [wapp-param CKLIST_ADMIN 0]
  if {$admin} {
    if {$this!="sql"} {
      wapp-subst {<a href='%html($base/sql)'>sql</a>\n}
    }
    if {$this!="cklistedit"} {
      wapp-subst {<a href='%html($base/cklistedit)'>edit-checklist</a>\n}
    }
  }
  set dir [wapp-param ROOT_URL]
  wapp-subst {<a href='%html($dir/listing)'>catalog</a>\n}
  wapp-subst {</div>\n}
  return 0
}

# Close out a web page.  Close the database connection that was opened
# by checklist-common-header.
#
proc checklist-common-footer {} {
  wapp-subst {</div>}
  catch {db close}
}

# Show the main checklist page
#
proc wapp-page-index {} {
  if {[checklist-common-header]} return
  set level 0
  set v1 0
  set v2 0
  db eval {SELECT seq, printf('%016llx',itemid) AS itemid, txt
           FROM checklist ORDER BY seq} {
    if {$seq%100==0} {
      set newlevel 1
      incr v1
      set v2 0
      set v $v1
    } else {
      set newlevel 2
      incr v2
      set v $v2
    }
    while {$newlevel>$level} {
      if {$level==0} {
        wapp-subst {<ol id="mainCklist" type='1'>\n}
      } else {
        wapp-subst {<p><ol type='a'>\n}
      }
      incr level
    }
    while {$newlevel<$level} {
      wapp-subst {</ol>\n}
      incr level -1
    }
    if {$level==1} {wapp-subst {<p>}}
    wapp-trim {
      <li class='ckitem' id='item-%unsafe($itemid)' value='%html($v)'>
      <span>%unsafe($txt)</span>
      <span class='ckuid' id='stat-%unsafe($itemid)'></span>
      <div class='ckcom' id='com-%unsafe($itemid)'></div></li>\n
    }
  }
  while {$level>0} {
    wapp-subst {</ol>\n}
    incr level -1
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
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
  }
  wapp-subst {</script>\n}
  set base [wapp-param BASE]
  wapp-subst {<script src='%html($base/cklist.js)'></script>\n}
  checklist-common-footer
}

# The CSS for the main checklist page goes here
#
proc wapp-page-style.css {} {
  wapp-mimetype text/css
  wapp-cache-control max-age=86400
  wapp {
    h1 { text-align: center; }
    div.ckcom {
      font-size: 80%;
      font-style: italic;
      white-space: pre;
    }
    span.ckuid {
      font-size: 80%;
      cursor: pointer;
    }
    div.mainmenu {
      text-align: center;
      border: 1px solid black;
      padding: 2ex;
    }
    div.mainmenu a {
      margin: 0 1.5ex;
    }
    p.error {
      font-weight: bold;
      color: red;
    }
    #editBox {
      display: none;
      border: 1px solid black;
    }
  }
}

# The javascript for the main checklist page goes here
#
proc wapp-page-cklist.js {} {
  wapp-mimetype text/javascript
  wapp-cache-control max-age=86400
  set base [wapp-param BASE]
  wapp-trim {







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







250
251
252
253
254
255
256



































257
258
259
260
261
262
263
  }
  wapp-subst {</script>\n}
  set base [wapp-param BASE]
  wapp-subst {<script src='%html($base/cklist.js)'></script>\n}
  checklist-common-footer
}




































# The javascript for the main checklist page goes here
#
proc wapp-page-cklist.js {} {
  wapp-mimetype text/javascript
  wapp-cache-control max-age=86400
  set base [wapp-param BASE]
  wapp-trim {