this.validator.validate(g, result);
if (result.hasErrors()) {
- Sht.log(this).finest("content is empty.");
+ Sht.log(this).finest("BBS Post Validate fail.");
return null;
}
final PersistenceManager pm = PMF.get().getPersistenceManager();
public class IndexController implements IPublicController {
@RequestMapping(method = RequestMethod.GET, value = "/index.html")
public void index() {
-
}
}
import jp.sourceforge.rabbitBTS.services.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
/**
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
- request.setAttribute("login", false);
request.setAttribute("account", null);
-
try {
final Account acc = this.accountService.fetchAccount();
if (acc == null) {
Sht.log(this).warning("403 " + request.getRequestURL());
return false;
}
- request.setAttribute("login", true);
request.setAttribute("account", acc);
return true;
} catch (final NotRegisteredException e) {
}
}
+ /**
+ * viewでの描画用にアカウント、ログインURL、ログアウトURLをセットする。
+ */
+ @Override
+ public void postHandle(HttpServletRequest request,
+ HttpServletResponse response, Object handler,
+ ModelAndView modelAndView) throws Exception {
+ modelAndView.addObject("acc", request.getAttribute("account"));
+ modelAndView.addObject("loginurl", Sht.loginUrl(request));
+ modelAndView.addObject("logouturl", Sht.logoutUrl(request));
+ }
+
}
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-*/
-
+ */
package jp.sourceforge.rabbitBTS.interceptors;
-
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import jp.sourceforge.rabbitBTS.Sht;
+import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
-
public class TraceInterceptor extends HandlerInterceptorAdapter {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.web.servlet.handler.HandlerInterceptorAdapter#postHandle
+ * (javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse, java.lang.Object,
+ * org.springframework.web.servlet.ModelAndView)
+ */
+ @Override
+ public void postHandle(HttpServletRequest request,
+ HttpServletResponse response, Object handler,
+ ModelAndView modelAndView) throws Exception {
+ Sht.log(this).finest("postHandle " + request.getRequestURI());
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.springframework.web.servlet.handler.HandlerInterceptorAdapter#preHandle
+ * (javax.servlet.http.HttpServletRequest,
+ * javax.servlet.http.HttpServletResponse, java.lang.Object)
+ */
@Override
public boolean preHandle(HttpServletRequest request,
HttpServletResponse response, Object handler) throws Exception {
- Sht.log(handler.getClass()).finest("REQEST");
+ Sht.log(this).finest("preHandle " + request.getRequestURI());
return true;
}
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;
+import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;
import org.springmodules.validation.bean.conf.loader.annotation.handler.NotBlank;
@PersistenceCapable(identityType = IdentityType.APPLICATION)
private Long authorId;
@Persistent
@NotBlank
+ @Length(max = 10)
+ // TODO: 短い
private String content;
@Persistent
private Date date;
<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>rabbit-bts</application>
- <version>1</version>
+ <version>2</version>
<!-- Configure java.util.logging -->
<system-properties>
<entry key="BbsPost.content[not.blank]">
内容がないよう
</entry>
-
+<entry key="Account.nickName[not.blank]">
+ニックネームを入力せよ
+</entry>
+<entry key="Account.bio[not.blank]">
+自己紹介を入力せよ
+</entry>
</properties>
\ No newline at end of file
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
- <!-- <ref bean="tracer"></ref>-->
+ <ref bean="tracer"></ref>
<ref bean="authInterceptor" />
</list>
</property>
<bean class="jp.sourceforge.rabbitBTS.SomeBindingInitializer" />
</property>
</bean>
- <bean
+
+ <!-- view -->
+ <!--
+ <bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
- value="org.springframework.web.servlet.view.JstlView" />
- <property name="prefix" value="/WEB-INF/views/" />
- <property name="suffix" value=".jsp" />
- </bean>
+ value="org.springframework.web.servlet.view.JstlView" /> <property
+ name="prefix" value="/WEB-INF/views/" /> <property name="suffix"
+ value=".jsp" /> </bean>
+ -->
+ <bean id="freemarkerConfig"
+ class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
+ <property name="templateLoaderPath" value="/WEB-INF/views/" />
+ <property name="freemarkerSettings">
+ <props>
+ <prop key="default_encoding">utf-8</prop>
+ </props>
+ </property>
+ </bean>
+ <bean id="viewResolver"
+ class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
+ <property name="cache" value="false" />
+ <property name="prefix" value="" />
+ <property name="suffix" value=".ftl" />
+ <property name="requestContextAttribute" value="rc" />
+ <property name="exposeSpringMacroHelpers" value="true" />
+ <property name="contentType">
+ <value>text/html; charset=utf-8</value>
+ </property>
+ </bean>
<bean
class="org.springframework.web.servlet.mvc.support.ControllerClassNameHandlerMapping">
<property name="interceptors">
<list>
- <!-- <ref bean="tracer"></ref> -->
+ <ref bean="tracer"></ref>
<ref bean="authInterceptor" />
</list>
</property>
<context:component-scan base-package="jp.sourceforge.rabbitBTS"
use-default-filters="true" />
-
-
<!-- trace log -->
<!--
<bean id="dInterceptor"
--- /dev/null
+[#ftl]
+[#assign title="BBS"]
+[#include "/common/head.ftl"]
+<h1>BBS</h1>
+<table class="bbs">
+<tr><th>投稿者</th><th>内容</th><th>時刻</th></tr>
+[#list posts as g]
+<tr>
+<td>${g.author.nickName }</td>
+<td>${g.content }</td>
+<td>${g.date?datetime }</td>
+</tr>
+[/#list]
+</table>
+
+<p><a href="postEdit.html">投稿する</a></p>
+[#include "/common/foot.ftl"]
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<%@ page language="java" contentType="text/html; charset=UTF-8"%>
-<%@include file="/WEB-INF/views/header.jsp" %>
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-
-<title>BBS App
-<c:if test="${bbsPost.author != null }"> - </c:if>
-<c:out value="${bbsPost.author.nickname}" /></title>
-
-</head>
-<body>
-<p>BBS App</p>
-<c:choose>
-<c:when test="${!login}">
-<a href="${loginurl}">ログイン</a>
-</c:when>
-<c:otherwise>
-<a href="${logouturl}">ログアウト</a>
-</c:otherwise>
-</c:choose>
-
-<table>
-<c:forEach var="g" items="${posts}">
-<tr>
-<td>${g.author.nickName }</td>
-<td>${g.content }</td>
-<td>${g.date }</td>
-</tr>
-</c:forEach>
-</table>
-
-<p><a href="postEdit.html">投稿する</a></p>
-
-</body>
-</html>
\ No newline at end of file
--- /dev/null
+[#ftl]
+[#assign title="BBS 投稿"]
+[#include "/common/head.ftl"]
+
+<h1>BBS 投稿</h1>
+<p>内容を入力し 投稿するボタン を押下してください。</p>
+<p>投稿内容は即座に反映されますのでご注意ください。</p>
+[#--[@spring.bind "bbsPost.content" /]--]
+<form action="postEdit.html" method="post">
+[@spring.formTextarea "bbsPost.content" /]
+[@spring.showErrors "<br />", "err" /]
+<input type="submit" value="投稿する" />
+</form>
+<a href="/bbs/">戻る</a>
+
+[#include "/common/foot.ftl"]
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<%@ page language="java" contentType="text/html; charset=UTF-8"%>
-<%@include file="/WEB-INF/views/header.jsp" %>
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>POST Edit</title>
-</head>
-<body>
-
-<form:form modelAttribute="bbsPost" method="post"
- action="postEdit.html">
- <form:textarea path="content" />
- <form:errors path="content"></form:errors>
- <input type="submit" />
-</form:form>
-
-</body>
-</html>
\ No newline at end of file
--- /dev/null
+[#ftl]
+commonだよ。
\ No newline at end of file
--- /dev/null
+[#ftl]
+</div> <!-- mainWrap -->
+
+<div id="sideWrap">
+ サイドバー
+</div> <!-- sideWrap -->
+
+</div> <!-- inner -->
+
+<hr />
+
+<div class="foot">
+<p>Copyright (c) 2009 senju@users.sourceforge.jp</p>
+</div>
+
+</div> <!-- bodyWrap -->
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+[#ftl]
+[#import "/spring.ftl" as spring /]
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+<title>[Rabbit BTS] ${title}</title>
+<link href="/st/common.css" rel="stylesheet" type="text/css" />
+</head>
+<body>
+<div id="bodyWrap">
+
+<div class="head">
+ <a href="/">
+ <img id="logo" src="http://www.logomaker.com/logo-images/c413a03c56b71ec0.gif" alt="Rabbit BTS logo" />
+ </a>
+ <div class="headMenu">
+ <p class="title">${title}</p>
+
+ [#if acc??]
+ <a href="/home/">${acc.nickName}</a>でログイン中(<a href="${logouturl}">ログアウト</a>)
+ [#else]
+ <a href="http://www.businesslogos.com"><img src="http://www.logomaker.com/images/logos.gif" alt="logos" border="0"/></a>
+ <a href="${loginurl}">ログイン</a>または<a href="/register/">新規登録</a>
+ [/#if]
+ </div>
+</div> <!-- head -->
+
+<hr />
+<div id="inner">
+<div id="mainWrap">
\ No newline at end of file
+++ /dev/null
-<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
-<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
-<%@ taglib prefix="sp" uri="http://www.springframework.org/tags"%>
\ No newline at end of file
--- /dev/null
+[#ftl]
+[#assign title="サイトトップ"]
+[#include "/common/head.ftl"]
+<h1>Rabbit BTSへようこそ</h1>
+<ul>
+<li><a href="/bbs/">BBS</a></li>
+<li><a href="http://localhost:8080/_ah/admin/datastore">data viewer</a></li></ul>
+[#include "/common/foot.ftl"]
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<%@ page language="java" contentType="text/html; charset=UTF-8"%>
-<%@include file="/WEB-INF/views/header.jsp" %>
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Rabbit BTS</title>
-</head>
-<body>
-<div class="header">
-ログイン or <a href="/register">新規登録</a>
-<a href="/home.html">ユーザー名</a>
-</div>
-<h1>Rabbit BTSへようこそ</h1>
-<ul>
-<li><a href="/bbs">BBS</a></li>
-<li><a href="http://localhost:8080/_ah/admin/datastore">data viewer</a></li></ul>
-</body>
-</html>
\ No newline at end of file
--- /dev/null
+[#ftl]
+[#assign title="ユーザー登録"]
+[#include "/common/head.ftl"]
+<h1>Rabbit BTSへようこそ</h1>
+<p>新しくRabbit BTSアカウントを作成します。以下のフォームを入力し、登録ボタンをクリックしてください。</p>
+
+<form action="" method="post">
+<ul>
+<li>ニックネーム[@spring.formInput "account.nickName" /]</li>
+[@spring.showErrors "<br />", "err" /]
+
+<li>自己紹介[@spring.formTextarea "account.bio" /]</li>
+[@spring.showErrors "<br />", "err" /]
+
+<li><input type="submit" value="登録" /></li>
+</form>
+[#include "/common/foot.ftl"]
\ No newline at end of file
+++ /dev/null
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<%@ page language="java" contentType="text/html; charset=UTF-8"%>
-<%@include file="/WEB-INF/views/header.jsp"%>
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
-<title>Rabbit BTS - 新規登録画面</title>
-</head>
-<body>
-<h1>Rabbit BTSへようこそ</h1>
-<p>新しくRabbit BTSアカウントを作成します。以下のフォームを入力し、作成ボタンをクリックしてください。</p>
-<c:if test="${errorMessage != null}">${errorMessage}</c:if>
-<form:form modelAttribute="account" method="post">
-<ul>
-<li>ニックネーム <form:errors></form:errors> <form:input path="nickName"/></li>
-<li>自己紹介 <form:errors path="bio"></form:errors> <form:textarea path="bio" /></li>
-<li><input type="submit" value="作成" /></li>
-</ul>
-</form:form>
-</body>
-</html>
\ No newline at end of file
--- /dev/null
+/*
+\90F
+\90Â #1d7d8e
+\83I\83\8c\83\93\83W #ee6720
+\97Î #6ebb1f
+\8aD\90F #6ebb1f
+*/
+body {
+ color: #1d7d8e;
+ text-align: center;
+}
+
+#bodyWrap {
+ width: 780px;
+ text-align: left;
+ margin: 0 auto;
+}
+
+#inner {
+ margin: 0 10px;
+}
+
+#mainWrap {
+ width: 500px;
+ float: left;
+ background-color: #e0e0e0;
+}
+
+#sideWrap {
+ width: 250px;
+ float: left;
+}
+
+a {
+
+}
+
+img#logo {
+ float: left;
+ border: none;
+ width: 150px;
+}
+
+.headMenu {
+ text-align: left;
+ color: #ee6720;
+}
+
+.title {
+ font-size: 0.8em;
+ color: #6ebb1f;
+}
+
+hr {
+ clear: both;
+}
+
+.foot p {
+ text-align: center;
+}
+
+.err {
+ color: red;
+ font-style: italic;
+}
+
+.bbs th {
+ border-style: solid;
+ border-width: thin;
+ text-align: center;
+}
+
+.bbs td {
+ border-style: solid;
+ border-width: thin;
+}
\ No newline at end of file