This commit is contained in:
parent
eb236275a3
commit
686d994b32
12 changed files with 12 additions and 318 deletions
|
@ -286,12 +286,9 @@ public class FreemarkerHttpServlet extends VitroHttpServlet {
|
|||
*/
|
||||
public static Map<String, Object> getDirectives() {
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("dump", new edu.cornell.mannlib.vitro.webapp.web.directives.dump.DumpDirective());
|
||||
map.put("dumpAll", new edu.cornell.mannlib.vitro.webapp.web.directives.dump.DumpAllDirective());
|
||||
map.put("help", new edu.cornell.mannlib.vitro.webapp.web.directives.dump.HelpDirective());
|
||||
map.put("dump1", new freemarker.ext.dump.DumpDirective());
|
||||
map.put("dumpAll1", new freemarker.ext.dump.DumpAllDirective());
|
||||
map.put("help1", new freemarker.ext.dump.HelpDirective());
|
||||
map.put("dump", new freemarker.ext.dump.DumpDirective());
|
||||
map.put("dumpAll", new freemarker.ext.dump.DumpAllDirective());
|
||||
map.put("help", new freemarker.ext.dump.HelpDirective());
|
||||
map.put("url", new edu.cornell.mannlib.vitro.webapp.web.directives.UrlDirective());
|
||||
map.put("widget", new edu.cornell.mannlib.vitro.webapp.web.directives.WidgetDirective());
|
||||
return map;
|
||||
|
|
|
@ -77,8 +77,6 @@ public class SamplesController extends FreemarkerHttpServlet {
|
|||
body.put("trueStatement", true);
|
||||
body.put("falseStatement", false);
|
||||
|
||||
body.put("pojo", new EditConfiguration());
|
||||
|
||||
getBerries(body);
|
||||
|
||||
body.put("bookTitle", "Pride and Prejudice");
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for dumping a template variable -->
|
||||
|
||||
<div class="var">
|
||||
<#if var??> <#-- not defined for a nested template model object -->
|
||||
<p><strong>Variable name:</strong> ${var}</p>
|
||||
</#if>
|
||||
|
||||
<#if value??>
|
||||
<p><strong>Type:</strong> ${type}</p>
|
||||
<p><strong>Value:</strong> ${value}</p>
|
||||
|
||||
<#-- Template model objects -->
|
||||
<#if properties?has_content>
|
||||
<p><strong>Properties:</strong></p>
|
||||
<ul>
|
||||
<#list properties?keys as property>
|
||||
<li>${property}: ${properties[property]}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
<#if methods?has_content>
|
||||
<p><strong>Methods:</strong></p>
|
||||
<ul>
|
||||
<#list methods as method>
|
||||
<li>${method}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
<#else>
|
||||
<p><strong>Value:</strong> null</p>
|
||||
</#if>
|
||||
</div>
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for dump directive -->
|
||||
|
||||
<div class="dump">
|
||||
<h3>Template variable dump</h3>
|
||||
|
||||
${var}
|
||||
</div>
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/dump.css" />')}
|
||||
|
|
@ -5,8 +5,13 @@
|
|||
<#-- Styles here are temporary; use stylesheets.add() once that's working (see below) -->
|
||||
<style>
|
||||
div.dump {
|
||||
margin-top: 1em;
|
||||
border-top: 2px solid #ccc;
|
||||
padding-top: .75em;
|
||||
}
|
||||
|
||||
.dump ul li.variable {
|
||||
margin-bottom: .5em;
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ccc;
|
||||
padding-top: .75em;
|
||||
padding-bottom: .75em;
|
||||
|
@ -47,7 +52,7 @@ div.dump {
|
|||
<#if dump?keys?has_content>
|
||||
<ul>
|
||||
<#list dump?keys as key>
|
||||
<li>
|
||||
<li class="variable">
|
||||
<p><strong>Variable name:</strong> ${key}</p>
|
||||
|
||||
<#local type = dump[key].type>
|
||||
|
@ -153,7 +158,7 @@ div.dump {
|
|||
|
||||
<#macro doMethod method>
|
||||
<p><strong>Type:</strong> ${method.type}</p>
|
||||
<#local help = method.help>
|
||||
<#local help = method.help!>
|
||||
<#if help?has_content>
|
||||
<p><strong>Help:</strong><p>
|
||||
<ul class="help">
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for dumpAll directive (dumping template data model) -->
|
||||
|
||||
<div class="dump datamodel">
|
||||
|
||||
<h3>Data model dump for template <em>${containingTemplate}</em></h3>
|
||||
|
||||
<h4>VARIABLES</h4>
|
||||
<ul>
|
||||
<#list models as model>
|
||||
<li>${model}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
|
||||
<#if directives?has_content>
|
||||
<h4>DIRECTIVES</h4>
|
||||
<ul>
|
||||
<#list directives as directive>
|
||||
<li>${directive}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
<#if methods?has_content>
|
||||
<h4>METHODS</h4>
|
||||
<ul>
|
||||
<#list methods as method>
|
||||
<li>${method}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
</div>
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/dump.css" />')}
|
|
@ -1,29 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Styles here are temporary; move to css file once stylesheets.add() works -->
|
||||
<style>
|
||||
div.dump.var {
|
||||
padding-top: .75em;
|
||||
padding-bottom: .75em;
|
||||
border-top: 1px solid #ccc;
|
||||
border-bottom: 1px solid #ccc;
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
|
||||
div.dump.var p {
|
||||
margin-bottom: .5em;
|
||||
}
|
||||
</style>
|
||||
|
||||
|
||||
<div class="dump var">
|
||||
<p><strong>Variable name:</strong> ${var.name}</p>
|
||||
<p><strong>Type:</strong> ${var.type}</p>
|
||||
|
||||
<#-- What to do here depends on time. Test either ${var.type} or ${var.value} -->
|
||||
<#-- <p><strong>Value:</strong> ${var.value}</p> -->
|
||||
</div>
|
||||
|
||||
<#-- This will work after we move stylesheets to Configuration sharedVariables
|
||||
${stylesheets.add('<link rel="stylesheet" href="/css/fmdump.css">')}
|
||||
-->
|
|
@ -1,40 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for displaying directive help -->
|
||||
|
||||
<div class="directive">
|
||||
<p><strong>Directive name:</strong> ${name}</p>
|
||||
|
||||
<#if effect??>
|
||||
<p><strong>Effect:</strong> ${effect}</p>
|
||||
|
||||
<#if comments??>
|
||||
<p><strong>Comments:</strong> ${comments}</p>
|
||||
</#if>
|
||||
|
||||
<p><strong>Parameters: </strong>
|
||||
<#if params??>
|
||||
</p>
|
||||
<ul>
|
||||
<#list params?keys as param>
|
||||
<li><strong>${param}:</strong> ${params[param]}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
<#else>
|
||||
none</p>
|
||||
</#if>
|
||||
<br />
|
||||
|
||||
<p><strong>Examples:</strong></p>
|
||||
<#if examples??>
|
||||
<ul>
|
||||
<#list examples as example>
|
||||
<li>${example}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
<#else>
|
||||
<p>No help available for this directive.</p>
|
||||
</#if>
|
||||
</div>
|
|
@ -1,40 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for displaying directive help -->
|
||||
|
||||
<div class="directive">
|
||||
<p><strong>Method name:</strong> ${name}</p>
|
||||
|
||||
<#if returnValue??>
|
||||
<p><strong>Return value:</strong> ${returnValue}</p>
|
||||
|
||||
<#if comments??>
|
||||
<p><strong>Comments:</strong> ${comments}</p>
|
||||
</#if>
|
||||
|
||||
<p><strong>Parameters:</strong>
|
||||
<#if params??>
|
||||
</p>
|
||||
<ol>
|
||||
<#list params as param>
|
||||
<li>${param}</li>
|
||||
</#list>
|
||||
</ol>
|
||||
<#else>
|
||||
none</p>
|
||||
</#if>
|
||||
<br />
|
||||
|
||||
<p><strong>Examples:</strong></p>
|
||||
<#if examples??>
|
||||
<ul>
|
||||
<#list examples as example>
|
||||
<li>${example}</li>
|
||||
</#list>
|
||||
</ul>
|
||||
</#if>
|
||||
|
||||
<#else>
|
||||
<p>No help available for this method.</p>
|
||||
</#if>
|
||||
</div>
|
|
@ -1,11 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- Template for displaying help for a template directive or method -->
|
||||
|
||||
<div class="dump help">
|
||||
<h3>Template ${type} help</h3>
|
||||
|
||||
${help}
|
||||
</div>
|
||||
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/dump.css" />')}
|
|
@ -127,7 +127,6 @@ ${s2} => ${str.unCamelCase(s2)}<br />
|
|||
<@dump var="fruit" />
|
||||
<@dump var="trueStatement" />
|
||||
<@dump var="zoo1" />
|
||||
<@dump var="pojo" />
|
||||
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/script1.js"></script>',
|
||||
'<script type="text/javascript" src="${urls.base}/js/script2.js"></script>',
|
||||
|
@ -139,6 +138,6 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/script1.js"><
|
|||
|
||||
<@help for="profileUrl" />
|
||||
|
||||
<@describe var="stylesheets" />
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,100 +0,0 @@
|
|||
<#-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
|
||||
|
||||
<#-- dump.ftl
|
||||
--
|
||||
-- Generates tree representations of data model items.
|
||||
--
|
||||
-- Usage:
|
||||
-- <#import "dump.ftl" as dumper>
|
||||
--
|
||||
-- <#assign foo = something.in["your"].data[0].model />
|
||||
--
|
||||
-- <@dumper.dump foo />
|
||||
--
|
||||
-- When used within html pages you've to use <pre>-tags to get the wanted
|
||||
-- result:
|
||||
-- <pre>
|
||||
-- <@dumper.dump foo />
|
||||
-- <pre>
|
||||
-->
|
||||
|
||||
<#-- The black_list contains bad hash keys. Any hash key which matches a
|
||||
-- black_list entry is prevented from being displayed.
|
||||
-->
|
||||
<#assign black_list = ["class"] />
|
||||
|
||||
|
||||
<#--
|
||||
-- The main macro.
|
||||
-->
|
||||
|
||||
<#macro dump data>
|
||||
(root)
|
||||
<#if data?is_enumerable>
|
||||
<@printList data,[] />
|
||||
<#elseif data?is_hash_ex>
|
||||
<@printHashEx data,[] />
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#-- private helper macros. it's not recommended to use these macros from
|
||||
-- outside the macro library.
|
||||
-->
|
||||
|
||||
<#macro printList list has_next_array>
|
||||
<#local counter=0 />
|
||||
<#list list as item>
|
||||
<#list has_next_array+[true] as has_next><#if !has_next> <#else> | </#if></#list>
|
||||
<#list has_next_array as has_next><#if !has_next> <#else> | </#if></#list><#t>
|
||||
<#t><@printItem item?if_exists,has_next_array+[item_has_next], counter />
|
||||
<#local counter = counter + 1/>
|
||||
</#list>
|
||||
</#macro>
|
||||
|
||||
<#macro printHashEx hash has_next_array>
|
||||
<#list hash?keys as key>
|
||||
<#list has_next_array+[true] as has_next><#if !has_next> <#else> | </#if></#list>
|
||||
<#list has_next_array as has_next><#if !has_next> <#else> | </#if></#list><#t>
|
||||
<#t><@printItem hash[key]?if_exists,has_next_array+[key_has_next], key />
|
||||
</#list>
|
||||
</#macro>
|
||||
|
||||
<#macro printItem item has_next_array key>
|
||||
<#if item?is_method>
|
||||
+- ${key} = ?? (method)
|
||||
<#elseif item?is_enumerable>
|
||||
+- ${key}
|
||||
<@printList item, has_next_array /><#t>
|
||||
<#elseif item?is_hash_ex && omit(key?string)><#-- omit bean-wrapped java.lang.Class objects -->
|
||||
+- ${key} (omitted)
|
||||
<#elseif item?is_hash_ex>
|
||||
+- ${key}
|
||||
<@printHashEx item, has_next_array /><#t>
|
||||
<#elseif item?is_number>
|
||||
+- ${key} = ${item}
|
||||
<#elseif item?is_string>
|
||||
+- ${key} = "${item}"
|
||||
<#elseif item?is_boolean>
|
||||
+- ${key} = ${item?string}
|
||||
<#elseif item?is_date>
|
||||
+- ${key} = ${item?string("yyyy-MM-dd HH:mm:ss zzzz")}
|
||||
<#elseif item?is_transform>
|
||||
+- ${key} = ?? (transform)
|
||||
<#elseif item?is_macro>
|
||||
+- ${key} = ?? (macro)
|
||||
<#elseif item?is_hash>
|
||||
+- ${key} = ?? (hash)
|
||||
<#elseif item?is_node>
|
||||
+- ${key} = ?? (node)
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#function omit key>
|
||||
<#local what = key?lower_case>
|
||||
<#list black_list as item>
|
||||
<#if what?index_of(item) gte 0>
|
||||
<#return true>
|
||||
</#if>
|
||||
</#list>
|
||||
<#return false>
|
||||
</#function>
|
Loading…
Add table
Reference in a new issue