#!/bin/sh # MetaCard 2.4 stack # The following is not ASCII text, # so now would be a good time to q out of more exec mc $0 "$@" Docs251Patch 2 8 (Revolution Documentation 2.5.1 Enhancer U Lucida Grande U Lucida Grande W Lucida Grande @U Lucida Grande U Georgia U Georgia cREVGeneral debugObjects bookmarks handlerList tempScript prevHandler script X ]/* Revolution Documentation 2.5.1 Enhancer by Eric Chatonet sosmartsoftware.com March 2005 */ on preOpenStack set the loc of this stack to the screenloc set the style of this stack to modeless end preOpenStack --------------------------------- on openStack if there is no stack revDocsPath() then -- answer error "Could not find Revolution Documentation." with "Sorry" as sheet disable btn "Apply Patch" exit openStack end if ----- switch case revAppVersion() <> "2.5.1" answer error "This enhancer is for Rev 2.5.1 only." with "Sorry" as sheet disable btn "Apply Patch" break case the script of stack "revDocs" = the script of btn "NewStackScript" answer info "This enhancer has been already applied." as sheet disable btn "Apply Patch" break default enable btn "Apply Patch" end switch end openStack --------------------------------- function revDocsPath local tPath ----- set the itemDel to slash put the filename of stack "revmenubar" into tPath put "help/revdocumentation.rev" into item -2 to -1 of tPath return tPath end revDocsPath cREVGeneral scriptChecksum p0噲_X6G bookmarks handlerList "preOpenStack openStack revDocsPathtempScript prevHandler openStackscriptSelection char 501 to 500script
/*
Revolution Documentation 2.5.1 Enhancer by Eric Chatonet
sosmartsoftware.com
March 2005
*/
on preOpenStack
set the loc of this stack to the screenloc
set the style of this stack to modeless
end preOpenStack
---------------------------------
on openStack
if there is no stack revDocsPath() then --
answer error "Could not find Revolution Documentation." with "Sorry" as sheet
disable btn "Apply Patch"
exit openStack
end if
-----
switch
case revAppVersion() <> "2.5.1"
answer error "This enhancer is for Rev 2.5.1 only." with "Sorry" as sheet
disable btn "Apply Patch"
break
case the script of stack "revDocs" = the script of btn "NewStackScript"
answer info "This enhancer has been already applied." as sheet
disable btn "Apply Patch"
break
default
enable btn "Apply Patch"
end switch
end openStack
---------------------------------
function revDocsPath
local tPath
-----
set the itemDel to slash
put the filename of stack "revmenubar" into tPath
put "help/revdocumentation.rev" into item -2 to -1 of tPath
return tPath
end revDocsPath
@ NewStackScript Epi^local sCurrentNode,sCategories,sSeeAlso,sMergeData,sTimer,sDownload,sOldColor constant kDocsHTTP = "http://support.runrev.com/docs/webnotes/" on preOpenStack local tFolder if the cRevDocsRect of stack "revPreferences" <> "" then set the rect of this stack to the cRevDocsRect of stack "revPreferences" end if put "" into fld "status" if the platform = "MacOS" and char 1 of the systemVersion = "1" then set the decorations of this stack to "metal,title,minimize,maximize,close" else set the decorations of this stack to "default" end if repeat with X=1 to the number of btns of group "toolbar" if the platform = "MacOS" then set the style of btn X of group "toolbar" to "rectangle" else set the style of btn X of group "toolbar" to "standard" end if set the textAlign of btn X of group "toolbar" to "center" set the showBorder of btn X of group "toolbar" to false end repeat set the itemDel to "," repeat for each item tBtn in "Getting Started,Dictionary,Objects,Topics,Bookmarks" if the textStyle of btn tBtn is "bold" then goIndex tBtn end repeat ############# modified lines by Docs Enhancer: if the cRevDocs["uNav"] of stack "revPreferences" then -- restore previous navigation links: set the uBackList of this stack to the cRevDocs["uBackList"] of stack "revPreferences" set the uForwardList of this stack to the cRevDocs["uForwardList"] of stack "revPreferences" set the enabled of btn "back" to the uBackList of this stack <> empty set the enabled of btn "forward" to the uForwardList of this stack <> empty if the enabled of btn "Back" and the textStyle of btn "Dictionary" is "bold" then send "mouseUp" to btn "Back" end if else -- usual behaviour: set the uBackList of this stack to "" set the uForwardList of this stack to "" disable btn "forward" disable btn "back" end if ############# end preOpenStack setProp uDoc pPath put "" into sCategories put "" into sSeeAlso put "" into sMergeData put the milliseconds into sTimer enable btn "add bookmark" parseDoc pPath displayDoc pPath if the hilite of btn "Download and show web notes" then put "notes" into sDownload set the itemDel to "/" put item -2 to -1 of pPath into pPath set the itemDel to "." put "note" into item 2 of pPath unload url (kDocsHTTP&pPath) load url (kDocsHTTP&pPath) with "showDownloadStatus" end if pass uDoc end uDoc getProp uDocsFolder local tFolder set the itemDel to "/" put the effective filename of stack "revdocs" into tFolder delete item -1 of tFolder if the platform is "macos" and char 1 of the systemversion = 1 then --darwin uses utf8 paths in fopen which revxml uses return unidecode(uniencode(tFolder,"roman"),"utf8") end if return tFolder end uDocsFolder on setTitle pText set the htmlText of fld "label" to pText set the title of this stack to "Reference Documentation - "&fld "label" end setTitle on linkClicked pWhat goDoc pWhat end linkClicked on closeStack if the short name of this stack <> "RevDocs Edit Web Notes" and not the dontDelete of fld "list" of cd 1 then revDeleteXMLTree the docid of fld "List" of cd 1 end if set the cRevDocsRect of stack "revPreferences" to the rect of this stack put "" into fld "find" of cd 1 ############# added lines by Docs Enhancer: put the uBackList of this stack into tBackList put lineOffset(the uDoc of this stack,tBackList) into tLine if tLine <> 0 then delete line tLine of tBackList put the uDoc of this stack & cr before tBackList set the cRevDocs["uBackList"] of stack "revPreferences" to line 1 to 10 of tBackList set the cRevDocs["uForwardList"] of stack "revPreferences" to line 1 to 10 the uForwardList of this stack ############# end closeStack on displayDoc pPath local tMerge,tObj,tIntro delete char -2 of sMergeData["SeeAlso"] switch case pPath contains "/faq/" put "[[sMergeData[topic] ]]
[[sMergeData[answer] ]]
" into tMerge break case pPath contains "/topics/" put "[[sMergeData[topic] ]]
" into tMerge if sMergeData["summary"] <> "" then put "[[sMergeData[summary] ]]
" after tMerge end if put "[[sMergeData[toc] ]][[sMergeData[answer] ]]
" after tMerge break case pPath contains "/dictionary/" delete char -1 of sMergeData["synonym"] if sMergeData["summary"] <> "" then put "[[sMergeData[summary] ]]
" after tMerge if sMergeData["syntax"] <> "" then put "" after tMerge end if if sMergeData["syntax"] <> "" then put "[[sMergeData[syntax] ]]
" after tMerge end if if sMergeData["example"] <> "" then put "[[sMergeData[example] ]]
" after tMerge end if if "xmlerr" is not in sMergeData["objects"] and sMergeData["objects"] <> "" then if sMergeData["objects"] <> "" then put "([[sMergeData[objects] ]])" into tObj end if else if "xmlerr" is not in sMergeData["library"] and sMergeData["library"] <> "" then put "([[sMergeData[library] ]])" into tObj end if end if if sMergeData["introduced"] <> "" then put "Introduced in version [[sMergeData[introduced] ]]" into tIntro else put "Introduced in version 1.0" into tIntro end if if sMergeData["changed"] <> "" and sMergeData["changed"] <> sMergeData["introduced"] then put " (Changed in version [[sMergeData[changed] ]])" after tIntro end if put "[[sMergeData[name] ]] [[sMergeData[type] ]] "&tObj&"
[[sMergeData[synonym] ]]
Platform support: [[sMergeData[platforms] ]]
"&tIntro&"
"&tMerge&"See also: [[sMergeData[seealso] ]]
Description[[sMergeData[description] ]]
" into tMerge break end switch set the htmlText of fld "doc" to merge(tMerge) end displayDoc on parseDoc pPath local tID put revCreateXMLTreeFromFile(pPath,true,true,false) into tID -- "topic" put ""&xmlToHTML(revXMLNodeContents(tID,"/doc/topic"))&"" into sMergeData["topic"] if "xmlerr" is not in sMergeData["name"] then setTitle revXMLNodeContents(tID,"/doc/topic") end if -- "answer" put xmlToHTML(revXMLNodeContents(tID,"/doc/answer")) into sMergeData["answer"] -- "category" --put sCurrentNode["data"] into sMergeData["type"] --put cr&sCurrentNode["data"] after sCategories -- "docRef" repeat for each line tRef in revXMLChildNames(tID,"/doc/related",cr,,true) put ""&revXMLNodeContents(tID,"/doc/related/"&tRef)&", " after sMergeData["seeAlso"] end repeat -- "toc" put xmlToHTML(""&tab&"
"&revXMLNodeContents(tID,"/doc/syntax")&"") into sMergeData["syntax"]
end if
-- "library"
put revXMLNodeContents(tID,"/doc/library") into sMergeData["library"]
-- "objects"
put revXMLNodeContents(tID,"/doc/objects") into sMergeData["objects"]
-- "type"
put revXMLNodeContents(tID,"/doc/type") into sMergeData["type"]
-- "synonym"
repeat for each line tSynonym in revXMLChildNames(tID,"/doc/synonyms",cr,,true)
put revXMLNodeContents(tID,"/doc/synonyms/"&tSynonym)&"," after sMergeData["synonym"]
end repeat
-- "introduced"
put revXMLAttribute(tID,"/doc/introduced","version") into sMergeData["introduced"]
-- "changed"
put revXMLAttribute(tID,"/doc/changed","version") into sMergeData["changed"]
-- "Win32"
if revXMLAttribute(tID,"/doc/win32","support") = "true" then
put ""&revXMLNodeContents(tID,"/doc/example")&"") into sMergeData["example"]
end if
-- "description"
put xmlToHTML(revXMLNodeContents(tID,"/doc/description")) into sMergeData["description"]
revDeleteXMLTree tID
end parseDoc
function replaceEntities pData
replace "&" with "&" in pData
replace "<" with "<" in pData
replace ">" with ">" in pData
return pData
end replaceEntities
setProp XMLstring pXML
set the XMLString of fld "List" to pXML
pass XMLstring
end XMLstring
on goDoc pDoc
local tFile,destinationLineNumber,neededScroll,tBackList,tLine
set the itemDel to "."
switch
case item -1 of pDoc = "rev"
put the uDocsFolder of this stack&"/"&toLower(pDoc) into tFile
if there is not a file tFile then
--put "doc" into sDownload
--downloadDoc kDocsHTTP&"docs/"&toLower(pDoc),tFile
exit goDoc
end if
go tFile
break
case pDoc contains "http://revonline"
case pDoc contains "pdf:"
send "revGoOnline" &"e&pDoc"e to stack "revOnline"
--send "rcvGoto" &"e&pDoc"e to stack "revOnline"
break
case "@" is in pDoc and "keyword" is not in pDoc
case pDoc contains "www"
case pDoc contains "http://"
case pDoc contains "ftp://"
revGoURL pDoc
case pDoc contains "index:"
click at the loc of btn char 7 to -1 of pDoc
break
case pDoc contains "TOC:"
set the wholeMatches to true
put lineOffset(the clickText, the text of field "doc") into destinationLineNumber
put the formattedHeight of line 1 to destinationLineNumber - 1 of field "doc" into neededScroll
set the scroll of field "doc" to neededScroll
break
case "glossary/" is in pDoc
set the hilite of btn "Show mouse over text" to true
resizeStack the width of this stack,the height of this stack
mouseOverDoc pDoc
break
default
put the uDocsFolder of this stack&"/"&pDoc into tFile
if there is not a file tFile then
--put "doc" into sDownload
--downloadDoc kDocsHTTP&"docs/"&pDoc,tFile
exit goDoc
end if
if there is a file the uDoc of this stack then
put the uBackList of this stack into tBackList
put lineOffset(the uDoc of this stack,tBackList) into tLine
if tLine <> 0 then delete line tLine of tBackList
set the uBackList of this stack to the uDoc of this stack &cr&tBackList
enable btn "back"
end if
set the uDoc of this stack to tFile
break
end switch
end goDoc
on downloadDoc pURL,pFile
repeat for each line tLine in the cachedUrls
unload url tLine
end repeat
libURLDownloadToFile pURL,pFile,"showDownloadStatus"
end downloadDoc
on showDownloadStatus pURL
local tStatus,tDownloadStatus,tFile
put the urlStatus of pURL into tStatus
switch item 1 of tStatus
case "loading"
put "downloading: "&item 2 of tStatus div 1024&"/"&item 3 of tStatus div 1024 into tDownloadStatus
break
case "error"
if sDownload = "doc" then
put "error downloading" into tDownloadStatus
else
put "" into tDownloadStatus
end if
break
case "cached"
put "" into tDownloadStatus
set the itemDel to "/"
if libURLErrorData(pURL) = "" then
switch sDownload
case "doc"
goDoc item -2 to -1 of pURL
break
case "mouse"
mouseOverDoc item -2 to -1 of pURL
break
case "notes"
set the htmlText of fld "doc" to the htmlText of fld "doc" & xmlToHTML(""&xmlToHTML(revXMLNodeContents(tID,"/doc/name"))&&xmlToHTML(revXMLNodeContents(tID,"/doc/type"))&"
" into tHTML if the length of revXMLNodeContents(tID,"/doc/syntax") > 4 then put ""&xmlToHTML(""&revXMLNodeContents(tID,"/doc/syntax")&"")&"
" with "" in pData
replace "" with "" in pData
return pData
end xmlToHTML
function parseLinks tData
local tStart,tEnd,tLinkText,tID,tReplaceTag
repeat for 1000 -- enough to loop, but not "forever" in case I get stuck
get matchChunk(tData,"(?si)(local sCurrentNode,sCategories,sSeeAlso,sMergeData,sTimer,sDownload,sOldColor
constant kDocsHTTP = "http://support.runrev.com/docs/webnotes/"
on preOpenStack
local tFolder
if the cRevDocsRect of stack "revPreferences" <> "" then
set the rect of this stack to the cRevDocsRect of stack "revPreferences"
end if
put "" into fld "status"
if the platform = "MacOS" and char 1 of the systemVersion = "1" then
set the decorations of this stack to "metal,title,minimize,maximize,close"
else
set the decorations of this stack to "default"
end if
repeat with X=1 to the number of btns of group "toolbar"
if the platform = "MacOS" then
set the style of btn X of group "toolbar" to "rectangle"
else
set the style of btn X of group "toolbar" to "standard"
end if
set the textAlign of btn X of group "toolbar" to "center"
set the showBorder of btn X of group "toolbar" to false
end repeat
set the itemDel to ","
repeat for each item tBtn in "Getting Started,Dictionary,Objects,Topics,Bookmarks"
if the textStyle of btn tBtn is "bold" then goIndex tBtn
end repeat
############# modified lines by Docs Enhancer:
if the cRevDocs["uNav"] of stack "revPreferences" then -- restore previous navigation links:
set the uBackList of this stack to the cRevDocs["uBackList"] of stack "revPreferences"
set the uForwardList of this stack to the cRevDocs["uForwardList"] of stack "revPreferences"
set the enabled of btn "back" to the uBackList of this stack <> empty
set the enabled of btn "forward" to the uForwardList of this stack <> empty
if the enabled of btn "Back" and the textStyle of btn "Dictionary" is "bold" then
send "mouseUp" to btn "Back"
end if
else -- usual behaviour:
set the uBackList of this stack to ""
set the uForwardList of this stack to ""
disable btn "forward"
disable btn "back"
end if
#############
end preOpenStack
setProp uDoc pPath
put "" into sCategories
put "" into sSeeAlso
put "" into sMergeData
put the milliseconds into sTimer
enable btn "add bookmark"
parseDoc pPath
displayDoc pPath
if the hilite of btn "Download and show web notes" then
put "notes" into sDownload
set the itemDel to "/"
put item -2 to -1 of pPath into pPath
set the itemDel to "."
put "note" into item 2 of pPath
unload url (kDocsHTTP&pPath)
load url (kDocsHTTP&pPath) with "showDownloadStatus"
end if
pass uDoc
end uDoc
getProp uDocsFolder
local tFolder
set the itemDel to "/"
put the effective filename of stack "revdocs" into tFolder
delete item -1 of tFolder
if the platform is "macos" and char 1 of the systemversion = 1 then
--darwin uses utf8 paths in fopen which revxml uses
return unidecode(uniencode(tFolder,"roman"),"utf8")
end if
return tFolder
end uDocsFolder
on setTitle pText
set the htmlText of fld "label" to pText
set the title of this stack to "Reference Documentation - "&fld "label"
end setTitle
on linkClicked pWhat
goDoc pWhat
end linkClicked
on closeStack
if the short name of this stack <> "RevDocs Edit Web Notes" and not the dontDelete of fld "list" of cd 1 then
revDeleteXMLTree the docid of fld "List" of cd 1
end if
set the cRevDocsRect of stack "revPreferences" to the rect of this stack
put "" into fld "find" of cd 1
############# added lines by Docs Enhancer:
put the uBackList of this stack into tBackList
put lineOffset(the uDoc of this stack,tBackList) into tLine
if tLine <> 0 then delete line tLine of tBackList
put the uDoc of this stack & cr before tBackList
set the cRevDocs["uBackList"] of stack "revPreferences" to line 1 to 10 of tBackList
set the cRevDocs["uForwardList"] of stack "revPreferences" to line 1 to 10 the uForwardList of this stack
#############
end closeStack
on displayDoc pPath
local tMerge,tObj,tIntro
delete char -2 of sMergeData["SeeAlso"]
switch
case pPath contains "/faq/"
put "<p>[[sMergeData[topic] ]]</p><p>[[sMergeData[answer] ]]</p>" into tMerge
break
case pPath contains "/topics/"
put "<p>[[sMergeData[topic] ]]</p>" into tMerge
if sMergeData["summary"] <> "" then
put "<p>[[sMergeData[summary] ]]</p>" after tMerge
end if
put "[[sMergeData[toc] ]]<p>[[sMergeData[answer] ]]</p>" after tMerge
break
case pPath contains "/dictionary/"
delete char -1 of sMergeData["synonym"]
if sMergeData["summary"] <> "" then
put "<p>[[sMergeData[summary] ]]</p>" after tMerge
if sMergeData["syntax"] <> "" then put "<p></p>" after tMerge
end if
if sMergeData["syntax"] <> "" then
put "<p><b>[[sMergeData[syntax] ]]</b></p>" after tMerge
end if
if sMergeData["example"] <> "" then
put "<p>[[sMergeData[example] ]]</p>" after tMerge
end if
if "xmlerr" is not in sMergeData["objects"] and sMergeData["objects"] <> "" then
if sMergeData["objects"] <> "" then
put "([[sMergeData[objects] ]])" into tObj
end if
else
if "xmlerr" is not in sMergeData["library"] and sMergeData["library"] <> "" then
put "([[sMergeData[library] ]])" into tObj
end if
end if
if sMergeData["introduced"] <> "" then
put "Introduced in version [[sMergeData[introduced] ]]" into tIntro
else
put "Introduced in version 1.0" into tIntro
end if
if sMergeData["changed"] <> "" and sMergeData["changed"] <> sMergeData["introduced"] then
put " (Changed in version [[sMergeData[changed] ]])" after tIntro
end if
put "<p><font size=18 color=#606060><b>[[sMergeData[name] ]]</b> [[sMergeData[type] ]]</font> "&tObj&"</p><p><font color=#606060>[[sMergeData[synonym] ]]</font></p><p><font size=14 color=#606060>Platform support: [[sMergeData[platforms] ]]</font></p><p><font size=10>"&tIntro&"</font></p>"&tMerge&"<p></p><p><font size=14 color=#606060>See also: </font>[[sMergeData[seealso] ]]</p><p></p><p><font size=14 color=#606060><b>Description</b></font>[[sMergeData[description] ]]</p>" into tMerge
break
end switch
set the htmlText of fld "doc" to merge(tMerge)
end displayDoc
on parseDoc pPath
local tID
put revCreateXMLTreeFromFile(pPath,true,true,false) into tID
-- "topic"
put "<b><font size=18 color=#606060 face=Verdana>"&xmlToHTML(revXMLNodeContents(tID,"/doc/topic"))&"</font></b>" into sMergeData["topic"]
if "xmlerr" is not in sMergeData["name"] then
setTitle revXMLNodeContents(tID,"/doc/topic")
end if
-- "answer"
put xmlToHTML(revXMLNodeContents(tID,"/doc/answer")) into sMergeData["answer"]
-- "category"
--put sCurrentNode["data"] into sMergeData["type"]
--put cr&sCurrentNode["data"] after sCategories
-- "docRef"
repeat for each line tRef in revXMLChildNames(tID,"/doc/related",cr,,true)
put "<a href=""e&revXMLAttribute(tID,"/doc/related/"&tRef,"src")"e&">"&revXMLNodeContents(tID,"/doc/related/"&tRef)&"</a>, " after sMergeData["seeAlso"]
end repeat
-- "toc"
put xmlToHTML("<p></p><p><h2>"&revXMLAttribute(tID,"/doc/toc","heading")&"</h2></p>") into sMergeData["toc"]
repeat for each line tRef in revXMLChildNames(tID,"/doc/toc",cr,,true)
put xmlToHTML("<p>"&tab&"<important><a href=""e&"TOC:"&revXMLNodeContents(tID,"/doc/toc/"&tRef)"e&">"&revXMLNodeContents(tID,"/doc/toc/"&tRef)&"</a></important></p>") after sMergeData["toc"]
end repeat
-- "name"
put revXMLNodeContents(tID,"/doc/name") into sMergeData["name"]
if "xmlerr" is not in sMergeData["name"] then
setTitle revXMLNodeContents(tID,"/doc/name")&&revXMLNodeContents(tID,"/doc/type")
end if
-- "syntax"
if the length of revXMLNodeContents(tID,"/doc/syntax") > 4 then
put xmlToHTML("<code>"&revXMLNodeContents(tID,"/doc/syntax")&"</code>") into sMergeData["syntax"]
end if
-- "library"
put revXMLNodeContents(tID,"/doc/library") into sMergeData["library"]
-- "objects"
put revXMLNodeContents(tID,"/doc/objects") into sMergeData["objects"]
-- "type"
put revXMLNodeContents(tID,"/doc/type") into sMergeData["type"]
-- "synonym"
repeat for each line tSynonym in revXMLChildNames(tID,"/doc/synonyms",cr,,true)
put revXMLNodeContents(tID,"/doc/synonyms/"&tSynonym)&"," after sMergeData["synonym"]
end repeat
-- "introduced"
put revXMLAttribute(tID,"/doc/introduced","version") into sMergeData["introduced"]
-- "changed"
put revXMLAttribute(tID,"/doc/changed","version") into sMergeData["changed"]
-- "Win32"
if revXMLAttribute(tID,"/doc/win32","support") = "true" then
put "<img src=204121 \>" after sMergeData["platforms"]
else
put "<img src=204122 \>" after sMergeData["platforms"]
end if
-- "OSX"
if revXMLAttribute(tID,"/doc/osx","support") = "true" then
put "<img src=204123 \>" after sMergeData["platforms"]
else
put "<img src=204124 \>" after sMergeData["platforms"]
end if
-- "MacOS"
if revXMLAttribute(tID,"/doc/macos","support") = "true" then
put "<img src=204117 \>" after sMergeData["platforms"]
else
put "<img src=204118 \>" after sMergeData["platforms"]
end if
-- "unix"
if revXMLAttribute(tID,"/doc/unix","support") = "true" then
put "<img src=204119 \>" after sMergeData["platforms"]
else
put "<img src=204120 \>" after sMergeData["platforms"]
end if
-- "platform"
if revXMLAttribute(tID,"/doc/platform","warning") = "true" then
put "<img src=202648 \>" before sMergeData["platforms"]
end if
-- "summary"
put xmlToHTML(revXMLNodeContents(tID,"/doc/summary")) into sMergeData["summary"]
-- "example"
if the length of revXMLNodeContents(tID,"/doc/example") > 7 then
put xmlToHTML("<code>"&revXMLNodeContents(tID,"/doc/example")&"</code>") into sMergeData["example"]
end if
-- "description"
put xmlToHTML(revXMLNodeContents(tID,"/doc/description")) into sMergeData["description"]
revDeleteXMLTree tID
end parseDoc
function replaceEntities pData
replace "&" with "&" in pData
replace "<" with "<" in pData
replace ">" with ">" in pData
return pData
end replaceEntities
setProp XMLstring pXML
set the XMLString of fld "List" to pXML
pass XMLstring
end XMLstring
on goDoc pDoc
local tFile,destinationLineNumber,neededScroll,tBackList,tLine
set the itemDel to "."
switch
case item -1 of pDoc = "rev"
put the uDocsFolder of this stack&"/"&toLower(pDoc) into tFile
if there is not a file tFile then
--put "doc" into sDownload
--downloadDoc kDocsHTTP&"docs/"&toLower(pDoc),tFile
exit goDoc
end if
go tFile
break
case pDoc contains "http://revonline"
case pDoc contains "pdf:"
send "revGoOnline" &"e&pDoc"e to stack "revOnline"
--send "rcvGoto" &"e&pDoc"e to stack "revOnline"
break
case "@" is in pDoc and "keyword" is not in pDoc
case pDoc contains "www"
case pDoc contains "http://"
case pDoc contains "ftp://"
revGoURL pDoc
case pDoc contains "index:"
click at the loc of btn char 7 to -1 of pDoc
break
case pDoc contains "TOC:"
set the wholeMatches to true
put lineOffset(the clickText, the text of field "doc") into destinationLineNumber
put the formattedHeight of line 1 to destinationLineNumber - 1 of field "doc" into neededScroll
set the scroll of field "doc" to neededScroll
break
case "glossary/" is in pDoc
set the hilite of btn "Show mouse over text" to true
resizeStack the width of this stack,the height of this stack
mouseOverDoc pDoc
break
default
put the uDocsFolder of this stack&"/"&pDoc into tFile
if there is not a file tFile then
--put "doc" into sDownload
--downloadDoc kDocsHTTP&"docs/"&pDoc,tFile
exit goDoc
end if
if there is a file the uDoc of this stack then
put the uBackList of this stack into tBackList
put lineOffset(the uDoc of this stack,tBackList) into tLine
if tLine <> 0 then delete line tLine of tBackList
set the uBackList of this stack to the uDoc of this stack &cr&tBackList
enable btn "back"
end if
set the uDoc of this stack to tFile
break
end switch
end goDoc
on downloadDoc pURL,pFile
repeat for each line tLine in the cachedUrls
unload url tLine
end repeat
libURLDownloadToFile pURL,pFile,"showDownloadStatus"
end downloadDoc
on showDownloadStatus pURL
local tStatus,tDownloadStatus,tFile
put the urlStatus of pURL into tStatus
switch item 1 of tStatus
case "loading"
put "downloading: "&item 2 of tStatus div 1024&"/"&item 3 of tStatus div 1024 into tDownloadStatus
break
case "error"
if sDownload = "doc" then
put "error downloading" into tDownloadStatus
else
put "" into tDownloadStatus
end if
break
case "cached"
put "" into tDownloadStatus
set the itemDel to "/"
if libURLErrorData(pURL) = "" then
switch sDownload
case "doc"
goDoc item -2 to -1 of pURL
break
case "mouse"
mouseOverDoc item -2 to -1 of pURL
break
case "notes"
set the htmlText of fld "doc" to the htmlText of fld "doc" & xmlToHTML("<p></p><p><h2>Web Notes</h2></p>"& url pURL)
break
end switch
put "" into fld "Status"
else
set the itemDel to "/"
put the uDocsFolder of this stack&"/"&item -2 to -1 of pURL into tFile
if there is a file tFile then delete file tFile
end if
default
put tStatus into tDownloadStatus
break
end switch
put tDownloadStatus into fld "Status"
end showDownloadStatus
on mouseOverDoc pDoc
local tFile,tID,tHTML
set the itemDel to "."
switch
case item -1 of pDoc = "rev"
case "@" is in pDoc and "keyword" is not in pDoc
case pDoc contains "www"
case pDoc contains "http://"
case pDoc contains "ftp://"
case pDoc contains "TOC:"
case pDoc contains "index:"
exit mouseOverDoc
break
case "glossary/" is in pDoc
put the uDocsFolder of this stack&"/"&pDoc into tFile
if there is not a file tFile then
--downloadDoc kDocsHTTP&"docs/"&pDoc,tFile
--put "mouse" into sDownload
exit mouseOverDoc
end if
put revCreateXMLTreeFromFile(tFile,true,true,false) into tID
put "<font size=14><b>"&xmlToHTML(revXMLNodeContents(tID,"/doc/term"))&"</b></font>" &\
xmlToHTML(revXMLNodeContents(tID,"/doc/definition")) into tHTML
revDeleteXMLTree tID
break
case "dictionary/" is in pDoc
put the uDocsFolder of this stack&"/"&pDoc into tFile
if there is not a file tFile then
--downloadDoc kDocsHTTP&"docs/"&pDoc,tFile
--put "mouse" into sDownload
exit mouseOverDoc
end if
put revCreateXMLTreeFromFile(tFile,true,true,false) into tID
put "<p><font size=14><b>"&xmlToHTML(revXMLNodeContents(tID,"/doc/name"))&&xmlToHTML(revXMLNodeContents(tID,"/doc/type"))&"</b></font></p>" into tHTML
if the length of revXMLNodeContents(tID,"/doc/syntax") > 4 then
put "<p>"&xmlToHTML("<code>"&revXMLNodeContents(tID,"/doc/syntax")&"</code>")&"</p>" after tHTML
end if
put xmlToHTML(revXMLNodeContents(tID,"/doc/summary")) after tHTML
revDeleteXMLTree tID
break
default
put the uDocsFolder of this stack&"/"&pDoc into tFile
if there is not a file tFile then
--downloadDoc kDocsHTTP&"docs/"&pDoc,tFile
--put "mouse" into sDownload
exit mouseOverDoc
end if
put revCreateXMLTreeFromFile(tFile,true,true,false) into tID
put xmlToHTML(revXMLNodeContents(tID,"/doc/summary")) into tHTML
revDeleteXMLTree tID
break
end switch
if "xmlerr" is not in tHTML then set the htmlText of fld "mouseOver" to replaceText(tHTML,"<p></p>","")
lock screen
set the height of fld "mouseOver" to the formattedHeight of fld "mouseOver"
resizeStack the width of this stack,the height of this stack
end mouseOverDoc
function xmlToHTML pData
local tSize,tFont
put parseLinks(pData) into pData
replace "<h1>" with "<b><font size=18 color=#404040>" in pData
replace "</h1>" with "</b></font><p></p>" in pData
replace "<h2>" with "<b><font size=16 color=#404040>" in pData
replace "</h2>" with "</b></font>" in pData
replace "<h3>" with "<font size=14 color=#404040>" in pData
replace "</h3>" with "</font>" in pData
replace "<important>" with "<b><font size=14 color=#404040>" in pData
replace "</important>" with "</font></b>" in pData
put the scriptTextSize into tSize
if tSize = "" then put 12 into tSize
put the scriptTextFont into tFont
if tFont = "" then
if the platform = "MacOS" and char 1 of the systemVersion = 1 then
put "Courier" into tFont
else
put "Courier New" into tFont
end if
end if
replace "<code>" with "<font face=""e&tFont"e&" size="&tSize&" >" in pData
replace "</code>" with "</font>" in pData
return pData
end xmlToHTML
function parseLinks tData
local tStart,tEnd,tLinkText,tID,tReplaceTag
repeat for 1000 -- enough to loop, but not "forever" in case I get stuck
get matchChunk(tData,"(?si)(<docRef.*?</docRef>)",tStart,tEnd)
if it is true then
put char (tStart) to (tEnd) of tData into tLinkText
put revCreateXMLTree(tLinkText,true,true,false) into tID
if "xmlerr" is in the result then
replace "docRef" with "dummy" in tLinkText
put tLinkText into tReplaceTag
else
put "<a href=" "e& revXMLAttribute(tID,"/docRef","src") "e& ">" & revXMLNodeContents(tID,"/docRef") & "</a>" into tReplaceTag
end if
revDeleteXMLTree tID
put tReplaceTag into char tStart to tEnd of tData
else
exit repeat
end if
end repeat
return tData
end parseLinks
constant kFromEdge = 3
constant kStatusBar = 21
constant kToolBar = 45
on resizeStack pWidth,pHeight
lock screen
lock messages
if the hilite of btn "Show mouse over text" then
set the rect of fld "doc" to the right of btn "resizer",kToolBar,pWidth-kFromEdge,pHeight-kStatusBar-the height of fld "mouseover"-kFromEdge
else
set the rect of fld "doc" to the right of btn "resizer",kToolBar,pWidth-kFromEdge,pHeight-kStatusBar
end if
set the rect of fld "mouseover" to the right of btn "resizer",pHeight-kStatusBar-the height of fld "mouseover",pWidth-kFromEdge,pHeight-kStatusBar
set the rect of fld "List" to kFromEdge,kToolBar+kStatusBar+kFromEdge,the left of btn "resizer",pHeight-kStatusBar
set the rect of fld "Find" to 105,kToolBar,the left of btn "resizer"-kFromEdge-the width of btn "go",kToolBar+kStatusBar
set the loc of btn "go" to the left of btn "resizer"-(the width of btn "go" div 2),item 2 of the loc of btn "go"
set the rect of btn "resizer" to the left of btn "resizer",kToolBar,the right of btn "resizer",pHeight-kStatusBar
set the top of btn "Show mouse over text" to pHeight-kStatusBar
set the top of btn "Download and show web notes" to pHeight-kStatusBar
set the top of fld "status" to pHeight-kStatusBar
unlock messages
unlock screen
end resizeStack
on popupAction pMenuPick
local tName,tBookmarks,tID,tSection
set the itemDel to "|"
switch
case pMenuPick= "Open linked document in a new window"
revDocsGoDoc the uLink of btn "linkPopup"
break
case pMenuPick = "Add to bookmarks section|New bookmarks section"
ask question "What is the name of your new bookmarks section?" titled "New Bookmarks Section" as sheet
if the result is "cancel" or it is empty then exit to top
put it into tName
put bookmarksFile() into tBookmarks
if there is a file tBookmarks then
put revCreateXMLTreeFromFile(tBookmarks,true,true,false) into tID
repeat for each line tRef in revXMLChildNames(tID,"/index",cr,,true)
if tName = revXMLAttribute(tID,"/index/"&tRef,"name") then
answer information "There is already a bookmarks section with that name" as sheet
exit to top
end if
end repeat
put "<section name=""e&tName"e&"><docRef src=""e&the uLink of btn "linkPopup""e&">"&the uText of btn "linkPopup"&"</docRef></section>" into tSection
revAppendXML tID,"/index",tSection
put revXMLText(tID) into url ("file:"&tBookmarks)
revDeleteXMLTree tID
else
put "<index><section name=""e&tName"e&"><docRef src=""e&the uLink of btn "linkPopup""e&">"&the uText of btn "linkPopup"&"</docRef></section></index>" into tSection
put tSection into url ("file:"&tBookmarks)
end if
if the textStyle of btn "Bookmarks" = "bold" then goIndex "Bookmarks"
break
case item 1 of pMenuPick = "Add to bookmarks section"
put bookmarksFile() into tBookmarks
if there is a file tBookmarks then
put revCreateXMLTreeFromFile(tBookmarks,true,true,false) into tID
repeat for each line tRef in revXMLChildNames(tID,"/index",cr,,true)
if item 2 to -1 of pMenuPick = revXMLAttribute(tID,"/index/"&tRef,"name") then
revAddXMLNode tID,"/index/"&tRef,"docRef",the uText of btn "linkPopup"
revSetXMLAttribute tID,the result,"src",the uLink of btn "linkPopup"
end if
end repeat
put revXMLText(tID) into url ("file:"&tBookmarks)
revDeleteXMLTree tID
end if
if the textStyle of btn "Bookmarks" = "bold" then goIndex "Bookmarks"
break
case pMenuPick = "Delete from bookmarks"
put bookmarksFile() into tBookmarks
if there is a file tBookmarks then
put revCreateXMLTreeFromFile(tBookmarks,true,true,false) into tID
repeat for each line tSection in revXMLChildNames(tID,"/index",cr,,true)
repeat for each line tRef in revXMLChildNames(tID,"/index/"&tSection,cr,,true)
if the uLink of btn "linkPopup" = revXMLAttribute(tID,"/index/"&tSection&"/"&tRef,"src") then
revDeleteXMLNode tID,"/index/"&tSection&"/"&tRef
end if
end repeat
end repeat
put revXMLText(tID) into url ("file:"&tBookmarks)
revDeleteXMLTree tID
end if
if the textStyle of btn "Bookmarks" = "bold" then goIndex "Bookmarks"
break
default
goDoc the uRelatedLinks[item 2 to -1 of pMenuPick] of btn "linkPopup"
end switch
end popupAction
-- ----------------------------------
-- handlers for glossary highlighting
-- ----------------------------------
on highlightLink currentMouseChunk
local tText
-- set cursor to hand over hypertext phrases, I-beam over Find field, arrow otherwise
-- highlight hypertext phrases (if they're not Transcript terms or URLs)
--if char 1 to 7 of the short name of this stack is not "revDocs" then exit revDocsHighlight
if currentMouseChunk is empty then put the mouseChunk into currentMouseChunk
global gRevHelpHiliteColor
-- first unhighlight the "old" phrase if necessary
clearHighlight
-- check where we are to see the desired state of the cursor
if the mouseStack is not the short name of this stack then
lock cursor
else -- within the stack's rect
if currentMouseChunk is empty then -- not over a field
lock cursor
set the cursor to arrow
else -- over a field
if the lockText of the mouseControl is false then exit highlightLink
if the mouse is down then exit highlightLink -- don't hilite when dragging
put the linkText of currentMouseChunk into tText
if tText <> "" then -- over hypertext
set the storedHilitedChunk of this stack to currentMouseChunk -- save for later unhighlighting
if the foregroundColor of currentMouseChunk <> gRevHelpHiliteColor then
put the foregroundColor of currentMouseChunk into sOldColor
end if
set the foregroundColor of currentMouseChunk to gRevHelpHiliteColor
mouseOverDoc the linkText of currentMouseChunk
if "glossary/" is not in tText or not the hilite of btn "Show mouse over text" then
set the cursor to hand
end if
else -- not over hypertext
set the cursor to arrow
end if
end if
end if
end highlightLink
on clearHighlight
if the storedHilitedChunk of this stack is not empty then
if sOldColor <> "" then
do "set the foregroundColor of" && (the storedHilitedChunk of this stack) && "to "&sOldColor
else
do "set the foregroundColor of" && (the storedHilitedChunk of this stack) && "to empty"
end if
set the storedHilitedChunk of this stack to empty
end if
if the mouseStack is not the short name of this stack then unlock cursor
end clearHighlight
function bookmarksFile
local tPath
switch the platform
case "MacOS"
put specialFolderPath("preferences") into tPath
break
case "Win32"
put specialFolderPath(26) into tPath
break
default
put $HOME into tPath
end switch
put "/Revolution" after tPath
if there is not a folder tPath then create folder tPath
return tPath&"/docsbookmarks.xml"
end bookmarksFile
on goIndex pIndex
local tFolder,tFile
if pIndex = "Getting Started" then
go cd "Getting Started"
else
go cd "Welcome to revolution"
put the uDocsFolder of this stack into tFolder
switch pIndex
case "Objects"
set the XMLstring of this stack to url ("file:"&tFolder&"/objects.xml")
break
case "FAQ"
set the XMLstring of this stack to url ("file:"&tFolder&"/faq.xml")
break
case "Dictionary"
--set the htmlText of fld "List" to the uDictionaryList of this stack
break
case "Topics"
set the XMLstring of this stack to url ("file:"&tFolder&"/topics.xml")
break
case "Bookmarks"
put bookmarksFile() into tFile
if there is a file tFile then
set the XMLstring of this stack to url ("file:"&tFile)
else
set the XMLstring of this stack to "<index></index>"
end if
break
end switch
if the label of btn "filter type" = "Search for:" then put "" into fld "find"
send "mouseUp" to btn "go"
end if
end goIndex
function docFileName pData
replace ":" with "colon" in pData
replace "\" with "backslash" in pData
replace "/" with "slash" in pData
replace " " with "_" in pData
replace ">" with "gt" in pData
replace "<" with "lt" in pData
replace "*" with "asterisk" in pData
replace "&" with "amp" in pData
replace "?" with "" in pData
replace "+" with "plus" in pData
replace "-" with "dash" in pData
replace "@" with "at" in pData
replace "=" with "equals" in pData
replace ";" with "semicolon" in pData
--replace "," with "comma" in pData
return char 1 to 27 of pData
end docFileName
--workaround for xml issue
on OpenStack
put the effective filename of stack home into tFilePath
put matchText(tFilePath,"^[ -~]+$") into tMatch
if tMatch is false then
answer info "The documentation will not work correctly because you have located it in a directory that contains non English characters somewhere in its name. This is a known issue that will be fixed shortly. In the mean time, please move your installation or rename the directory(s) involved to use the documentation."
end if
pass OpenStack
end OpenStack
Apply Patch epon mouseUp local tCurPath,tSavePath,tFileType,tNewStackScript,tNewCardScript,tPrompt ----- set the cursor to watch ----- saving current docs: put revDocsPath() into tCurPath -- C put tCurPath into tSavePath set the itemDel to slash put "revdocumentation old.rev" into item -1 of tSavePath if the platform = "MacOS" then put the fileType into tFileType set the fileType to "revoRSTK" end if put url("binfile:" & tCurPath) into url("binfile:" & tSavePath) put the result if the platform = "MacOS" then set the fileType to tFileType ------ preparing: put the script of btn "NewStackScript" into tNewStackScript put the script of btn "NewCardScript" into tNewCardScript copy btn "Box" if tCurPath is among the lines of the stacks then close stack tCurPath lock messages set the cantModify of stack tCurPath to false set the botright of stack tCurPath to "-10,-10" ----- modifying: go to cd "getting started" of stack tCurPath paste choose browse tool set the left of last btn to 2 set the script of this cd to tNewCardScript set the script of this stack to tNewStackScript send "resizeStack" to this cd set the cantModify of stack tCurPath to true save stack tCurPath close stack tCurPath ----- cleaning up: disable the target unlock messages put "Rev Docs enhancer has been applied succesfully.
" & cr \ & "You might need to resize Docs window in order to refresh it and display the check box.
" \ & cr & "To ensure the security, a copy of your previous Revolution Documentation has been saved as
" & tSavePath & ".
" into tPrompt replace cr with cr & "" & cr in tPrompt answer info tPrompt ----- opening the docs: go stack tCurPath end mouseUp Kd !Enhance Revolution Documentation cREVGeneral scriptChecksum O