[ 
https://issues.apache.org/jira/browse/ACCUMULO-4739?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16252651#comment-16252651
 ] 

Christopher Tubbs commented on ACCUMULO-4739:
---------------------------------------------

[~lstav] sent me the following example code for how we might be able to do 
this. I'm not sure if it will work as is, or if we'd want to do something 
different. But, it does assume that our configuration represent some sort of 
list-like structure (vs. a text blob to drop in to the header, which might be 
easier). He says:

{code}
On the Java side you would need something like this:


List<Map<String,String>> importList = new ArrayList<>();
Map<String,String> imports = new HashMap<>();

// These values would come from the configuration file so they would go on a 
loop inside the Java class to create the Map

imports.put("type", "css");
imports.put("href", "google.com");
imports.put("test", "bing.com");

// This is the list that we store on the model

importList.add(imports);

model.put("imports",importList); // This is the model we already have on the 
Java class


Then on the FTL file you would write something like this:


<#list imports as val>
  <#if val["type"] = "css">
    <link rel="stylesheet" type="text/css"
      <#list val?keys as key>
        <#if key != "type"> 
          ${key}="${val[key]}" 
        </#if>
      </#list> 
    />
  <#elseif val["type"] = "js">
    <script
      <#list val?keys as key>
        <#if key != "type"> 
          ${key}="$val[key]}"
        </#if>
      </#list>>
    </script>
  </#if>
</#list>
{code}

> Make 3rd party web resources (js, css) location configurable
> ------------------------------------------------------------
>
>                 Key: ACCUMULO-4739
>                 URL: https://issues.apache.org/jira/browse/ACCUMULO-4739
>             Project: Accumulo
>          Issue Type: Task
>          Components: monitor
>            Reporter: Christopher Tubbs
>            Assignee: Michael Miller
>            Priority: Blocker
>             Fix For: 2.0.0
>
>
> Currently, in the new monitor for 2.0 (after ACCUMULO-3005), some 3rd party 
> web resources are accessed via an external CDN. This is suitable in many 
> cases, but could be problematic for client browsers not currently connected 
> to the internet or with a cached copy of the resources from the CDN.
> These resources include bootstrap and jquery. Flot is also a 3rd party 
> resource, but is currently bundled with Accumulo and served by the monitor.
> The location of these resources should be made configurable, so that they can 
> be bundled with, and served by, the Accumulo monitor instead of a 
> internet-based CDN. Making the locations configurable also makes it possible 
> for users to update, if there's a bug in a particular version of jquery that 
> the administrator wishes to avoid, or they want to use a different bootstrap 
> theme, for example.
> Any new configuration option added to support making these configurable 
> should be capable of supporting an arbitrary number of script and stylesheet 
> resources, and possibly other resource types, as well as any accompanying 
> integrity/crossorigin attributes for CDN access (see 
> server/monitor/src/main/resources/templates/default.ftl for current values).
> Also, I think the default value should be to point to the CDN, and not the 
> locally bundled and served resources, so that the browser can take advantage 
> of any caching for these commonly used resources. This would allow us to 
> achieve ACCUMULO-2983 by stopping bundling these third party resources, but 
> still supporting bundling, if needed.
> To complete this issue, we basically need 2 things:
> # Ensure monitor serves (to a predictable location) whatever arbitrary static 
> resources it finds on the class path (so users can bundle their own static 
> resources), and
> # Ensure resources are configurable to point to the served versions or 
> versions in a CDN.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to