REBOL [
    Title: "Embedded Search"
    Date: 20-Aug-2006
    Name: 'embedded-search
    File: %embedded-search.r
    Version: 1.0.0
    Author: "rwvd.zee"
    Purpose: "The script enables a document search  from within a browser."
    Note: {
        - "call [firefox found.html]" might be changed to "browse %found.html"      
        - requires REBOL browser plugin    
        - script refers to Firefox, but other browsers might be named
    }
  Library: [
     level: 'beginner
     platform: 'all
     type: [reference tool]
     domain: [files html]
     tested-under: none
     support: none
     license: none
     see-also: document-search.r
   ]
]



                               ;the document search script that will be embedded

script-directory: what-dir 
if not exists? %embedded-script.r [
    write %embedded-script.r {
    REBOL [Title: "Plugin Ready" Version: 1.2.0]
    vers: 1.2.46
    view layout [
    size 600x595
    backdrop 187.219.220
    origin 5
    image logo.gif
    space 0
    indent 9 h3 130 "Document Search"
    space 10
    indent 20 directory: h3 450 
    space 3
    indent 30
    searchField: field 208 tan tan font-size 15 bold center 
    across
    indent 60
    btn "Open A Directory To Search"  [
        search-directory: request-dir/offset 350x170 
        if  (search-directory <> none) [
            change-dir search-directory
            directory/text: join "Searching " search-directory
            show directory
        ]
    ]
                                 ;a web page to display the search results

    btn "Search" [
       manualFiles: read %.
       finds: rejoin [
           {
            
            
Search Results For "} searchField/text {"
 
} ] foreach fileIn manualFiles [ if find read fileIn searchField/text [ parse read fileIn [thru copy theTitle to ] append finds rejoin ["" theTitle "
" ] ] ] append finds "
" write %found.html finds call [firefox found.html] ] ] } ] ;and the html page that contains the script page-path: join script-directory %embedded-script.r if not exists? %webPage.html [ write %webPage.html rejoin [ { Document Search } ] ] if (not exists? %logo.gif) [save/png %logo.png logo.gif] browse %webpage.html