00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 ::REQUIRES 'htmlutil.cls'
00047 ::REQUIRES 'pathsep.cls'
00048
00049
00050
00051
00052
00053
00054 ::CLASS htmlindexelement PUBLIC inherit Comparable
00055
00056 ::ATTRIBUTE displayname
00057 ::ATTRIBUTE urlrefs
00058
00059
00060
00061 ::METHOD init
00062 use strict arg displayname, urlrefs
00063 self~displayname = displayname
00064 self~urlrefs = urlrefs
00065
00066
00067 ::METHOD compareTo
00068 use arg other
00069 if other~displayname~translate > self~displayname~translate
00070 then return -1
00071 if other~displayname~translate < self~displayname~translate
00072 then return 1
00073 return 0
00074
00075
00076 ::CLASS i_index
00077 ::ATTRIBUTE iname
00078 ::ATTRIBUTE contains
00079 ::ATTRIBUTE url_tail
00080 ::METHOD init
00081 use arg iname
00082 self~iname = iname
00083 self~contains = .queue~new
00084 self~url_tail = ''
00085
00086
00087 ::CLASS i_page
00088 ::ATTRIBUTE pname
00089 ::ATTRIBUTE items
00090 ::ATTRIBUTE contains
00091 ::METHOD init
00092 use arg pname
00093 self~pname = pname
00094 self~contains = .queue~new
00095 self~items = 0
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106 ::ROUTINE hiea2html PUBLIC
00107 use strict arg elementlist, prefix, firstpage, fpath, pagemax, header, trailer
00108
00109
00110 if elementlist~items = 0
00111 then do
00112 fn = fpath||.pathsep~sep||prefix||firstpage'.html'
00113 tp = .queue~new
00114 tp = tp~union(header)
00115 tp~queue('<p></p><p></p>')
00116 tp~queue('<h3>No entries</h3>')
00117 tp = tp~union(trailer)
00118 .htmlutil~writepage(tp, fn)
00119 return
00120 end
00121
00122
00123 elementlist~sort
00124
00125
00126 tlindices = .queue~new
00127 initial = ''
00128 curr = .nil
00129
00130
00131 do e over elementlist
00132 tinit = e~displayname~left(1)~translate
00133 if tinit <> initial
00134 then do
00135 initial = tinit
00136 curr = .i_index~new(initial)
00137 tlindices~queue(curr)
00138 end
00139 curr~contains~queue(e)
00140 end
00141
00142
00143
00144
00145
00146 pages = .queue~new
00147 pagename = prefix||firstpage
00148
00149 pgents = tlindices[1]~contains~items
00150 pageq = .queue~new
00151 pages~queue(.array~of(pagename, pageq))
00152
00153 do i over tlindices
00154 if pgents + i~contains~items > pagemax
00155 then do
00156 if i <> tlindices[1]
00157 then do
00158 pagename = prefix'_index_'i~iname~c2x
00159 pageq = .queue~new
00160 pages~queue(.array~of(pagename, pageq))
00161 pgents = 0
00162 end
00163 end
00164
00165 pgents = pgents + i~contains~items
00166 pageq~queue(i)
00167 i~url_tail = pagename
00168 end
00169
00170
00171 topmenu = .queue~new
00172 do i over tlindices
00173 topmenu~queue(.array~of(i~iname, i~url_tail'.html#'i~iname, 'pet'i~iname))
00174 end
00175
00176
00177 do i over pages
00178
00179 fn = fpath||.pathsep~sep||i[1]'.html'
00180
00181 tp = .queue~new
00182 tp = tp~union(header)
00183
00184 .htmlutil~tabshead(tp, topmenu, 'pet'i[2][1]~iname)
00185 tp~queue('<p></p><p></p>')
00186
00187 do j over i[2]
00188 tp~queue('<h3><a class="anchor" name="'j~iname'"> -' j~iname '-</a></h3>')
00189 tp~queue('<ul>')
00190 do k over j~contains
00191 tp~queue('<li>' k~displayname)
00192 do m over k~urlrefs
00193 if m[1] = ''
00194 then tp~queue('<a class="el" href="'m[2]'">' k~displayname '</a>')
00195 else tp~queue('<a class="el" href="'m[2]'">' m[1] '</a>')
00196 end
00197 tp~queue('</li>')
00198 end
00199 tp~queue('</ul>')
00200 end
00201 tp = tp~union(trailer)
00202
00203 .htmlutil~writepage(tp, fn)
00204
00205 end
00206
00207
00208