Skip to content

Commit

Permalink
Issue #8: Added context path to all templates
Browse files Browse the repository at this point in the history
All URLs produced by template engines are context aware.
Turned on caching for all viewResolvers, because there was one-two resolvers with the enabled caching.
  All engines will work under the same (or similar) conditions.
Rythm template version was updated, however it will not work in Spring 4 (see comments in mvc-dispatcher-servlet.xml). Probably Rythm should be removed in future.
Scalate: corrected head.scaml template.
  minor bug fixed in index-scalate.scaml - the was no border under h1.page-header.
Cleaned OS X files.
  • Loading branch information
Vest committed Nov 23, 2015
1 parent 3337709 commit e090f2b
Show file tree
Hide file tree
Showing 24 changed files with 97 additions and 63 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
*.bak
*.iml
.idea
target
.project
.settings
.classpath
.DS_Store


atlassian-ide-plugin.xml
8 changes: 7 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@
<mustache-spring.version>1.1.1</mustache-spring.version>
<scalate-core_2.10.version>1.7.1</scalate-core_2.10.version>
<httl-springmvc.version>1.0.11</httl-springmvc.version>
<spring-rythm.version>1.0</spring-rythm.version>
<spring-rythm.version>1.1.1-SNAPSHOT</spring-rythm.version>
<pebble-spring3.version>1.4.5</pebble-spring3.version>
<mustache-spring-view.version>1.2</mustache-spring-view.version>
<handlebars.version>2.3.2</handlebars.version>
<jtwig-spring.version>3.1.1</jtwig-spring.version>
<spring-jade4j.version>1.0.4</spring-jade4j.version>
</properties>

<parent>
<groupId>org.sonatype.oss</groupId>
<artifactId>oss-parent</artifactId>
<version>7</version>
</parent>

<dependencies>

<!-- Core -->
Expand Down
Binary file removed src/main/resources/.DS_Store
Binary file not shown.
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/freemarker/includes.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv=X-UA-Compatible content="IE=Edge"/>
<title>[@spring.message code="example.title"/] - Freemarker</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" href="${rc.getContextPath()}/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen" />
</head>
[/#macro]

Expand All @@ -16,6 +16,6 @@
[/#macro]

[#macro scripts]
<script src=/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
<script src=${rc.getContextPath()}/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=${rc.getContextPath()}/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
[/#macro]
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/handlebars/head.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>{{i18n "example.title"}} - Mustache</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css"/>
<title>{{i18n "example.title"}} - Handlebars</title>
<link rel="stylesheet" href="{{rc.contextPath}}/webjars/bootstrap/3.0.1/css/bootstrap.min.css"/>
</head>
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/handlebars/scripts.hbs
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<script src="/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
<script src="{{rc.contextPath}}/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="{{rc.contextPath}}/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
4 changes: 3 additions & 1 deletion src/main/webapp/WEB-INF/httl/index-httl.httl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>${"example.title".message} - Httl</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen"/>
<link rel="stylesheet" href="${contextPath}/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen"/>
</head>
<body>
<div class="container">
Expand All @@ -24,5 +24,7 @@
</div>
<!--#end-->
</div>
<script src=${contextPath}/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=${contextPath}/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
</body>
</html>
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/jade/layout.jade
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ doctype html
html
block head
title
link(rel="stylesheet", href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css")
link(rel="stylesheet", href=rc.contextPath + "/webjars/bootstrap/3.0.1/css/bootstrap.min.css")
meta(name="viewport", content="width=device-width, initial-scale=1.0")
meta(charset="UTF-8")
body
.container
.page-header
h1 JFall 2013 Presentations - Jade4j
block content
script(src="/webjars/jquery/2.0.2/jquery.min.js")
script(src="/webjars/bootstrap/3.0.1/js/bootstrap.min.js")
script(src=rc.contextPath + "/webjars/jquery/2.0.2/jquery.min.js")
script(src=rc.contextPath + "/webjars/bootstrap/3.0.1/js/bootstrap.min.js")
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/head.jspf
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<meta name=viewport content="width=device-width, initial-scale=1.0">
<meta http-equiv=X-UA-Compatible content="IE=Edge">
<title><spring:message code="example.title"/> - JSP</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen">
</head>
<link rel="stylesheet" href="${root}/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen">
</head>
1 change: 1 addition & 0 deletions src/main/webapp/WEB-INF/jsp/index-jsp.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="forms" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<c:set var="root" value="${pageContext.request.contextPath}" />
<!DOCTYPE html>
<html>
<%@ include file="head.jspf" %>
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jsp/scripts.jspf
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<script src=/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
<script src=${root}/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=${root}/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/jtwig/head.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>

<title>{{ 'example.title' | translate }} - jtwig</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen"/>
<link rel="stylesheet" href={{ '/webjars/bootstrap/3.0.1/css/bootstrap.min.css' | path }} media="screen"/>
4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/jtwig/scripts.twig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<script src="/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
<script src={{ '/webjars/jquery/2.0.2/jquery.min.js' | path }}></script>
<script src={{ '/webjars/bootstrap/3.0.1/js/bootstrap.min.js' | path }}></script>
2 changes: 1 addition & 1 deletion src/main/webapp/WEB-INF/mustache/head.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>{{#i18n}}example.title{{/i18n}} - Mustache</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css"/>
<link rel="stylesheet" href="{{rc.contextPath}}/webjars/bootstrap/3.0.1/css/bootstrap.min.css"/>
</head>
2 changes: 2 additions & 0 deletions src/main/webapp/WEB-INF/mustache/scripts.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<script src="{{rc.contextPath}}/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="{{rc.contextPath}}/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
38 changes: 28 additions & 10 deletions src/main/webapp/WEB-INF/mvc-dispatcher-servlet.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
<property name="viewNames" value="*-jsp"/>
<property name="suffix" value=".jsp"/>
<property name="order" value="6"/>
<property name="cache" value="true"/>
</bean>

<!-- Jade4j -->
Expand All @@ -41,6 +42,7 @@
<bean id="jadeConfiguration" class="de.neuland.jade4j.JadeConfiguration">
<property name="prettyPrint" value="false"/>
<property name="templateLoader" ref="jade4jTemplateLoader"/>
<property name="caching" value="true"/>
</bean>

<bean id="jadeViewResolver" class="de.neuland.jade4j.spring.view.JadeViewResolver">
Expand All @@ -51,6 +53,8 @@
<!-- rendering nice html formatted error pages for development -->
<property name="renderExceptions" value="true"/>
<property name="order" value="5"/>
<property name="requestContextAttribute" value="rc"/>
<property name="cache" value="true"/>
</bean>

<!-- Mustache -->
Expand All @@ -62,6 +66,7 @@
<property name="templateLoader">
<bean class="org.springframework.web.servlet.view.mustache.MustacheTemplateLoader"/>
</property>
<property name="requestContextAttribute" value="rc"/>
</bean>

<!-- THYMELEAF: Template Resolver for webapp pages -->
Expand Down Expand Up @@ -102,6 +107,8 @@
<property name="prefix" value=""/>
<property name="suffix" value=".ftl"/>
<property name="order" value="0"/>
<property name="requestContextAttribute" value="rc" />
<property name="cache" value="true"/>
</bean>

<!-- velocity -->
Expand All @@ -121,32 +128,39 @@
<property name="order" value="1"/>
<property name="toolboxConfigLocation" value="/WEB-INF/velocity/toolbox.xml"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="cache" value="true"/>
</bean>

<!-- Scalate -->
<bean id="scalateViewResolver" class="org.fusesource.scalate.spring.view.ScalateViewResolver">
<property name="prefix" value="/WEB-INF/scalate/"/>
<property name="suffix" value=".scaml"/>
<property name="order" value="7"/>
<property name="cache" value="true"/>
</bean>

<!-- Rythm -->
<!-- does not seem to work with Spring4 -->
<!--<bean id="rythmConfigurer" class="org.rythmengine.spring.web.RythmConfigurer">-->
<!--<property name="resourceLoaderPath" value="/WEB-INF/rythm/"/>-->
<!--<property name="autoImports"-->
<!--value="com.jeroenreijn.examples.model.*"/>-->
<!--</bean>-->
<!--<bean class="org.rythmengine.spring.web.RythmViewResolver">-->
<!--<property name="order" value="0"/>-->
<!--</bean>-->
<!-- does not seem to work with Spring4.
Known issue: https://github.com/greenlaw110/spring-rythm/issues/9 -->
<!--
<bean id="rythmConfigurer" class="org.rythmengine.spring.web.RythmConfigurer">
<property name="resourceLoaderPath" value="/WEB-INF/rythm/"/>
<property name="autoImports"
value="com.jeroenreijn.examples.model.*"/>
</bean>
<bean class="org.rythmengine.spring.web.RythmViewResolver">
<property name="order" value="0"/>
<property name="cache" value="true"/>
</bean>
-->

<!-- Httl -->
<bean id="httlViewResolver" class="httl.web.springmvc.HttlViewResolver">
<property name="prefix" value="/WEB-INF/httl/"/>
<property name="suffix" value=".httl"/>
<property name="order" value="9"/>
<property name="order" value="9"/>
<property name="contentType" value="text/html; charset=UTF-8"/>
<property name="cache" value="true"/>
</bean>

<!-- Pebble -->
Expand All @@ -162,6 +176,8 @@
<property name="suffix" value=".html" />
<property name="order" value="10"/>
<property name="pebbleEngine" ref="pebbleEngine" />
<property name="cache" value="true"/>
<property name="requestContextAttribute" value="rc"/>
</bean>

<!-- jtwig -->
Expand All @@ -179,6 +195,8 @@
<property name="prefix" value="/WEB-INF/handlebars/"/>
<property name="suffix" value=".hbs"/>
<property name="order" value="11"/>
<property name="requestContextAttribute" value="rc" />
<property name="cache" value="true"/>
</bean>

<bean id="localeResolver"
Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/pebble/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title>{{ i18n("messages","example.title") }} - Pebble</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen"/>
<link rel="stylesheet" href="{{rc.contextPath}}/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen"/>
</head>
<body>
<div class="container">
{% block content %}
{# This section is to be overriden by child templates #}
{% endblock content %}
</div>
<script src="/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
<script src="{{rc.contextPath}}/webjars/jquery/2.0.2/jquery.min.js"></script>
<script src="{{rc.contextPath}}/webjars/bootstrap/3.0.1/js/bootstrap.min.js"></script>
</body>
</html>
7 changes: 4 additions & 3 deletions src/main/webapp/WEB-INF/scalate/head.scaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
-@ var title : String
%head
%title= title
%link(rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css")
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
%meta(charset="UTF-8")
%meta(name="viewport" content="width=device-width, initial-scale=1.0")
%meta(http-equiv="X-UA-Compatible" content="IE=Edge")
%title= title
%link(rel="stylesheet" href="#{context.contextPath}/webjars/bootstrap/3.0.1/css/bootstrap.min.css")
12 changes: 6 additions & 6 deletions src/main/webapp/WEB-INF/scalate/index-scalate.scaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
%div.container
%div.page-header
%h1= title
- for(item <- presentations)
%div.panel.panel-default
%div.panel-heading
%h3.panel-title= item.getTitle + " - " + item.getSpeakerName
%div.panel-body
!= item.getSummary
- for(item <- presentations)
%div.panel.panel-default
%div.panel-heading
%h3.panel-title= item.getTitle + " - " + item.getSpeakerName
%div.panel-body
!= item.getSummary
- render("scripts.scaml")

4 changes: 2 additions & 2 deletions src/main/webapp/WEB-INF/scalate/scripts.scaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
%script(type="text/javascript" src="/webjars/jquery/2.0.2/jquery.min.js")
%script(type="text/javascript" src="/webjars/bootstrap/3.0.1/js/bootstrap.min.js")
%script(type="text/javascript" src="#{context.contextPath}/webjars/jquery/2.0.2/jquery.min.js")
%script(type="text/javascript" src="#{context.contextPath}/webjars/bootstrap/3.0.1/js/bootstrap.min.js")
9 changes: 3 additions & 6 deletions src/main/webapp/WEB-INF/thymeleaf/includes.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
<title th:text="#{example.title} + ' - Thymeleaf'">Title</title>
<link rel="stylesheet" href="../../static/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/3.0.1/css/bootstrap.min.css}"/>
<link rel="stylesheet" th:href="@{/webjars/bootstrap/3.0.1/css/bootstrap.min.css}"/>
</head>

<body>

<div class="page-header" th:fragment="pageHeader">
<h1 th:text="#{example.title} + ' - Thymeleaf'">Title</h1>
</div>

<section th:fragment="scripts" th:remove="tag">
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.2.min.js"
th:src="@{/webjars/jquery/2.0.2/jquery.min.js}"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/3.0.1/js/bootstrap.min.js}"></script>
<script th:src="@{/webjars/jquery/2.0.2/jquery.min.js}"></script>
<script th:src="@{/webjars/bootstrap/3.0.1/js/bootstrap.min.js}"></script>
</section>

</body>

</html>
8 changes: 4 additions & 4 deletions src/main/webapp/WEB-INF/thymeleaf/index-thymeleaf.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<head th:substituteby="includes :: head">
<link rel="stylesheet" href="../../static/css/bootstrap.min.css"/>
<link rel="stylesheet" th:href="@{/webjars/bootstrap/3.0.1/css/bootstrap.min.css}"/>
</head>
<body>
<div class="container">
<div class="container">
<div th:substituteby="includes :: pageHeader"></div>
<div class="panel panel-default" th:each="item : ${presentations}">
<div class="panel-heading">
Expand All @@ -13,7 +13,7 @@ <h3 class="panel-title" th:text="${item.title} +' - '+ ${item.speakerName}">Titl
<div class="panel-body" th:utext="${item.summary}">Summary</div>
</div>
</div>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.2.min.js" th:substituteby="includes :: scripts"></script>
<script th:remove="all" type="text/javascript" src="../../static/js/thymol.js"></script>
<script th:src="@{/webjars/jquery/2.0.2/jquery.min.js}" th:substituteby="includes :: scripts"></script>
<script th:remove="all" type="text/javascript" th:src="@{/static/js/thymol.js}"></script>
</body>
</html>
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/velocity/includes.vm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv=X-UA-Compatible content="IE=Edge"/>
<title>#springMessage("example.title") - Velocity</title>
<link rel="stylesheet" href="/webjars/bootstrap/3.0.1/css/bootstrap.min.css" media="screen" />
<link rel="stylesheet" href="$link.setRelative("/webjars/bootstrap/3.0.1/css/bootstrap.min.css")" media="screen" />
</head>
#end

Expand All @@ -15,6 +15,6 @@
#end

#macro( scripts )
<script src=/webjars/jquery/2.0.2/jquery.min.js></script>
<script src=/webjars/bootstrap/3.0.1/js/bootstrap.min.js></script>
<script src=$link.setRelative("/webjars/jquery/2.0.2/jquery.min.js")></script>
<script src=$link.setRelative("/webjars/bootstrap/3.0.1/js/bootstrap.min.js")></script>
#end

0 comments on commit e090f2b

Please sign in to comment.