|
From: creedon <icr...@us...> - 2005-09-08 17:46:12
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/html/utilities In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22460 Modified Files: buildMCF Log Message: changed UserLand Frontier to Frontier Index: buildMCF =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/html/utilities/buildMCF,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** buildMCF 26 Mar 2005 19:43:16 -0000 1.1.1.1 --- buildMCF 8 Sep 2005 17:46:02 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.html.utilities.buildMCF ! on buildMCF (folder, url, f, sitename, author=user.name, org=user.organization, email=user.mailaddress, filter=@defaultFilter) { ÇWed, Dec 25, 1996 at 8:08:38 AM by DW ÇDerived from Jim Correia's MCFGenerator suite. ÇI'll list changes I make on the change notes page. ÇThu, Dec 26, 1996 at 9:57:32 PM by JimC Çremoved remaning dependencies on MCFGenerator suite - uses the 4.2 html.getOneTagValue Çincorporated Guha's suggestions about the generated MCF Çadded the email parameter Çadded the filter paramter ( gives users more control over what files are included in the mcf ) Çthis is the default filter - only includes .html files in the resulting mcf on defaultFilter(f) { if file.isFolder(f) { return true}; if ( f endsWith ".html" ) { msg (file.fileFromPath (f)); return true}; return false}; Çthis is the filter that is used if someone passes in nil - everything is included on nilFilter(f) { msg (file.fileFromPath (f)); return true}; Çthis function does all the work on generateFileStructureMCF (baseFolder,outputFile,siteURL,siteName,authorName="",orgName="",mailAddress="",fileFilter) { local { mcfText = ""}; if ( ! (siteURL endsWith "/" ) ) { siteURL = siteURL + "/"}; Çutility methods on add(s) { mcfText = mcfText + s + cr}; on addAuthor() { Çif (authorName!="") Çadd("author_individual_name: \"" + authorName + "\"") if ((authorName!="")&&(mailAddress!="")) { add("authorIndividual: #\"" + mailAddress + "\"")}}; on addOrganization() { Çif (orgName!="") Çadd("author_organization_name: \"" + orgName + "\"") if (orgName!="") { add("authorOrganization: #\"" + orgName + "\"")}}; on addFileInfo(f) { add("firstPublicationDate: \"" + date.shortString(file.created(f)) + "\""); add("lastRevisionDate: \"" + date.shortString(file.modified(f)) + "\""); add("size: \"" + file.size(f) + "\"")}; bundle { Çadd the file header information Çadd("begin-headers:\rMCFVersion: 1.0\rname: \"" + siteName + "\"\rend-headers:") add(";This MCF File was generated by Userland Frontier 4.2 Mac -" + clock.now()); Çadd(";Script by Jim Correia <pmt...@um...> and Dave Winer <dw...@we...>.") add(""); add("begin-headers:"); add("MCFVersion: 1.0"); add("name: \"" + siteName + "\""); add("typeOf: #\"TableOfContents\""); add("tocOf: \"" + siteURL + "\""); add("end-headers:"); add(""); bundle { Ç add an author tag if ((authorName!="")&&(mailAddress!="")) { add("unit: \"" + mailAddress + "\""); add("name: \"" + authorName + "\""); add("typeOf: #\"person\""); add("emailAddress: \"" + mailAddress + "\""); add("")}}; bundle { Ç add an organization tag if (orgName!="") { add("unit: \"" + orgName + "\""); add("name: \"" + orgName + "\""); add("typeOf:#\"Organization\""); add("")}}}; on ProcessFolder(theFolder,parentgenls="",topmostfolder=false) { rollBeachBall(); local ( genls="" ); if ( topmostfolder==false ) { genls = string(theFolder) - string(baseFolder); Çgenls = string.replaceAll(genls,":","/") - "/" genls = string.replaceAll(genls,":","/"); Çgenls = (siteURL - "http://") + (genls) + ".mco" genls = (siteURL - "http://") + (genls); add( "unit: \"" + genls + "\""); add( "name: \"" + ( file.fileFromPath(theFolder) - ":") + "\""); add( "typeOf: #\"SubjectCategory\"" ); addAuthor(); addOrganization(); if ( parentgenls!="" ) { Çadd( "genls: \"" + parentgenls + "\"") add( "parent: #\"" + parentgenls + "\"")}; add("")}; local ( f ); fileloop( f in theFolder ) { if ( fileFilter^(f) ) { if ( file.isFolder(f) ) { ProcessFolder(f,genls)} else { ProcessFile(f,genls)}}}}; on ProcessFile(theFile,thegenls) { Çif ( ! (theFile endsWith ".html") ) Çreturn Çmoved into the default filters rollBeachBall(); local ( s ); s = theFile - baseFolder; s = string.replaceAll(s,":","/"); add( "unit: \"" + siteURL + s + "\""); local ( theTitle = html.getOneTagValue( string(file.readWholeFile(f)), "title") ); if ( theTitle == "" ) { theTitle = file.fileFromPath(f)}; add( "name: \"" + theTitle + "\""); addAuthor(); addOrganization(); addFileInfo(f); if ( thegenls!="" ) { Çadd( "genls: \"" + thegenls + "\"") add( "parent: #\"" + thegenls + "\"")}; add("")}; ProcessFolder(baseFolder,"",true); msg ("Writing file..."); file.writeWholeFile(outputFile, mcfText, 'TEXT', 'R*ch', clock.now()); msg (""); return true}; if ( filter == nil ) { filter = @nilFilter}; return (generateFileStructureMCF (folder, f, url, sitename, author, org, email, filter))}; Çbundle Çtest code Çlocal (folder = "internal:apps:webstar:frontier:") Çlocal (url = "http://www.scripting.com/frontier/") Çlocal (f = folder + "siteMap.mcf") ÇbuildMCF (folder, url, f, "Frontier") Çbundle ÇÊmore test code Çhtml.utilities.buildMCF ("Touch of Grey:WebSite:", "http://tango.mth.umassd.edu/correia/", "Touch of Grey:WebSite:root.mcf", "JimC") \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.html.utilities.buildMCF ! on buildMCF (folder, url, f, sitename, author=user.name, org=user.organization, email=user.mailaddress, filter=@defaultFilter) { ÇChanges Ç9/8/05; 10:36:21 AM by TAC Çchanged UserLand Frontier to Froniter Ç12/25/96; 8:08:38 AM by DW ÇDerived from Jim Correia's MCFGenerator suite. ÇI'll list changes I make on the change notes page. Ç12/26/96; 9:57:32 PM by JimC Çremoved remaning dependencies on MCFGenerator suite - uses the 4.2 html.getOneTagValue Çincorporated Guha's suggestions about the generated MCF Çadded the email parameter Çadded the filter paramter ( gives users more control over what files are included in the mcf ) Çthis is the default filter - only includes .html files in the resulting mcf on defaultFilter(f) { if file.isFolder(f) { return true}; if ( f endsWith ".html" ) { msg (file.fileFromPath (f)); return true}; return false}; Çthis is the filter that is used if someone passes in nil - everything is included on nilFilter(f) { msg (file.fileFromPath (f)); return true}; Çthis function does all the work on generateFileStructureMCF (baseFolder,outputFile,siteURL,siteName,authorName="",orgName="",mailAddress="",fileFilter) { local { mcfText = ""}; if ( ! (siteURL endsWith "/" ) ) { siteURL = siteURL + "/"}; Çutility methods on add(s) { mcfText = mcfText + s + cr}; on addAuthor() { Çif (authorName!="") Çadd("author_individual_name: \"" + authorName + "\"") if ((authorName!="")&&(mailAddress!="")) { add("authorIndividual: #\"" + mailAddress + "\"")}}; on addOrganization() { Çif (orgName!="") Çadd("author_organization_name: \"" + orgName + "\"") if (orgName!="") { add("authorOrganization: #\"" + orgName + "\"")}}; on addFileInfo(f) { add("firstPublicationDate: \"" + date.shortString(file.created(f)) + "\""); add("lastRevisionDate: \"" + date.shortString(file.modified(f)) + "\""); add("size: \"" + file.size(f) + "\"")}; bundle { Çadd the file header information Çadd("begin-headers:\rMCFVersion: 1.0\rname: \"" + siteName + "\"\rend-headers:") add(";This MCF File was generated by Frontier 4.2 Mac -" + clock.now()); Çadd(";Script by Jim Correia <pmt...@um...> and Dave Winer <dw...@we...>.") add(""); add("begin-headers:"); add("MCFVersion: 1.0"); add("name: \"" + siteName + "\""); add("typeOf: #\"TableOfContents\""); add("tocOf: \"" + siteURL + "\""); add("end-headers:"); add(""); bundle { Ç add an author tag if ((authorName!="")&&(mailAddress!="")) { add("unit: \"" + mailAddress + "\""); add("name: \"" + authorName + "\""); add("typeOf: #\"person\""); add("emailAddress: \"" + mailAddress + "\""); add("")}}; bundle { Ç add an organization tag if (orgName!="") { add("unit: \"" + orgName + "\""); add("name: \"" + orgName + "\""); add("typeOf:#\"Organization\""); add("")}}}; on ProcessFolder(theFolder,parentgenls="",topmostfolder=false) { rollBeachBall(); local ( genls="" ); if ( topmostfolder==false ) { genls = string(theFolder) - string(baseFolder); Çgenls = string.replaceAll(genls,":","/") - "/" genls = string.replaceAll(genls,":","/"); Çgenls = (siteURL - "http://") + (genls) + ".mco" genls = (siteURL - "http://") + (genls); add( "unit: \"" + genls + "\""); add( "name: \"" + ( file.fileFromPath(theFolder) - ":") + "\""); add( "typeOf: #\"SubjectCategory\"" ); addAuthor(); addOrganization(); if ( parentgenls!="" ) { Çadd( "genls: \"" + parentgenls + "\"") add( "parent: #\"" + parentgenls + "\"")}; add("")}; local ( f ); fileloop( f in theFolder ) { if ( fileFilter^(f) ) { if ( file.isFolder(f) ) { ProcessFolder(f,genls)} else { ProcessFile(f,genls)}}}}; on ProcessFile(theFile,thegenls) { Çif ( ! (theFile endsWith ".html") ) Çreturn Çmoved into the default filters rollBeachBall(); local ( s ); s = theFile - baseFolder; s = string.replaceAll(s,":","/"); add( "unit: \"" + siteURL + s + "\""); local ( theTitle = html.getOneTagValue( string(file.readWholeFile(f)), "title") ); if ( theTitle == "" ) { theTitle = file.fileFromPath(f)}; add( "name: \"" + theTitle + "\""); addAuthor(); addOrganization(); addFileInfo(f); if ( thegenls!="" ) { Çadd( "genls: \"" + thegenls + "\"") add( "parent: #\"" + thegenls + "\"")}; add("")}; ProcessFolder(baseFolder,"",true); msg ("Writing file..."); file.writeWholeFile(outputFile, mcfText, 'TEXT', 'R*ch', clock.now()); msg (""); return true}; if ( filter == nil ) { filter = @nilFilter}; return (generateFileStructureMCF (folder, f, url, sitename, author, org, email, filter))}; Çbundle Çtest code Çlocal (folder = "internal:apps:webstar:frontier:") Çlocal (url = "http://www.scripting.com/frontier/") Çlocal (f = folder + "siteMap.mcf") ÇbuildMCF (folder, url, f, "Frontier") Çbundle ÇÊmore test code Çhtml.utilities.buildMCF ("Touch of Grey:WebSite:", "http://tango.mth.umassd.edu/correia/", "Touch of Grey:WebSite:root.mcf", "JimC") \ No newline at end of file |