public String getBundledJsParam(ICollection <String> features, GadgetContext context) { StringBuilder buf = new StringBuilder(); bool first = false; foreach (String feature in features) { if (ALLOWED_FEATURE_NAME.Match(feature).Success) { if (!first) { first = true; } else { buf.Append("__"); } buf.Append(feature); } } if (!first) { buf.Append("core"); } buf.Append(".js?v=").Append(jsChecksum) .Append("&container=").Append(context.getContainer()) .Append("&debug=").Append(context.getDebug() ? "1" : "0"); return(buf.ToString()); }
public String getBundledJsUrl(ICollection<String> features, GadgetContext context) { String jsPrefix; if (!jsUriTemplates.TryGetValue(context.getContainer(), out jsPrefix)) { return ""; } return jsPrefix.Replace("%host%", context.getHost()) .Replace("%js%", getBundledJsParam(features, context)); }
public GadgetSpec getGadgetSpec(GadgetContext context) { String rawxml = context.getParameter(RAW_GADGETSPEC_XML_PARAM_NAME); if (rawxml != null) { // Set URI to a fixed, safe value (localhost), preventing a gadget rendered // via raw XML (eg. via POST) to be rendered on a locked domain of any other // gadget whose spec is hosted non-locally. return new GadgetSpec(RAW_GADGET_URI, rawxml); } return getGadgetSpec(context.getUrl(), context.getIgnoreCache()); }
public String getBundledJsUrl(ICollection <String> features, GadgetContext context) { String jsPrefix; if (!jsUriTemplates.TryGetValue(context.getContainer(), out jsPrefix)) { return(""); } return(jsPrefix.Replace("%host%", context.getHost()) .Replace("%js%", getBundledJsParam(features, context))); }
public GadgetSpec getGadgetSpec(GadgetContext context) { String rawxml = context.getParameter(RAW_GADGETSPEC_XML_PARAM_NAME); if (rawxml != null) { // Set URI to a fixed, safe value (localhost), preventing a gadget rendered // via raw XML (eg. via POST) to be rendered on a locked domain of any other // gadget whose spec is hosted non-locally. return(new GadgetSpec(RAW_GADGET_URI, rawxml)); } return(getGadgetSpec(context.getUrl(), context.getIgnoreCache())); }
/** * @param context The request that the gadget is being processed for. */ public Gadget setContext(GadgetContext context) { this.context = context; return this; }
public String getBundledJsParam(ICollection<String> features, GadgetContext context) { StringBuilder buf = new StringBuilder(); bool first = false; foreach (String feature in features) { if (ALLOWED_FEATURE_NAME.Match(feature).Success) { if (!first) { first = true; } else { buf.Append("__"); } buf.Append(feature); } } if (!first) { buf.Append("core"); } buf.Append(".js?v=").Append(jsChecksum) .Append("&container=").Append(context.getContainer()) .Append("&debug=").Append(context.getDebug() ? "1" : "0"); return buf.ToString(); }
/** * @param context The request that the gadget is being processed for. */ public Gadget setContext(GadgetContext context) { this.context = context; return(this); }
/** * TODO: This is in need of a rewrite most likely. It doesn't even take locked domain into * consideration! */ public String getIframeUrl(Gadget gadget) { GadgetContext context = gadget.getContext(); GadgetSpec spec = gadget.getSpec(); String url = context.getUrl().ToString(); View view = gadget.getCurrentView(); View.ContentType type = view == null ? View.ContentType.HTML : view.getType(); UriBuilder uri; if (type == View.ContentType.URL) { uri = view == null ? new UriBuilder() : new UriBuilder(view.getHref()); } else { // TODO: Locked domain support. Uri iframeBaseUri; uri = iframeBaseUris.TryGetValue(context.getContainer(), out iframeBaseUri) ? new UriBuilder(iframeBaseUri) : new UriBuilder(); String host = lockedDomainService.getLockedDomainForGadget(spec, context.getContainer()); if (host != null) { uri.setAuthority(host); } } uri.addQueryParameter("container", context.getContainer()); if (!string.IsNullOrEmpty(context.getModuleId())) { uri.addQueryParameter("mid", context.getModuleId()); } if (context.getIgnoreCache()) { uri.addQueryParameter("nocache", "1"); } else { uri.addQueryParameter("v", spec.getChecksum()); } uri.addQueryParameter("lang", context.getLocale().getLanguage()); uri.addQueryParameter("country", context.getLocale().getCountry()); uri.addQueryParameter("view", context.getView()); UserPrefs prefs = context.getUserPrefs(); foreach (UserPref pref in gadget.getSpec().getUserPrefs()) { String name = pref.getName(); String value = prefs.getPref(name); if (value == null) { value = pref.getDefaultValue(); } uri.addQueryParameter("up_" + pref.getName(), value); } // add url last to work around browser bugs if (!type.Equals(View.ContentType.URL)) { uri.addQueryParameter("url", url); } return(uri.ToString()); }