home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / comm / mail / YAMscripts.lha / MakeHotlist.rexx < prev    next >
OS/2 REXX Batch file  |  1997-02-21  |  5KB  |  114 lines

  1. /*                         MakeHotlist.rexx
  2.                            v1.0 - 20-Nov-96
  3.  
  4.    This script grabs all URLs from the read messages in the current
  5.    folder and creates a hotlist which it sends to a browser.
  6.    Currently supported browsers are AWeb, IBrowse and Voyager.
  7.  
  8.    All adresses which end with a character in variable dup_chars will be
  9.    duplicated and displayed also without that character.
  10.  
  11.    This script requires rexxreqtools and reqtools libraries, if the
  12.    filerequester is used.
  13.  
  14.    Send bug reports, comments and spare bodyparts to knikulai@utu.fi
  15.  
  16.    If you send a message with subject REQUEST INDEX, you'll get a list
  17.    of my AREXX scripts. REQUEST <filename> will get you the script you
  18.    want.
  19.  
  20.    This script is the grandson of GrabURL.rexx and son of GrabAllURLs.rexx.
  21.    I have no idea what the fourth generation will do.
  22. */
  23. options results
  24.  
  25. hname='yam:hotlist.html'/* Full path and name of hotlist */
  26.  
  27. /* If you wish to select the name of the hotlist, uncomment next three lines*/
  28. /*
  29. addlib('rexxreqtools.library',0,-30)
  30. hname=rtfilerequest('yam:','hotlist.html','Enter name of the hotlist',,'rtfi_flags=freqf_save')
  31. if hname='' then exit
  32. */
  33.  
  34. dup_chars='.,!?"*%&)'   /* If one of these ends the URL, it will be duplicated */
  35. not_found='Sorry,no URLs were found in any of the read messages!'
  36. uc=0                    /* URL-counter */
  37.  
  38. call open(hotlist,hname,'W')
  39. writeln(hotlist,'<html><head><title>URLs from read messages</title></head>')
  40. writeln(hotlist,'<body><center><h3>URLs from read messages in current YAM folder</h3></center>')
  41. writeln(hotlist,'<center>An URL is only displayed once, even if it appears in several messages.</center>')
  42. writeln(hotlist,'<hr><ul>')
  43. address 'YAM'
  44. GetFolderInfo Max
  45. n=result
  46. do viesti=0 to n-1
  47.     SetMail viesti
  48.     GetMailInfo File
  49.     fname=result
  50.     GetMailInfo Subject
  51.     sub=result
  52.     GetMailInfo Status
  53.     if pos(result,'UN')=0 then do  /* The message isn't new or unread */
  54.        if open(msg,fname,'R') then do
  55.            do until eof(msg) | uc=maxurl
  56.                rivi=readln(msg)
  57.                rivi=rivi || '  '                /* Just making sure there is a space at the end */
  58.                do while uc<maxurl & (pos('GOPHER://',upper(rivi))>0 | pos('FILE://',upper(rivi))>0 | pos('HTTP://',upper(rivi))>0 | pos('FTP://',upper(rivi))>0)
  59.                   /* There might be several URLs on one line */
  60.                   b=pos('HTTP://',upper(rivi))          /* beginning */
  61.                   if b=0 then b=pos('FTP://',upper(rivi))
  62.                   /* Adding other types is easy, just add a line like this: */
  63.                   if b=0 then b=pos('GOPHER://',upper(rivi))
  64.                   if b=0 then b=pos('FILE://',upper(rivi))
  65.                   e=pos(' ',rivi,b)                     /* space ends the URL */
  66.                   if e-pos('//',rivi,b)>2 then do       /* only save if URL has chars in it */
  67.                       call AddURL(substr(rivi,b,e-b))   /* save URL */
  68.                       do while uc<maxurl & pos(right(url.uc,1),dup_chars)>0
  69.                           /* Add another URL without the last character */
  70.                           spare=left(url.uc,length(url.uc)-1)
  71.                           call AddURL(spare)
  72.                           end /* do while uc<maxurl & pos */
  73.                   end /*if e-pos('//',rivi,b)>2*/
  74.                   rivi=right(rivi,length(rivi)-e)
  75.                end /* do while uc<maxurl & (pos('FILE://',upper(rivi))> */
  76.            end /* do until eof(msg) */
  77.            close(msg)
  78.         end /* if open(msg,fname,'R') then do */
  79.     end /* if pos(result,'UN')=0 then do */
  80. end /* do viesti=0 to n-1 */
  81. writeln(hotlist,'</ul><hr><a href="mailto:knikulai@utu.fi">Send praise or bug reports to Kai.Nikulainen@utu.fi</a></body></html>')
  82. call close(hotlist)
  83.  
  84. if uc=0 then
  85.    'request "'||not_found||'" "_Ok"'
  86. else do
  87.    lst=show('P') || '  '
  88.    if pos('MINDWALKER',lst)>0 then
  89.       address 'MINDWALKER' 'OpenURL file:///'|| hname
  90.    if pos('VOYAGER',lst)>0 then
  91.       address 'VOYAGER' 'OpenURL file:///'|| hname
  92.    if pos('IBROWSE',lst)>0 then
  93.       address 'IBROWSE' 'GotoURL file:///' || hname
  94.    if pos('AWEB',lst)>0 then do
  95.         address value substr(lst,pos('AWEB.',lst),6)
  96.         'Open file://localhost/' || hname
  97.         end
  98. end /* else */
  99. exit
  100.  
  101. AddURL:
  102.   parse arg u
  103.   do i=1 to uc
  104.       if url.i=u then return
  105.       end
  106.   uc=uc+1
  107.   url.uc=u
  108.   if sub~='' then do /* First write the subject of the message */
  109.         writeln(hotlist,'</ul><p><p><strong>'|| sub ||'</strong><ul>')
  110.         sub=''
  111.         end
  112.   writeln(hotlist,'<li><a href="'|| u ||'">'|| u ||'</a>')
  113. return
  114.