Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@
<artifactId>spring-context-support</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>

<dependency>
<groupId>kr.pe.kwonnam.freemarker</groupId>
<artifactId>freemarker-template-inheritance</artifactId>
<version>0.4.RELEASE</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net._4programmers._4note.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
Expand Down
7 changes: 7 additions & 0 deletions src/main/webapp/WEB-INF/application-context.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,18 @@
<context:component-scan base-package="net._4programmers._4note" />

<mvc:annotation-driven />
<mvc:resources mapping="/resources/**" location="/resources/"/>

<tx:annotation-driven />

<import resource="classpath:/kr/pe/kwonnam/freemarker/inheritance/freemarker-layout-directives.xml" />
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/views" />
<property name="freemarkerVariables">
<map>
<entry key="layout" value-ref="freemarkerLayoutDirectives" />
</map>
</property>
</bean>

<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
Expand Down
10 changes: 5 additions & 5 deletions src/main/webapp/WEB-INF/views/index.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
<@layout.extends name="template.ftl">
<@layout.put block="content" type="replace">
<h1>Welcome to 4Notes</h1>
</@layout.put>
</@layout.extends>
35 changes: 17 additions & 18 deletions src/main/webapp/WEB-INF/views/inserted-user.ftl
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
<html>
<head>
<title>4note</title>
</head>
<body>
<h2>Informacje o wstawionym uzytkowniku:</h2>
<table>
<tr>
<td>Nazwa:</td>
<td>${user.getUsername()}</td>
</tr>
<tr>
<td>Email:</td>
<td>${user.getEmail()}</td>
</tr>
</table>
</body>
</html>
<@layout.extends name="template.ftl">

<@layout.put block="content" type="replace">
<h2>Informacje o wstawionym uzytkowniku:</h2>
<table>
<tr>
<td>Nazwa:</td>
<td>${user.getUsername()}</td>
</tr>
<tr>
<td>Email:</td>
<td>${user.getEmail()}</td>
</tr>
</table>
</@layout.put>

</@layout.extends>
56 changes: 56 additions & 0 deletions src/main/webapp/WEB-INF/views/template.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>4Note</title>

<link href="/resources/bootstrap-3.3.2-dist/css/bootstrap.min.css" rel="stylesheet">
<link href="/resources/css/custom-styles.css" rel="stylesheet">
</head>

<body>

<@layout.block name="header">
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">4Notes</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</div>
</div>
</nav>
</@layout.block>

<div class="container">
<div class="jumbotron content">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure it is good idea to surround a main content with jumbotron class :)

<@layout.block name="content">
</@layout.block>
</div>
</div>


<@layout.block name="footer">
<footer class="footer">
<p>4Notes footer</p>
</footer>
</@layout.block>


<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="/resources/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script>
</body>
</html>
26 changes: 8 additions & 18 deletions src/main/webapp/WEB-INF/views/user.ftl
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
<html>
<head>
<title>4note</title>
</head>
<body>
<h2>Informacje o uzytkowniku:</h2>
<table>
<tr>
<td>Nazwa:</td>
<td>${user.getUsername()}</td>
</tr>
<tr>
<td>Email:</td>
<td>${user.getEmail()}</td>
</tr>
</table>
</body>
</html>
<@layout.extends name="template.ftl">

<@layout.put block="content" type="replace">
<h1>Hello, ${user.getUsername()}!</h1>
<p>Here is your email: ${user.getEmail()}</p>
</@layout.put>

</@layout.extends>
Loading