aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexander Alexeev2016-12-12 16:58:18 +0700
committerGravatar Vitaly Takmazov2016-12-12 22:49:47 +0300
commitd446ba75acc05ec331540d51348bdc2be5aecb42 (patch)
tree445814fcf456999e9955c3570c381bdced015eab
parent02979491ee071371bdbcc1e6ed813ffd44b5834b (diff)
rtemplate refactoring: layout templates moved to layout directory;
show error message on login error
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java2
-rw-r--r--juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java9
-rw-r--r--juick-spring-www/src/main/resources/errors.properties4
-rw-r--r--juick-spring-www/src/main/resources/errors_en.properties4
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/index.html17
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html (renamed from juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html)1
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html2
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html (renamed from juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html)5
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html (renamed from juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html)4
-rw-r--r--juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html9
10 files changed, 46 insertions, 11 deletions
diff --git a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
index bb6387d6..d10f2532 100644
--- a/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
+++ b/juick-spring-www/src/main/java/com/juick/www/configuration/WebSecurityConfig.java
@@ -51,7 +51,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.loginProcessingUrl("/do_login")
.usernameParameter("j_username")
.passwordParameter("j_password")
- .failureUrl("/login?error=1")
+ .failureUrl("/login-error")
.and()
.rememberMe()
.tokenValiditySeconds(6 * 30 * 24 * 3600)
diff --git a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
index 6f25844f..4df4d350 100644
--- a/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
+++ b/juick-spring-www/src/main/java/com/juick/www/controllers/IndexController.java
@@ -11,6 +11,7 @@ import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.context.MessageSource;
import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@@ -121,6 +122,12 @@ public class IndexController {
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String getLoginForm() {
- return "views/login";
+ return "layout/login";
+ }
+
+ @RequestMapping(value = "/login-error", method = RequestMethod.GET)
+ public String getLoginErrorForm(Model model) {
+ model.addAttribute("loginError", true);
+ return "layout/login";
}
} \ No newline at end of file
diff --git a/juick-spring-www/src/main/resources/errors.properties b/juick-spring-www/src/main/resources/errors.properties
index e0e14c56..e000394e 100644
--- a/juick-spring-www/src/main/resources/errors.properties
+++ b/juick-spring-www/src/main/resources/errors.properties
@@ -1,4 +1,6 @@
error.pageNotFound = Страница не найдена
errors.pageNotFound.extended = Похоже, пользователь удалил пост #{0}, или пост не был создан.
error.userNotFound = Пользователь не найден
-errors.userNotFound.extended = Пользователь {0} не найден \ No newline at end of file
+errors.userNotFound.extended = Пользователь {0} не найден
+
+error.login=Произошла ошибка, проверьте имя пользователя и пароль \ No newline at end of file
diff --git a/juick-spring-www/src/main/resources/errors_en.properties b/juick-spring-www/src/main/resources/errors_en.properties
index 99e70b14..7824bbe1 100644
--- a/juick-spring-www/src/main/resources/errors_en.properties
+++ b/juick-spring-www/src/main/resources/errors_en.properties
@@ -1,4 +1,6 @@
error.pageNotFound = Page not found
errors.pageNotFound.extended = Probably, user deleted this post #{0}, or this post never existed.
error.userNotFound = User not found
-errors.userNotFound.extended = User {0} not found \ No newline at end of file
+errors.userNotFound.extended = User {0} not found
+
+error.login=Wrong user or password \ No newline at end of file
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html
new file mode 100644
index 00000000..4cd32be3
--- /dev/null
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/index.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org"
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
+ layout:decorate="~{layout/mainLayout}">
+<head>
+ <title>Главная страница</title>
+</head>
+
+<body>
+<section layout:fragment="content">
+ <p>Главная страница !</p>
+</section>
+<aside id="column">
+ <p layout:fragment="column"></p>
+</aside>
+</body>
+</html> \ No newline at end of file
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html
index d2e424cd..9fd43192 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/login.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/login.html
@@ -133,6 +133,7 @@
<div id="signin">
<a href="#" onclick="$('#signinform').toggle(); $('#nickinput').focus(); return false" th:text="#{question.areRegistered}">Уже зарегистрированы?</a>
<div id="signinform">
+ <p th:if="${loginError}" class="error" th:text="#{error.login}">Произошла ошибка, проверьте имя пользователя и пароль</p>
<form action="#" th:action="@{/do_login}" method="POST">
<input class="txt" type="text" name="j_username" placeholder="Имя пользователя" th:placeholder="#{label.username}" id="nickinput"/>
<input class="txt" type="password" name="j_password" placeholder="Пароль" th:placeholder="#{label.password}"/>
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html
index e851aefa..ef9887d2 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/mainLayout.html
@@ -25,6 +25,6 @@
<p layout:fragment="column">Side column</p>
</aside>
-<footer layout:replace="~{views/partial/footer :: footer}">Footer</footer>
+<footer layout:replace="~{layout/partial/footer :: footer}">Footer</footer>
</body>
</html> \ No newline at end of file
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html
index da911619..0e4e8540 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/footer.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/footer.html
@@ -5,10 +5,9 @@
<body layout:fragment="footer">
<div id="footer">
<div id="footer-right">
- <a href="/settings" th:href="@{/settings}" th:text="#{link.settings}" rel="nofollow">Настройки</a> &#183;
- <a href="/help/ru/contacts" th:href="@{/help/ru/contacts}" th:text="#{link.contacts}" rel="nofollow">Контакты</a> &#183;
+ <a href="/help/ru/contacts" th:href="@{/help/contacts}" th:text="#{link.contacts}" rel="nofollow">Контакты</a> &#183;
<a href="/help/" th:href="@{/help/}" th:text="#{link.help}" rel="nofollow">Справка</a> &#183;
- <a href="/help/ru/adv" th:href="@{/help/ru/adv}" th:text="#{link.adv}" rel="nofollow">Реклама</a>
+ <a href="/help/ru/adv" th:href="@{/help/adv}" th:text="#{link.adv}" rel="nofollow">Реклама</a>
</div>
<div id="footer-social">
<a href="https://twitter.com/Juick" rel="nofollow" class="ico32-twi">Twitter</a>
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html
index 77c9321a..95714e10 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/navigation.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/layout/partial/navigation.html
@@ -35,8 +35,8 @@
<nav id="actions">
<ul>
<li><a href="/#post" th:href="@{/#post}" th:text="#{link.postMessage}">Написать</a></li>
- <li><a href="/ugnich" th:href="@{/{userName}(userName=${visitor.name})}"
- th:text="'@'+${visitor.name}">@ugnich</a></li>
+ <li><a href="/ugnich" th:href="@{/{userName}(userName=${visitor.name})}" th:text="'@'+${visitor.name}">@ugnich</a></li>
+ <li><a href="/settings" th:href="@{/settings}" th:text="#{link.settings}" rel="nofollow">Настройки</a></li>
<li><a href="/logout" th:href="@{/logout}" th:text="#{link.logout}">Выйти</a></li>
</ul>
</nav>
diff --git a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html
index 534e0368..2f0d707c 100644
--- a/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html
+++ b/juick-spring-www/src/main/webapp/WEB-INF/templates/views/partial/homecolumn.html
@@ -1,4 +1,11 @@
+<!DOCTYPE html>
+<html xmlns:th="http://www.thymeleaf.org"
+ xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
+
+<body>
<p class="tags">
<div th:replace="views/partial/tags">Tags</div>
<a href="http://ru.wix.com/" th:if="${showAdv}">конструктор сайтов</a>
-</p> \ No newline at end of file
+</p>
+</body>
+</html>