Permalink
Browse files

Merge pull request #275 from hizel/title-war-3

замена двойного минуса слэшем в заголовке топиков и комментариев
  • Loading branch information...
2 parents 9ca8c9d + 4d96bb5 commit c57bacd5c8dc4f24fdf7a062770a08a951f2230b @maxcom committed May 29, 2012
@@ -0,0 +1,41 @@
+/*
+ * Copyright 1998-2012 Linux.org.ru
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 ru.org.linux.site.tags;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+import java.io.IOException;
+
+import static ru.org.linux.util.StringUtil.makeTitle;
+
+/**
+ */
+public class MakeTitleTag extends BodyTagSupport {
+ public int doAfterBody() throws JspException {
+ try {
+ BodyContent bc = getBodyContent();
+ String body = bc.getString();
+ JspWriter out = bc.getEnclosingWriter();
+ out.print(makeTitle(body));
+ } catch (IOException e) {
+ throw new JspException("Error:" + e.getMessage());
+ }
+ return SKIP_BODY;
+ }
+}
@@ -0,0 +1,43 @@
+/*
+ * Copyright 1998-2012 Linux.org.ru
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * 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 ru.org.linux.site.tags;
+
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.tagext.BodyContent;
+import javax.servlet.jsp.tagext.BodyTagSupport;
+
+import java.io.IOException;
+
+import static ru.org.linux.util.StringUtil.processTitle;
+
+/**
+ */
+public class TitleTag extends BodyTagSupport {
+ public int doAfterBody() throws JspException {
+ try {
+ BodyContent bc = getBodyContent();
+ String body = bc.getString();
+ JspWriter out = bc.getEnclosingWriter();
+ if(body != null && !body.trim().isEmpty()) {
+ out.print(processTitle(body));
+ }
+ } catch (IOException e) {
+ throw new JspException("Error:" + e.getMessage());
+ }
+ return SKIP_BODY;
+ }
+}
@@ -15,6 +15,8 @@
package ru.org.linux.util;
+import ru.org.linux.util.formatter.ToHtmlFormatter;
+
import java.math.BigInteger;
import java.security.GeneralSecurityException;
import java.security.MessageDigest;
@@ -54,6 +56,10 @@ public static boolean checkLoginName(String login) {
return loginCheckRE.matcher(login).matches();
}
+ public static String processTitle(String title) {
+ return title.replace(ToHtmlFormatter.MDASH_REGEX, ToHtmlFormatter.MDASH_REPLACE);
+ }
+
public static String makeTitle(String title) {
if (title != null && !title.trim().isEmpty()) {
return title;
@@ -50,8 +50,8 @@
/*
Замена двойного минуса на тире
*/
- private static final String MDASH_REGEX = " -- ";
- private static final String MDASH_REPLACE = " — ";
+ public static final String MDASH_REGEX = " -- ";
+ public static final String MDASH_REPLACE = " — ";
private Configuration configuration;
private TopicDao messageDao;
@@ -1,6 +1,7 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="lor" uri="http://www.linux.org.ru" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,7 +29,7 @@
<a href="${url}">
<c:choose>
<c:when test="${not empty item.info}">
- <img src="${item.icon}" alt="Скриншот: ${item.title}" ${item.info.code}>
+ <img src="${item.icon}" alt="Скриншот: <l:title>${item.title}</l:title>" ${item.info.code}>
</c:when>
<c:otherwise>
[bad image] <img src="${item.icon}" alt="Скриншот: ${item.title}">
@@ -15,6 +15,7 @@
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="lor" uri="http://www.linux.org.ru" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<h2>Top 10</h2>
@@ -28,7 +29,7 @@
<c:param name="lastmod" value="${message.lastmod.time}"/>
</c:if>
</c:url>
- <a href="${fn:escapeXml(msg_link)}">${message.title}</a>
+ <a href="${fn:escapeXml(msg_link)}"><l:title>${message.title}</l:title></a>
<c:if test="${message.pages gt 1}">
<c:url value="${message.url}/page${message.pages-1}" var="page_link">
<c:param name="lastmod" value="${message.lastmod.time}"/>
@@ -1,6 +1,7 @@
<%@ page contentType="text/html; charset=utf-8"%>
<%@ page buffer="200kb"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -21,7 +22,7 @@
<jsp:include page="/WEB-INF/jsp/head.jsp"/>
-<title>${add.topic.title} - ${preparedMessage.group.title} - ${preparedMessage.section.title}</title>
+<title><l:title>${add.topic.title}</l:title> - ${preparedMessage.group.title} - ${preparedMessage.section.title}</title>
<jsp:include page="/WEB-INF/jsp/header.jsp"/>
<div class=messages>
<lor:message messageMenu="<%= null %>" preparedMessage="${preparedMessage}" message="${add.topic}" showMenu="false"/>
@@ -4,6 +4,7 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -189,13 +190,13 @@
<c:if test="${firstPage and topic.pages<=1}">
<a href="${group.url}${topic.msgid}?lastmod=${topic.lastmod.time}">
- ${topic_tags} ${topic.subj}
+ ${topic_tags} <l:title>${topic.subj}</l:title>
</a>
</c:if>
<c:if test="${not firstPage or topic.pages>1}">
<a href="${group.url}${topic.msgid}">
- ${topic_tags} ${topic.subj}
+ ${topic_tags} <l:title>${topic.subj}</l:title>
</a>
</c:if>
@@ -1,6 +1,7 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -183,7 +184,7 @@ function checkCustomBan(idx) {
<c:if test="${topic.deleted}">
<s>
</c:if>
- <a href="view-message.jsp?msgid=${topic.id}" rev=contents>${topic.title}</a>
+ <a href="view-message.jsp?msgid=${topic.id}" rev=contents><l:title>${topic.title}</l:title></a>
<c:if test="${topic.deleted}">
</s>
</c:if>
@@ -211,7 +212,7 @@ function checkCustomBan(idx) {
<c:if test="${topic.deleted}">
<s>
</c:if>
- <a href="jump-message.jsp?msgid=${topic.topicId}&amp;cid=${topic.id}" rev=contents>${topic.title}</a>
+ <a href="jump-message.jsp?msgid=${topic.topicId}&amp;cid=${topic.id}" rev=contents><l:title>${topic.title}</l:title></a>
<c:if test="${topic.deleted}">
</s>
</c:if>
@@ -2,6 +2,7 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page contentType="text/html; charset=utf-8"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
@@ -109,7 +110,7 @@
<c:forEach items="${result}" var="item">
<div class="msg">
<div class="msg_header">
- <h2><a href="${item.url}"><c:out escapeXml="true" value="${item.title}"/></a></h2>
+ <h2><a href="${item.url}"><l:title><c:out escapeXml="true" value="${item.title}"/></l:title></a></h2>
</div>
<div class="msg_body">
@@ -17,6 +17,7 @@
<%@ page import="java.util.Date" buffer="200kb"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<rss version="2.0">
<channel>
<link>http://www.linux.org.ru/</link>
@@ -3,6 +3,7 @@
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
~ Licensed under the Apache License, Version 2.0 (the "License");
@@ -56,7 +57,7 @@
<tr>
<td>${comment.sectionTitle}</td>
<td>${comment.groupTitle}</td>
- <td><a href="jump-message.jsp?msgid=${comment.topicId}&amp;cid=${comment.commentId}" rev=contents>${comment.title}</a></td>
+ <td><a href="jump-message.jsp?msgid=${comment.topicId}&amp;cid=${comment.commentId}" rev=contents><l:title>${comment.title}</l:title></a></td>
<td><lor:dateinterval date="${comment.postdate}"/></td>
</c:forEach>
@@ -98,7 +99,7 @@
<td>${item.ptitle}</td>
<td>${item.gtitle}</td>
<td>
- <a href="view-message.jsp?msgid=${item.msgid}" rev=contents>${item.title}</a>
+ <a href="view-message.jsp?msgid=${item.msgid}" rev=contents><l:title>${item.title}</l:title></a>
</td>
<td><c:out value="${item.reason}" escapeXml="true"/></td>
<td>
@@ -16,6 +16,7 @@
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--@elvariable id="topicsList" type="java.util.List<ru.org.linux.user.PreparedUserEvent>"--%>
<%--@elvariable id="firstPage" type="Boolean"--%>
<%--@elvariable id="nick" type="String"--%>
@@ -154,16 +155,16 @@
<td>
<c:if test="${topic.event.type != 'DELETED'}">
<c:if test="${topic.event.cid>0}">
- <a href="jump-message.jsp?msgid=${topic.event.msgid}&amp;cid=${topic.event.cid}">${topic.event.subj}</a>
+ <a href="jump-message.jsp?msgid=${topic.event.msgid}&amp;cid=${topic.event.cid}"><l:title>${topic.event.subj}</l:title></a>
</c:if>
<c:if test="${topic.event.cid==0}">
- <a href="jump-message.jsp?msgid=${topic.event.msgid}">${topic.event.subj}</a>
+ <a href="jump-message.jsp?msgid=${topic.event.msgid}"><l:title>${topic.event.subj}</l:title></a>
</c:if>
(<a class="secondary" href="${topic.event.groupUrl}">${topic.event.groupTitle}</a>)
</c:if>
<c:if test="${topic.event.type == 'DELETED'}">
- <a href="view-message.jsp?msgid=${topic.event.msgid}">${topic.event.subj}</a>
+ <a href="view-message.jsp?msgid=${topic.event.msgid}"><l:title>${topic.event.subj}</l:title></a>
(<a class="secondary" href="${topic.event.groupUrl}">${topic.event.groupTitle}</a>)
<br>
<c:out value="${topic.event.eventMessage}" escapeXml="true"/>
@@ -28,6 +28,7 @@
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="ftm" uri="http://java.sun.com/jsp/jstl/fmt" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%
String title = "Последние сообщения";
@@ -100,7 +101,7 @@
<span class="tag">${tag}</span>
</c:forEach>
- ${msg.title}
+ <l:title>${msg.title}</l:title>
</a>
(<%--
@@ -3,6 +3,7 @@
<%@ page import="ru.org.linux.util.StringUtil" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
<%--
~ Copyright 1998-2012 Linux.org.ru
@@ -46,8 +47,8 @@
Topic nextMessage = (Topic) request.getAttribute("nextMessage");
%>
-<title>${message.title} - ${preparedMessage.group.title} - ${preparedMessage.section.title}</title>
-<meta property="og:title" content="${message.title}" >
+<title><l:title>${message.title}</l:title> - ${preparedMessage.group.title} - ${preparedMessage.section.title}</title>
+<meta property="og:title" content="<l:title>${message.title}</l:title>" >
<c:if test="${preparedMessage.section.imagepost}">
<meta property="og:image" content="${preparedMessage.image.mediumName}">
@@ -64,11 +65,11 @@
<link rel="canonical" href="${template.mainUrlNoSlash}<%= message.getLinkPage(npage) %>">
<c:if test="${prevMessage != null}">
- <link rel="Previous" id="PrevLink" href="${fn:escapeXml(prevMessage.link)}" title="<%= StringUtil.makeTitle(prevMessage.getTitle()) %>">
+ <link rel="Previous" id="PrevLink" href="${fn:escapeXml(prevMessage.link)}" title="<l:title><l:mkTitle>${prevMessage.title}</l:mkTitle></l:title>">
</c:if>
<c:if test="${nextMessage != null}">
- <link rel="Next" id="NextLink" href="${fn:escapeXml(nextMessage.link)}" title="<%= StringUtil.makeTitle(nextMessage.getTitle()) %>">
+ <link rel="Next" id="NextLink" href="${fn:escapeXml(nextMessage.link)}" title="<l:title><l:mkTitle>${nextMessage.title}</l:mkTitle></l:title>">
</c:if>
<c:if test="${not message.expired}">
@@ -109,7 +110,7 @@
</td>
<td align=left valign=top class="hideon-phone">
<a href="${fn:escapeXml(prevMessage.link)}" rel=prev>
- <%= StringUtil.makeTitle(prevMessage.getTitle()) %>
+ <l:title><l:mkTitle>${prevMessage.title}</l:mkTitle></l:title>
</a>
</td>
</c:if>
@@ -124,7 +125,7 @@
<tr valign=middle align=right>
<td class="hideon-phone">
<a href="${fn:escapeXml(nextMessage.link)}" rel=next>
- <%= StringUtil.makeTitle(nextMessage.getTitle()) %>
+ <l:title><l:mkTitle>${nextMessage.title}</l:mkTitle></l:title>
</a>
</td>
<td align="right" valign="middle" style="padding-left: 5px">
@@ -148,7 +149,7 @@
</td>
<td align=left valign=top class="hideon-phone">
<a href="${fn:escapeXml(prevMessage.link)}" rel=prev>
- <%= StringUtil.makeTitle(prevMessage.getTitle()) %>
+ <l:title><l:mkTitle>${prevMessage.title}</l:mkTitle></l:title>
</a>
</td>
</c:if>
@@ -167,7 +168,7 @@
<tr valign=middle align=right>
<td class="hideon-phone">
<a href="${fn:escapeXml(nextMessage.link)}" rel=next>
- <%= StringUtil.makeTitle(nextMessage.getTitle()) %>
+ <l:title><l:mkTitle>${nextMessage.title}</l:mkTitle></l:title>
</a>
</td>
<td align="right" valign="middle" style="padding-left: 5px">
@@ -15,6 +15,7 @@
~ limitations under the License.
--%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="lor" %>
+<%@ taglib prefix="l" uri="http://www.linux.org.ru" %>
<%--@elvariable id="message" type="ru.org.linux.topic.Topic"--%>
<%--@elvariable id="poll" type="ru.org.linux.poll.Poll"--%>
@@ -25,7 +26,7 @@
<H1>Голосование</H1>
<h2><a href="view-message.jsp?msgid=${poll.topicId}">Опрос</a></h2>
-<h3><c:out value="${message.title}" escapeXml="true"/></h3>
+<h3><l:title><c:out value="${message.title}" escapeXml="true"/></l:title></h3>
<lor:poll-form poll="${poll}" enabled="true"/>
Oops, something went wrong.

0 comments on commit c57bacd

Please sign in to comment.