Changeset 6570
- Timestamp:
- Oct 22, 2014, 7:55:46 AM (8 years ago)
- Location:
- branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib/Head.java
r6562 r6570 103 103 private static final Map<String, String> xtVersions = new HashMap<String, String>(); 104 104 105 // Match files under / extensions path. group 2is the JAR file name105 // Match files under /base-root/extensions path. group 1 is the JAR file name 106 106 private static final Pattern PATH_MATCH = 107 Pattern.compile("(" + ExtensionsControl.RESOURCES_URL + "/([^/]+)/(.*))"); 108 109 /** 110 Register the version for an exteniosn JAR file 107 Pattern.compile("/?[^/]*" + ExtensionsControl.RESOURCES_URL + "/([^/]+)/(.*)"); 108 109 /** 110 Register the version for an exteniosn JAR file. 111 Used for appending a query parameter to all scripts and style sheets 112 to prevent that browsers cache the old version. 113 @see #getVersionParameter(String) 111 114 @since 3.3.2 112 115 */ … … 119 122 } 120 123 124 /** 125 Get query parameter to the given absolute path (including root directory). 126 If the path points to a file in the /base-root/extensions/ directory the version 127 of the extension is used, otherwise the BASE version is used. The 128 returned parameter is of the form v=<version>. 129 @param absolutePath An absolute path with or without the base-root directory 130 @since 3.3.2 131 */ 132 public static final String getVersionParameter(String absolutePath) 133 { 134 Matcher m = PATH_MATCH.matcher(absolutePath); 135 String version = globalVersion; 136 if (m.matches()) 137 { 138 String jarFile = m.group(1); 139 if (xtVersions.containsKey(jarFile)) 140 { 141 version = xtVersions.get(jarFile); 142 } 143 } 144 return version; 145 } 146 147 121 148 /** 122 149 The parent <base:page> tag. … … 179 206 { 180 207 // Full absolute path 181 sb.append(style).append(pp).append(g lobalVersion);208 sb.append(style).append(pp).append(getVersionParameter(style)); 182 209 } 183 210 else if (style.startsWith("/")) 184 211 { 185 // Absolute path is relative the page root (eg. /foo/bar.css --> /base/foo/bar.css) 186 sb.append(appRoot).append(style.substring(1)).append(pp).append(globalVersion); 212 sb.append(appRoot).append(style.substring(1)).append(pp).append(getVersionParameter(style)); 187 213 } 188 214 else if (style.startsWith("~")) … … 229 255 { 230 256 // Full absolute path 231 sb.append(script).append(pp).append(g lobalVersion);257 sb.append(script).append(pp).append(getVersionParameter(script)); 232 258 } 233 259 else if (script.startsWith("/")) 234 260 { 235 261 // Absolute path that is relative the BASE root (eg. /foo/bar.js --> /base/foo/bar.js) 236 sb.append(appRoot).append(script.substring(1)).append(pp).append(g lobalVersion);262 sb.append(appRoot).append(script.substring(1)).append(pp).append(getVersionParameter(script)); 237 263 } 238 264 else if (script.startsWith("~")) … … 254 280 { 255 281 super.setPageContext(pageContext); 256 282 HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); 257 283 // If we are on /extension subpage, the localVersion is the 258 284 // version for the extension, otherwise we use the global version 259 localVersion = globalVersion; 260 HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); 261 Matcher m = PATH_MATCH.matcher(req.getServletPath()); 262 if (m.matches()) 263 { 264 String jarFile = m.group(2); 265 if (xtVersions.containsKey(jarFile)) 266 { 267 localVersion = xtVersions.get(jarFile); 268 } 269 } 285 localVersion = getVersionParameter(req.getServletPath()); 270 286 } 271 287 -
branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib/extensions/Scripts.java
r6134 r6570 34 34 35 35 import net.sf.basedb.clients.web.extensions.JspContext; 36 import net.sf.basedb.clients.web.taglib.Head; 36 37 37 38 /** … … 92 93 for (String script : scripts) 93 94 { 95 char pp = script.indexOf('?') == -1 ? '?' : '&'; 94 96 sb.append("<script type=\"text/javascript\" src=\""); 95 sb.append(script) ;97 sb.append(script).append(pp).append(Head.getVersionParameter(script)); 96 98 sb.append("\" charset=\"UTF-8\"></script>\n"); 97 99 } -
branches/3.3-stable/src/clients/web/net/sf/basedb/clients/web/taglib/extensions/Stylesheets.java
r5384 r6570 34 34 35 35 import net.sf.basedb.clients.web.extensions.JspContext; 36 import net.sf.basedb.clients.web.taglib.Head; 36 37 37 38 /** … … 93 94 for (String stylesheet : stylesheets) 94 95 { 96 char pp = stylesheet.indexOf('?') == -1 ? '?' : '&'; 95 97 sb.append("<link rel=\"stylesheet\" type=\"text/css\" href=\""); 96 sb.append(stylesheet) ;98 sb.append(stylesheet).append(pp).append(Head.getVersionParameter(stylesheet)); 97 99 sb.append("\">\n"); 98 100 }
Note: See TracChangeset
for help on using the changeset viewer.