%!PS-Adobe-3.1 % PostScript xml clone sitemap2.psl % ====================================================== % Copyright c 2019 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % This reads an xml file and converts it into a clickable .PDF document. % Normally sent to Acrobat Distiller via command line //acrodist /F . % BE SURE TO CHANGE filenameprefix BELOW! BE SURE TO ACTIVATE FILE READS WITH /F! % set narrow cropbox... % [/CropBox [0 0 520 620] % old set the weird size % /PAGES pdfmark [/CropBox [0 0 325 792] % set the weird size /PAGES pdfmark %%////// Extracted Gonzo Utilities ////// /mt {moveto} def /li {lineto} def /rm {rmoveto} def /rl {rlineto} def /ct {curveto} def /cp {closepath} def /f {fill} def /pd {0 exch neg rl} def /pr { 0 rl} def /pu {0 exch rl} def /pl {neg 0 rl} def /line1 {.06 dup setlinewidth 5 mul /erase exch def} def /line2 {.12 dup setlinewidth 5 mul /erase exch def} def /line3 {.18 dup setlinewidth 5 mul /erase exch def} def /thingridlines {0} def /setgrid { /blocksize exch def translate % simplified blocksize dup scale} def /showgrid {gsave /vblocks exch def /hblocks exch def thingridlines setlinewidth [{0 0 moveto 0 vblocks rlineto stroke} 1 hblocks 1 add] xrpt [{0 0 moveto hblocks 0 rlineto stroke} 1 vblocks 1 add] yrpt fatterborder { gsave newpath 0 0.96 blocksize div dtransform round idtransform setlinewidth pop 2 setlinecap 0 0 moveto hblocks 0 rlineto 0 vblocks rlineto hblocks neg 0 rlineto closepath stroke grestore} if fat5 { gsave newpath 0 0.48 blocksize div dtransform round idtransform setlinewidth pop mark {5 0 moveto 0 vblocks rlineto stroke} 5 hblocks 5 div cvi] xrpt mark {0 5 moveto hblocks 0 rlineto stroke} 5 vblocks 5 div cvi] yrpt grestore} if fatter10 { gsave 18 setwebtint % emphasize here newpath 0 0.96 blocksize div dtransform round idtransform setlinewidth pop mark {10 0 moveto 0 vblocks rlineto stroke} 10 hblocks 10 div cvi] xrpt mark {0 10 moveto hblocks 0 rlineto stroke} 10 vblocks 10 div cvi] yrpt grestore} if grestore} def /fatterborder {true } store /fat5 {true} store /fatter10 { true} store /showdots { false } store /dot { showdots { currentpoint newpath 0.150 0 360 arc fill }if} def /mdot { mt dot} def /random {rand 65536 div 32768 div mul cvi} def % as in -- 6 random -- /gonzofont {dup type cvlit /arraytype eq {exch findfont exch makefont} {exch findfont exch scalefont} ifelse setfont mark /spacewidth ( ) stringwidth pop /cstretch cvx /add cvx /sstretch cvx /add cvx /def cvx currentfont dup backcdict exch (F?) dup 1 14 index (xxxxx) cvs 4 get put put /setfont cvx ] cvx def} def 50 dict /backcdict exch def % used "backwards" during compiling to get % fontname given the "made" font dictionary /cstretch 0 store /sstretch 0 store % repeats [ proc distance trips] xrpt /xrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore dist 0 translate } repeat grestore} def /yrpt{gsave aload pop /trips exch def /dist exch def /rproc exch def trips { gsave rproc grestore 0 dist translate } repeat grestore} def % timing utilities. use stopwatchon and stopwatchoff for simple % one shot timing. For multiple time totals, use resettimer % starttimer stoptimer ... starttimer stoptimer reporttimer /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def /stopwatchoff {stoptimer reporttimer} def % for single shots /stopwatchon {resettimer starttimer} def % for single shots /reporttimer {mytime 1000 div (\rElapsed time: ) print 20 string cvs print ( seconds.\r) print flush} def % to host /resettimer {/mytime 0 def} def % reset timer /starttimer {usertime /mytimenow exch def} def % add to time so far /stoptimer {usertime mytimenow sub /mytime exch mytime add def} def % for multiple timing intervals % curvetrace - creates a smooth curved path from a data point list. % enter with currentpoint set and absolute array. % 0 0 as initial data appends path; any other values % creates new path /curvetrace {/curvelist exch def tension 0 eq {/tension .000001 def} if curvelist length 3 div 1 sub cvi /#triads exch def /ptr 0 def firstpoint morepoint} def /tension 2.83301 def % default value for best fit SLIGHTLY REVISED! /showtick false def % don't show points /ticklen 15 def % length of ticks /tickhead ticklen 4 div def /prvx { curvelist ptr 3 sub get } def /curx { curvelist ptr get } def /prvy { curvelist ptr 2 sub get } def /cury { curvelist ptr 1 add get } def /prva { curvelist ptr 1 sub get } def /cura { curvelist ptr 2 add get 180 sub} def /showtic1 { showtick true eq {gsave currentpoint newpath translate cura 180 add rotate ticklen neg 2 div 0 moveto ticklen 0 rlineto tickhead neg dup rlineto tickhead dup rlineto tickhead dup neg exch rlineto 0 setlinewidth stroke 0 ticklen neg 2 div moveto 0 ticklen rlineto stroke grestore} if }def /firstpoint { curx cury 2 copy abs exch abs add 0 eq {pop pop currentpoint curvelist exch 1 exch put curvelist exch 0 exch put}{moveto} ifelse showtic1 /ptr ptr 3 add def}def /morepoint {#triads { curx prvx sub dup mul cury prvy sub dup mul add sqrt tension div /zdist exch def prva cos zdist mul prvx add prva sin zdist mul prvy add cura cos zdist mul curx add cura sin zdist mul cury add curx cury curveto showtic1 /ptr ptr 3 add def} repeat} def /showtick false def % ///////// (A) WEB FRIENDLY COLOR UTILITIES ///////////// % tintmat is a self-generating list of 216 triple color values /webtintmat [ 0 1 5 { /a exch store 0 1 5 { /b exch store 0 1 5 { 5 div b 5 div a 5 div }for } for } for ] def % setwebtint accepts a color number 0 to 215 and then % sets the PostScript color generator for later use... /setwebtint { abs cvi 216 cvi mod % restrict range webtintmat exch 3 mul 3 getinterval % get values from table aload pop setrgbcolor} def % and set them % The blocks are arranged as red to the right, green % up in order of increasing blue. % Some "pure color" sequences are % red: 0 1 2 3 4 5 % orange: 0 7 8 15 16 23 (sort of) % yellow: 0 7 14 21 28 35 % green: 0 6 12 18 24 30 % aqua: 0 42 84 126 168 210 % blue: 0 36 72 108 144 180 % magenta: 0 37 74 111 148 185 % purple 0 73 73 110 147 183 (sort of) % gray 0 43 86 129 172 215 % /makeurl generates the pdfmark Simplified non-gonzo only left justifiable! /makeurl1 { /cururlname exch store % save the url string mark % start pdfmark /Rect [x1 0.3 sub y1 0.3 sub x2 0.3 add y2 1.2 add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } store %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % attempt at string sorts... /bubsort3a {/curmat1 exch store curmat1 length 1 sub -1 1 % start outer loop {/done true store % short exit marker /maxposition exch store 0 1 maxposition 1 sub {/posn exch store % inner loop curmat1 posn get % find current count curmat1 posn 1 add get % compare to next higher gt{curmat1 posn get % swap only if needed curmat1 posn 1 add get curmat1 exch posn exch put curmat1 exch posn 1 add exch put /done false store % a swap was needed }if } for % inner loop done {exit} if % stop on no swaps } for % outer loop curmat1 % update sorted array } bind store % ////////// xml clone procs ////////////////// /searchstring (.psl) store /setupfileread { /readfile filenameprefix xmlfilename mergestr (r) file store } store % this creates an array of the filenames in the xml document /scanreadfile {mark % start array % zzzz { readfile 400 string readline not {exit} if findloc % scan for } loop pop % flush ? ] /filearray exch store % filearray == } store % % reject all files that do not have in them /findloc { /curline exch store curline () search { pop pop findnotloc }{pop} ifelse } store /findnotloc {/zorch exch store} store /findnotloc {/zorch exch store zorch () search {exch pop exch pop}{ } ifelse } store % createpage builds as many single column pages as needed. % A 10x grid is used. /leftmargin 1.2 store /topmargin 72 store /bottommargin 3 store /extraledding 10 store /yinc 1.3 store /group 10 store /groupcount 1 store /pagenum 1 store /wantgrid false store /wantbackground true store /wantcount true store /wantalphabatise true store /wantextfilt false store /exfilt (.psl) store /ypos topmargin store /font1 /StoneSans 1 gonzofont /addurltopage {leftmargin ypos moveto font1 show /ypos ypos yinc sub store groupcount group mod 0 eq {/ypos ypos yinc 1 div sub store} if /groupcount groupcount 1 add store ypos bottommargin le {addpagenum showpage /ypos topmargin store wantbackground {showbackground} if 30 setwebtint 1.5 1.5 10 setgrid wantgrid { 47 76 showgrid } if 180 setwebtint /groupcount 1 store } if } store % allow a few seconds for alphabetising if used... /alphabetise { wantalphabatise {filearray bubsort3a } if } store /createdoc { alphabetise { %%%% filter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /lookfor (.psl) store mark filearray { /nusrch exch store nusrch lookfor search {exch mergestr exch pop }{pop} ifelse } forall ] /filearray exch store } pop % filearray == (\n\nthere are now ) filearray length 10 string cvs mergestr (.psl files here ) mergestr == filearray {addurltopage} forall } store /showbackground { gsave 0 0 mt 1000 0 rlineto 0 1000 rlineto -1000 0 rlineto closepath 213 setwebtint fill grestore} store % this avoids the use of full gonzo /showheader {gsave 9 setwebtint 2 74 mt (A .PDF interpretation of ) show wantcount { (the ) show filearray length 7 string cvs show % psl count % ( .psl ) show ( files found in ) show } if currentpoint /y1 exch store /x1 exch store 180 setwebtint xmlfilename show currentpoint /y2 exch store /x2 exch store xmlfilename makeurl1 % make ANN gsave 9 setwebtint (...) show grestore grestore } store /addpagenum {gsave 9 setwebtint 14 1 mt (page ) pagenum 10 string cvs mergestr show /pagenum pagenum 1 add store } store % ///////// sml clone demo ///////////////////// % Be sure to activate distiller from the command line with //acrodist /F % .psl program should be rerun after any significant sitemap.xlm change. % present code only links files starting with http! Set your xml file here and % be sure it is in the same directory % at present, results listed in xml priority. Alphabetizing and extension % selection can be added later. % A simplified ANN is used here that does not use full gonzo. /xmlfilename (sitemap.xml) store % name the input xml file /filenameprefix (C:\\Users\\don\\Desktop\\google_drive\\xml\\) store setupfileread % start the xml reading process scanreadfile % convert the url's into an array % at present, filearray can be sorted externally % and quite fast at https://alphabetizer.flap.tv/ % at present, the full gonzo utilities are not in use. % Also at present, Distiller will automatically link anything that starts with % https: or http: Not sure whether this always will be true of sitemap.xml. % More elegant solutions are readily available with .psl using /surl. wantbackground {showbackground} if 30 setwebtint 1.5 1.5 10 setgrid wantgrid {47 76 showgrid} if 180 setwebtint showheader createdoc % create url only document addpagenum showpage %EOF