From 8891c86af686d7eb1f1cbae64bf545f304f607fb Mon Sep 17 00:00:00 2001 From: Kohsuke Kawaguchi Date: Wed, 12 Sep 2012 14:04:19 -0700 Subject: [PATCH] share code between --- core/src/main/java/hudson/Functions.java | 15 +++++++++++++-- core/src/main/resources/lib/layout/layout.jelly | 17 +++++------------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index 53c61a8255..1ce8caa559 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -161,10 +161,21 @@ public class Functions { public static void initPageVariables(JellyContext context) { String rootURL = Stapler.getCurrentRequest().getContextPath(); - Functions h = new Functions(); - context.setVariable("rootURL", rootURL); + Functions h = new Functions(); context.setVariable("h", h); + + + // The path starts with a "/" character but does not end with a "/" character. + context.setVariable("rootURL", rootURL); + + /* + load static resources from the path dedicated to a specific version. + This "/static/VERSION/abc/def.ghi" path is interpreted by stapler to be + the same thing as "/abc/def.ghi", but this avoids the stale cache + problem when the user upgrades to new Jenkins. Stapler also sets a long + future expiration dates for such static resources. + */ context.setVariable("resURL",rootURL+getResourcePath()); context.setVariable("imagesURL",rootURL+getResourcePath()+"/images"); } diff --git a/core/src/main/resources/lib/layout/layout.jelly b/core/src/main/resources/lib/layout/layout.jelly index d72dfa2f64..1fb3fec52b 100644 --- a/core/src/main/resources/lib/layout/layout.jelly +++ b/core/src/main/resources/lib/layout/layout.jelly @@ -57,9 +57,10 @@ THE SOFTWARE. - - - + + +${h.initPageVariables(context)} +${h.initPageVariables(context)} - - - +