Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#7 #16

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 7 additions & 5 deletions src/main/webapp/WEB-INF/views/index.ftl
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
<@layout.extends name="template.ftl">
<@layout.put block="content" type="replace">
<div class="jumbotron content">
<h1>Welcome to 4Notes!</h1>
</div>
</@layout.put>
</@layout.extends>
37 changes: 19 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,19 @@
<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">
<div class="jumbotron content">
<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>
</div>
</@layout.put>

</@layout.extends>
54 changes: 54 additions & 0 deletions src/main/webapp/WEB-INF/views/template.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!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">
<@layout.block name="content">
</@layout.block>
</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>
28 changes: 10 additions & 18 deletions src/main/webapp/WEB-INF/views/user.ftl
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
<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">
<div class="jumbotron content">
<h1>Hello, ${user.getUsername()}!</h1>
<p>Here is your email: ${user.getEmail()}</p>
</div>
</@layout.put>

</@layout.extends>
Loading