Changeset 6929
- Timestamp:
- 12/20/06 22:40:10 (2 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 7 modified
-
buildscripts/build.xml (modified) (1 diff)
-
buildscripts/buildUtil.js (modified) (1 diff)
-
buildscripts/buildUtil.py (modified) (1 diff)
-
buildscripts/internStrings.js (added)
-
src/uri/cache.js (added)
-
src/widget/DomWidget.js (modified) (3 diffs)
-
src/widget/Editor2.js (modified) (3 diffs)
-
src/widget/Editor2Plugin/DropDownList.js (modified) (4 diffs)
-
src/widget/Editor2Plugin/FindReplace.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/buildscripts/build.xml
r6924 r6929 813 813 ]]> 814 814 </script> 815 <script language="jython"> 816 <![CDATA[ 817 import sys 818 # make the python standard library avialable 819 sys.path.append(project.resolveFile("lib/pyLib.zip").getPath()) 820 sys.path.append(project.resolveFile(".").getPath()) 821 822 # import re 823 import os 824 from buildUtil import * 825 826 print "Interning strings for directory: " + dojo.getProperty("release_dir") 827 internTemplateStrings(project.resolveFile(dojo.getProperty("profileFile")).getPath(), dojo.getProperty("dojoLoader"), project.resolveFile(dojo.getProperty("release_dir")).getPath()) 828 ]]> 829 </script> 815 816 <java jar="./lib/custom_rhino.jar" failonerror="true" fork="true" 817 logError="true"> 818 <arg value="internStrings.js" /> 819 <arg value="${profileFile}" /> 820 <arg value="${dojoLoader}" /> 821 <arg value="${release_dir}" /> 822 </java> 830 823 </target> 831 824 <!-- end intern-strings task --> -
trunk/buildscripts/buildUtil.js
r6847 r6929 196 196 } 197 197 198 199 buildUtil.getPrefixesFromProfile = function(profileFile){ 200 //summary: Load the profile file to get resource paths for external modules. 198 buildUtil.getDependencyPropertyFromProfile = function(/*String*/profileFile, /*String*/propName){ 199 //summary: Gets a dependencies property from the profile file. The value 200 //of the property is assumed to be an array. An array will always be returned, 201 //but it may be an empty array. 202 201 203 //Use new String to make sure we have a JS string (not a Java string) 202 204 //readText is from hostenv_rhino.js, so be sure to load Dojo before calling this function. 203 205 var profileText = new String(readText(profileFile)); 204 var result = null;205 206 //Extract only dependencies.prefixes.207 var dependencies = {208 prefixes: []209 };210 211 206 //Get rid of CR and LFs since they seem to mess with the regexp match. 212 207 //Using the "m" option on the regexp was not enough. 213 208 profileText = profileText.replace(/\r/g, ""); 214 209 profileText = profileText.replace(/\n/g, ""); 215 216 var matches = profileText.match(/(dependencies\.prefixes\s*=\s*\[.*\]\s*\;)/m); 210 211 212 var result = []; 213 var matchRegExp = new RegExp("(dependencies\\." + propName + "\\s*=\\s*\\[[^;]*\\s*\\])", "m"); 214 215 var matches = profileText.match(matchRegExp); 216 //Create a shell object to hold the evaled properties. 217 var dependencies = {}; 218 217 219 if(matches && matches.length > 0){ 218 220 eval(matches[0]); 219 if(dependencies && dependencies .prefixes && dependencies.prefixes.length > 0){220 result = dependencies .prefixes;221 } 222 } 223 224 return result; //Array of arrays221 if(dependencies && dependencies[propName] && dependencies[propName].length > 0){ 222 result = dependencies[propName]; 223 } 224 } 225 226 return result; //Array 225 227 } 226 228 227 229 buildUtil.configPrefixes = function(profileFile){ 228 230 //summary: Get the resource prefixes from the profile and registers the prefixes with Dojo. 229 var prefixes = this.get PrefixesFromProfile(profileFile);231 var prefixes = this.getDependencyPropertyFromProfile(profileFile, "prefixes"); 230 232 if(prefixes && prefixes.length > 0){ 231 233 for(i = 0; i < prefixes.length; i++){ -
trunk/buildscripts/buildUtil.py
r6590 r6929 10 10 import glob 11 11 import string 12 13 def escape(instr):14 out = []15 for x in xrange(len(instr)):16 if instr[x] == "\\":17 out.append("\\\\")18 elif instr[x] == "\n":19 out.append("\\n")20 elif instr[x] == "\"":21 out.append("\\\"")22 else:23 out.append(instr[x])24 return string.join(out, "")25 26 def makeResourceUri(resourceName, templatePath, srcRoot, prefixes):27 # Find best matching prefix.28 bestPrefix = ""29 bestPrefixPath = ""30 if prefixes:31 for prefix in prefixes:32 # Prefix must match from the start of the resourceName string.33 if resourceName.find(prefix[0]) == 0:34 if len(prefix[0]) > len(bestPrefix):35 bestPrefix = prefix[0]36 bestPrefixPath = prefix[1]37 38 if bestPrefixPath != "":39 # Convert resourceName to a path40 resourceName = resourceName.replace(bestPrefix, "", 1);41 if resourceName.find(".") == 0:42 resourceName = resourceName[1:len(resourceName)]43 resourceName = resourceName.replace(".", "/");44 45 # Final path construction46 finalPath = srcRoot47 finalPath += bestPrefixPath + "/"48 if resourceName:49 finalPath += resourceName + "/"50 finalPath += templatePath51 52 return finalPath53 54 return srcRoot + templatePath55 56 def regexpMagic(loader, pkgString, srcRoot, prefixes, skiplist=[]):57 uriMethod = "dojo.uri.dojoUri"58 #if loader == "xdomain":59 # uriMethod = "dojo.uri.dojoUriXd"60 # "Now they have two problems" -- jwz61 # http://en.wikiquote.org/wiki/Jamie_Zawinski62 matches = re.findall('((templatePath|templateCssPath)\s*(=|:)\s*(dojo\.uri\.(dojo|module)?Uri\(\s*)?[\"\']([\w\.\/]+)[\"\'](([\,\s]*)[\"\']([\w\.\/]*)[\"\'])?(\s*\))?)', pkgString)63 filePath = ""64 for x in matches:65 # Build file path66 if x[4] == "dojo":67 print "Dojo match: " + x[5]68 filePath = srcRoot + x[5]69 resourceNsName = "dojo:"+x[5];70 else:71 print "Module match: " + x[5] + " and " + x[8]72 filePath = makeResourceUri(x[5], x[8], srcRoot, prefixes)73 resourceNsName = x[5]+':'+x[8]74 75 if resourceNsName in skiplist:76 print "Skip intern resource " + filePath77 continue78 79 print "Interning resource path: " + filePath80 81 if x[1] == "templatePath":82 # Replace templatePaths83 replacement = "templateString" + x[2] + "\"" + escape(open(filePath).read()) + "\""84 pkgString = string.replace(pkgString, x[0], replacement)85 else:86 # Dealing with templateCssPath87 # For the CSS we need to keep the template path in there88 # since the widget loading stuff uses the template path to89 # know whether the CSS has been processed yet.90 # Could have matched assignment via : or =. Need different statement separators at the end.91 assignSeparator = x[2]92 statementSeparator = ","93 statementPrefix = ""94 95 # FIXME: this is a little weak because it assumes a "this" in front of the templateCssPath96 # when it is assigned using an "=", as in 'this.templateCssPath = dojo.uri.dojoUri("some/path/to/Css.css");'97 # In theory it could be something else, but in practice it is not, and it gets a little too weird98 # to figure out, at least for now.99 if assignSeparator == "=":100 statementSeparator = ";"101 statementPrefix = "this."102 103 replacement = "templateCssString" + assignSeparator + "\"" + escape(open(filePath).read()) + "\"" + statementSeparator + statementPrefix + x[0]104 pkgString = string.replace(pkgString, x[0], replacement)105 106 return pkgString107 108 def internTemplateStringsInFile(loader, packageFile, srcRoot, prefixes, skiplist):109 print packageFile110 pfd = open(packageFile)111 pkgString = pfd.read()112 pfd.close()113 114 pkgString = regexpMagic(loader, pkgString, srcRoot, prefixes, skiplist)115 116 pfd = open(packageFile, "w")117 pfd.write(pkgString)118 pfd.close() # flush is implicit119 120 121 def internXdFiles(loader, xdDir, srcRoot, prefixes, skiplist):122 xdFiles = glob.glob1(xdDir, "*.xd.js")123 for name in xdFiles:124 print "XD INTERNING: " + name125 internTemplateStringsInFile(loader, xdDir+os.sep+name, srcRoot, prefixes, skiplist)126 127 128 def internTemplateStrings(profileFile, loader="default", packageDir="../release/dojo", srcRoot="../"):129 #Fix up dojo.js130 print "loader: " + loader131 print "packageDir - " + packageDir132 packageFile = packageDir+"/dojo.js"133 134 135 #Load the profile file so we can get module prefixes.136 pfd = open(profileFile)137 profileString = pfd.read()138 pfd.close()139 140 # Parse out the module prefixes and build a python list of lists object.141 compiledRe = re.compile('(dependencies\.prefixes\s*=\s*(\[\s*([^;]*)\s*\]))', re.DOTALL | re.MULTILINE)142 matches = compiledRe.findall(profileString)143 144 if matches:145 exec("prefixes = " + matches[0][1])146 print "Using the following prefixes: "147 print prefixes148 else:149 prefixes = []150 151 skiplistRe = re.compile('(dependencies\.internSkipList\s*=\s*(\[\s*([^;]*)\s*\]))', re.DOTALL | re.MULTILINE)152 matches = skiplistRe.findall(profileString)153 154 if matches:155 exec("skiplist = " + matches[0][1])156 print "Using the following skip list: "157 print skiplist158 else:159 skiplist = []160 #try:161 internTemplateStringsInFile(loader, packageFile, srcRoot, prefixes, skiplist)162 #except:163 # packageFile = packageDir+"/__package__.js"164 # internTemplateStringsInFile(loader, packageFile, srcRoot)165 166 #If doing xdomain, then need to fix up the .xd.js files in the widget subdir.167 #Hack alert! I am not patient enough to figure out how to do dir recursion168 #in python right now.169 internXdFiles(loader, packageDir+"/src/widget", srcRoot, prefixes, skiplist)170 internXdFiles(loader, packageDir+"/src/widget/html", srcRoot, prefixes, skiplist)171 internXdFiles(loader, packageDir+"/src/widget/svg", srcRoot, prefixes, skiplist)172 internXdFiles(loader, packageDir+"/src/widget/vml", srcRoot, prefixes, skiplist)173 174 12 175 13 def replaceVersion(fileName, version): -
trunk/src/widget/DomWidget.js
r6794 r6929 55 55 } 56 56 } 57 57 58 if((!obj.templateString)&&(!avoidCache)){ 58 59 obj.templateString = templateString || ts["string"]; 59 60 } 61 if(obj.templateString){ 62 obj.templateString = this._sanitizeTemplateString(obj.templateString); 63 } 64 60 65 if((!obj.templateNode)&&(!avoidCache)){ 61 66 obj.templateNode = ts["node"]; … … 64 69 // fetch a text fragment and assign it to templateString 65 70 // NOTE: we rely on blocking IO here! 66 var tstring = dojo.hostenv.getText(tpath); 67 if(tstring){ 68 // strip <?xml ...?> declarations so that external SVG and XML 69 // documents can be added to a document without worry 70 tstring = tstring.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, ""); 71 var matches = tstring.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); 72 if(matches){ 73 tstring = matches[1]; 74 } 75 }else{ 76 tstring = ""; 77 } 71 var tstring = this._sanitizeTemplateString(dojo.hostenv.getText(tpath)); 78 72 79 73 obj.templateString = tstring; … … 86 80 } 87 81 } 82 83 dojo.widget._sanitizeTemplateString = function(/*String*/tString){ 84 //summary: Strips <?xml ...?> declarations so that external SVG and XML 85 //documents can be added to a document without worry. Also, if the string 86 //is an HTML document, only the part inside the body tag is returned. 87 if(tString){ 88 tString = tString.replace(/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im, ""); 89 var matches = tString.match(/<body[^>]*>\s*([\s\S]+)\s*<\/body>/im); 90 if(matches){ 91 tString = matches[1]; 92 } 93 }else{ 94 tString = ""; 95 } 96 return tString; //String 97 } 98 88 99 dojo.widget._templateCache.dummyCount = 0; 89 100 -
trunk/src/widget/Editor2.js
r6773 r6929 5 5 dojo.require("dojo.widget.Editor2Toolbar"); 6 6 dojo.require("dojo.i18n.common"); 7 dojo.require("dojo.uri.cache"); 7 8 dojo.requireLocalization("dojo.widget", "Editor2"); 8 9 dojo.requireLocalization("dojo.widget", "Editor2BrowserCommand"); … … 206 207 // toolbarTemplatePath: dojo.uri.Uri 207 208 // to specify the template file for the toolbar 208 toolbarTemplatePath: dojo.uri. dojoUri("src/widget/templates/EditorToolbarOneline.html"),209 toolbarTemplatePath: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/EditorToolbarOneline.html")), 209 210 210 211 // toolbarTemplateCssPath: dojo.uri.Uri 211 212 // to specify the css file for the toolbar 212 toolbarTemplateCssPath: dojo.uri. dojoUri("src/widget/templates/EditorToolbar.css"),213 toolbarTemplateCssPath: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/EditorToolbar.css")), 213 214 214 215 // toolbarPlaceHolder: String 215 216 // element id to specify where to attach the toolbar 216 217 toolbarPlaceHolder: '', 217 218 // toolbarTemplatePath: dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbarFCKStyle.html"),219 // toolbarTemplateCssPath: dojo.uri.dojoUri("src/widget/templates/Editor2/FCKDefault/EditorToolbarFCKStyle.css"),220 218 221 219 _inSourceMode: false, … … 260 258 if(!this.toolbarWidget){ 261 259 var tbOpts = {shareGroup: this.toolbarGroup, parent: this, lang: this.lang}; 262 tbOpts.template Path = this.toolbarTemplatePath;260 tbOpts.templateString = dojo.uri.cache.get(this.toolbarTemplatePath); 263 261 if(this.toolbarTemplateCssPath){ 264 262 tbOpts.templateCssPath = this.toolbarTemplateCssPath; 263 tbOpts.templateCssString = dojo.uri.cache.get(this.toolbarTemplateCssPath); 265 264 } 266 265 if(this.toolbarPlaceHolder){ -
trunk/src/widget/Editor2Plugin/DropDownList.js
r6588 r6929 51 51 this._contentPane = dojo.widget.createWidget("ContentPane", {preload: 'true'}); 52 52 this._contentPane.addOnLoad(this, "setup"); 53 this._contentPane.set Url(this.href);53 this._contentPane.setContent(dojo.uri.cache.get(this.href)); 54 54 } 55 55 }, … … 101 101 // summary: dojo.widget.Editor2ToolbarFormatBlockSelect is an improved format block setting item 102 102 103 href: dojo.uri. dojoUri("src/widget/templates/Editor2/EditorToolbar_FormatBlock.html"),103 href: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FormatBlock.html")), 104 104 105 105 setup: function(){ … … 172 172 // summary: dojo.widget.Editor2ToolbarFontSizeSelect provides a dropdown list for setting fontsize 173 173 174 href: dojo.uri. dojoUri("src/widget/templates/Editor2/EditorToolbar_FontSize.html"),174 href: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontSize.html")), 175 175 176 176 setup: function(){ … … 240 240 dojo.declare("dojo.widget.Editor2ToolbarFontNameSelect", dojo.widget.Editor2ToolbarFontSizeSelect, { 241 241 // summary: dojo.widget.Editor2ToolbarFontNameSelect provides a dropdown list for setting fontname 242 href: dojo.uri. dojoUri("src/widget/templates/Editor2/EditorToolbar_FontName.html")243 }); 242 href: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/Editor2/EditorToolbar_FontName.html")) 243 }); -
trunk/src/widget/Editor2Plugin/FindReplace.js
r6608 r6929 51 51 {contentFile: "dojo.widget.Editor2Plugin.FindReplaceDialog", 52 52 contentClass: "Editor2ReplaceDialog", 53 href: dojo.uri. dojoUri("src/widget/templates/Editor2/Dialog/replace.html"),53 href: dojo.uri.cache.allow(dojo.uri.dojoUri("src/widget/templates/Editor2/Dialog/replace.html")), 54 54 title: "Replace", width: "350px", height: "200px", modal: false}); 55 55 }