Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Antwort: Re: Antwort: Switch! (LONG)

From: sharriff:aina:med-iq at: 20-Nov-2000 15:34

Thanks Brett! Speaking of a deadline, the indexer is supposed to produce index pages tommorow!!! for an application thats going to be used in a exibition, my boss was a little worried, but I finished coding this morning 3.00AM, I would definately have to recode it after the exibition according to your examples. I just went through your code (have to prepare a lot of things for the exibition) and saw directly that your code would need thorough study. I apologise if this very big script has annoyed anyone, but I am curious to see how way off I was with my code. Thanks Brett and Andrew for the kick in the right direction. The indexer, an index CGI utility for indexing HTML for a touchscreen application #!c:\rebol\rebol.exe -cs REBOL [] Print "Content-Type: text/html ^/^/" ; code to decode the HTML form comes here!! ; ------------- initialize containers toc-list: make block! 0 temp-block:make block! 0 title-list: make block! 0 file-list: make block! 0 ; contains the raw files sorted-files: make block! 0 ; finally contains only HTML/HTM files file-dir: make block! 0 sub-list: make block! 0 ; contains links to sublists titles: make block! 0 ; contains Titles and file names char-list: make block! 0 finished-links: make block! 0 temp-html: make block! 0 ; ------------------------- individual sub list container blocks a: make block! 0 b: make block! 0 c: make block! 0 ; all the way to Z...... z: make block! 0 ; ----------------------- sub TOC HTML template sub-toc-html-template: { <html> <head> <style type="text/css"> a {font-family: Verdana; font-size: 18pt} h2 { font-family: Verdana; font-size: 12pt} h3.c1 {font-family: Verdana} p {font-family: Verdana,Tahoma,Arial,Helvetic; font-size: 15pt} td {font-family: Verdana; font-size: 18pt} body {background-color: #FFFFE0} </style> <title> Sub-TOC </title> </head> <body> <table border="0 cellpadding="0" cellspacing="2" width="700">} sub-toc-html-stub: { </tr> </table> </body> </html>} ; ----------- containers for the final sub HTML files a: copy sub-toc-html-template b: copy sub-toc-html-template ;...... all the way to Z, you must have guessed by now! z: copy sub-toc-html-template ;----------------- Code begin -------------- ;___________________________________________ ;----------------- function for user directory selection select-dir: func [ module-name ] [prefix: "../medintouch/modules/" change-dir (to-file join prefix user-dir)] either exists? toc.html [ write %toc.html main-html-toc][print "ERROR! TOC is missing"] ; read and store all files in "file-list" file-list: read sort %./ ; selects all HTML or HTM files and stores them in a separate list foreach file file-list [either find/any file ".ht?" [append sorted-files :file][save %non-html-files.txt :file]] ; parse the titles from the html and htm files and store the titles ;foreach file sorted-files [temp-file: read file ; parse temp-file [any [thru "<title>" copy title-list to "</title>"] to end] ; append titles title-list ; append titles file] ; taking care of medintouch version bug (bad HTML) foreach file sorted-files [temp-file: read file parse temp-file [any [thru "<title> Patienteninformierung zu" copy title-list to "</title>"] to end] append titles title-list append titles file] ; creates subindexes from the first characters foreach [title file] titles [ switch second title [ #"a" [clear sub-list ; temp-html: copy sub-toc-html-template append sub-list rejoin [{<tr><td>}{<a href="} file {" target ="touchscreencontent"><img src="./images/round-button.jpg" border="0" /> &nbsp;&nbsp;&nbsp;&nbsp;}title {</a>}{</td><td>&nbsp;</td>}] append a newline append a sub-list] #"b" [clear sub-list ; temp-html: copy sub-toc-html-template append sub-list rejoin [{<tr><td>}{<a href="} file {" target ="touchscreencontent"><img src="./images/round-button.jpg" border="0" /> &nbsp;&nbsp;&nbsp;&nbsp;}title {</a>}{</td><td>&nbsp;</td>}] append b newline append b sub-list] #"c" [clear sub-list ; temp-html: copy sub-toc-html-template append sub-list rejoin [{<tr><td>}{<a href="} file {" target ="touchscreencontent"><img src="./images/round-button.jpg" border="0" /> &nbsp;&nbsp;&nbsp;&nbsp;}title {</a>}{</td><td>&nbsp;</td>}] append c newline append c sub-list] ; all the way to Z.------------ #"z" [clear sub-list ; temp-html: copy sub-toc-html-template append sub-list rejoin [{<tr><td>}{<a href="} file {" target ="touchscreencontent"><img src="./images/round-button.jpg" border="0" /> &nbsp;&nbsp;&nbsp;&nbsp;}title {</a>}{</td><td>&nbsp;</td>}] append z newline append z sub-list]]] ; ----------- code lines that creates the individual sub-TOC pages append a sub-toc-html-stub write %aa.html a append b sub-toc-html-stub write %bb.html b ; all the way to Z.... This script takes a directory of HTML pages, extracts the titles and creates an index page of links for each alphabet.. The pages are used in a touchscreen application. Sharriff Aina med.iq information & quality in healthcare AG