Commit 7e418c8f authored by Van's avatar Van

Merge remote-tracking branch 'origin/3.2.0-dev' into 3.2.0-dev

parents 3e2d72a8 15009f3e
...@@ -6,7 +6,7 @@ ADD . /tmp ...@@ -6,7 +6,7 @@ ADD . /tmp
RUN cd /tmp && mvn install -DskipTests -Pci && mv target/solo/* /opt/b3log/solo/ \ RUN cd /tmp && mvn install -DskipTests -Pci && mv target/solo/* /opt/b3log/solo/ \
&& mkdir -p /opt/b3log/backup/ && mkdir -p /opt/b3log/tmp/ \ && mkdir -p /opt/b3log/backup/ && mkdir -p /opt/b3log/tmp/ \
&& rm -rf /opt/b3log/solo/WEB-INF/classes/local.properties /opt/b3log/solo/WEB-INF/classes/mail.properties /opt/b3log/solo/WEB-INF/classes/latke.properties \ && rm -rf /opt/b3log/solo/WEB-INF/classes/local.properties /opt/b3log/solo/WEB-INF/classes/latke.properties \
&& rm -rf /tmp/* && rm -rf ~/.m2 && rm -rf /tmp/* && rm -rf ~/.m2
ADD ./src/main/resources/docker/entrypoint.sh $WORKDIR ADD ./src/main/resources/docker/entrypoint.sh $WORKDIR
......
...@@ -11,10 +11,6 @@ services: ...@@ -11,10 +11,6 @@ services:
SERVER_SCHMEA: https SERVER_SCHMEA: https
SERVER_NAME: <your host> SERVER_NAME: <your host>
SERVER_PORT: 80 SERVER_PORT: 80
EMAIL_ADDRESS: <your address>
EMAIL_PASSWORD: <your smtp password>
SMTP_HOST: <your smtp host>
SMTP_PROT: <your smtp port>
volumes: volumes:
- database:/opt/b3log/backup - database:/opt/b3log/backup
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!-- <!--
Description: Solo POM. Description: Solo POM.
Version: 3.18.3.50, Mar 1, 2019 Version: 3.18.3.51, Mar 3, 2019
Author: <a href="http://88250.b3log.org">Liang Ding</a> Author: <a href="http://88250.b3log.org">Liang Ding</a>
Author: <a href="http://www.annpeter.cn">Ann Peter</a> Author: <a href="http://www.annpeter.cn">Ann Peter</a>
Author: <a href="http://vanessa.b3log.org">Vanessa</a> Author: <a href="http://vanessa.b3log.org">Vanessa</a>
...@@ -74,11 +74,11 @@ ...@@ -74,11 +74,11 @@
</scm> </scm>
<properties> <properties>
<org.b3log.latke.version>2.4.44</org.b3log.latke.version> <org.b3log.latke.version>2.4.45</org.b3log.latke.version>
<slf4j.version>1.7.5</slf4j.version> <slf4j.version>1.7.5</slf4j.version>
<jsoup.version>1.9.1</jsoup.version> <jsoup.version>1.9.1</jsoup.version>
<flexmark.version>0.40.0</flexmark.version> <flexmark.version>0.40.20</flexmark.version>
<jetty.version>9.4.12.v20180830</jetty.version> <jetty.version>9.4.12.v20180830</jetty.version>
<commons-cli.version>1.3.1</commons-cli.version> <commons-cli.version>1.3.1</commons-cli.version>
<commons-codec.version>1.10</commons-codec.version> <commons-codec.version>1.10</commons-codec.version>
...@@ -89,7 +89,6 @@ ...@@ -89,7 +89,6 @@
<freemarker.version>2.3.28</freemarker.version> <freemarker.version>2.3.28</freemarker.version>
<user-agent-utils.version>1.21</user-agent-utils.version> <user-agent-utils.version>1.21</user-agent-utils.version>
<servlet.version>3.1.0</servlet.version> <servlet.version>3.1.0</servlet.version>
<javax.mail.version>1.6.2</javax.mail.version>
<license-maven-plugin.version>3.0</license-maven-plugin.version> <license-maven-plugin.version>3.0</license-maven-plugin.version>
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version> <maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
...@@ -117,12 +116,6 @@ ...@@ -117,12 +116,6 @@
<version>${servlet.version}</version> <version>${servlet.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
<dependency> <dependency>
<groupId>mysql</groupId> <groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId> <artifactId>mysql-connector-java</artifactId>
......
...@@ -34,7 +34,10 @@ import org.b3log.latke.servlet.DispatcherServlet; ...@@ -34,7 +34,10 @@ import org.b3log.latke.servlet.DispatcherServlet;
import org.b3log.latke.util.Requests; import org.b3log.latke.util.Requests;
import org.b3log.latke.util.Stopwatchs; import org.b3log.latke.util.Stopwatchs;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.event.*; import org.b3log.solo.event.B3ArticleSender;
import org.b3log.solo.event.B3ArticleUpdater;
import org.b3log.solo.event.B3CommentSender;
import org.b3log.solo.event.PluginRefresher;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.Skin; import org.b3log.solo.model.Skin;
import org.b3log.solo.processor.InitCheckHandler; import org.b3log.solo.processor.InitCheckHandler;
...@@ -216,10 +219,6 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -216,10 +219,6 @@ public final class SoloServletListener extends AbstractServletListener {
try { try {
final EventManager eventManager = beanManager.getReference(EventManager.class); final EventManager eventManager = beanManager.getReference(EventManager.class);
final ArticleCommentReplyNotifier articleCommentReplyNotifier = beanManager.getReference(ArticleCommentReplyNotifier.class);
eventManager.registerListener(articleCommentReplyNotifier);
final PageCommentReplyNotifier pageCommentReplyNotifier = beanManager.getReference(PageCommentReplyNotifier.class);
eventManager.registerListener(pageCommentReplyNotifier);
final PluginRefresher pluginRefresher = beanManager.getReference(PluginRefresher.class); final PluginRefresher pluginRefresher = beanManager.getReference(PluginRefresher.class);
eventManager.registerListener(pluginRefresher); eventManager.registerListener(pluginRefresher);
eventManager.registerListener(new ViewLoadEventHandler()); eventManager.registerListener(new ViewLoadEventHandler());
...@@ -386,8 +385,6 @@ public final class SoloServletListener extends AbstractServletListener { ...@@ -386,8 +385,6 @@ public final class SoloServletListener extends AbstractServletListener {
DispatcherServlet.post("/console/plugin/updateSetting", pluginConsole::updateSetting); DispatcherServlet.post("/console/plugin/updateSetting", pluginConsole::updateSetting);
final PreferenceConsole preferenceConsole = beanManager.getReference(PreferenceConsole.class); final PreferenceConsole preferenceConsole = beanManager.getReference(PreferenceConsole.class);
DispatcherServlet.get("/console/reply/notification/template", preferenceConsole::getReplyNotificationTemplate);
DispatcherServlet.put("/console/reply/notification/template", preferenceConsole::updateReplyNotificationTemplate);
DispatcherServlet.get("/console/signs/", preferenceConsole::getSigns); DispatcherServlet.get("/console/signs/", preferenceConsole::getSigns);
DispatcherServlet.get("/console/preference/", preferenceConsole::getPreference); DispatcherServlet.get("/console/preference/", preferenceConsole::getPreference);
DispatcherServlet.put("/console/preference/", preferenceConsole::updatePreference); DispatcherServlet.put("/console/preference/", preferenceConsole::updatePreference);
......
...@@ -20,7 +20,6 @@ package org.b3log.solo.cache; ...@@ -20,7 +20,6 @@ package org.b3log.solo.cache;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.ioc.Singleton; import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.model.Role; import org.b3log.latke.model.Role;
import org.b3log.latke.model.User;
import org.b3log.solo.util.Solos; import org.b3log.solo.util.Solos;
import org.json.JSONObject; import org.json.JSONObject;
...@@ -31,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -31,7 +30,7 @@ import java.util.concurrent.ConcurrentHashMap;
* User cache. * User cache.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.1, Sep 25, 2018 * @version 1.1.0.2, Mar 3, 2019
* @since 2.3.0 * @since 2.3.0
*/ */
@Singleton @Singleton
...@@ -42,11 +41,6 @@ public class UserCache { ...@@ -42,11 +41,6 @@ public class UserCache {
*/ */
private final Map<String, JSONObject> idCache = new ConcurrentHashMap<>(); private final Map<String, JSONObject> idCache = new ConcurrentHashMap<>();
/**
* Email, User.
*/
private final Map<String, JSONObject> emailCache = new ConcurrentHashMap<>();
/** /**
* Admin user. * Admin user.
*/ */
...@@ -85,21 +79,6 @@ public class UserCache { ...@@ -85,21 +79,6 @@ public class UserCache {
return Solos.clone(user); return Solos.clone(user);
} }
/**
* Gets a user by the specified user email.
*
* @param userEmail the specified user email
* @return user, returns {@code null} if not found
*/
public JSONObject getUserByEmail(final String userEmail) {
final JSONObject user = emailCache.get(userEmail);
if (null == user) {
return null;
}
return Solos.clone(user);
}
/** /**
* Adds or updates the specified user. * Adds or updates the specified user.
* *
...@@ -107,7 +86,6 @@ public class UserCache { ...@@ -107,7 +86,6 @@ public class UserCache {
*/ */
public void putUser(final JSONObject user) { public void putUser(final JSONObject user) {
idCache.put(user.optString(Keys.OBJECT_ID), Solos.clone(user)); idCache.put(user.optString(Keys.OBJECT_ID), Solos.clone(user));
emailCache.put(user.optString(User.USER_EMAIL), Solos.clone(user));
} }
/** /**
...@@ -122,9 +100,6 @@ public class UserCache { ...@@ -122,9 +100,6 @@ public class UserCache {
} }
idCache.remove(id); idCache.remove(id);
final String email = user.optString(User.USER_EMAIL);
emailCache.remove(email);
} }
/** /**
...@@ -132,7 +107,6 @@ public class UserCache { ...@@ -132,7 +107,6 @@ public class UserCache {
*/ */
public void clear() { public void clear() {
idCache.clear(); idCache.clear();
emailCache.clear();
adminCache.clear(); adminCache.clear();
} }
} }
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.event;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.event.AbstractEventListener;
import org.b3log.latke.event.Event;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.util.Strings;
import org.b3log.solo.mail.MailService;
import org.b3log.solo.mail.MailServiceFactory;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.util.Solos;
import org.json.JSONObject;
/**
* This listener is responsible for processing article comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://www.wanglay.com">Lei Wang</a>
* @version 1.2.2.12, Oct 23, 2018
* @since 0.3.1
*/
@Singleton
public class ArticleCommentReplyNotifier extends AbstractEventListener<JSONObject> {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(ArticleCommentReplyNotifier.class);
/**
* Mail service.
*/
private MailService mailService = MailServiceFactory.getMailService();
@Override
public void action(final Event<JSONObject> event) {
final JSONObject eventData = event.getData();
final JSONObject comment = eventData.optJSONObject(Comment.COMMENT);
final JSONObject article = eventData.optJSONObject(Article.ARTICLE);
LOGGER.log(Level.DEBUG, "Processing an event [type={0}, data={1}] in listener [className={2}]",
event.getType(), eventData, ArticleCommentReplyNotifier.class.getName());
final String originalCommentId = comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID);
if (StringUtils.isBlank(originalCommentId)) {
LOGGER.log(Level.DEBUG, "This comment[id={0}] is not a reply", comment.optString(Keys.OBJECT_ID));
return;
}
if (Latkes.getServePath().contains("localhost") || Strings.isIPv4(Latkes.getServePath())) {
LOGGER.log(Level.INFO, "Solo runs on local server, so should not send mail");
return;
}
if (!Solos.isMailConfigured()) {
return;
}
final BeanManager beanManager = BeanManager.getInstance();
final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
final CommentRepository commentRepository = beanManager.getReference(CommentRepository.class);
try {
final String commentEmail = comment.getString(Comment.COMMENT_EMAIL);
final JSONObject originalComment = commentRepository.get(originalCommentId);
final String originalCommentEmail = originalComment.getString(Comment.COMMENT_EMAIL);
if (originalCommentEmail.equalsIgnoreCase(commentEmail)) {
return;
}
if (!Strings.isEmail(originalCommentEmail)) {
return;
}
final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) {
throw new Exception("Not found preference");
}
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT);
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
final MailService.Message message = new MailService.Message();
message.setFrom(adminEmail);
message.addRecipient(originalCommentEmail);
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
final String articleTitle = article.getString(Article.ARTICLE_TITLE);
final String articleLink = Latkes.getServePath() + article.getString(Article.ARTICLE_PERMALINK);
final String commentName = comment.getString(Comment.COMMENT_NAME);
final String commentURL = comment.getString(Comment.COMMENT_URL);
String commenter;
if (!"http://".equals(commentURL)) {
commenter = "<a target=\"_blank\" " + "href=\"" + commentURL + "\">" + commentName + "</a>";
} else {
commenter = commentName;
}
final String mailSubject = replyNotificationTemplate.getString(
"subject").replace("${postLink}", articleLink).
replace("${postTitle}", articleTitle).
replace("${replier}", commenter).
replace("${blogTitle}", blogTitle).
replace("${replyURL}", Latkes.getServePath() + commentSharpURL).
replace("${replyContent}", commentContent).
replace("${servePath}", Latkes.getServePath());
message.setSubject(mailSubject);
final String mailBody = replyNotificationTemplate.
getString("body").
replace("${postLink}", articleLink).
replace("${postTitle}", articleTitle).
replace("${replier}", commenter).
replace("${blogTitle}", blogTitle).
replace("${replyURL}", Latkes.getServePath() + commentSharpURL).
replace("${replyContent}", commentContent).
replace("${servePath}", Latkes.getServePath());
message.setHtmlBody(mailBody);
LOGGER.log(Level.DEBUG, "Sending a mail [mailSubject={0}, mailBody=[{1}] to [{2}]",
mailSubject, mailBody, originalCommentEmail);
mailService.send(message);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
}
}
/**
* Gets the event type {@linkplain EventTypes#ADD_COMMENT_TO_ARTICLE}.
*
* @return event type
*/
@Override
public String getEventType() {
return EventTypes.ADD_COMMENT_TO_ARTICLE;
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.event;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.event.AbstractEventListener;
import org.b3log.latke.event.Event;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.ioc.Singleton;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.util.Strings;
import org.b3log.solo.mail.MailService;
import org.b3log.solo.mail.MailServiceFactory;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option;
import org.b3log.solo.model.Page;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.service.PreferenceQueryService;
import org.b3log.solo.util.Solos;
import org.json.JSONObject;
/**
* This listener is responsible for processing page comment reply.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.6, Sep 25, 2018
* @since 0.3.1
*/
@Singleton
public class PageCommentReplyNotifier extends AbstractEventListener<JSONObject> {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(PageCommentReplyNotifier.class);
/**
* Mail service.
*/
private MailService mailService = MailServiceFactory.getMailService();
@Override
public void action(final Event<JSONObject> event) {
final JSONObject eventData = event.getData();
final JSONObject comment = eventData.optJSONObject(Comment.COMMENT);
final JSONObject page = eventData.optJSONObject(Page.PAGE);
LOGGER.log(Level.DEBUG, "Processing an event [type={0}, data={1}] in listener [className={2}]",
event.getType(), eventData, PageCommentReplyNotifier.class.getName());
final String originalCommentId = comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID);
if (StringUtils.isBlank(originalCommentId)) {
LOGGER.log(Level.DEBUG, "This comment[id={0}] is not a reply", comment.optString(Keys.OBJECT_ID));
return;
}
if (!Solos.isMailConfigured()) {
return;
}
final BeanManager beanManager = BeanManager.getInstance();
final PreferenceQueryService preferenceQueryService = beanManager.getReference(PreferenceQueryService.class);
final CommentRepository commentRepository = beanManager.getReference(CommentRepository.class);
try {
final String commentEmail = comment.getString(Comment.COMMENT_EMAIL);
final JSONObject originalComment = commentRepository.get(originalCommentId);
final String originalCommentEmail = originalComment.getString(Comment.COMMENT_EMAIL);
if (originalCommentEmail.equalsIgnoreCase(commentEmail)) {
return;
}
if (!Strings.isEmail(originalCommentEmail)) {
return;
}
final JSONObject preference = preferenceQueryService.getPreference();
if (null == preference) {
LOGGER.log(Level.ERROR, "Not found preference");
return;
}
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT);
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
final MailService.Message message = new MailService.Message();
message.setFrom(adminEmail);
message.addRecipient(originalCommentEmail);
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
final String mailSubject = replyNotificationTemplate.getString("subject").replace("${blogTitle}", blogTitle);
message.setSubject(mailSubject);
final String pageTitle = page.getString(Page.PAGE_TITLE);
final String pageLink = Latkes.getServePath() + page.getString(Page.PAGE_PERMALINK);
final String commentName = comment.getString(Comment.COMMENT_NAME);
final String commentURL = comment.getString(Comment.COMMENT_URL);
String commenter;
if (!"http://".equals(commentURL)) {
commenter = "<a target=\"_blank\" " + "href=\"" + commentURL + "\">" + commentName + "</a>";
} else {
commenter = commentName;
}
final String mailBody = replyNotificationTemplate.getString("body").replace("${postLink}", pageLink).replace("${postTitle}", pageTitle).replace("${replier}", commenter).replace("${replyURL}", Latkes.getServePath() + commentSharpURL).replace(
"${replyContent}", commentContent);
message.setHtmlBody(mailBody);
LOGGER.log(Level.DEBUG, "Sending a mail[mailSubject={0}, mailBody=[{1}] to [{2}]",
mailSubject, mailBody, originalCommentEmail);
mailService.send(message);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
}
}
/**
* Gets the event type {@linkplain EventTypes#ADD_COMMENT_TO_PAGE}.
*
* @return event type
*/
@Override
public String getEventType() {
return EventTypes.ADD_COMMENT_TO_PAGE;
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.mail;
import java.io.IOException;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
/**
* Mail service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Aug 8, 2011
*/
public interface MailService {
/**
* Sends the specified message as a mail asynchronously.
*
* @param message the specified message
* @throws IOException if internal errors
*/
void send(final Message message) throws IOException;
/**
* Mail message.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Aug 8, 2011
*/
class Message {
/**
* From.
*/
private String from;
/**
* Recipients.
*/
private Set<String> recipients = new HashSet<>();
/**
* HTML body.
*/
private String htmlBody;
/**
* Subject.
*/
private String subject;
/**
* Gets the recipients.
*
* @return recipients
*/
public Set<String> getRecipients() {
return Collections.unmodifiableSet(recipients);
}
/**
* Adds the specified recipient.
*
* @param recipient the specified recipient
*/
public void addRecipient(final String recipient) {
recipients.add(recipient);
}
/**
* Gets the HTML body.
*
* @return HTML body
*/
public String getHtmlBody() {
return htmlBody;
}
/**
* Sets the HTML body with the specified HTML body.
*
* @param htmlBody the specified HTML body
*/
public void setHtmlBody(final String htmlBody) {
this.htmlBody = htmlBody;
}
/**
* Gets the from.
*
* @return from
*/
public String getFrom() {
return from;
}
/**
* Sets the from with the specified from.
*
* @param from the specified from
*/
public void setFrom(final String from) {
this.from = from;
}
/**
* Gets the subject.
*
* @return subject
*/
public String getSubject() {
return subject;
}
/**
* Sets the subject with the specified subject.
*
* @param subject the specified subject
*/
public void setSubject(final String subject) {
this.subject = subject;
}
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.mail;
/**
* Mail service factory.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.3, Dec 3, 2018
*/
public final class MailServiceFactory {
/**
* Mail service.
*/
private static final MailService MAIL_SERVICE;
static {
try {
final Class<MailService> mailServiceClass = (Class<MailService>) Class.forName("org.b3log.solo.mail.local.LocalMailService");
MAIL_SERVICE = mailServiceClass.newInstance();
} catch (final Exception e) {
throw new RuntimeException("Can not initialize mail service!", e);
}
}
/**
* Private constructor.
*/
private MailServiceFactory() {
}
/**
* Gets mail service.
*
* @return mail service
*/
public static MailService getMailService() {
return MAIL_SERVICE;
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.mail.local;
import org.b3log.solo.mail.MailService;
/**
* JavaMail implementation of the {@link MailService} interface.
*
* @author <a href="https://hacpai.com/member/jiangzezhou">zezhou jiang</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Jan 18, 2019
*/
public final class LocalMailService implements MailService {
@Override
public void send(final Message message) {
new Thread(() -> new MailSender().sendMail(message)).start();
}
}
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.mail.local;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.solo.mail.MailService.Message;
import javax.mail.*;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMessage.RecipientType;
import javax.mail.internet.MimeUtility;
import java.util.Properties;
import java.util.ResourceBundle;
import java.util.Set;
/**
* Email sender.
*
* @author <a href="https://hacpai.com/member/jiangzezhou">zezhou jiang</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.2.5, Jan 18, 2019
*/
final class MailSender {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(MailSender.class);
/**
* Mail configurations.
*
* <ul>
* <li>mail.user</li>
* <li>mail.password</li>
* <li>mail.smtp.host</li>
* <li>mail.smtp.auth</li>
* <li>mail.smtp.port</li>
* <li>mail.smtp.starttls.enable</li>
* <li>mail.debug</li>
* <li>mail.smtp.socketFactory.class</li>
* <li>mail.smtp.socketFactory.fallback</li>
* <li>mail.smtp.socketFactory.port</li>
* </ul>
*/
private static final ResourceBundle mailProperties = ResourceBundle.getBundle("mail");
/**
* Create session based on the mail properties.
*
* @return session session from mail properties
*/
private Session getSession() {
final Properties props = new Properties();
props.setProperty("mail.smtp.host", mailProperties.getString("mail.smtp.host"));
String auth = "true";
if (mailProperties.containsKey("mail.smtp.auth")) {
auth = mailProperties.getString("mail.smtp.auth");
}
props.setProperty("mail.smtp.auth", auth);
props.setProperty("mail.smtp.port", mailProperties.getString("mail.smtp.port"));
String starttls = "true";
if (mailProperties.containsKey("mail.smtp.starttls.enable")) {
starttls = mailProperties.getString("mail.smtp.starttls.enable");
}
props.put("mail.smtp.starttls.enable", starttls);
props.put("mail.debug", mailProperties.getString("mail.debug"));
props.put("mail.smtp.socketFactory.class", mailProperties.getString("mail.smtp.socketFactory.class"));
props.put("mail.smtp.socketFactory.fallback", mailProperties.getString("mail.smtp.socketFactory.fallback"));
props.put("mail.smtp.socketFactory.port", mailProperties.getString("mail.smtp.socketFactory.port"));
return Session.getInstance(props, new SMTPAuthenticator());
}
/**
* Converts the specified message into a {@link javax.mail.Message javax.mail.Message}.
*
* @param message the specified message
* @return a {@link javax.mail.internet.MimeMessage}
* @throws Exception if converts error
*/
public javax.mail.Message convert2JavaMailMsg(final Message message) throws Exception {
if (null == message) {
return null;
}
if (StringUtils.isBlank(message.getFrom())) {
throw new MessagingException("Null from");
}
if (null == message.getRecipients() || message.getRecipients().isEmpty()) {
throw new MessagingException("Null recipients");
}
final MimeMessage ret = new MimeMessage(getSession());
ret.setFrom(new InternetAddress(message.getFrom()));
final String subject = message.getSubject();
ret.setSubject(MimeUtility.encodeText(subject != null ? subject : "", "UTF-8", "B"));
final String htmlBody = message.getHtmlBody();
ret.setContent(htmlBody != null ? htmlBody : "", "text/html;charset=UTF-8");
ret.addRecipients(RecipientType.TO, transformRecipients(message.getRecipients()));
return ret;
}
/**
* Transport recipients to InternetAddress array.
*
* @param recipients the set of all recipients
* @return InternetAddress array of all recipients internetAddress
* @throws MessagingException messagingException from javax.mail
*/
private InternetAddress[] transformRecipients(final Set<String> recipients) throws MessagingException {
if (recipients.isEmpty()) {
throw new MessagingException("recipients of mail should not be empty");
}
final InternetAddress[] ret = new InternetAddress[recipients.size()];
int i = 0;
for (String recipient : recipients) {
ret[i] = new InternetAddress(recipient);
i++;
}
return ret;
}
/**
* Sends email.
*
* @param message the specified message
* @throws Exception message exception
*/
void sendMail(final Message message) {
try {
final javax.mail.Message msg = convert2JavaMailMsg(message);
Transport.send(msg);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Sends mail failed", e);
}
}
/**
* Inner class for Authenticator.
*/
private class SMTPAuthenticator extends Authenticator {
@Override
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(mailProperties.getString("mail.user"), mailProperties.getString("mail.password"));
}
}
}
/**
* Provides mail service (via <a href="http://www.oracle.com/technetwork/java/javamail/index.html">
* JavaMail</a>) on local (standard Servlet container).
*/
package org.b3log.solo.mail.local;
/**
* Main service.
*/
package org.b3log.solo.mail;
...@@ -138,11 +138,6 @@ public final class Article { ...@@ -138,11 +138,6 @@ public final class Article {
*/ */
public static final String ARTICLE_AUTHOR_ID = "articleAuthorId"; public static final String ARTICLE_AUTHOR_ID = "articleAuthorId";
/**
* Key of author email.
*/
public static final String ARTICLE_T_AUTHOR_EMAIL = "articleAuthorEmail";
/** /**
* Key of had been published. * Key of had been published.
*/ */
......
...@@ -24,7 +24,7 @@ import org.json.JSONObject; ...@@ -24,7 +24,7 @@ import org.json.JSONObject;
* This class defines all comment model relevant keys. * This class defines all comment model relevant keys.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.0, Sep 21, 2018 * @version 1.2.0.1, Mar 3, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
public final class Comment { public final class Comment {
...@@ -49,11 +49,6 @@ public final class Comment { ...@@ -49,11 +49,6 @@ public final class Comment {
*/ */
public static final String COMMENT_NAME = "commentName"; public static final String COMMENT_NAME = "commentName";
/**
* Key of comment email.
*/
public static final String COMMENT_EMAIL = "commentEmail";
/** /**
* Key of comment URL. * Key of comment URL.
*/ */
......
...@@ -26,7 +26,7 @@ import org.json.JSONObject; ...@@ -26,7 +26,7 @@ import org.json.JSONObject;
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://github.com/hzchendou">hzchendou</a> * @author <a href="https://github.com/hzchendou">hzchendou</a>
* @version 1.5.0.3, Feb 8, 2019 * @version 1.5.0.4, Mar 3, 2019
* @since 0.6.0 * @since 0.6.0
*/ */
public final class Option { public final class Option {
...@@ -117,11 +117,6 @@ public final class Option { ...@@ -117,11 +117,6 @@ public final class Option {
*/ */
public static final String ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE = "articleListPaginationWindowSize"; public static final String ID_C_ARTICLE_LIST_PAGINATION_WINDOW_SIZE = "articleListPaginationWindowSize";
/**
* Key of administrator's email.
*/
public static final String ID_C_ADMIN_EMAIL = "adminEmail";
/** /**
* Key of locale string. * Key of locale string.
*/ */
...@@ -227,16 +222,6 @@ public final class Option { ...@@ -227,16 +222,6 @@ public final class Option {
*/ */
public static final String ID_C_SKIN_NAME = "skinName"; public static final String ID_C_SKIN_NAME = "skinName";
/**
* Key of reply notification template body.
*/
public static final String ID_C_REPLY_NOTI_TPL_BODY = "replyNotiTplBody";
/**
* Key of reply notification template subject.
*/
public static final String ID_C_REPLY_NOTI_TPL_SUBJECT = "replyNotiTplSubject";
/** /**
* Key of footer content. * Key of footer content.
*/ */
...@@ -426,16 +411,6 @@ public final class Option { ...@@ -426,16 +411,6 @@ public final class Option {
*/ */
public static final String DEFAULT_ARTICLE_LIST_STYLE = "titleAndAbstract"; public static final String DEFAULT_ARTICLE_LIST_STYLE = "titleAndAbstract";
/**
* Default key of solo.
*/
public static final String DEFAULT_KEY_OF_SOLO = "Your key";
/**
* Default reply notification template.
*/
public static final String DEFAULT_REPLY_NOTIFICATION_TEMPLATE;
/** /**
* Default feed output mode. * Default feed output mode.
*/ */
...@@ -459,13 +434,6 @@ public final class Option { ...@@ -459,13 +434,6 @@ public final class Option {
// Sign(id=0) is the 'empty' sign, used for article user needn't a sign // Sign(id=0) is the 'empty' sign, used for article user needn't a sign
DEFAULT_SIGNS = signs.toString(); DEFAULT_SIGNS = signs.toString();
final JSONObject replyNotificationTemplate = new JSONObject();
replyNotificationTemplate.put("subject", "${blogTitle}: New reply of your comment");
replyNotificationTemplate.put("body",
"Your comment on post[<a href='${postLink}'>" + "${postTitle}</a>] received an reply: <p>${replier}"
+ ": <span><a href='${replyURL}'>${replyContent}</a></span></p>");
DEFAULT_REPLY_NOTIFICATION_TEMPLATE = replyNotificationTemplate.toString();
} }
/** /**
......
...@@ -148,7 +148,7 @@ public class ArticleProcessor { ...@@ -148,7 +148,7 @@ public class ArticleProcessor {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@RequestProcessing(value = "/console/markdown/2html", method = HttpMethod.POST) @RequestProcessing(value = "/console/markdown/2html", method = HttpMethod.POST)
public void markdown2HTML(final RequestContext context) { public void markdown2HTML(final RequestContext context) {
...@@ -741,12 +741,7 @@ public class ArticleProcessor { ...@@ -741,12 +741,7 @@ public class ArticleProcessor {
article.put(Common.AUTHOR_ID, authorId); article.put(Common.AUTHOR_ID, authorId);
article.put(Common.AUTHOR_ROLE, author.getString(User.USER_ROLE)); article.put(Common.AUTHOR_ROLE, author.getString(User.USER_ROLE));
final String userAvatar = author.optString(UserExt.USER_AVATAR); final String userAvatar = author.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(userAvatar)) { article.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
article.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
} else {
final String thumbnailURL = Solos.getGravatarURL(author.optString(User.USER_EMAIL), "128");
article.put(Common.AUTHOR_THUMBNAIL_URL, thumbnailURL);
}
dataModelService.fillCategory(article); dataModelService.fillCategory(article);
...@@ -836,12 +831,7 @@ public class ArticleProcessor { ...@@ -836,12 +831,7 @@ public class ArticleProcessor {
dataModel.put(Common.AUTHOR_NAME, author.optString(User.USER_NAME)); dataModel.put(Common.AUTHOR_NAME, author.optString(User.USER_NAME));
final String userAvatar = author.optString(UserExt.USER_AVATAR); final String userAvatar = author.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(userAvatar)) { dataModel.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
dataModel.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
} else {
final String thumbnailURL = Solos.getGravatarURL(author.optString(User.USER_EMAIL), "128");
dataModel.put(Common.AUTHOR_THUMBNAIL_URL, thumbnailURL);
}
dataModel.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, currentPageNum); dataModel.put(Pagination.PAGINATION_CURRENT_PAGE_NUM, currentPageNum);
} }
......
...@@ -133,7 +133,7 @@ public class B3Receiver { ...@@ -133,7 +133,7 @@ public class B3Receiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@RequestProcessing(value = "/apis/symphony/article", method = {HttpMethod.POST, HttpMethod.PUT}) @RequestProcessing(value = "/apis/symphony/article", method = {HttpMethod.POST, HttpMethod.PUT})
public void postArticle(final RequestContext context) { public void postArticle(final RequestContext context) {
...@@ -235,7 +235,7 @@ public class B3Receiver { ...@@ -235,7 +235,7 @@ public class B3Receiver {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@RequestProcessing(value = "/apis/symphony/comment", method = HttpMethod.PUT) @RequestProcessing(value = "/apis/symphony/comment", method = HttpMethod.PUT)
public void addComment(final RequestContext context) { public void addComment(final RequestContext context) {
...@@ -290,7 +290,6 @@ public class B3Receiver { ...@@ -290,7 +290,6 @@ public class B3Receiver {
final String commentId = Ids.genTimeMillisId(); final String commentId = Ids.genTimeMillisId();
comment.put(Keys.OBJECT_ID, commentId); comment.put(Keys.OBJECT_ID, commentId);
comment.put(Comment.COMMENT_NAME, commentName); comment.put(Comment.COMMENT_NAME, commentName);
comment.put(Comment.COMMENT_EMAIL, "");
comment.put(Comment.COMMENT_URL, commentURL); comment.put(Comment.COMMENT_URL, commentURL);
comment.put(Comment.COMMENT_THUMBNAIL_URL, commentThumbnailURL); comment.put(Comment.COMMENT_THUMBNAIL_URL, commentThumbnailURL);
comment.put(Comment.COMMENT_CONTENT, commentContent); comment.put(Comment.COMMENT_CONTENT, commentContent);
...@@ -304,12 +303,7 @@ public class B3Receiver { ...@@ -304,12 +303,7 @@ public class B3Receiver {
comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL); comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL);
commentRepository.add(comment); commentRepository.add(comment);
articleMgmtService.incArticleCommentCount(articleId); articleMgmtService.incArticleCommentCount(articleId);
try {
final JSONObject preference = preferenceQueryService.getPreference();
commentMgmtService.sendNotificationMail(article, comment, null, preference);
} catch (final Exception e) {
LOGGER.log(Level.WARN, "Send mail failed", e);
}
transaction.commit(); transaction.commit();
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
......
...@@ -99,7 +99,6 @@ public class CommentProcessor { ...@@ -99,7 +99,6 @@ public class CommentProcessor {
* "captcha": "", * "captcha": "",
* "oId": pageId, * "oId": pageId,
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply * "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
...@@ -196,7 +195,6 @@ public class CommentProcessor { ...@@ -196,7 +195,6 @@ public class CommentProcessor {
* "captcha": "", * "captcha": "",
* "oId": articleId, * "oId": articleId,
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
* "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply * "commentOriginalCommentId": "" // optional, if exists this key, the comment is an reply
...@@ -295,7 +293,6 @@ public class CommentProcessor { ...@@ -295,7 +293,6 @@ public class CommentProcessor {
} }
requestJSONObject.put(Comment.COMMENT_NAME, currentUser.optString(User.USER_NAME)); requestJSONObject.put(Comment.COMMENT_NAME, currentUser.optString(User.USER_NAME));
requestJSONObject.put(Comment.COMMENT_EMAIL, currentUser.optString(User.USER_EMAIL));
requestJSONObject.put(Comment.COMMENT_URL, currentUser.optString(User.USER_URL)); requestJSONObject.put(Comment.COMMENT_URL, currentUser.optString(User.USER_URL));
} }
} }
...@@ -49,7 +49,7 @@ public class KanBanNiangProcessor { ...@@ -49,7 +49,7 @@ public class KanBanNiangProcessor {
/** /**
* Returns a random model. * Returns a random model.
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@RequestProcessing(value = "/plugins/kanbanniang/assert/model", method = HttpMethod.GET) @RequestProcessing(value = "/plugins/kanbanniang/assert/model", method = HttpMethod.GET)
public void randomModel(final RequestContext context) { public void randomModel(final RequestContext context) {
......
...@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap; ...@@ -54,7 +54,7 @@ import java.util.concurrent.ConcurrentHashMap;
* </ul> * </ul>
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.5, Feb 27, 2019 * @version 1.0.0.6, Mar 2, 2019
* @since 2.9.5 * @since 2.9.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -142,7 +142,7 @@ public class OAuthProcessor { ...@@ -142,7 +142,7 @@ public class OAuthProcessor {
STATES.put(state, URLs.encode(state)); STATES.put(state, URLs.encode(state));
final String path = loginAuthURL + "?client_id=" + clientId + "&state=" + state final String path = loginAuthURL + "?client_id=" + clientId + "&state=" + state
+ "&scope=public_repo,read:user,user:email,user:follow"; + "&scope=public_repo,read:user,user:follow";
context.sendRedirect(path); context.sendRedirect(path);
} }
...@@ -157,7 +157,7 @@ public class OAuthProcessor { ...@@ -157,7 +157,7 @@ public class OAuthProcessor {
final String state = context.param("state"); final String state = context.param("state");
String referer = STATES.get(state); String referer = STATES.get(state);
if (StringUtils.isBlank(referer)) { if (StringUtils.isBlank(referer)) {
context.sendError(HttpServletResponse.SC_FORBIDDEN); context.sendError(HttpServletResponse.SC_BAD_REQUEST);
return; return;
} }
...@@ -166,6 +166,7 @@ public class OAuthProcessor { ...@@ -166,6 +166,7 @@ public class OAuthProcessor {
final String accessToken = context.param("ak"); final String accessToken = context.param("ak");
final JSONObject userInfo = GitHubs.getGitHubUserInfo(accessToken); final JSONObject userInfo = GitHubs.getGitHubUserInfo(accessToken);
if (null == userInfo) { if (null == userInfo) {
LOGGER.log(Level.WARN, "Can't get user info with token [" + accessToken + "]");
context.sendError(HttpServletResponse.SC_FORBIDDEN); context.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
...@@ -175,7 +176,6 @@ public class OAuthProcessor { ...@@ -175,7 +176,6 @@ public class OAuthProcessor {
final HttpServletRequest request = context.getRequest(); final HttpServletRequest request = context.getRequest();
final String openId = userInfo.optString("openId"); final String openId = userInfo.optString("openId");
final String userName = userInfo.optString(User.USER_NAME); final String userName = userInfo.optString(User.USER_NAME);
final String userEmail = userInfo.optString(User.USER_EMAIL);
final String userAvatar = userInfo.optString(UserExt.USER_AVATAR); final String userAvatar = userInfo.optString(UserExt.USER_AVATAR);
JSONObject user = userQueryService.getUserByGitHubId(openId); JSONObject user = userQueryService.getUserByGitHubId(openId);
...@@ -183,20 +183,16 @@ public class OAuthProcessor { ...@@ -183,20 +183,16 @@ public class OAuthProcessor {
if (!initService.isInited()) { if (!initService.isInited()) {
final JSONObject initReq = new JSONObject(); final JSONObject initReq = new JSONObject();
initReq.put(User.USER_NAME, userName); initReq.put(User.USER_NAME, userName);
initReq.put(User.USER_EMAIL, userEmail);
initReq.put(UserExt.USER_AVATAR, userAvatar); initReq.put(UserExt.USER_AVATAR, userAvatar);
initReq.put(UserExt.USER_B3_KEY, openId); initReq.put(UserExt.USER_B3_KEY, openId);
initReq.put(UserExt.USER_GITHUB_ID, openId); initReq.put(UserExt.USER_GITHUB_ID, openId);
try { initService.init(initReq);
initService.init(initReq);
} catch (final Exception e) {
// ignored
}
} else { } else {
user = userQueryService.getUserByEmailOrUserName(userName); user = userQueryService.getUserByName(userName);
if (null == user) { if (null == user) {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
if (!preference.optBoolean(Option.ID_C_ALLOW_REGISTER)) { if (!preference.optBoolean(Option.ID_C_ALLOW_REGISTER)) {
LOGGER.log(Level.DEBUG, "Not allow register");
context.sendError(HttpServletResponse.SC_FORBIDDEN); context.sendError(HttpServletResponse.SC_FORBIDDEN);
return; return;
...@@ -204,7 +200,6 @@ public class OAuthProcessor { ...@@ -204,7 +200,6 @@ public class OAuthProcessor {
final JSONObject addUserReq = new JSONObject(); final JSONObject addUserReq = new JSONObject();
addUserReq.put(User.USER_NAME, userName); addUserReq.put(User.USER_NAME, userName);
addUserReq.put(User.USER_EMAIL, userEmail);
addUserReq.put(UserExt.USER_AVATAR, userAvatar); addUserReq.put(UserExt.USER_AVATAR, userAvatar);
addUserReq.put(User.USER_ROLE, Role.VISITOR_ROLE); addUserReq.put(User.USER_ROLE, Role.VISITOR_ROLE);
addUserReq.put(UserExt.USER_GITHUB_ID, openId); addUserReq.put(UserExt.USER_GITHUB_ID, openId);
...@@ -213,7 +208,7 @@ public class OAuthProcessor { ...@@ -213,7 +208,7 @@ public class OAuthProcessor {
userMgmtService.addUser(addUserReq); userMgmtService.addUser(addUserReq);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Register via oauth failed", e); LOGGER.log(Level.ERROR, "Register via oauth failed", e);
context.sendError(HttpServletResponse.SC_UNAUTHORIZED); context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return; return;
} }
...@@ -221,8 +216,9 @@ public class OAuthProcessor { ...@@ -221,8 +216,9 @@ public class OAuthProcessor {
} }
} }
user = userQueryService.getUserByEmailOrUserName(userName); user = userQueryService.getUserByName(userName);
if (null == user) { if (null == user) {
LOGGER.log(Level.WARN, "Can't get user by name [" + userName + "]");
context.sendError(HttpServletResponse.SC_UNAUTHORIZED); context.sendError(HttpServletResponse.SC_UNAUTHORIZED);
return; return;
......
...@@ -135,14 +135,8 @@ public class AdminConsole { ...@@ -135,14 +135,8 @@ public class AdminConsole {
dataModel.put(User.USER_NAME, userName); dataModel.put(User.USER_NAME, userName);
final String roleName = currentUser.optString(User.USER_ROLE); final String roleName = currentUser.optString(User.USER_ROLE);
dataModel.put(User.USER_ROLE, roleName); dataModel.put(User.USER_ROLE, roleName);
final String email = currentUser.optString(User.USER_EMAIL);
final String userAvatar = currentUser.optString(UserExt.USER_AVATAR); final String userAvatar = currentUser.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(userAvatar)) { dataModel.put(Common.GRAVATAR, userAvatar);
dataModel.put(Common.GRAVATAR, userAvatar);
} else {
final String gravatar = Solos.getGravatarURL(email, "128");
dataModel.put(Common.GRAVATAR, gravatar);
}
try { try {
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
...@@ -238,7 +232,7 @@ public class AdminConsole { ...@@ -238,7 +232,7 @@ public class AdminConsole {
/** /**
* Exports data as SQL zip file. * Exports data as SQL zip file.
* *
* @param context the specified HTTP request context * @param context the specified request context
*/ */
public void exportSQL(final RequestContext context) { public void exportSQL(final RequestContext context) {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
...@@ -351,7 +345,7 @@ public class AdminConsole { ...@@ -351,7 +345,7 @@ public class AdminConsole {
/** /**
* Exports data as JSON zip file. * Exports data as JSON zip file.
* *
* @param context the specified HTTP request context * @param context the specified request context
*/ */
public void exportJSON(final RequestContext context) { public void exportJSON(final RequestContext context) {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
...@@ -401,7 +395,7 @@ public class AdminConsole { ...@@ -401,7 +395,7 @@ public class AdminConsole {
/** /**
* Exports data as Hexo markdown zip file. * Exports data as Hexo markdown zip file.
* *
* @param context the specified HTTP request context * @param context the specified request context
*/ */
public void exportHexo(final RequestContext context) { public void exportHexo(final RequestContext context) {
final HttpServletResponse response = context.getResponse(); final HttpServletResponse response = context.getResponse();
......
...@@ -114,7 +114,7 @@ public class ArticleConsole { ...@@ -114,7 +114,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getArticleThumbs(final RequestContext context) { public void getArticleThumbs(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -175,7 +175,7 @@ public class ArticleConsole { ...@@ -175,7 +175,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getArticle(final RequestContext context) { public void getArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -224,7 +224,7 @@ public class ArticleConsole { ...@@ -224,7 +224,7 @@ public class ArticleConsole {
* </pre>, order by article update date and sticky(put top). * </pre>, order by article update date and sticky(put top).
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getArticles(final RequestContext context) { public void getArticles(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -285,7 +285,7 @@ public class ArticleConsole { ...@@ -285,7 +285,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void removeArticle(final RequestContext context) { public void removeArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -329,7 +329,7 @@ public class ArticleConsole { ...@@ -329,7 +329,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void cancelPublishArticle(final RequestContext context) { public void cancelPublishArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -373,7 +373,7 @@ public class ArticleConsole { ...@@ -373,7 +373,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void cancelTopArticle(final RequestContext context) { public void cancelTopArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -414,7 +414,7 @@ public class ArticleConsole { ...@@ -414,7 +414,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void putTopArticle(final RequestContext context) { public void putTopArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -475,7 +475,7 @@ public class ArticleConsole { ...@@ -475,7 +475,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updateArticle(final RequestContext context) { public void updateArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -540,7 +540,7 @@ public class ArticleConsole { ...@@ -540,7 +540,7 @@ public class ArticleConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void addArticle(final RequestContext context) { public void addArticle(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -108,7 +108,7 @@ public class CategoryConsole { ...@@ -108,7 +108,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
* @throws Exception exception * @throws Exception exception
*/ */
public void changeOrder(final RequestContext context) { public void changeOrder(final RequestContext context) {
...@@ -151,7 +151,7 @@ public class CategoryConsole { ...@@ -151,7 +151,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
* @throws Exception exception * @throws Exception exception
*/ */
public void getCategory(final RequestContext context) { public void getCategory(final RequestContext context) {
...@@ -197,7 +197,7 @@ public class CategoryConsole { ...@@ -197,7 +197,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
* @throws Exception exception * @throws Exception exception
*/ */
public void removeCategory(final RequestContext context) { public void removeCategory(final RequestContext context) {
...@@ -243,7 +243,7 @@ public class CategoryConsole { ...@@ -243,7 +243,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updateCategory(final RequestContext context) { public void updateCategory(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -375,7 +375,7 @@ public class CategoryConsole { ...@@ -375,7 +375,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void addCategory(final RequestContext context) { public void addCategory(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -505,7 +505,7 @@ public class CategoryConsole { ...@@ -505,7 +505,7 @@ public class CategoryConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getCategories(final RequestContext context) { public void getCategories(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -81,7 +81,7 @@ public class CommentConsole { ...@@ -81,7 +81,7 @@ public class CommentConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void removePageComment(final RequestContext context) { public void removePageComment(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -123,7 +123,7 @@ public class CommentConsole { ...@@ -123,7 +123,7 @@ public class CommentConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void removeArticleComment(final RequestContext context) { public void removeArticleComment(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -173,7 +173,6 @@ public class CommentConsole { ...@@ -173,7 +173,6 @@ public class CommentConsole {
* "oId": "", * "oId": "",
* "commentTitle": "", * "commentTitle": "",
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "thumbnailUrl": "", * "thumbnailUrl": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
...@@ -184,7 +183,7 @@ public class CommentConsole { ...@@ -184,7 +183,7 @@ public class CommentConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getComments(final RequestContext context) { public void getComments(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -219,7 +218,6 @@ public class CommentConsole { ...@@ -219,7 +218,6 @@ public class CommentConsole {
* "comments": [{ * "comments": [{
* "oId": "", * "oId": "",
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "thumbnailUrl": "", * "thumbnailUrl": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
...@@ -231,7 +229,7 @@ public class CommentConsole { ...@@ -231,7 +229,7 @@ public class CommentConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getArticleComments(final RequestContext context) { public void getArticleComments(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -264,7 +262,6 @@ public class CommentConsole { ...@@ -264,7 +262,6 @@ public class CommentConsole {
* "comments": [{ * "comments": [{
* "oId": "", * "oId": "",
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "thumbnailUrl": "", * "thumbnailUrl": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
...@@ -276,7 +273,7 @@ public class CommentConsole { ...@@ -276,7 +273,7 @@ public class CommentConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getPageComments(final RequestContext context) { public void getPageComments(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -82,7 +82,7 @@ public class LinkConsole { ...@@ -82,7 +82,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void removeLink(final RequestContext context) { public void removeLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -129,7 +129,7 @@ public class LinkConsole { ...@@ -129,7 +129,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updateLink(final RequestContext context) { public void updateLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -173,7 +173,7 @@ public class LinkConsole { ...@@ -173,7 +173,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void changeOrder(final RequestContext context) { public void changeOrder(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -223,7 +223,7 @@ public class LinkConsole { ...@@ -223,7 +223,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void addLink(final RequestContext context) { public void addLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -273,7 +273,7 @@ public class LinkConsole { ...@@ -273,7 +273,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getLinks(final RequestContext context) { public void getLinks(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -320,7 +320,7 @@ public class LinkConsole { ...@@ -320,7 +320,7 @@ public class LinkConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getLink(final RequestContext context) { public void getLink(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -109,7 +109,7 @@ public class PageConsole { ...@@ -109,7 +109,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updatePage(final RequestContext context) { public void updatePage(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -144,7 +144,7 @@ public class PageConsole { ...@@ -144,7 +144,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void removePage(final RequestContext context) { public void removePage(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -196,7 +196,7 @@ public class PageConsole { ...@@ -196,7 +196,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void addPage(final RequestContext context) { public void addPage(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -241,7 +241,7 @@ public class PageConsole { ...@@ -241,7 +241,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void changeOrder(final RequestContext context) { public void changeOrder(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -288,7 +288,7 @@ public class PageConsole { ...@@ -288,7 +288,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getPage(final RequestContext context) { public void getPage(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -338,7 +338,7 @@ public class PageConsole { ...@@ -338,7 +338,7 @@ public class PageConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getPages(final RequestContext context) { public void getPages(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -82,7 +82,7 @@ public class PluginConsole { ...@@ -82,7 +82,7 @@ public class PluginConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void setPluginStatus(final RequestContext context) { public void setPluginStatus(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -122,7 +122,7 @@ public class PluginConsole { ...@@ -122,7 +122,7 @@ public class PluginConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
* @throws Exception exception * @throws Exception exception
*/ */
public void getPlugins(final RequestContext context) { public void getPlugins(final RequestContext context) {
...@@ -149,7 +149,7 @@ public class PluginConsole { ...@@ -149,7 +149,7 @@ public class PluginConsole {
/** /**
* get the info of the specified pluginoId,just fot the plugin-setting. * get the info of the specified pluginoId,just fot the plugin-setting.
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void toSetting(final RequestContext context) { public void toSetting(final RequestContext context) {
final ConsoleRenderer renderer = new ConsoleRenderer(context, "admin-plugin-setting.ftl"); final ConsoleRenderer renderer = new ConsoleRenderer(context, "admin-plugin-setting.ftl");
...@@ -175,7 +175,7 @@ public class PluginConsole { ...@@ -175,7 +175,7 @@ public class PluginConsole {
/** /**
* update the setting of the plugin. * update the setting of the plugin.
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updateSetting(final RequestContext context) { public void updateSetting(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -87,82 +87,6 @@ public class PreferenceConsole { ...@@ -87,82 +87,6 @@ public class PreferenceConsole {
@Inject @Inject
private LangPropsService langPropsService; private LangPropsService langPropsService;
/**
* Gets reply template.
* <p>
* Renders the response with a json object, for example,
* <pre>
* {
* "sc": boolean,
* "replyNotificationTemplate": {
* "subject": "",
* "body": ""
* }
* }
* </pre>
* </p>
*
* @param context the specified http request context
*/
public void getReplyNotificationTemplate(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
final JSONObject ret = new JSONObject();
renderer.setJSONObject(ret);
ret.put("replyNotificationTemplate", replyNotificationTemplate);
ret.put(Keys.STATUS_CODE, true);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("getFailLabel"));
}
}
/**
* Updates reply template.
* <p>
* <p>
* Request json:
* <pre>
* {
* "replyNotificationTemplate": {
* "subject": "",
* "body": ""
* }
* }
* </pre>
* </p>
*
* @param context the specified http request context
*/
public void updateReplyNotificationTemplate(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer();
context.setRenderer(renderer);
try {
final JSONObject requestJSONObject = context.requestJSON();
final JSONObject replyNotificationTemplate = requestJSONObject.getJSONObject("replyNotificationTemplate");
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
final JSONObject ret = new JSONObject();
ret.put(Keys.STATUS_CODE, true);
ret.put(Keys.MSG, langPropsService.get("updateSuccLabel"));
renderer.setJSONObject(ret);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e);
final JSONObject jsonObject = new JSONObject().put(Keys.STATUS_CODE, false);
renderer.setJSONObject(jsonObject);
jsonObject.put(Keys.MSG, langPropsService.get("updateFailLabel"));
}
}
/** /**
* Gets signs. * Gets signs.
* <p> * <p>
...@@ -178,7 +102,7 @@ public class PreferenceConsole { ...@@ -178,7 +102,7 @@ public class PreferenceConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getSigns(final RequestContext context) { public void getSigns(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -237,7 +161,6 @@ public class PreferenceConsole { ...@@ -237,7 +161,6 @@ public class PreferenceConsole {
* "noticeBoard": "", * "noticeBoard": "",
* "footerContent": "", * "footerContent": "",
* "htmlHead": "", * "htmlHead": "",
* "adminEmail": "",
* "metaKeywords": "", * "metaKeywords": "",
* "metaDescription": "", * "metaDescription": "",
* "enableArticleUpdateHint": boolean, * "enableArticleUpdateHint": boolean,
...@@ -258,7 +181,7 @@ public class PreferenceConsole { ...@@ -258,7 +181,7 @@ public class PreferenceConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void getPreference(final RequestContext context) { public void getPreference(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
...@@ -336,7 +259,7 @@ public class PreferenceConsole { ...@@ -336,7 +259,7 @@ public class PreferenceConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
public void updatePreference(final RequestContext context) { public void updatePreference(final RequestContext context) {
final JsonRenderer renderer = new JsonRenderer(); final JsonRenderer renderer = new JsonRenderer();
......
...@@ -24,8 +24,6 @@ import org.b3log.latke.servlet.RequestContext; ...@@ -24,8 +24,6 @@ import org.b3log.latke.servlet.RequestContext;
import org.b3log.latke.servlet.annotation.Before; import org.b3log.latke.servlet.annotation.Before;
import org.b3log.latke.servlet.annotation.RequestProcessor; import org.b3log.latke.servlet.annotation.RequestProcessor;
import org.b3log.latke.servlet.renderer.TextHtmlRenderer; import org.b3log.latke.servlet.renderer.TextHtmlRenderer;
import org.b3log.solo.mail.MailService;
import org.b3log.solo.mail.MailServiceFactory;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.TagArticleRepository; import org.b3log.solo.repository.TagArticleRepository;
...@@ -40,7 +38,7 @@ import org.json.JSONObject; ...@@ -40,7 +38,7 @@ import org.json.JSONObject;
* Provides patches on some special issues. * Provides patches on some special issues.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.20, Jan 28, 2019 * @version 1.2.0.21, Mar 3, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
@RequestProcessor @RequestProcessor
...@@ -52,11 +50,6 @@ public class RepairConsole { ...@@ -52,11 +50,6 @@ public class RepairConsole {
*/ */
private static final Logger LOGGER = Logger.getLogger(RepairConsole.class); private static final Logger LOGGER = Logger.getLogger(RepairConsole.class);
/**
* Mail service.
*/
private static final MailService MAIL_SVC = MailServiceFactory.getMailService();
/** /**
* Preference query service. * Preference query service.
*/ */
......
...@@ -83,7 +83,7 @@ public class TagConsole { ...@@ -83,7 +83,7 @@ public class TagConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAuthAdvice.class) @Before(ConsoleAuthAdvice.class)
public void getTags(final RequestContext context) { public void getTags(final RequestContext context) {
...@@ -117,7 +117,7 @@ public class TagConsole { ...@@ -117,7 +117,7 @@ public class TagConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void getUnusedTags(final RequestContext context) { public void getUnusedTags(final RequestContext context) {
...@@ -160,7 +160,7 @@ public class TagConsole { ...@@ -160,7 +160,7 @@ public class TagConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void removeUnusedTags(final RequestContext context) { public void removeUnusedTags(final RequestContext context) {
......
...@@ -86,7 +86,6 @@ public class UserConsole { ...@@ -86,7 +86,6 @@ public class UserConsole {
* { * {
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "",
* "userRole": "", * "userRole": "",
* "userURL": "", * "userURL": "",
* "userAvatar": "", * "userAvatar": "",
...@@ -104,7 +103,7 @@ public class UserConsole { ...@@ -104,7 +103,7 @@ public class UserConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void updateUser(final RequestContext context) { public void updateUser(final RequestContext context) {
...@@ -117,7 +116,7 @@ public class UserConsole { ...@@ -117,7 +116,7 @@ public class UserConsole {
userMgmtService.updateUser(requestJSONObject); userMgmtService.updateUser(requestJSONObject);
final String userName = requestJSONObject.optString(User.USER_NAME); final String userName = requestJSONObject.optString(User.USER_NAME);
final JSONObject user = userQueryService.getUserByEmailOrUserName(userName); final JSONObject user = userQueryService.getUserByName(userName);
Solos.login(user, context.getResponse()); Solos.login(user, context.getResponse());
ret.put(Keys.STATUS_CODE, true); ret.put(Keys.STATUS_CODE, true);
...@@ -144,7 +143,7 @@ public class UserConsole { ...@@ -144,7 +143,7 @@ public class UserConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void removeUser(final RequestContext context) { public void removeUser(final RequestContext context) {
...@@ -183,7 +182,6 @@ public class UserConsole { ...@@ -183,7 +182,6 @@ public class UserConsole {
* "users": [{ * "users": [{
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "",
* "roleName": "", * "roleName": "",
* .... * ....
* }, ....] * }, ....]
...@@ -192,7 +190,7 @@ public class UserConsole { ...@@ -192,7 +190,7 @@ public class UserConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void getUsers(final RequestContext context) { public void getUsers(final RequestContext context) {
...@@ -233,14 +231,13 @@ public class UserConsole { ...@@ -233,14 +231,13 @@ public class UserConsole {
* "user": { * "user": {
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "",
* "userAvatar": "" * "userAvatar": ""
* } * }
* } * }
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void getUser(final RequestContext context) { public void getUser(final RequestContext context) {
...@@ -273,7 +270,7 @@ public class UserConsole { ...@@ -273,7 +270,7 @@ public class UserConsole {
* </pre> * </pre>
* </p> * </p>
* *
* @param context the specified http request context * @param context the specified request context
*/ */
@Before(ConsoleAdminAuthAdvice.class) @Before(ConsoleAdminAuthAdvice.class)
public void changeUserRole(final RequestContext context) { public void changeUserRole(final RequestContext context) {
......
...@@ -24,16 +24,13 @@ import org.b3log.latke.model.User; ...@@ -24,16 +24,13 @@ import org.b3log.latke.model.User;
import org.b3log.latke.repository.*; import org.b3log.latke.repository.*;
import org.b3log.latke.repository.annotation.Repository; import org.b3log.latke.repository.annotation.Repository;
import org.b3log.solo.cache.UserCache; import org.b3log.solo.cache.UserCache;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.util.List;
/** /**
* User repository. * User repository.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.1, Sep 30, 2018 * @version 1.1.0.2, Mar 2, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
@Repository @Repository
...@@ -96,41 +93,7 @@ public class UserRepository extends AbstractRepository { ...@@ -96,41 +93,7 @@ public class UserRepository extends AbstractRepository {
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
public JSONObject getByUserName(final String userName) throws RepositoryException { public JSONObject getByUserName(final String userName) throws RepositoryException {
final Query query = new Query().setPageCount(1). return getFirst(new Query().setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, userName)));
setFilter(new PropertyFilter(User.USER_NAME, FilterOperator.EQUAL, userName));
final List<JSONObject> users = getList(query);
if (users.isEmpty()) {
return null;
}
return users.get(0);
}
/**
* Gets a user by the specified email.
*
* @param email the specified email
* @return user, returns {@code null} if not found
* @throws RepositoryException repository exception
*/
public JSONObject getByEmail(final String email) throws RepositoryException {
JSONObject ret = userCache.getUserByEmail(email);
if (null != ret) {
return ret;
}
final Query query = new Query().setPageCount(1).
setFilter(new PropertyFilter(User.USER_EMAIL, FilterOperator.EQUAL, email.toLowerCase().trim()));
final JSONObject result = get(query);
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null;
}
ret = array.optJSONObject(0);
userCache.putUser(ret);
return ret;
} }
/** /**
...@@ -145,14 +108,11 @@ public class UserRepository extends AbstractRepository { ...@@ -145,14 +108,11 @@ public class UserRepository extends AbstractRepository {
return ret; return ret;
} }
final Query query = new Query().setFilter(new PropertyFilter(User.USER_ROLE, FilterOperator.EQUAL, Role.ADMIN_ROLE)).setPageCount(1); ret = getFirst(new Query().setFilter(new PropertyFilter(User.USER_ROLE, FilterOperator.EQUAL, Role.ADMIN_ROLE)));
final JSONObject result = get(query); if (null == ret) {
final JSONArray array = result.optJSONArray(Keys.RESULTS);
if (0 == array.length()) {
return null; return null;
} }
ret = array.optJSONObject(0);
userCache.putAdmin(ret); userCache.putAdmin(ret);
return ret; return ret;
......
...@@ -17,11 +17,9 @@ ...@@ -17,11 +17,9 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import jodd.http.HttpRequest;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.event.Event; import org.b3log.latke.event.Event;
import org.b3log.latke.event.EventManager; import org.b3log.latke.event.EventManager;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
...@@ -35,8 +33,6 @@ import org.b3log.latke.service.annotation.Service; ...@@ -35,8 +33,6 @@ import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids; import org.b3log.latke.util.Ids;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.event.EventTypes; import org.b3log.solo.event.EventTypes;
import org.b3log.solo.mail.MailService;
import org.b3log.solo.mail.MailServiceFactory;
import org.b3log.solo.model.*; import org.b3log.solo.model.*;
import org.b3log.solo.repository.ArticleRepository; import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository; import org.b3log.solo.repository.CommentRepository;
...@@ -44,42 +40,28 @@ import org.b3log.solo.repository.PageRepository; ...@@ -44,42 +40,28 @@ import org.b3log.solo.repository.PageRepository;
import org.b3log.solo.repository.UserRepository; import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.util.Emotions; import org.b3log.solo.util.Emotions;
import org.b3log.solo.util.Markdowns; import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.Solos;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
import org.jsoup.safety.Whitelist; import org.jsoup.safety.Whitelist;
import javax.servlet.http.HttpServletResponse;
import java.net.URL;
import java.util.Date; import java.util.Date;
/** /**
* Comment management service. * Comment management service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.3.5, Feb 21, 2019 * @version 1.3.3.6, Mar 3, 2019
* @since 0.3.5 * @since 0.3.5
*/ */
@Service @Service
public class CommentMgmtService { public class CommentMgmtService {
/**
* Comment mail HTML body.
*/
public static final String COMMENT_MAIL_HTML_BODY = "<p>{articleOrPage} [<a href=\"" + "{articleOrPageURL}\">" + "{title}</a>]"
+ " received a new comment:</p>" + "{commenter}: <span><a href=\"{commentSharpURL}\">" + "{commentContent}</a></span>";
/** /**
* Logger. * Logger.
*/ */
private static final Logger LOGGER = Logger.getLogger(CommentMgmtService.class); private static final Logger LOGGER = Logger.getLogger(CommentMgmtService.class);
/**
* Default user thumbnail.
*/
private static final String DEFAULT_USER_THUMBNAIL = "default-user-thumbnail.png";
/** /**
* Minimum length of comment name. * Minimum length of comment name.
*/ */
...@@ -154,103 +136,6 @@ public class CommentMgmtService { ...@@ -154,103 +136,6 @@ public class CommentMgmtService {
@Inject @Inject
private LangPropsService langPropsService; private LangPropsService langPropsService;
/**
* Mail service.
*/
private MailService mailService = MailServiceFactory.getMailService();
/**
* Sends a notification mail to administrator for notifying the specified article or page received the specified
* comment and original comment.
*
* @param articleOrPage the specified article or page
* @param comment the specified comment
* @param originalComment original comment, if not exists, set it as {@code null}
* @param preference the specified preference
* @throws Exception exception
*/
public void sendNotificationMail(final JSONObject articleOrPage,
final JSONObject comment,
final JSONObject originalComment,
final JSONObject preference) throws Exception {
if (!Solos.isMailConfigured()) {
return;
}
final String commentEmail = comment.getString(Comment.COMMENT_EMAIL);
final String commentId = comment.getString(Keys.OBJECT_ID);
final String commentContent = comment.getString(Comment.COMMENT_CONTENT);
final String adminEmail = preference.getString(Option.ID_C_ADMIN_EMAIL);
if (adminEmail.equalsIgnoreCase(commentEmail)) {
LOGGER.log(Level.DEBUG, "Do not send comment notification mail to admin itself[{0}]", adminEmail);
return;
}
if (Latkes.getServePath().contains("localhost") || Strings.isIPv4(Latkes.getServePath())) {
LOGGER.log(Level.INFO, "Solo runs on local server, so should not send mail");
return;
}
if (null != originalComment && comment.has(Comment.COMMENT_ORIGINAL_COMMENT_ID)) {
final String originalEmail = originalComment.getString(Comment.COMMENT_EMAIL);
if (originalEmail.equalsIgnoreCase(adminEmail)) {
LOGGER.log(Level.DEBUG, "Do not send comment notification mail to admin while the specified comment[{0}] is an reply",
commentId);
return;
}
}
final String blogTitle = preference.getString(Option.ID_C_BLOG_TITLE);
boolean isArticle = true;
String title = articleOrPage.optString(Article.ARTICLE_TITLE);
if (StringUtils.isBlank(title)) {
title = articleOrPage.getString(Page.PAGE_TITLE);
isArticle = false;
}
final String commentSharpURL = comment.getString(Comment.COMMENT_SHARP_URL);
final MailService.Message message = new MailService.Message();
message.setFrom(adminEmail);
message.addRecipient(adminEmail);
String mailSubject;
String articleOrPageURL;
String mailBody;
if (isArticle) {
mailSubject = blogTitle + ": New comment on article [" + title + "]";
articleOrPageURL = Latkes.getServePath() + articleOrPage.getString(Article.ARTICLE_PERMALINK);
mailBody = COMMENT_MAIL_HTML_BODY.replace("{articleOrPage}", "Article");
} else {
mailSubject = blogTitle + ": New comment on page [" + title + "]";
articleOrPageURL = Latkes.getServePath() + articleOrPage.getString(Page.PAGE_PERMALINK);
mailBody = COMMENT_MAIL_HTML_BODY.replace("{articleOrPage}", "Page");
}
message.setSubject(mailSubject);
final String commentName = comment.getString(Comment.COMMENT_NAME);
final String commentURL = comment.getString(Comment.COMMENT_URL);
String commenter;
if (!"http://".equals(commentURL)) {
commenter = "<a target=\"_blank\" " + "href=\"" + commentURL + "\">" + commentName + "</a>";
} else {
commenter = commentName;
}
mailBody = mailBody.replace("{articleOrPageURL}", articleOrPageURL).replace("{title}", title).replace("{commentContent}", commentContent).replace("{commentSharpURL}", Latkes.getServePath() + commentSharpURL).replace(
"{commenter}", commenter);
message.setHtmlBody(mailBody);
LOGGER.log(Level.DEBUG, "Sending a mail[mailSubject={0}, mailBody=[{1}] to admin[email={2}]",
mailSubject, mailBody, adminEmail);
mailService.send(message);
}
/** /**
* Checks the specified comment adding request. * Checks the specified comment adding request.
* <p> * <p>
...@@ -262,7 +147,6 @@ public class CommentMgmtService { ...@@ -262,7 +147,6 @@ public class CommentMgmtService {
* "type": "", // "article"/"page" * "type": "", // "article"/"page"
* "oId": "", * "oId": "",
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
* } * }
...@@ -309,16 +193,24 @@ public class CommentMgmtService { ...@@ -309,16 +193,24 @@ public class CommentMgmtService {
String commentName = requestJSONObject.getString(Comment.COMMENT_NAME); String commentName = requestJSONObject.getString(Comment.COMMENT_NAME);
if (MAX_COMMENT_NAME_LENGTH < commentName.length() || MIN_COMMENT_NAME_LENGTH > commentName.length()) { if (MAX_COMMENT_NAME_LENGTH < commentName.length() || MIN_COMMENT_NAME_LENGTH > commentName.length()) {
LOGGER.log(Level.WARN, "Comment name is too long[{0}]", commentName); LOGGER.log(Level.WARN, "Comment name is too long [{0}]", commentName);
ret.put(Keys.MSG, langPropsService.get("nameTooLongLabel")); ret.put(Keys.MSG, langPropsService.get("nameTooLongLabel"));
return ret; return ret;
} }
final JSONObject commenter = userRepository.getByUserName(commentName);
if (null == commenter) {
LOGGER.log(Level.WARN, "Not found user [" + commentName + "]");
ret.put(Keys.MSG, langPropsService.get("queryUserFailedLabel"));
return ret;
}
final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL); final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL);
if (!Strings.isURL(commentURL) || StringUtils.contains(commentURL, "<")) { if (!Strings.isURL(commentURL) || StringUtils.contains(commentURL, "<")) {
LOGGER.log(Level.WARN, "Comment URL is invalid[{0}]", commentURL); LOGGER.log(Level.WARN, "Comment URL is invalid [{0}]", commentURL);
ret.put(Keys.MSG, langPropsService.get("urlInvalidLabel")); ret.put(Keys.MSG, langPropsService.get("urlInvalidLabel"));
return ret; return ret;
...@@ -356,7 +248,6 @@ public class CommentMgmtService { ...@@ -356,7 +248,6 @@ public class CommentMgmtService {
* { * {
* "oId": "", // page id * "oId": "", // page id
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "commentURL": "", // optional * "commentURL": "", // optional
* "commentContent": "", * "commentContent": "",
* "commentOriginalCommentId": "" // optional * "commentOriginalCommentId": "" // optional
...@@ -391,7 +282,6 @@ public class CommentMgmtService { ...@@ -391,7 +282,6 @@ public class CommentMgmtService {
final JSONObject page = pageRepository.get(pageId); final JSONObject page = pageRepository.get(pageId);
ret.put(Page.PAGE, page); ret.put(Page.PAGE, page);
final String commentName = requestJSONObject.getString(Comment.COMMENT_NAME); final String commentName = requestJSONObject.getString(Comment.COMMENT_NAME);
final String commentEmail = requestJSONObject.getString(Comment.COMMENT_EMAIL).trim().toLowerCase();
final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL); final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL);
final String commentContent = requestJSONObject.getString(Comment.COMMENT_CONTENT); final String commentContent = requestJSONObject.getString(Comment.COMMENT_CONTENT);
...@@ -406,7 +296,6 @@ public class CommentMgmtService { ...@@ -406,7 +296,6 @@ public class CommentMgmtService {
JSONObject originalComment = null; JSONObject originalComment = null;
comment.put(Comment.COMMENT_NAME, commentName); comment.put(Comment.COMMENT_NAME, commentName);
comment.put(Comment.COMMENT_EMAIL, commentEmail);
comment.put(Comment.COMMENT_URL, commentURL); comment.put(Comment.COMMENT_URL, commentURL);
comment.put(Comment.COMMENT_CONTENT, commentContent); comment.put(Comment.COMMENT_CONTENT, commentContent);
final JSONObject preference = preferenceQueryService.getPreference(); final JSONObject preference = preferenceQueryService.getPreference();
...@@ -450,11 +339,6 @@ public class CommentMgmtService { ...@@ -450,11 +339,6 @@ public class CommentMgmtService {
comment.put(Keys.OBJECT_ID, commentId); comment.put(Keys.OBJECT_ID, commentId);
commentRepository.add(comment); commentRepository.add(comment);
incPageCommentCount(pageId); incPageCommentCount(pageId);
try {
sendNotificationMail(page, comment, originalComment, preference);
} catch (final Exception e) {
LOGGER.log(Level.WARN, "Send mail failed", e);
}
final JSONObject eventData = new JSONObject(); final JSONObject eventData = new JSONObject();
eventData.put(Comment.COMMENT, comment); eventData.put(Comment.COMMENT, comment);
...@@ -480,7 +364,6 @@ public class CommentMgmtService { ...@@ -480,7 +364,6 @@ public class CommentMgmtService {
* { * {
* "oId": "", // article id * "oId": "", // article id
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "commentURL": "", // optional * "commentURL": "", // optional
* "commentContent": "", * "commentContent": "",
* "commentOriginalCommentId": "" // optional * "commentOriginalCommentId": "" // optional
...@@ -515,7 +398,6 @@ public class CommentMgmtService { ...@@ -515,7 +398,6 @@ public class CommentMgmtService {
final JSONObject article = articleRepository.get(articleId); final JSONObject article = articleRepository.get(articleId);
ret.put(Article.ARTICLE, article); ret.put(Article.ARTICLE, article);
final String commentName = requestJSONObject.getString(Comment.COMMENT_NAME); final String commentName = requestJSONObject.getString(Comment.COMMENT_NAME);
final String commentEmail = requestJSONObject.getString(Comment.COMMENT_EMAIL).trim().toLowerCase();
final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL); final String commentURL = requestJSONObject.optString(Comment.COMMENT_URL);
final String commentContent = requestJSONObject.getString(Comment.COMMENT_CONTENT); final String commentContent = requestJSONObject.getString(Comment.COMMENT_CONTENT);
...@@ -526,11 +408,7 @@ public class CommentMgmtService { ...@@ -526,11 +408,7 @@ public class CommentMgmtService {
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, "");
JSONObject originalComment = null;
comment.put(Comment.COMMENT_NAME, commentName); comment.put(Comment.COMMENT_NAME, commentName);
comment.put(Comment.COMMENT_EMAIL, commentEmail);
comment.put(Comment.COMMENT_URL, commentURL); comment.put(Comment.COMMENT_URL, commentURL);
comment.put(Comment.COMMENT_CONTENT, commentContent); comment.put(Comment.COMMENT_CONTENT, commentContent);
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, requestJSONObject.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID)); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, requestJSONObject.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID));
...@@ -552,6 +430,7 @@ public class CommentMgmtService { ...@@ -552,6 +430,7 @@ public class CommentMgmtService {
ret.put(Comment.COMMENT_CONTENT, cmtContent); ret.put(Comment.COMMENT_CONTENT, cmtContent);
ret.put(Comment.COMMENT_URL, commentURL); ret.put(Comment.COMMENT_URL, commentURL);
JSONObject originalComment;
if (StringUtils.isNotBlank(originalCommentId)) { if (StringUtils.isNotBlank(originalCommentId)) {
originalComment = commentRepository.get(originalCommentId); originalComment = commentRepository.get(originalCommentId);
if (null != originalComment) { if (null != originalComment) {
...@@ -582,12 +461,6 @@ public class CommentMgmtService { ...@@ -582,12 +461,6 @@ public class CommentMgmtService {
commentRepository.add(comment); commentRepository.add(comment);
articleMgmtService.incArticleCommentCount(articleId); articleMgmtService.incArticleCommentCount(articleId);
try {
sendNotificationMail(article, comment, originalComment, preference);
} catch (final Exception e) {
LOGGER.log(Level.WARN, "Send mail failed", e);
}
final JSONObject eventData = new JSONObject(); final JSONObject eventData = new JSONObject();
eventData.put(Comment.COMMENT, comment); eventData.put(Comment.COMMENT, comment);
eventData.put(Article.ARTICLE, article); eventData.put(Article.ARTICLE, article);
...@@ -637,8 +510,7 @@ public class CommentMgmtService { ...@@ -637,8 +510,7 @@ public class CommentMgmtService {
* @param commentId the given comment id * @param commentId the given comment id
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void removeArticleComment(final String commentId) public void removeArticleComment(final String commentId) throws ServiceException {
throws ServiceException {
final Transaction transaction = commentRepository.beginTransaction(); final Transaction transaction = commentRepository.beginTransaction();
try { try {
...@@ -665,8 +537,7 @@ public class CommentMgmtService { ...@@ -665,8 +537,7 @@ public class CommentMgmtService {
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
public void incPageCommentCount(final String pageId) public void incPageCommentCount(final String pageId) throws JSONException, RepositoryException {
throws JSONException, RepositoryException {
final JSONObject page = pageRepository.get(pageId); final JSONObject page = pageRepository.get(pageId);
final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page)); final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT); final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT);
...@@ -682,8 +553,7 @@ public class CommentMgmtService { ...@@ -682,8 +553,7 @@ public class CommentMgmtService {
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void decArticleCommentCount(final String articleId) private void decArticleCommentCount(final String articleId) throws JSONException, RepositoryException {
throws JSONException, RepositoryException {
final JSONObject article = articleRepository.get(articleId); final JSONObject article = articleRepository.get(articleId);
final JSONObject newArticle = new JSONObject(article, JSONObject.getNames(article)); final JSONObject newArticle = new JSONObject(article, JSONObject.getNames(article));
final int commentCnt = article.getInt(Article.ARTICLE_COMMENT_COUNT); final int commentCnt = article.getInt(Article.ARTICLE_COMMENT_COUNT);
...@@ -700,8 +570,7 @@ public class CommentMgmtService { ...@@ -700,8 +570,7 @@ public class CommentMgmtService {
* @throws JSONException json exception * @throws JSONException json exception
* @throws RepositoryException repository exception * @throws RepositoryException repository exception
*/ */
private void decPageCommentCount(final String pageId) private void decPageCommentCount(final String pageId) throws JSONException, RepositoryException {
throws JSONException, RepositoryException {
final JSONObject page = pageRepository.get(pageId); final JSONObject page = pageRepository.get(pageId);
final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page)); final JSONObject newPage = new JSONObject(page, JSONObject.getNames(page));
final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT); final int commentCnt = page.getInt(Page.PAGE_COMMENT_COUNT);
...@@ -712,46 +581,14 @@ public class CommentMgmtService { ...@@ -712,46 +581,14 @@ public class CommentMgmtService {
/** /**
* Sets commenter thumbnail URL for the specified comment. * Sets commenter thumbnail URL for the specified comment.
* <p>
* Try to set thumbnail URL using:
* <ol>
* <li>User avatar</li>
* <li>Gravatar service</li>
* <ol>
* </p>
* *
* @param comment the specified comment * @param comment the specified comment
* @throws Exception exception * @throws Exception exception
*/ */
public void setCommentThumbnailURL(final JSONObject comment) throws Exception { public void setCommentThumbnailURL(final JSONObject comment) throws Exception {
final String commentEmail = comment.getString(Comment.COMMENT_EMAIL); final String commenterName = comment.optString(Comment.COMMENT_NAME);
final JSONObject commenter = userRepository.getByUserName(commenterName);
// 1. user avatar final String avatarURL = commenter.optString(UserExt.USER_AVATAR);
final JSONObject user = userRepository.getByEmail(commentEmail); comment.put(Comment.COMMENT_THUMBNAIL_URL, avatarURL);
if (null != user) {
final String avatar = user.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(avatar)) {
comment.put(Comment.COMMENT_THUMBNAIL_URL, avatar);
return;
}
}
// 2. Gravatar
String thumbnailURL = Solos.getGravatarURL(commentEmail.toLowerCase(), "128");
final URL gravatarURL = new URL(thumbnailURL);
int statusCode = HttpServletResponse.SC_OK;
try {
statusCode = HttpRequest.get(thumbnailURL).header("User-Agent", Solos.USER_AGENT).send().statusCode();
} catch (final Exception e) {
LOGGER.log(Level.DEBUG, "Can not fetch thumbnail from Gravatar [commentEmail={0}]", commentEmail);
} finally {
if (HttpServletResponse.SC_OK != statusCode) {
thumbnailURL = Latkes.getStaticServePath() + "/images/" + DEFAULT_USER_THUMBNAIL;
}
}
comment.put(Comment.COMMENT_THUMBNAIL_URL, thumbnailURL);
} }
} }
...@@ -39,7 +39,6 @@ import org.b3log.solo.repository.CommentRepository; ...@@ -39,7 +39,6 @@ import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.PageRepository; import org.b3log.solo.repository.PageRepository;
import org.b3log.solo.util.Emotions; import org.b3log.solo.util.Emotions;
import org.b3log.solo.util.Markdowns; import org.b3log.solo.util.Markdowns;
import org.b3log.solo.util.Solos;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import org.jsoup.Jsoup; import org.jsoup.Jsoup;
...@@ -145,7 +144,6 @@ public class CommentQueryService { ...@@ -145,7 +144,6 @@ public class CommentQueryService {
* "oId": "", * "oId": "",
* "commentTitle": "", * "commentTitle": "",
* "commentName": "", * "commentName": "",
* "commentEmail": "",
* "thumbnailUrl": "", * "thumbnailUrl": "",
* "commentURL": "", * "commentURL": "",
* "commentContent": "", * "commentContent": "",
...@@ -248,12 +246,6 @@ public class CommentQueryService { ...@@ -248,12 +246,6 @@ public class CommentQueryService {
comment.put(Comment.COMMENT_URL, url); comment.put(Comment.COMMENT_URL, url);
comment.put(Common.IS_REPLY, false); // Assumes this comment is not a reply comment.put(Common.IS_REPLY, false); // Assumes this comment is not a reply
final String thumbnailURL = comment.optString(Comment.COMMENT_THUMBNAIL_URL);
if (StringUtils.isBlank(thumbnailURL)) {
final String email = comment.optString(Comment.COMMENT_EMAIL);
comment.put(Comment.COMMENT_THUMBNAIL_URL, Solos.getGravatarURL(email, "128"));
}
if (StringUtils.isNotBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID))) { if (StringUtils.isNotBlank(comment.optString(Comment.COMMENT_ORIGINAL_COMMENT_ID))) {
// This comment is a reply // This comment is a reply
comment.put(Common.IS_REPLY, true); comment.put(Common.IS_REPLY, true);
......
...@@ -528,15 +528,8 @@ public class DataModelService { ...@@ -528,15 +528,8 @@ public class DataModelService {
comment.put(Comment.COMMENT_NAME, comment.getString(Comment.COMMENT_NAME)); comment.put(Comment.COMMENT_NAME, comment.getString(Comment.COMMENT_NAME));
comment.put(Comment.COMMENT_URL, comment.getString(Comment.COMMENT_URL)); comment.put(Comment.COMMENT_URL, comment.getString(Comment.COMMENT_URL));
comment.put(Common.IS_REPLY, false); comment.put(Common.IS_REPLY, false);
comment.remove(Comment.COMMENT_EMAIL); // Erases email for security reason
comment.put(Comment.COMMENT_T_DATE, new Date(comment.optLong(Comment.COMMENT_CREATED))); comment.put(Comment.COMMENT_T_DATE, new Date(comment.optLong(Comment.COMMENT_CREATED)));
comment.put("commentDate2", new Date(comment.optLong(Comment.COMMENT_CREATED))); comment.put("commentDate2", new Date(comment.optLong(Comment.COMMENT_CREATED)));
final String email = comment.optString(Comment.COMMENT_EMAIL);
final String thumbnailURL = comment.optString(Comment.COMMENT_THUMBNAIL_URL);
if (StringUtils.isBlank(thumbnailURL)) {
comment.put(Comment.COMMENT_THUMBNAIL_URL, Solos.getGravatarURL(email, "128"));
}
} }
dataModel.put(Common.RECENT_COMMENTS, recentComments); dataModel.put(Common.RECENT_COMMENTS, recentComments);
...@@ -615,14 +608,7 @@ public class DataModelService { ...@@ -615,14 +608,7 @@ public class DataModelService {
final JSONObject currentUser = Solos.getCurrentUser(context.getRequest(), context.getResponse()); final JSONObject currentUser = Solos.getCurrentUser(context.getRequest(), context.getResponse());
if (null != currentUser) { if (null != currentUser) {
final String userAvatar = currentUser.optString(UserExt.USER_AVATAR); final String userAvatar = currentUser.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(userAvatar)) { dataModel.put(Common.GRAVATAR, userAvatar);
dataModel.put(Common.GRAVATAR, userAvatar);
} else {
final String email = currentUser.optString(User.USER_EMAIL);
final String gravatar = Solos.getGravatarURL(email, "128");
dataModel.put(Common.GRAVATAR, gravatar);
}
dataModel.put(User.USER_NAME, currentUser.optString(User.USER_NAME)); dataModel.put(User.USER_NAME, currentUser.optString(User.USER_NAME));
} }
...@@ -909,12 +895,7 @@ public class DataModelService { ...@@ -909,12 +895,7 @@ public class DataModelService {
article.put(Article.ARTICLE_T_UPDATE_DATE, new Date(article.optLong(Article.ARTICLE_UPDATED))); article.put(Article.ARTICLE_T_UPDATE_DATE, new Date(article.optLong(Article.ARTICLE_UPDATED)));
final String userAvatar = author.optString(UserExt.USER_AVATAR); final String userAvatar = author.optString(UserExt.USER_AVATAR);
if (StringUtils.isNotBlank(userAvatar)) { article.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
article.put(Common.AUTHOR_THUMBNAIL_URL, userAvatar);
} else {
final String thumbnailURL = Solos.getGravatarURL(author.optString(User.USER_EMAIL), "128");
article.put(Common.AUTHOR_THUMBNAIL_URL, thumbnailURL);
}
if (preference.getBoolean(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT)) { if (preference.getBoolean(Option.ID_C_ENABLE_ARTICLE_UPDATE_HINT)) {
article.put(Common.HAS_UPDATED, articleQueryService.hasUpdated(article)); article.put(Common.HAS_UPDATED, articleQueryService.hasUpdated(article));
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils; import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang.time.DateUtils; import org.apache.commons.lang.time.DateUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
...@@ -34,7 +33,6 @@ import org.b3log.latke.repository.Transaction; ...@@ -34,7 +33,6 @@ import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.JdbcRepositories; import org.b3log.latke.repository.jdbc.util.JdbcRepositories;
import org.b3log.latke.repository.jdbc.util.JdbcRepositories.CreateTableResult; import org.b3log.latke.repository.jdbc.util.JdbcRepositories.CreateTableResult;
import org.b3log.latke.service.LangPropsService; import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Ids; import org.b3log.latke.util.Ids;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
...@@ -56,7 +54,7 @@ import java.util.Set; ...@@ -56,7 +54,7 @@ import java.util.Set;
* Solo initialization service. * Solo initialization service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.29, Feb 10, 2019 * @version 1.5.2.30, Mar 2, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -214,14 +212,12 @@ public class InitService { ...@@ -214,14 +212,12 @@ public class InitService {
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* { * {
* "userName": "", * "userName": "",
* "userEmail": "",
* "userAvatar": "", // optional * "userAvatar": "", // optional
* "userB3Key": "", // optional * "userB3Key": "", // optional
* "userGitHubId": "" // optional * "userGitHubId": "" // optional
* } * }
* @throws ServiceException service exception
*/ */
public void init(final JSONObject requestJSONObject) throws ServiceException { public void init(final JSONObject requestJSONObject) {
if (isInited()) { if (isInited()) {
return; return;
} }
...@@ -230,15 +226,15 @@ public class InitService { ...@@ -230,15 +226,15 @@ public class InitService {
try { try {
initStatistic(); initStatistic();
initPreference(requestJSONObject); initPreference(requestJSONObject);
initReplyNotificationTemplate();
initAdmin(requestJSONObject); initAdmin(requestJSONObject);
initLink(); initLink();
helloWorld(); helloWorld();
transaction.commit(); transaction.commit();
} catch (final Exception e) { } catch (final Throwable e) {
LOGGER.log(Level.ERROR, "Initializes Solo failed", e);
throw new ServiceException("Initializes Solo failed: " + e.getMessage()); System.exit(-1);
} finally { } finally {
if (transaction.isActive()) { if (transaction.isActive()) {
transaction.rollback(); transaction.rollback();
...@@ -287,7 +283,6 @@ public class InitService { ...@@ -287,7 +283,6 @@ public class InitService {
final JSONObject comment = new JSONObject(); final JSONObject comment = new JSONObject();
comment.put(Keys.OBJECT_ID, articleId); comment.put(Keys.OBJECT_ID, articleId);
comment.put(Comment.COMMENT_NAME, "88250"); comment.put(Comment.COMMENT_NAME, "88250");
comment.put(Comment.COMMENT_EMAIL, "d@b3log.org");
comment.put(Comment.COMMENT_URL, "https://hacpai.com/member/88250"); comment.put(Comment.COMMENT_URL, "https://hacpai.com/member/88250");
comment.put(Comment.COMMENT_CONTENT, langPropsService.get("helloWorld.comment.content")); comment.put(Comment.COMMENT_CONTENT, langPropsService.get("helloWorld.comment.content"));
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
...@@ -302,6 +297,8 @@ public class InitService { ...@@ -302,6 +297,8 @@ public class InitService {
comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL); comment.put(Comment.COMMENT_SHARP_URL, commentSharpURL);
commentRepository.add(comment); commentRepository.add(comment);
LOGGER.info("Hello World!");
} }
/** /**
...@@ -411,7 +408,6 @@ public class InitService { ...@@ -411,7 +408,6 @@ public class InitService {
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* { * {
* "userName": "", * "userName": "",
* "userEmail": "",
* "userAvatar": "", // optional * "userAvatar": "", // optional
* "userB3Key": "", // optional * "userB3Key": "", // optional
* "userGitHubId": "" // optional * "userGitHubId": "" // optional
...@@ -423,19 +419,14 @@ public class InitService { ...@@ -423,19 +419,14 @@ public class InitService {
final JSONObject admin = new JSONObject(); final JSONObject admin = new JSONObject();
admin.put(User.USER_NAME, requestJSONObject.getString(User.USER_NAME)); admin.put(User.USER_NAME, requestJSONObject.getString(User.USER_NAME));
admin.put(User.USER_EMAIL, requestJSONObject.getString(User.USER_EMAIL));
admin.put(User.USER_URL, Latkes.getServePath()); admin.put(User.USER_URL, Latkes.getServePath());
admin.put(User.USER_ROLE, Role.ADMIN_ROLE); admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
String avatar = requestJSONObject.optString(UserExt.USER_AVATAR); admin.put(UserExt.USER_AVATAR, requestJSONObject.optString(UserExt.USER_AVATAR));
if (StringUtils.isBlank(avatar)) {
avatar = Solos.getGravatarURL(requestJSONObject.getString(User.USER_EMAIL), "128");
}
admin.put(UserExt.USER_AVATAR, avatar);
admin.put(UserExt.USER_B3_KEY, requestJSONObject.optString(UserExt.USER_B3_KEY)); admin.put(UserExt.USER_B3_KEY, requestJSONObject.optString(UserExt.USER_B3_KEY));
admin.put(UserExt.USER_GITHUB_ID, requestJSONObject.optString(UserExt.USER_GITHUB_ID)); admin.put(UserExt.USER_GITHUB_ID, requestJSONObject.optString(UserExt.USER_GITHUB_ID));
userRepository.add(admin); userRepository.add(admin);
LOGGER.debug("Initialized admin"); LOGGER.info("Initialized admin");
} }
/** /**
...@@ -444,6 +435,7 @@ public class InitService { ...@@ -444,6 +435,7 @@ public class InitService {
* @throws Exception exception * @throws Exception exception
*/ */
private void initLink() throws Exception { private void initLink() throws Exception {
LOGGER.debug("Initializing link....");
final JSONObject link = new JSONObject(); final JSONObject link = new JSONObject();
link.put(Link.LINK_TITLE, "黑客派"); link.put(Link.LINK_TITLE, "黑客派");
...@@ -451,7 +443,8 @@ public class InitService { ...@@ -451,7 +443,8 @@ public class InitService {
link.put(Link.LINK_DESCRIPTION, "黑客与画家的社区"); link.put(Link.LINK_DESCRIPTION, "黑客与画家的社区");
final int maxOrder = linkRepository.getMaxOrder(); final int maxOrder = linkRepository.getMaxOrder();
link.put(Link.LINK_ORDER, maxOrder + 1); link.put(Link.LINK_ORDER, maxOrder + 1);
final String ret = linkRepository.add(link); linkRepository.add(link);
LOGGER.info("Initialized link");
} }
/** /**
...@@ -469,33 +462,7 @@ public class InitService { ...@@ -469,33 +462,7 @@ public class InitService {
statisticBlogViewCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_STATISTIC); statisticBlogViewCountOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_STATISTIC);
optionRepository.add(statisticBlogViewCountOpt); optionRepository.add(statisticBlogViewCountOpt);
LOGGER.debug("Initialized statistic"); LOGGER.info("Initialized statistic");
}
/**
* Initializes reply notification template.
*
* @throws Exception exception
*/
private void initReplyNotificationTemplate() throws Exception {
LOGGER.debug("Initializing reply notification template");
final JSONObject replyNotificationTemplate = new JSONObject(DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put(Keys.OBJECT_ID, "replyNotificationTemplate");
final JSONObject subjectOpt = new JSONObject();
subjectOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.add(subjectOpt);
final JSONObject bodyOpt = new JSONObject();
bodyOpt.put(Keys.OBJECT_ID, Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.add(bodyOpt);
LOGGER.debug("Initialized reply notification template");
} }
/** /**
...@@ -609,12 +576,6 @@ public class InitService { ...@@ -609,12 +576,6 @@ public class InitService {
blogSubtitleOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_BLOG_SUBTITLE); blogSubtitleOpt.put(Option.OPTION_VALUE, DefaultPreference.DEFAULT_BLOG_SUBTITLE);
optionRepository.add(blogSubtitleOpt); optionRepository.add(blogSubtitleOpt);
final JSONObject adminEmailOpt = new JSONObject();
adminEmailOpt.put(Keys.OBJECT_ID, Option.ID_C_ADMIN_EMAIL);
adminEmailOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
adminEmailOpt.put(Option.OPTION_VALUE, requestJSONObject.getString(User.USER_EMAIL));
optionRepository.add(adminEmailOpt);
final JSONObject localeStringOpt = new JSONObject(); final JSONObject localeStringOpt = new JSONObject();
localeStringOpt.put(Keys.OBJECT_ID, Option.ID_C_LOCALE_STRING); localeStringOpt.put(Keys.OBJECT_ID, Option.ID_C_LOCALE_STRING);
localeStringOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE); localeStringOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
...@@ -718,6 +679,6 @@ public class InitService { ...@@ -718,6 +679,6 @@ public class InitService {
skinsOpt.put(Option.OPTION_VALUE, skinArray.toString()); skinsOpt.put(Option.OPTION_VALUE, skinArray.toString());
optionRepository.add(skinsOpt); optionRepository.add(skinsOpt);
LOGGER.debug("Initialized preference"); LOGGER.info("Initialized preference");
} }
} }
...@@ -140,35 +140,6 @@ public class PreferenceMgmtService { ...@@ -140,35 +140,6 @@ public class PreferenceMgmtService {
Stopwatchs.end(); Stopwatchs.end();
} }
/**
* Updates the reply notification template with the specified reply notification template.
*
* @param replyNotificationTemplate the specified reply notification template
* @throws ServiceException service exception
*/
public void updateReplyNotificationTemplate(final JSONObject replyNotificationTemplate) throws ServiceException {
final Transaction transaction = optionRepository.beginTransaction();
try {
final JSONObject bodyOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_BODY);
bodyOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("body"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_BODY, bodyOpt);
final JSONObject subjectOpt = optionRepository.get(Option.ID_C_REPLY_NOTI_TPL_SUBJECT);
subjectOpt.put(Option.OPTION_VALUE, replyNotificationTemplate.optString("subject"));
optionRepository.update(Option.ID_C_REPLY_NOTI_TPL_SUBJECT, subjectOpt);
transaction.commit();
} catch (final Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
LOGGER.log(Level.ERROR, "Updates reply notification failed", e);
throw new ServiceException(e);
}
}
/** /**
* Updates the preference with the specified preference. * Updates the preference with the specified preference.
* *
...@@ -209,20 +180,13 @@ public class PreferenceMgmtService { ...@@ -209,20 +180,13 @@ public class PreferenceMgmtService {
preference.put(Option.ID_C_SIGNS, preference.get(Option.ID_C_SIGNS).toString()); preference.put(Option.ID_C_SIGNS, preference.get(Option.ID_C_SIGNS).toString());
final JSONObject oldPreference = preferenceQueryService.getPreference(); final JSONObject oldPreference = preferenceQueryService.getPreference();
final String adminEmail = oldPreference.getString(Option.ID_C_ADMIN_EMAIL);
preference.put(Option.ID_C_ADMIN_EMAIL, adminEmail);
final String version = oldPreference.optString(Option.ID_C_VERSION); final String version = oldPreference.optString(Option.ID_C_VERSION);
preference.put(Option.ID_C_VERSION, version); preference.put(Option.ID_C_VERSION, version);
final String localeString = preference.getString(Option.ID_C_LOCALE_STRING); final String localeString = preference.getString(Option.ID_C_LOCALE_STRING);
LOGGER.log(Level.DEBUG, "Current locale[string={0}]", localeString);
Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString))); Latkes.setLocale(new Locale(Locales.getLanguage(localeString), Locales.getCountry(localeString)));
final JSONObject adminEmailOpt = optionRepository.get(Option.ID_C_ADMIN_EMAIL);
adminEmailOpt.put(Option.OPTION_VALUE, adminEmail);
optionRepository.update(Option.ID_C_ADMIN_EMAIL, adminEmailOpt);
final JSONObject allowVisitDraftViaPermalinkOpt = optionRepository.get(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK); final JSONObject allowVisitDraftViaPermalinkOpt = optionRepository.get(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK);
allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK)); allowVisitDraftViaPermalinkOpt.put(Option.OPTION_VALUE, preference.optString(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK));
optionRepository.update(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK, allowVisitDraftViaPermalinkOpt); optionRepository.update(Option.ID_C_ALLOW_VISIT_DRAFT_VIA_PERMALINK, allowVisitDraftViaPermalinkOpt);
......
...@@ -20,7 +20,6 @@ package org.b3log.solo.service; ...@@ -20,7 +20,6 @@ package org.b3log.solo.service;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
import org.b3log.latke.service.ServiceException;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.repository.OptionRepository; import org.b3log.solo.repository.OptionRepository;
...@@ -53,27 +52,6 @@ public class PreferenceQueryService { ...@@ -53,27 +52,6 @@ public class PreferenceQueryService {
@Inject @Inject
private OptionQueryService optionQueryService; private OptionQueryService optionQueryService;
/**
* Gets the reply notification template.
*
* @return reply notification template, returns {@code null} if not found
* @throws ServiceException service exception
*/
public JSONObject getReplyNotificationTemplate() throws ServiceException {
try {
final JSONObject ret = new JSONObject();
final JSONObject preference = getPreference();
ret.put("subject", preference.optString(Option.ID_C_REPLY_NOTI_TPL_SUBJECT));
ret.put("body", preference.optString(Option.ID_C_REPLY_NOTI_TPL_BODY));
return ret;
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Updates reply notification template failed", e);
throw new ServiceException(e);
}
}
/** /**
* Gets the user preference. * Gets the user preference.
* *
...@@ -81,13 +59,10 @@ public class PreferenceQueryService { ...@@ -81,13 +59,10 @@ public class PreferenceQueryService {
*/ */
public JSONObject getPreference() { public JSONObject getPreference() {
try { try {
final JSONObject checkInit = optionRepository.get(Option.ID_C_ADMIN_EMAIL);
if (null == checkInit) {
return null;
}
return optionQueryService.getOptions(Option.CATEGORY_C_PREFERENCE); return optionQueryService.getOptions(Option.CATEGORY_C_PREFERENCE);
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Gets preference failed", e);
return null; return null;
} }
} }
......
...@@ -17,48 +17,22 @@ ...@@ -17,48 +17,22 @@
*/ */
package org.b3log.solo.service; package org.b3log.solo.service;
import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.Inject; import org.b3log.latke.ioc.Inject;
import org.b3log.latke.logging.Level; import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger; import org.b3log.latke.logging.Logger;
import org.b3log.latke.model.User;
import org.b3log.latke.repository.Query;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.latke.service.LangPropsService;
import org.b3log.latke.service.annotation.Service; import org.b3log.latke.service.annotation.Service;
import org.b3log.solo.SoloServletListener; import org.b3log.solo.SoloServletListener;
import org.b3log.solo.cache.ArticleCache;
import org.b3log.solo.cache.CommentCache;
import org.b3log.solo.mail.MailService;
import org.b3log.solo.mail.MailServiceFactory;
import org.b3log.solo.model.Article;
import org.b3log.solo.model.Comment;
import org.b3log.solo.model.Option; import org.b3log.solo.model.Option;
import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.CommentRepository;
import org.b3log.solo.repository.OptionRepository;
import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.upgrade.V299_300; import org.b3log.solo.upgrade.V299_300;
import org.b3log.solo.upgrade.V300_310; import org.b3log.solo.upgrade.V300_310;
import org.b3log.solo.util.Solos; import org.b3log.solo.upgrade.V310_320;
import org.json.JSONArray;
import org.json.JSONObject; import org.json.JSONObject;
import java.sql.Connection;
import java.sql.Statement;
import java.util.Date;
import java.util.List;
/** /**
* Upgrade service. * Upgrade service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a> * @version 1.2.1.2, Mar 3, 2019
* @version 1.2.1.1, Feb 28, 2019
* @since 1.2.0 * @since 1.2.0
*/ */
@Service @Service
...@@ -69,70 +43,12 @@ public class UpgradeService { ...@@ -69,70 +43,12 @@ public class UpgradeService {
*/ */
private static final Logger LOGGER = Logger.getLogger(UpgradeService.class); private static final Logger LOGGER = Logger.getLogger(UpgradeService.class);
/**
* Step for article updating.
*/
private static final int STEP = 50;
/**
* Mail Service.
*/
private static final MailService MAIL_SVC = MailServiceFactory.getMailService();
/**
* Article repository.
*/
@Inject
private ArticleRepository articleRepository;
/**
* Comment repository.
*/
@Inject
private CommentRepository commentRepository;
/**
* User repository.
*/
@Inject
private UserRepository userRepository;
/**
* Option repository.
*/
@Inject
private OptionRepository optionRepository;
/** /**
* Preference Query Service. * Preference Query Service.
*/ */
@Inject @Inject
private PreferenceQueryService preferenceQueryService; private PreferenceQueryService preferenceQueryService;
/**
* Statistic query service.
*/
@Inject
private StatisticQueryService statisticQueryService;
/**
* Language service.
*/
@Inject
private LangPropsService langPropsService;
/**
* Article cache.
*/
@Inject
private ArticleCache articleCache;
/**
* Comment cache.
*/
@Inject
private CommentCache commentCache;
/** /**
* Upgrades if need. * Upgrades if need.
*/ */
...@@ -153,6 +69,8 @@ public class UpgradeService { ...@@ -153,6 +69,8 @@ public class UpgradeService {
V299_300.perform(); V299_300.perform();
case "3.0.0": case "3.0.0":
V300_310.perform(); V300_310.perform();
case "3.1.0":
V310_320.perform();
break; break;
default: default:
...@@ -165,176 +83,4 @@ public class UpgradeService { ...@@ -165,176 +83,4 @@ public class UpgradeService {
System.exit(-1); System.exit(-1);
} }
} }
private void alterTables() throws Exception {
final Connection connection = Connections.getConnection();
final Statement statement = connection.createStatement();
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "archiveDate` RENAME TO `" + tablePrefix + "archivedate1`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "archivedate1` RENAME TO `" + tablePrefix + "archivedate`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "archiveDate_article` RENAME TO `" + tablePrefix + "archivedate_article1`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "archivedate_article1` RENAME TO `" + tablePrefix + "archivedate_article`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` ADD `articleAuthorId` VARCHAR(19) DEFAULT '' NOT NULL");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` ADD `articleCreated` BIGINT DEFAULT 0 NOT NULL");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` ADD `articleUpdated` BIGINT DEFAULT 0 NOT NULL");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "comment` ADD `commentCreated` BIGINT DEFAULT 0 NOT NULL");
statement.close();
connection.commit();
connection.close();
}
private void dropTables() throws Exception {
final Connection connection = Connections.getConnection();
final Statement statement = connection.createStatement();
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.execute("DROP TABLE `" + tablePrefix + "statistic`");
statement.close();
connection.commit();
connection.close();
}
private void upgradeUsers() throws Exception {
final JSONArray users = userRepository.get(new Query()).getJSONArray(Keys.RESULTS);
for (int i = 0; i < users.length(); i++) {
final JSONObject user = users.getJSONObject(i);
final String email = user.optString(User.USER_EMAIL);
user.put(UserExt.USER_AVATAR, Solos.getGravatarURL(email, "128"));
userRepository.update(user.optString(Keys.OBJECT_ID), user);
LOGGER.log(Level.INFO, "Updated user[email={0}]", email);
}
}
private void upgradeArticles() throws Exception {
final List<JSONObject> articles = articleRepository.getList(new Query().
select(Keys.OBJECT_ID, Article.ARTICLE_T_CREATE_DATE, Article.ARTICLE_T_UPDATE_DATE, Article.ARTICLE_T_AUTHOR_EMAIL));
if (articles.isEmpty()) {
LOGGER.log(Level.TRACE, "No articles");
return;
}
Transaction transaction = null;
try {
for (int i = 0; i < articles.size(); i++) {
if (0 == i % STEP || !transaction.isActive()) {
transaction = userRepository.beginTransaction();
}
final String articleId = articles.get(i).optString(Keys.OBJECT_ID);
final JSONObject article = articleRepository.get(articleId);
String authorEmail = article.optString(Article.ARTICLE_T_AUTHOR_EMAIL);
if (StringUtils.isBlank(authorEmail)) { // H2
authorEmail = article.optString(Article.ARTICLE_T_AUTHOR_EMAIL.toUpperCase());
}
JSONObject author = userRepository.getByEmail(authorEmail);
if (null == author) {
author = userRepository.getAdmin();
}
article.put(Article.ARTICLE_AUTHOR_ID, author.optString(Keys.OBJECT_ID));
Date createDate = (Date) article.opt(Article.ARTICLE_T_CREATE_DATE);
if (null == createDate) { // H2
createDate = (Date) article.opt(Article.ARTICLE_T_CREATE_DATE.toUpperCase());
}
article.put(Article.ARTICLE_CREATED, createDate.getTime());
Date updateDate = (Date) article.opt(Article.ARTICLE_T_UPDATE_DATE);
if (null == updateDate) { // H2
updateDate = (Date) article.opt(Article.ARTICLE_T_UPDATE_DATE.toUpperCase());
}
article.put(Article.ARTICLE_UPDATED, updateDate.getTime());
articleRepository.update(articleId, article);
if (0 == i % STEP) {
transaction.commit();
LOGGER.log(Level.INFO, "Updated some articles [" + i + "]");
}
}
if (transaction.isActive()) {
transaction.commit();
}
LOGGER.log(Level.INFO, "Updated all articles");
} catch (final Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
throw e;
}
}
private void upgradeComments() throws Exception {
final List<JSONObject> comments = commentRepository.getList(new Query());
if (comments.isEmpty()) {
LOGGER.log(Level.TRACE, "No comments");
return;
}
Transaction transaction = null;
try {
for (int i = 0; i < comments.size(); i++) {
if (0 == i % STEP || !transaction.isActive()) {
transaction = userRepository.beginTransaction();
}
final JSONObject comment = comments.get(i);
final String commentId = comment.optString(Keys.OBJECT_ID);
Date createDate = (Date) comment.opt(Comment.COMMENT_T_DATE);
if (null == createDate) { // H2
createDate = (Date) comment.opt(Comment.COMMENT_T_DATE.toUpperCase());
}
comment.put(Comment.COMMENT_CREATED, createDate.getTime());
commentRepository.update(commentId, comment);
if (0 == i % STEP) {
transaction.commit();
LOGGER.log(Level.INFO, "Updated some comments [" + i + "]");
}
}
if (transaction.isActive()) {
transaction.commit();
}
LOGGER.log(Level.INFO, "Updated all comments");
} catch (final Exception e) {
if (transaction.isActive()) {
transaction.rollback();
}
throw e;
}
}
/**
* Send an email to the user who upgrades Solo with a discontinuous version.
*
* @throws Exception exception
*/
private void notifyUserByEmail() throws Exception {
if (!Solos.isMailConfigured()) {
return;
}
final String adminEmail = preferenceQueryService.getPreference().getString(Option.ID_C_ADMIN_EMAIL);
final MailService.Message message = new MailService.Message();
message.setFrom(adminEmail);
message.addRecipient(adminEmail);
message.setSubject(langPropsService.get("skipVersionMailSubject"));
message.setHtmlBody(langPropsService.get("skipVersionMailBody"));
MAIL_SVC.send(message);
LOGGER.info("Send an email to the user who upgrades Solo with a discontinuous version.");
}
} }
...@@ -33,7 +33,6 @@ import org.b3log.latke.service.annotation.Service; ...@@ -33,7 +33,6 @@ import org.b3log.latke.service.annotation.Service;
import org.b3log.latke.util.Strings; import org.b3log.latke.util.Strings;
import org.b3log.solo.model.UserExt; import org.b3log.solo.model.UserExt;
import org.b3log.solo.repository.UserRepository; import org.b3log.solo.repository.UserRepository;
import org.b3log.solo.util.Solos;
import org.json.JSONObject; import org.json.JSONObject;
/** /**
...@@ -88,7 +87,6 @@ public class UserMgmtService { ...@@ -88,7 +87,6 @@ public class UserMgmtService {
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "",
* "userRole": "", * "userRole": "",
* "userURL": "", * "userURL": "",
* "userB3Key": "" * "userB3Key": ""
...@@ -104,19 +102,12 @@ public class UserMgmtService { ...@@ -104,19 +102,12 @@ public class UserMgmtService {
throw new ServiceException(langPropsService.get("updateFailLabel")); throw new ServiceException(langPropsService.get("updateFailLabel"));
} }
final String userNewEmail = requestJSONObject.optString(User.USER_EMAIL).toLowerCase().trim();
JSONObject mayBeAnother = userRepository.getByEmail(userNewEmail);
if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) {
throw new ServiceException(langPropsService.get("duplicatedEmailLabel"));
}
oldUser.put(User.USER_EMAIL, userNewEmail);
final String userName = requestJSONObject.optString(User.USER_NAME); final String userName = requestJSONObject.optString(User.USER_NAME);
if (UserExt.invalidUserName(userName)) { if (UserExt.invalidUserName(userName)) {
throw new ServiceException(langPropsService.get("userNameInvalidLabel")); throw new ServiceException(langPropsService.get("userNameInvalidLabel"));
} }
mayBeAnother = userRepository.getByUserName(userName);
JSONObject mayBeAnother = userRepository.getByUserName(userName);
if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) { if (null != mayBeAnother && !mayBeAnother.optString(Keys.OBJECT_ID).equals(oldUserId)) {
throw new ServiceException(langPropsService.get("duplicatedUserNameLabel")); throw new ServiceException(langPropsService.get("duplicatedUserNameLabel"));
} }
...@@ -189,7 +180,6 @@ public class UserMgmtService { ...@@ -189,7 +180,6 @@ public class UserMgmtService {
* *
* @param requestJSONObject the specified request json object, for example, * @param requestJSONObject the specified request json object, for example,
* "userName": "", * "userName": "",
* "userEmail": "",
* "userURL": "", // optional, uses 'servePath' instead if not specified * "userURL": "", // optional, uses 'servePath' instead if not specified
* "userRole": "", // optional, uses {@value Role#DEFAULT_ROLE} instead if not specified * "userRole": "", // optional, uses {@value Role#DEFAULT_ROLE} instead if not specified
* "userAvatar": "", // optional, users generated gravatar url instead if not specified * "userAvatar": "", // optional, users generated gravatar url instead if not specified
...@@ -202,28 +192,12 @@ public class UserMgmtService { ...@@ -202,28 +192,12 @@ public class UserMgmtService {
final Transaction transaction = userRepository.beginTransaction(); final Transaction transaction = userRepository.beginTransaction();
try { try {
final JSONObject user = new JSONObject();
final String userEmail = requestJSONObject.optString(User.USER_EMAIL).trim().toLowerCase();
if (!Strings.isEmail(userEmail)) {
throw new ServiceException(langPropsService.get("mailInvalidLabel"));
}
JSONObject duplicatedUser = userRepository.getByEmail(userEmail);
if (null != duplicatedUser) {
if (transaction.isActive()) {
transaction.rollback();
}
throw new ServiceException(langPropsService.get("duplicatedEmailLabel"));
}
user.put(User.USER_EMAIL, userEmail);
final String userName = requestJSONObject.optString(User.USER_NAME); final String userName = requestJSONObject.optString(User.USER_NAME);
if (UserExt.invalidUserName(userName)) { if (UserExt.invalidUserName(userName)) {
throw new ServiceException(langPropsService.get("userNameInvalidLabel")); throw new ServiceException(langPropsService.get("userNameInvalidLabel"));
} }
duplicatedUser = userRepository.getByUserName(userName);
JSONObject duplicatedUser = userRepository.getByUserName(userName);
if (null != duplicatedUser) { if (null != duplicatedUser) {
if (transaction.isActive()) { if (transaction.isActive()) {
transaction.rollback(); transaction.rollback();
...@@ -231,26 +205,22 @@ public class UserMgmtService { ...@@ -231,26 +205,22 @@ public class UserMgmtService {
throw new ServiceException(langPropsService.get("duplicatedUserNameLabel")); throw new ServiceException(langPropsService.get("duplicatedUserNameLabel"));
} }
final JSONObject user = new JSONObject();
user.put(User.USER_NAME, userName); user.put(User.USER_NAME, userName);
String userURL = requestJSONObject.optString(User.USER_URL); String userURL = requestJSONObject.optString(User.USER_URL);
if (StringUtils.isBlank(userURL)) { if (StringUtils.isBlank(userURL)) {
userURL = Latkes.getServePath(); userURL = Latkes.getServePath();
} }
if (!Strings.isURL(userURL)) { if (!Strings.isURL(userURL)) {
throw new ServiceException(langPropsService.get("urlInvalidLabel")); throw new ServiceException(langPropsService.get("urlInvalidLabel"));
} }
user.put(User.USER_URL, userURL); user.put(User.USER_URL, userURL);
final String roleName = requestJSONObject.optString(User.USER_ROLE, Role.DEFAULT_ROLE); final String roleName = requestJSONObject.optString(User.USER_ROLE, Role.DEFAULT_ROLE);
user.put(User.USER_ROLE, roleName); user.put(User.USER_ROLE, roleName);
String userAvatar = requestJSONObject.optString(UserExt.USER_AVATAR); final String userAvatar = requestJSONObject.optString(UserExt.USER_AVATAR);
if (StringUtils.isBlank(userAvatar)) {
userAvatar = Solos.getGravatarURL(userEmail, "128");
}
user.put(UserExt.USER_AVATAR, userAvatar); user.put(UserExt.USER_AVATAR, userAvatar);
final String userGitHubId = requestJSONObject.optString(UserExt.USER_GITHUB_ID); final String userGitHubId = requestJSONObject.optString(UserExt.USER_GITHUB_ID);
......
...@@ -43,7 +43,7 @@ import java.util.List; ...@@ -43,7 +43,7 @@ import java.util.List;
* User query service. * User query service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.7, Oct 5, 2018 * @version 1.1.0.0, Feb 3, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -98,21 +98,16 @@ public class UserQueryService { ...@@ -98,21 +98,16 @@ public class UserQueryService {
} }
/** /**
* Gets a user by the specified email or username. * Gets a user by the specified user name.
* *
* @param emailOrUserName the specified email or username * @param userName the specified user name
* @return user, returns {@code null} if not found * @return user, returns {@code null} if not found
*/ */
public JSONObject getUserByEmailOrUserName(final String emailOrUserName) { public JSONObject getUserByName(final String userName) {
try { try {
JSONObject ret = userRepository.getByEmail(emailOrUserName); return userRepository.getByUserName(userName);
if (null == ret) {
ret = userRepository.getByUserName(emailOrUserName);
}
return ret;
} catch (final RepositoryException e) { } catch (final RepositoryException e) {
LOGGER.log(Level.ERROR, "Gets a user by email or username [" + emailOrUserName + "] failed", e); LOGGER.log(Level.ERROR, "Gets a user by username [" + userName + "] failed", e);
return null; return null;
} }
...@@ -135,7 +130,6 @@ public class UserQueryService { ...@@ -135,7 +130,6 @@ public class UserQueryService {
* "users": [{ * "users": [{
* "oId": "", * "oId": "",
* "userName": "", * "userName": "",
* "userEmail": "",
* "roleName": "" * "roleName": ""
* }, ....] * }, ....]
* } * }
...@@ -181,8 +175,7 @@ public class UserQueryService { ...@@ -181,8 +175,7 @@ public class UserQueryService {
* { * {
* "user": { * "user": {
* "oId": "", * "oId": "",
* "userName": "", * "userName": ""
* "userEmail": ""
* } * }
* } * }
* </pre>, returns {@code null} if not found * </pre>, returns {@code null} if not found
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.upgrade;
import org.b3log.latke.Latkes;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.logging.Level;
import org.b3log.latke.logging.Logger;
import org.b3log.latke.repository.Transaction;
import org.b3log.latke.repository.jdbc.util.Connections;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.ArticleRepository;
import org.b3log.solo.repository.OptionRepository;
import org.json.JSONObject;
import java.sql.Connection;
import java.sql.Statement;
/**
* Upgrade script from v3.1.0 to v3.2.0.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, Mar 3, 2019
* @since 3.2.0
*/
public final class V310_320 {
/**
* Logger.
*/
private static final Logger LOGGER = Logger.getLogger(V310_320.class);
/**
* Performs upgrade from v3.1.0 to v3.2.0.
*
* @throws Exception upgrade fails
*/
public static void perform() throws Exception {
final String fromVer = "3.1.0";
final String toVer = "3.2.0";
LOGGER.log(Level.INFO, "Upgrading from version [" + fromVer + "] to version [" + fromVer + "]....");
final BeanManager beanManager = BeanManager.getInstance();
final OptionRepository optionRepository = beanManager.getReference(OptionRepository.class);
final ArticleRepository articleRepository = beanManager.getReference(ArticleRepository.class);
try {
Connection connection = Connections.getConnection();
Statement statement = connection.createStatement();
// 移除邮件相关功能 https://github.com/b3log/solo/issues/12690
final String tablePrefix = Latkes.getLocalProperty("jdbc.tablePrefix") + "_";
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "article` DROP COLUMN `userEmail`");
statement.executeUpdate("ALTER TABLE `" + tablePrefix + "comment` DROP COLUMN `commentEmail`");
statement.close();
connection.commit();
connection.close();
optionRepository.remove("adminEmail");
optionRepository.remove("replyNotiTplBody");
optionRepository.remove("replyNotiTplSubject");
final Transaction transaction = optionRepository.beginTransaction();
final JSONObject versionOpt = optionRepository.get(Option.ID_C_VERSION);
versionOpt.put(Option.OPTION_VALUE, toVer);
optionRepository.update(Option.ID_C_VERSION, versionOpt);
transaction.commit();
LOGGER.log(Level.INFO, "Upgraded from version [" + fromVer + "] to version [" + toVer + "] successfully");
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Upgrade failed!", e);
throw new Exception("Upgrade failed from version [" + fromVer + "] to version [" + toVer + "]");
}
}
}
...@@ -82,7 +82,6 @@ public final class GitHubs { ...@@ -82,7 +82,6 @@ public final class GitHubs {
* { * {
* "openId": "", * "openId": "",
* "userName": "D", * "userName": "D",
* "userEmail": "d@b3log.org", // may be empty
* "userAvatar": "https://avatars3.githubusercontent.com/u/873584?v=4" * "userAvatar": "https://avatars3.githubusercontent.com/u/873584?v=4"
* } * }
* </pre>, returns {@code null} if not found QQ user info * </pre>, returns {@code null} if not found QQ user info
...@@ -101,14 +100,12 @@ public final class GitHubs { ...@@ -101,14 +100,12 @@ public final class GitHubs {
} }
final JSONObject data = result.optJSONObject(Common.DATA); final JSONObject data = result.optJSONObject(Common.DATA);
final String userName = StringUtils.trim(data.optString("userName")); final String userName = StringUtils.trim(data.optString("userName"));
final String email = data.optString("userEmail");
final String openId = data.optString("userId"); final String openId = data.optString("userId");
final String avatarUrl = data.optString("userAvatarURL"); final String avatarUrl = data.optString("userAvatarURL");
final JSONObject ret = new JSONObject(); final JSONObject ret = new JSONObject();
ret.put("openId", openId); ret.put("openId", openId);
ret.put(User.USER_NAME, userName); ret.put(User.USER_NAME, userName);
ret.put(User.USER_EMAIL, email);
ret.put(UserExt.USER_AVATAR, avatarUrl); ret.put(UserExt.USER_AVATAR, avatarUrl);
return ret; return ret;
......
...@@ -19,7 +19,6 @@ package org.b3log.solo.util; ...@@ -19,7 +19,6 @@ package org.b3log.solo.util;
import jodd.http.HttpRequest; import jodd.http.HttpRequest;
import jodd.http.HttpResponse; import jodd.http.HttpResponse;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.RandomStringUtils; import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.b3log.latke.Keys; import org.b3log.latke.Keys;
...@@ -55,7 +54,7 @@ import java.util.ResourceBundle; ...@@ -55,7 +54,7 @@ import java.util.ResourceBundle;
* Solo utilities. * Solo utilities.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.7.0.0, Feb 7, 2019 * @version 1.7.0.1, Mar 3, 2019
* @since 2.8.0 * @since 2.8.0
*/ */
public final class Solos { public final class Solos {
...@@ -65,11 +64,6 @@ public final class Solos { ...@@ -65,11 +64,6 @@ public final class Solos {
*/ */
private static final Logger LOGGER = Logger.getLogger(Solos.class); private static final Logger LOGGER = Logger.getLogger(Solos.class);
/**
* Mail configuration (mail.properties).
*/
private static final ResourceBundle mailConf = ResourceBundle.getBundle("mail");
/** /**
* Favicon API. * Favicon API.
*/ */
...@@ -427,22 +421,6 @@ public final class Solos { ...@@ -427,22 +421,6 @@ public final class Solos {
return !(null != currentUser && !Role.VISITOR_ROLE.equals(currentUser.optString(User.USER_ROLE))); return !(null != currentUser && !Role.VISITOR_ROLE.equals(currentUser.optString(User.USER_ROLE)));
} }
/**
* Whether user configures the mail.properties.
*
* @return {@code true} if user configured, returns {@code false} otherwise
*/
public static boolean isMailConfigured() {
try {
return StringUtils.isNotBlank(mailConf.getString("mail.user")) &&
StringUtils.isNotBlank(mailConf.getString("mail.password")) &&
StringUtils.isNotBlank(mailConf.getString("mail.smtp.host")) &&
StringUtils.isNotBlank(mailConf.getString("mail.smtp.port"));
} catch (final Exception e) {
return false;
}
}
/** /**
* Checks the specified request is made from a mobile device. * Checks the specified request is made from a mobile device.
* *
...@@ -474,14 +452,12 @@ public final class Solos { ...@@ -474,14 +452,12 @@ public final class Solos {
} }
/** /**
* Gets the Gravatar URL for the specified email with the specified size. * Gets the default user avatar URL..
* *
* @param email the specified email * @return default user avatar URL
* @param size the specified size
* @return the Gravatar URL
*/ */
public static String getGravatarURL(final String email, final String size) { public static String getDefaultAvatar() {
return GRAVATAR + DigestUtils.md5Hex(email) + "?s=" + size; return Latkes.getStaticServePath() + "/images/default-user-thumbnail.png";
} }
/** /**
......
...@@ -41,13 +41,6 @@ if [ ! -f "/opt/b3log/solo/WEB-INF/classes/local.properties" ]; then ...@@ -41,13 +41,6 @@ if [ ! -f "/opt/b3log/solo/WEB-INF/classes/local.properties" ]; then
-e "s|{{SERVER_PORT}}|${SERVER_PORT:-8080}|g" \ -e "s|{{SERVER_PORT}}|${SERVER_PORT:-8080}|g" \
> /opt/b3log/solo/WEB-INF/classes/latke.properties > /opt/b3log/solo/WEB-INF/classes/latke.properties
cat /opt/b3log/tmp/mail.properties | sed \
-e "s|{{EMAIL_ADDRESS}}|${EMAIL_ADDRESS}|g" \
-e "s|{{EMAIL_PASSWORD}}|${EMAIL_PASSWORD}|g" \
-e "s|{{SMTP_HOST}}|${SMTP_HOST:-smtp.gmail.com}|g" \
-e "s|{{SMTP_PROT}}|${SMTP_PROT:-587}|g" \
-e "s|{{SMTP_SOCKETFACTORY_PORT}}|${SMTP_SOCKETFACTORY_PORT:-465}|g" \
> /opt/b3log/solo/WEB-INF/classes/mail.properties
rm -rf /opt/b3log/tmp rm -rf /opt/b3log/tmp
fi fi
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# Author: Dongxu Wang # Author: Dongxu Wang
# #
commentEmailLabel=Email queryUserFailedLabel=Query user info failed
commentContentLabel=Content commentContentLabel=Content
cancelLabel=Cancel cancelLabel=Cancel
langLabel=en_US langLabel=en_US
...@@ -89,15 +89,11 @@ type1Label=Type: ...@@ -89,15 +89,11 @@ type1Label=Type:
typeLabel=Type typeLabel=Type
onlineVisitor1Label=Online Visitors: onlineVisitor1Label=Online Visitors:
noDataLabel=Lazy guy, has nothing! noDataLabel=Lazy guy, has nothing!
replayEmailExplanationLabel=<b>Variables Explanation</b><ul class="marginLeft12"><li><b>${blogTitle}:</b> Blog title</li><li><b>${postLink}:</b> Post link</li><li><b>${postTitle}:</b> Post title</li><li><b>${replier}:</b> Replier ( if has link address, this variable is change to link address ) </li><li><b>${replyURL}:</b> Replay URL ( include # ) </li><li><b>${replyContent}:</b> Reply content</li></ul>
emailSubject1Label=Email Subject:
emailContent1Label=Email Content:
linkDescriptionLabel=Link Description linkDescriptionLabel=Link Description
linkDescription1Label=Description: linkDescription1Label=Description:
descriptionLabel=Description descriptionLabel=Description
addressInvalidLabel=start protocol, e.g.: http:// addressInvalidLabel=start protocol, e.g.: http://
ToolLabel=Tool ToolLabel=Tool
replayEmailTemplateLabel=Email Template for Reply
titleAndContentLabel=Title+Content titleAndContentLabel=Title+Content
titleAndAbstractLabel=Title+Abstract titleAndAbstractLabel=Title+Abstract
titleOnlyLabel=Title only titleOnlyLabel=Title only
...@@ -336,7 +332,6 @@ articleViewPwdLabel=View Password ...@@ -336,7 +332,6 @@ articleViewPwdLabel=View Password
articleViewPwd1Label=View Password: articleViewPwd1Label=View Password:
#### ####
forbiddenLabel=Forbidden Access! forbiddenLabel=Forbidden Access!
sorryLabel=Sorry!
notFoundLabel=Not Found! notFoundLabel=Not Found!
unPulbishSuccLabel=Un Publish Successfully unPulbishSuccLabel=Un Publish Successfully
unPulbishFailLabel=Un Publish Fail unPulbishFailLabel=Un Publish Fail
...@@ -355,7 +350,6 @@ updatePreferenceFailNeedMulUsersLabel=Update Fail, the selected skin need multip ...@@ -355,7 +350,6 @@ updatePreferenceFailNeedMulUsersLabel=Update Fail, the selected skin need multip
setFailLabel=Set Fail setFailLabel=Set Fail
setSuccLabel=Set Successfully setSuccLabel=Set Successfully
getFailLabel=Get Fail getFailLabel=Get Fail
noSettingLabel=No Setting
getSuccLabel=Get Successfully getSuccLabel=Get Successfully
importSuccLabel=Import Successfully :-) importSuccLabel=Import Successfully :-)
importFailLabel=Some Import Fail %>_<% importFailLabel=Some Import Fail %>_<%
...@@ -364,16 +358,10 @@ captchaErrorLabel=Captcha Error ...@@ -364,16 +358,10 @@ captchaErrorLabel=Captcha Error
inputErrorLabel=Input Error! inputErrorLabel=Input Error!
gotoLabel=Go gotoLabel=Go
nameEmptyLabel=Username is empty nameEmptyLabel=Username is empty
passwordEmptyLabel=Password is empty
passwordNotMatchLabel=Password Not Match passwordNotMatchLabel=Password Not Match
userPasswordConfirm1Label=Input password again:
blogEmptyLabel=Blogging service is empty
blogArticleEmptyLabel=Please select articles
notAllowCommentLabel=Not allow comment! notAllowCommentLabel=Not allow comment!
nameTooLongLabel=Sorry, your username must be between 2 and 20 characters long. nameTooLongLabel=Sorry, your username must be between 2 and 20 characters long.
categoryTooLongLabel=Sorry, category name must be between 2 and 32 characters long. categoryTooLongLabel=Sorry, category name must be between 2 and 32 characters long.
mailCannotEmptyLabel=Mail is empty
mailInvalidLabel=Mail is invalid
urlInvalidLabel=URL is invalid urlInvalidLabel=URL is invalid
nonNegativeIntegerOnlyLabel=Non-Negative integer only nonNegativeIntegerOnlyLabel=Non-Negative integer only
commentContentCannotEmptyLabel=Sorry, your content must be between 2 and 500 characters long. commentContentCannotEmptyLabel=Sorry, your content must be between 2 and 500 characters long.
...@@ -389,7 +377,6 @@ noAuthorizationURLLabel=Can not retrieve authorization URL from Google, please \ ...@@ -389,7 +377,6 @@ noAuthorizationURLLabel=Can not retrieve authorization URL from Google, please \
make sure the <em>Consumer Secret</em> you typed in and then try again. make sure the <em>Consumer Secret</em> you typed in and then try again.
duplicatedPermalinkLabel=Duplicated permalink! duplicatedPermalinkLabel=Duplicated permalink!
invalidPermalinkFormatLabel=Invalid permalink format! invalidPermalinkFormatLabel=Invalid permalink format!
duplicatedEmailLabel=Duplicated email!
duplicatedUserNameLabel=Duplicated username! duplicatedUserNameLabel=Duplicated username!
refreshAndRetryLabel=Please refresh and try again! refreshAndRetryLabel=Please refresh and try again!
editorLeaveLabel=Content is not null, Do you leave? editorLeaveLabel=Content is not null, Do you leave?
...@@ -402,10 +389,6 @@ confirmRemoveLabel=Are You Remove ...@@ -402,10 +389,6 @@ confirmRemoveLabel=Are You Remove
confirmInitLabel=Are You Sure? confirmInitLabel=Are You Sure?
###### Common ###### ###### Common ######
mobileLabel=Mobile Theme mobileLabel=Mobile Theme
# Send an email to the user who upgrades Solo with a discontinuous version #
skipVersionMailSubject=[no-reply]Better not to skip more than one version to upgrade Solo
skipVersionMailBody=Hey, sorry for any inconvenience caused. If your Solo is too old to upgrade, \
developers in <a href="https://b3log.org" target="_blank">B3log</a> are more than welcome to help, thank you.
helloWorld.title=\u4E16\u754C\uFF0C\u4F60\u597D\uFF01 helloWorld.title=\u4E16\u754C\uFF0C\u4F60\u597D\uFF01
helloWorld.content=Solo \u535A\u5BA2\u7CFB\u7EDF\u5DF2\u7ECF\u521D\u59CB\u5316\u5B8C\u6BD5\uFF0C\u53EF\u5728\u7BA1\u7406\u540E\u53F0 - \u5DE5\u5177 - \u504F\u597D\u8BBE\u5B9A\u4E2D\u8C03\u6574\u66F4\u591A\u7EC6\u8282\u8BBE\u7F6E\u3002\u5982\u679C\u9700\u8981\u5BFC\u5165\u5DF2\u6709\u535A\u5BA2\u6587\u7AE0\uFF0C\u8BF7\u53C2\u8003\u6587\u6863 [Hexo/Jekyll/Markdown \u6587\u4EF6\u5BFC\u5165](https://hacpai.com/article/1498490209748)\u3002\n\n\ helloWorld.content=Solo \u535A\u5BA2\u7CFB\u7EDF\u5DF2\u7ECF\u521D\u59CB\u5316\u5B8C\u6BD5\uFF0C\u53EF\u5728\u7BA1\u7406\u540E\u53F0 - \u5DE5\u5177 - \u504F\u597D\u8BBE\u5B9A\u4E2D\u8C03\u6574\u66F4\u591A\u7EC6\u8282\u8BBE\u7F6E\u3002\u5982\u679C\u9700\u8981\u5BFC\u5165\u5DF2\u6709\u535A\u5BA2\u6587\u7AE0\uFF0C\u8BF7\u53C2\u8003\u6587\u6863 [Hexo/Jekyll/Markdown \u6587\u4EF6\u5BFC\u5165](https://hacpai.com/article/1498490209748)\u3002\n\n\
\u53E6\u5916\uFF0C\u51FA\u4E8E\u5B89\u5168\u8003\u8651\u8BF7\u5C3D\u5FEB\u5B8C\u6210\u5982\u4E0B\u64CD\u4F5C\uFF1A\n\n\ \u53E6\u5916\uFF0C\u51FA\u4E8E\u5B89\u5168\u8003\u8651\u8BF7\u5C3D\u5FEB\u5B8C\u6210\u5982\u4E0B\u64CD\u4F5C\uFF1A\n\n\
......
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
# Author: Dongxu Wang # Author: Dongxu Wang
# #
commentEmailLabel=\u90AE\u7BB1 queryUserFailedLabel=\u67E5\u8BE2\u7528\u6237\u4FE1\u606F\u5931\u8D25
commentContentLabel=\u8BC4\u8BBA\u5185\u5BB9 commentContentLabel=\u8BC4\u8BBA\u5185\u5BB9
cancelLabel=\u53D6\u6D88 cancelLabel=\u53D6\u6D88
langLabel=zh_CN langLabel=zh_CN
...@@ -89,15 +89,11 @@ type1Label=\u7C7B\u578B\uFF1A ...@@ -89,15 +89,11 @@ type1Label=\u7C7B\u578B\uFF1A
typeLabel=\u7C7B\u578B typeLabel=\u7C7B\u578B
onlineVisitor1Label=\u5F53\u524D\u8BBF\u5BA2\uFF1A onlineVisitor1Label=\u5F53\u524D\u8BBF\u5BA2\uFF1A
noDataLabel=\u8BE5\u5217\u8868\u5F88\u61D2\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u6709\u7559\u4E0B\u3002\u3002\u3002 noDataLabel=\u8BE5\u5217\u8868\u5F88\u61D2\uFF0C\u4EC0\u4E48\u90FD\u6CA1\u6709\u7559\u4E0B\u3002\u3002\u3002
replayEmailExplanationLabel=<b>\u53D8\u91CF\u8BF4\u660E</b><ul class="marginLeft12"><li><b>${blogTitle}:</b> \u535A\u5BA2\u6807\u9898</li><li><b>${postLink}:</b> \u539F\u6587\uFF08\u6587\u7AE0/\u81EA\u5B9A\u4E49\u9875\u9762\uFF09\u94FE\u63A5\u5730\u5740</li><li><b>${postTitle}:</b> \u539F\u6587\u6807\u9898</li><li><b>${replier}:</b> \u56DE\u590D\u4EBA\uFF08\u5982\u679C\u56DE\u590D\u4EBA\u586B\u5199\u4E86\u4ED6\u7684\u94FE\u63A5\u5730\u5740\uFF0C\u8FD9\u4E2A\u53D8\u91CF\u5C06\u5305\u542B\u94FE\u63A5\u5730\u5740\uFF09</li><li><b>${replyURL}:</b> \u56DE\u590D\u94FE\u63A5\uFF08\u5E26 # \u951A\u70B9\uFF09</li><li><b>${replyContent}:</b> \u56DE\u590D\u5185\u5BB9</li></ul>
emailSubject1Label=\u90AE\u4EF6\u4E3B\u9898\uFF1A
emailContent1Label=\u90AE\u4EF6\u5185\u5BB9\uFF1A
linkDescriptionLabel=\u94FE\u63A5\u63CF\u8FF0 linkDescriptionLabel=\u94FE\u63A5\u63CF\u8FF0
linkDescription1Label=\u63CF\u8FF0\uFF1A linkDescription1Label=\u63CF\u8FF0\uFF1A
descriptionLabel=\u63CF\u8FF0 descriptionLabel=\u63CF\u8FF0
addressInvalidLabel=\u8BF7\u4EE5\u534F\u8BAE\u5F00\u5934\uFF0C\u5982: http:// addressInvalidLabel=\u8BF7\u4EE5\u534F\u8BAE\u5F00\u5934\uFF0C\u5982: http://
ToolLabel=\u5DE5\u5177 ToolLabel=\u5DE5\u5177
replayEmailTemplateLabel=\u56DE\u590D\u63D0\u9192\u90AE\u4EF6\u6A21\u7248
titleAndContentLabel=\u6807\u9898+\u6B63\u6587 titleAndContentLabel=\u6807\u9898+\u6B63\u6587
titleAndAbstractLabel=\u6807\u9898+\u6458\u8981 titleAndAbstractLabel=\u6807\u9898+\u6458\u8981
titleOnlyLabel=\u4EC5\u6807\u9898 titleOnlyLabel=\u4EC5\u6807\u9898
...@@ -336,7 +332,6 @@ articleViewPwdLabel=\u8BBF\u95EE\u5BC6\u7801 ...@@ -336,7 +332,6 @@ articleViewPwdLabel=\u8BBF\u95EE\u5BC6\u7801
articleViewPwd1Label=\u8BBF\u95EE\u5BC6\u7801\uFF1A articleViewPwd1Label=\u8BBF\u95EE\u5BC6\u7801\uFF1A
#### ####
forbiddenLabel=\u64CD\u4F5C\u88AB\u7981\u6B62\uFF01 forbiddenLabel=\u64CD\u4F5C\u88AB\u7981\u6B62\uFF01
sorryLabel=\u5BF9\u4E0D\u8D77\uFF01
notFoundLabel=\u627E\u4E0D\u5230\uFF01 notFoundLabel=\u627E\u4E0D\u5230\uFF01
unPulbishSuccLabel=\u53D6\u6D88\u53D1\u5E03\u6210\u529F unPulbishSuccLabel=\u53D6\u6D88\u53D1\u5E03\u6210\u529F
unPulbishFailLabel=\u53D6\u6D88\u53D1\u5E03\u5931\u8D25 unPulbishFailLabel=\u53D6\u6D88\u53D1\u5E03\u5931\u8D25
...@@ -355,7 +350,6 @@ updatePreferenceFailNeedMulUsersLabel=\u66F4\u65B0\u5931\u8D25\uFF0C\u9700\u8981 ...@@ -355,7 +350,6 @@ updatePreferenceFailNeedMulUsersLabel=\u66F4\u65B0\u5931\u8D25\uFF0C\u9700\u8981
setFailLabel=\u8BBE\u7F6E\u5931\u8D25 setFailLabel=\u8BBE\u7F6E\u5931\u8D25
setSuccLabel=\u8BBE\u7F6E\u6210\u529F setSuccLabel=\u8BBE\u7F6E\u6210\u529F
getFailLabel=\u83B7\u53D6\u5931\u8D25 getFailLabel=\u83B7\u53D6\u5931\u8D25
noSettingLabel=\u8BE5\u535A\u5BA2\u65E0\u8D26\u53F7\uFF0C\u8BF7\u6DFB\u52A0
getSuccLabel=\u83B7\u53D6\u6210\u529F getSuccLabel=\u83B7\u53D6\u6210\u529F
importSuccLabel=\u5BFC\u5165\u6210\u529F :-) importSuccLabel=\u5BFC\u5165\u6210\u529F :-)
importFailLabel=\u90E8\u5206\u5BFC\u5165\u5931\u8D25 %>_<% importFailLabel=\u90E8\u5206\u5BFC\u5165\u5931\u8D25 %>_<%
...@@ -364,16 +358,10 @@ captchaErrorLabel=\u9A8C\u8BC1\u7801\u9519\u8BEF ...@@ -364,16 +358,10 @@ captchaErrorLabel=\u9A8C\u8BC1\u7801\u9519\u8BEF
inputErrorLabel=\u8F93\u5165\u9519\u8BEF\uFF01 inputErrorLabel=\u8F93\u5165\u9519\u8BEF\uFF01
gotoLabel=\u8DF3\u8F6C gotoLabel=\u8DF3\u8F6C
nameEmptyLabel=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A\uFF01 nameEmptyLabel=\u59D3\u540D\u4E0D\u80FD\u4E3A\u7A7A\uFF01
passwordEmptyLabel=\u5BC6\u7801\u4E0D\u80FD\u4E3A\u7A7A\uFF01
passwordNotMatchLabel=\u5BC6\u7801\u4E0D\u5339\u914D\uFF01 passwordNotMatchLabel=\u5BC6\u7801\u4E0D\u5339\u914D\uFF01
userPasswordConfirm1Label=\u518D\u6B21\u8F93\u5165\u5BC6\u7801\uFF1A
blogEmptyLabel=\u8BF7\u9009\u62E9\u535A\u5BA2\u670D\u52A1\uFF01
blogArticleEmptyLabel=\u8BF7\u9009\u62E9\u9700\u8981\u5BFC\u5165\u7684\u6587\u7AE0
notAllowCommentLabel=\u4E0D\u5141\u8BB8\u8BC4\u8BBA\uFF01 notAllowCommentLabel=\u4E0D\u5141\u8BB8\u8BC4\u8BBA\uFF01
nameTooLongLabel=\u59D3\u540D\u53EA\u80FD\u4E3A 2 \u5230 20 \u4E2A\u5B57\u7B26\uFF01 nameTooLongLabel=\u59D3\u540D\u53EA\u80FD\u4E3A 2 \u5230 20 \u4E2A\u5B57\u7B26\uFF01
categoryTooLongLabel=\u5206\u7C7B\u540D\u79F0\u53EA\u80FD\u4E3A 2 \u5230 32 \u4E2A\u5B57\u7B26\uFF01 categoryTooLongLabel=\u5206\u7C7B\u540D\u79F0\u53EA\u80FD\u4E3A 2 \u5230 32 \u4E2A\u5B57\u7B26\uFF01
mailCannotEmptyLabel=\u90AE\u7BB1\u4E0D\u80FD\u4E3A\u7A7A\uFF01
mailInvalidLabel=\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
urlInvalidLabel=\u94FE\u63A5\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01 urlInvalidLabel=\u94FE\u63A5\u683C\u5F0F\u4E0D\u6B63\u786E\uFF01
nonNegativeIntegerOnlyLabel=\u53EA\u80FD\u4E3A\u975E\u8D1F\u6574\u6570\uFF01 nonNegativeIntegerOnlyLabel=\u53EA\u80FD\u4E3A\u975E\u8D1F\u6574\u6570\uFF01
commentContentCannotEmptyLabel=\u8BC4\u8BBA\u5185\u5BB9\u53EA\u80FD\u4E3A 2 \u5230 500 \u4E2A\u5B57\u7B26\uFF01 commentContentCannotEmptyLabel=\u8BC4\u8BBA\u5185\u5BB9\u53EA\u80FD\u4E3A 2 \u5230 500 \u4E2A\u5B57\u7B26\uFF01
...@@ -389,7 +377,6 @@ noAuthorizationURLLabel=\u4ECE Google \u83B7\u53D6\u6388\u6743\u5730\u5740\u5931 ...@@ -389,7 +377,6 @@ noAuthorizationURLLabel=\u4ECE Google \u83B7\u53D6\u6388\u6743\u5730\u5740\u5931
<em>Consumer Secret</em> \u662F\u6B63\u786E\u7684\uFF0C\u7136\u540E\u8FDB\u884C\u91CD\u8BD5\u3002 <em>Consumer Secret</em> \u662F\u6B63\u786E\u7684\uFF0C\u7136\u540E\u8FDB\u884C\u91CD\u8BD5\u3002
duplicatedPermalinkLabel=\u94FE\u63A5\u91CD\u590D\uFF01 duplicatedPermalinkLabel=\u94FE\u63A5\u91CD\u590D\uFF01
invalidPermalinkFormatLabel=\u975E\u6CD5\u7684\u94FE\u63A5\u683C\u5F0F\uFF01 invalidPermalinkFormatLabel=\u975E\u6CD5\u7684\u94FE\u63A5\u683C\u5F0F\uFF01
duplicatedEmailLabel=\u90AE\u4EF6\u5730\u5740\u91CD\u590D\uFF01
duplicatedUserNameLabel=\u7528\u6237\u540D\u91CD\u590D\uFF01 duplicatedUserNameLabel=\u7528\u6237\u540D\u91CD\u590D\uFF01
refreshAndRetryLabel=\u8BF7\u5237\u65B0\u91CD\u8BD5\uFF01 refreshAndRetryLabel=\u8BF7\u5237\u65B0\u91CD\u8BD5\uFF01
editorLeaveLabel=\u7F16\u8F91\u5668\u4E2D\u8FD8\u6709\u5185\u5BB9\uFF0C\u662F\u5426\u79BB\u5F00\uFF1F editorLeaveLabel=\u7F16\u8F91\u5668\u4E2D\u8FD8\u6709\u5185\u5BB9\uFF0C\u662F\u5426\u79BB\u5F00\uFF1F
...@@ -402,10 +389,6 @@ confirmRemoveLabel=\u662F\u5426\u5220\u9664 ...@@ -402,10 +389,6 @@ confirmRemoveLabel=\u662F\u5426\u5220\u9664
confirmInitLabel=\u786E\u5B9A\u8FDB\u884C\u521D\u59CB\u5316\u5417\uFF1F confirmInitLabel=\u786E\u5B9A\u8FDB\u884C\u521D\u59CB\u5316\u5417\uFF1F
###### Common ###### ###### Common ######
mobileLabel=\u79FB\u52A8\u7248 mobileLabel=\u79FB\u52A8\u7248
# Send an email to the user who upgrades Solo with a discontinuous version #
skipVersionMailSubject=[\u65E0\u9700\u56DE\u590D]\u8DE8\u7248\u672C\u5347\u7EA7 Solo \u63D0\u9192
skipVersionMailBody=Hey, \u60A8\u597D\uFF01<p>\u975E\u5E38\u9AD8\u5174\u60A8\u51C6\u5907\u5347\u7EA7 Solo\uFF0C\u4E0D\u8FC7\u76EE\u524D\u8FD8\u4E0D\u652F\u6301\u8DE8\u7248\u672C\u5347\u7EA7\uFF0C\u8BF7\u6309\u7167\u5386\u53F2\u7248\u672C\u4F9D\u6B21\u8FDB\u884C\u5347\u7EA7\u3002</p>\
<p>\u5BF9\u6B64\u7ED9\u60A8\u5E26\u6765\u7684\u4E0D\u4FBF\u6211\u4EEC\u6DF1\u8868\u6B49\u610F\uFF0C\u8C22\u8C22\u60A8\u5BF9 <a href="https://b3log.org" target="_blank">B3log</a> \u7684\u652F\u6301\u3002</p>
helloWorld.title=\u4E16\u754C\uFF0C\u4F60\u597D\uFF01 helloWorld.title=\u4E16\u754C\uFF0C\u4F60\u597D\uFF01
helloWorld.content=Solo \u535A\u5BA2\u7CFB\u7EDF\u5DF2\u7ECF\u521D\u59CB\u5316\u5B8C\u6BD5\uFF0C\u53EF\u5728\u7BA1\u7406\u540E\u53F0 - \u5DE5\u5177 - \u504F\u597D\u8BBE\u5B9A\u4E2D\u8C03\u6574\u66F4\u591A\u7EC6\u8282\u8BBE\u7F6E\u3002\u5982\u679C\u9700\u8981\u5BFC\u5165\u5DF2\u6709\u535A\u5BA2\u6587\u7AE0\uFF0C\u8BF7\u53C2\u8003\u6587\u6863 [Hexo/Jekyll/Markdown \u6587\u4EF6\u5BFC\u5165](https://hacpai.com/article/1498490209748)\u3002\n\n\ helloWorld.content=Solo \u535A\u5BA2\u7CFB\u7EDF\u5DF2\u7ECF\u521D\u59CB\u5316\u5B8C\u6BD5\uFF0C\u53EF\u5728\u7BA1\u7406\u540E\u53F0 - \u5DE5\u5177 - \u504F\u597D\u8BBE\u5B9A\u4E2D\u8C03\u6574\u66F4\u591A\u7EC6\u8282\u8BBE\u7F6E\u3002\u5982\u679C\u9700\u8981\u5BFC\u5165\u5DF2\u6709\u535A\u5BA2\u6587\u7AE0\uFF0C\u8BF7\u53C2\u8003\u6587\u6863 [Hexo/Jekyll/Markdown \u6587\u4EF6\u5BFC\u5165](https://hacpai.com/article/1498490209748)\u3002\n\n\
\u53E6\u5916\uFF0C\u51FA\u4E8E\u5B89\u5168\u8003\u8651\u8BF7\u5C3D\u5FEB\u5B8C\u6210\u5982\u4E0B\u64CD\u4F5C\uFF1A\n\n\ \u53E6\u5916\uFF0C\u51FA\u4E8E\u5B89\u5168\u8003\u8651\u8BF7\u5C3D\u5FEB\u5B8C\u6210\u5982\u4E0B\u64CD\u4F5C\uFF1A\n\n\
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
# #
# Description: Solo local environment configurations. # Description: Solo local environment configurations.
# Version: 1.1.3.13, Feb 4, 2019 # Version: 1.1.3.14, Mar 3, 2019
# Author: Liang Ding # Author: Liang Ding
# #
...@@ -40,8 +40,5 @@ jdbc.URL=jdbc:h2:~/solo_h2/db ...@@ -40,8 +40,5 @@ jdbc.URL=jdbc:h2:~/solo_h2/db
jdbc.minConnCnt=5 jdbc.minConnCnt=5
jdbc.maxConnCnt=10 jdbc.maxConnCnt=10
# Be care to change the transaction isolation
jdbc.transactionIsolation=REPEATABLE_READ
# The specific table name prefix # The specific table name prefix
jdbc.tablePrefix=b3_solo jdbc.tablePrefix=b3_solo
#
# Solo - A small and beautiful blogging system written in Java.
# Copyright (c) 2010-2019, b3log.org & hacpai.com
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
#
# Description: Solo mail configurations.
# Version: 1.0.0.6, Jan 18, 2019
# Author: Liang Ding
#
mail.user=
mail.password=
mail.debug=false
mail.smtp.host=smtp.qq.com
mail.smtp.port=465
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback=false
mail.smtp.socketFactory.port=465
mail.smtp.auth=true
mail.smtp.starttls.enable=true
\ No newline at end of file
...@@ -132,12 +132,6 @@ ...@@ -132,12 +132,6 @@
"description": "评论时间戳", "description": "评论时间戳",
"type": "long" "type": "long"
}, },
{
"name": "commentEmail",
"description": "评论人邮箱",
"type": "String",
"length": 255
},
{ {
"name": "commentName", "name": "commentName",
"description": "评论人名称", "description": "评论人名称",
...@@ -383,12 +377,6 @@ ...@@ -383,12 +377,6 @@
"type": "String", "type": "String",
"length": 19 "length": 19
}, },
{
"name": "userEmail",
"description": "用户邮箱",
"type": "String",
"length": 255
},
{ {
"name": "userName", "name": "userName",
"description": "用户名", "description": "用户名",
......
...@@ -79,21 +79,13 @@ ...@@ -79,21 +79,13 @@
"statusLabel": "${statusLabel}", "statusLabel": "${statusLabel}",
"versionLabel": "${versionLabel}", "versionLabel": "${versionLabel}",
"userNameLabel": "${userNameLabel}", "userNameLabel": "${userNameLabel}",
"commentEmailLabel": "${commentEmailLabel}",
"roleLabel": "${roleLabel}", "roleLabel": "${roleLabel}",
"administratorLabel": "${administratorLabel}", "administratorLabel": "${administratorLabel}",
"duplicatedEmailLabel": "${duplicatedEmailLabel}",
"mailInvalidLabel": "${mailInvalidLabel}",
"mailCannotEmptyLabel": "${mailCannotEmptyLabel}",
"noSettingLabel": "${noSettingLabel}",
"blogEmptyLabel": "${blogEmptyLabel}",
"sumLabel": "${sumLabel}", "sumLabel": "${sumLabel}",
"countLabel": "${countLabel}", "countLabel": "${countLabel}",
"blogArticleEmptyLabel": "${blogArticleEmptyLabel}",
"importSuccLabel": "${importSuccLabel}", "importSuccLabel": "${importSuccLabel}",
"categoryLabel": "${categoryLabel}", "categoryLabel": "${categoryLabel}",
"importedLabel": "${importedLabel}", "importedLabel": "${importedLabel}",
"passwordEmptyLabel": "${passwordEmptyLabel}",
"tagsEmptyLabel": "${tagsEmptyLabel}", "tagsEmptyLabel": "${tagsEmptyLabel}",
"abstractEmptyLabel": "${abstractEmptyLabel}", "abstractEmptyLabel": "${abstractEmptyLabel}",
"commonUserLabel": "${commonUserLabel}", "commonUserLabel": "${commonUserLabel}",
......
...@@ -19,11 +19,6 @@ ...@@ -19,11 +19,6 @@
--> -->
<div id="tabOthers" class="sub-tabs"> <div id="tabOthers" class="sub-tabs">
<ul> <ul>
<li>
<div id="tabOthers_email">
<a class="tab-current" href="#tools/others/email">${replayEmailTemplateLabel}</a>
</div>
</li>
<li> <li>
<div id="tabOthers_tag"> <div id="tabOthers_tag">
<a href="#tools/others/tag">${clearTagLabel}</a> <a href="#tools/others/tag">${clearTagLabel}</a>
...@@ -37,17 +32,6 @@ ...@@ -37,17 +32,6 @@
</ul> </ul>
</div> </div>
<div id="tabOthersPanel" class="sub-tabs-main"> <div id="tabOthersPanel" class="sub-tabs-main">
<div id="tabOthersPanel_email" class="form form__no-table">
<label for="replayEmailTemplateTitle">${emailSubject1Label}</label>
<input id="replayEmailTemplateTitle" type="text"/>
<label for="replayEmailTemplateBody">${emailContent1Label}</label>
<textarea rows="9" id="replayEmailTemplateBody"></textarea><br><br>
<button onclick="admin.others.update()" class="fn__right">${updateLabel}</button>
<div class="fn__clear"></div>
<div class="content-reset">
${replayEmailExplanationLabel}
</div>
</div>
<div id="tabOthersPanel_tag" class="fn__none"> <div id="tabOthersPanel_tag" class="fn__none">
<button class="fn__margin12" onclick="admin.others.removeUnusedTags();">${removeUnusedTagsLabel}</button> <button class="fn__margin12" onclick="admin.others.removeUnusedTags();">${removeUnusedTagsLabel}</button>
</div> </div>
......
...@@ -26,8 +26,6 @@ ...@@ -26,8 +26,6 @@
<div id="userUpdate" class="fn__none form form__no-table"> <div id="userUpdate" class="fn__none form form__no-table">
<label for="userNameUpdate">${userName1Label}</label> <label for="userNameUpdate">${userName1Label}</label>
<input id="userNameUpdate" type="text"/> <input id="userNameUpdate" type="text"/>
<label for="userEmailUpdate">${commentEmailLabel}</label>
<input id="userEmailUpdate" type="text"/>
<label for="userURLUpdate">${userURL1Label}</label> <label for="userURLUpdate">${userURL1Label}</label>
<input id="userURLUpdate" type="text"/> <input id="userURLUpdate" type="text"/>
<label for="userAvatarUpdate">${userAvatar1Label}</label> <label for="userAvatarUpdate">${userAvatar1Label}</label>
......
...@@ -19,17 +19,17 @@ Util.htmlDecode=function(t){var e=document.createElement("div");return e.innerHT ...@@ -19,17 +19,17 @@ Util.htmlDecode=function(t){var e=document.createElement("div");return e.innerHT
admin.editors={};var SoloEditor=function(e){this.conf=e,this.init()};$.extend(SoloEditor.prototype,{init:function(){this.editor=new Vditor(this.conf.id,{cache:!0,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},preview:{delay:500,show:this.conf.previewShow,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},upload:{max:10485760,url:Label.uploadURL,token:Label.uploadToken,filename:function(e){return e.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g,"-")}},height:this.conf.height,counter:102400,resize:{enable:this.conf.resize},lang:Label.localeString,classes:{preview:"content-reset"}}),"function"==typeof this.conf.fun&&this.conf.fun()},getContent:function(){return this.editor.getValue()},setContent:function(e){this.editor.setValue(e)},remove:function(){document.getElementById(this.editor.vditor.id).outerHTML=""}}),admin.editors.articleEditor={},admin.editors.abstractEditor={},admin.editors.pageEditor={}; admin.editors={};var SoloEditor=function(e){this.conf=e,this.init()};$.extend(SoloEditor.prototype,{init:function(){this.editor=new Vditor(this.conf.id,{cache:!0,hint:{emojiPath:latkeConfig.staticServePath+"/js/lib/emojify.js-1.1.0/images/basic"},preview:{delay:500,show:this.conf.previewShow,url:latkeConfig.servePath+"/console/markdown/2html",parse:function(e){"none"!==e.style.display&&(Util.parseMarkdown("content-reset"),Label.markedAvailable||(hljs.initHighlighting.called=!1,hljs.initHighlighting()))}},upload:{max:10485760,url:Label.uploadURL,token:Label.uploadToken,filename:function(e){return e.replace(/\?|\\|\/|:|\||<|>|\*|\[|\]|\s+/g,"-")}},height:this.conf.height,counter:102400,resize:{enable:this.conf.resize},lang:Label.localeString,classes:{preview:"content-reset"}}),"function"==typeof this.conf.fun&&this.conf.fun()},getContent:function(){return this.editor.getValue()},setContent:function(e){this.editor.setValue(e)},remove:function(){document.getElementById(this.editor.vditor.id).outerHTML=""}}),admin.editors.articleEditor={},admin.editors.abstractEditor={},admin.editors.pageEditor={};
var TablePaginate=function(a){this.id=a,this.currentPage=1};$.extend(TablePaginate.prototype,{buildTable:function(a,t){var e={colModel:a,noDataTip:Label.noDataLabel};t||(e.expendRow={index:"expendRow"}),$("#"+this.id+"Table").table(e)},initPagination:function(){var a=this.id;$("#"+a+"Pagination").paginate({bind:function(a,t){t?$("#tipMsg").text(t):admin.setHashByPage(a)},currentPage:1,errorMessage:Label.inputErrorLabel,nextPageText:">",previousPageText:"<",goText:Label.gotoLabel,type:"custom",custom:[1],pageCount:1})},initCommentsDialog:function(){var a=this;$("#"+this.id+"Comments").dialog({modal:!0,hideFooter:!0,close:function(){return admin[a.id+"List"].getList(a.currentPage),!0}})},updateTablePagination:function(a,t,e){if((t=parseInt(t))>e.paginationPageCount&&1<t)return $("#tipMsg").text(Label.pageLabel+t+Label.notFoundLabel),void $("#loadMsg").text("");$("#"+this.id+"Table").table("update",{data:[{groupName:"all",groupData:a}]}),0===e.paginationPageCount&&(e.paginationPageCount=1),$("#"+this.id+"Pagination").paginate("update",{pageCount:e.paginationPageCount,currentPage:t,custom:e.paginationPageNums}),this.currentPage=t}}); var TablePaginate=function(a){this.id=a,this.currentPage=1};$.extend(TablePaginate.prototype,{buildTable:function(a,t){var e={colModel:a,noDataTip:Label.noDataLabel};t||(e.expendRow={index:"expendRow"}),$("#"+this.id+"Table").table(e)},initPagination:function(){var a=this.id;$("#"+a+"Pagination").paginate({bind:function(a,t){t?$("#tipMsg").text(t):admin.setHashByPage(a)},currentPage:1,errorMessage:Label.inputErrorLabel,nextPageText:">",previousPageText:"<",goText:Label.gotoLabel,type:"custom",custom:[1],pageCount:1})},initCommentsDialog:function(){var a=this;$("#"+this.id+"Comments").dialog({modal:!0,hideFooter:!0,close:function(){return admin[a.id+"List"].getList(a.currentPage),!0}})},updateTablePagination:function(a,t,e){if((t=parseInt(t))>e.paginationPageCount&&1<t)return $("#tipMsg").text(Label.pageLabel+t+Label.notFoundLabel),void $("#loadMsg").text("");$("#"+this.id+"Table").table("update",{data:[{groupName:"all",groupData:a}]}),0===e.paginationPageCount&&(e.paginationPageCount=1),$("#"+this.id+"Pagination").paginate("update",{pageCount:e.paginationPageCount,currentPage:t,custom:e.paginationPageNums}),this.currentPage=t}});
function getUUID(){var a=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"==t?e:3&e|8).toString(16)});return t=t.replace(new RegExp("-","g"),"")}admin.article={isConfirm:!0,status:{id:void 0,isArticle:void 0,articleHadBeenPublished:void 0},content:"",autoSaveDraftTimer:"",AUTOSAVETIME:6e4,get:function(t,e){this.status.id=t,this.status.isArticle=e,admin.selectTab("article/article")},getAndSet:function(){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/article/"+admin.article.status.id,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){$("#title").val(e.article.articleTitle),admin.article.status.articleHadBeenPublished=e.article.articleHadBeenPublished,admin.editors.articleEditor.setContent(e.article.articleContent),admin.editors.abstractEditor.setContent(e.article.articleAbstract),admin.article.content=admin.editors.articleEditor.getContent();for(var a=e.article.articleTags,i="",l=0;l<a.length;l++)0===l?i=a[l].tagTitle:i+=","+a[l].tagTitle;$("#tag").val(i),$("#permalink").val(e.article.articlePermalink),$("#viewPwd").val(e.article.articleViewPwd),$("#articleCommentable").prop("checked",e.article.articleCommentable);var s=e.article.signs;$(".signs button").each(function(t){parseInt(e.article.articleSignId)===parseInt(s[t].oId)?$("#articleSign"+s[t].oId).addClass("selected"):$("#articleSign"+s[t].oId).removeClass("selected")}),admin.article.setStatus(),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(t,a,e){confirm(Label.confirmRemoveLabel+Label.articleLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/article/"+t,type:"DELETE",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc?admin[a+"List"].getList(1):$("#loadMsg").text("")}}))},add:function(a,i){if(admin.article.validate()){var l=this;l._addDisabled(),$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t="";$(".signs button").each(function(){"selected"===this.className&&(t=this.id.substr(this.id.length-1,1))});var e=admin.editors.articleEditor.getContent(),s=admin.editors.abstractEditor.getContent();if($("#articleThumbnail").prop("checked")){var r=$(".thumbnail__img").css("background-image");e="![]("+r.substring(5,r.length-2).replace("w/768","w/960").replace("h/432","h/540")+")\n\n"+e}var n={article:{articleTitle:$("#title").val(),articleContent:e,articleAbstract:s,articleTags:this.trimUniqueArray($("#tag").val()).toString(),articlePermalink:$("#permalink").val(),articleIsPublished:a,articleSignId:t,postToCommunity:$("#postToCommunity").prop("checked"),articleCommentable:$("#articleCommentable").prop("checked"),articleViewPwd:$("#viewPwd").val()}};$.ajax({url:latkeConfig.servePath+"/console/article/",type:"POST",cache:!1,data:JSON.stringify(n),success:function(t,e){if(i)return $("#tipMsg").text(Label.autoSaveLabel),void(admin.article.status.id=t.oId);$("#tipMsg").text(t.msg),t.sc&&(a?(admin.article.status.id=void 0,admin.selectTab("article/article-list")):admin.selectTab("article/draft-list"),admin.article.isConfirm=!1)},complete:function(t,e){l._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),l.add(a))}})}},update:function(a,i){if(admin.article.validate()){var l=this;l._addDisabled(),$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t="";$(".signs button").each(function(){"selected"===this.className&&(t=this.id.substr(this.id.length-1,1))});var e=admin.editors.articleEditor.getContent(),s=admin.editors.abstractEditor.getContent();if($("#articleThumbnail").prop("checked")){var r=$(".thumbnail__img").css("background-image");e="![]("+r.substring(5,r.length-2).replace("w/768","w/960").replace("h/432","h/540")+") \n\n"+e}var n={article:{oId:this.status.id,articleTitle:$("#title").val(),articleContent:e,articleAbstract:s,articleTags:this.trimUniqueArray($("#tag").val()).toString(),articlePermalink:$("#permalink").val(),articleIsPublished:a,articleSignId:t,articleCommentable:$("#articleCommentable").prop("checked"),articleViewPwd:$("#viewPwd").val(),postToCommunity:$("#postToCommunity").prop("checked")}};$.ajax({url:latkeConfig.servePath+"/console/article/",type:"PUT",cache:!1,data:JSON.stringify(n),success:function(t,e){i?$("#tipMsg").text(Label.autoSaveLabel):($("#tipMsg").text(t.msg),t.sc&&(a?admin.selectTab("article/article-list"):admin.selectTab("article/draft-list"),$("#tipMsg").text(Label.updateSuccLabel),admin.article.status.id=void 0,admin.article.isConfirm=!1))},complete:function(t,e){l._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),l.update(a))}})}},setStatus:function(){$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){$("#tagCheckboxPanel>span").remove("");for(var a="",i=0;i<t.tags.length;i++)a+="<span>"+t.tags[i].tagTitle+"</span>";$("#tagCheckboxPanel").html(a+'<div class="fn__clear"></div>'),$("#loadMsg").text("")}}else $("#loadMsg").text("")}}),this.status?this.status.isArticle?($("#unSubmitArticle").show(),$("#saveArticle").hide(),$("#submitArticle").show()):($("#submitArticle").show(),$("#unSubmitArticle").hide(),$("#saveArticle").show()):($("#submitArticle").show(),$("#unSubmitArticle").hide(),$("#saveArticle").show(),$("#postToCommunityPanel").show())},clear:function(){this.status={id:void 0,isArticle:void 0,articleHadBeenPublished:void 0},this.setStatus(),$("#title").val(""),admin.editors.articleEditor.setContent(""),admin.editors.abstractEditor.setContent(""),$("#tag").val(""),$("#tagCheckboxPanel").hide().find("span").removeClass("selected"),$("#permalink").val(""),$("#articleCammentable").prop("checked",!0),$("#postToCommunity").prop("checked",!0),$(".signs button").each(function(t){this.className=0===t?"selected":""}),$("#articleThumbnail").prop("checked")&&$("#articleThumbnail").click()},init:function(t){$(".signs button").click(function(t){$(".signs button").removeClass("selected"),$(this).addClass("selected")}),$("#tipMsg").text(Label.uploadMsg),$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){for(var a=[],i=0;i<t.tags.length;i++)a.push(t.tags[i].tagTitle);$("#tag").completed({height:160,buttonText:Label.selectLabel,data:a}),$("#loadMsg").text("")}}else $("#loadMsg").text("")}}),$("#submitArticle").click(function(){admin.article.status.id?admin.article.update(!0):admin.article.add(!0)}),$("#saveArticle").click(function(){admin.article.status.id?admin.article.update(admin.article.status.isArticle):admin.article.add(!1)}),admin.editors.articleEditor=new SoloEditor({id:"articleContent",height:500,fun:t,previewShow:!0,resize:!1}),admin.editors.abstractEditor=new SoloEditor({id:"abstract",height:200,previewShow:!1,resize:!0}),admin.article.clearDraftTimer(),admin.article.autoSaveDraftTimer=setInterval(function(){admin.article._autoSaveToDraft()},admin.article.AUTOSAVETIME),$("#articleThumbnailBtn").click(function(){$.ajax({url:latkeConfig.servePath+"/console/thumbs?n=1&w=768&h=432",type:"GET",cache:!1,success:function(t,e){t.sc?$("#articleThumbnailBtn").prev().css("background-image","url("+t.data[0]+")"):$("#loadMsg").text(t.msg)}})}).click()},_autoSaveToDraft:function(){""!==$("#title").val().replace(/\s/g,"")&&""!==admin.editors.articleEditor.getContent().replace(/\s/g,"")&&(admin.article.status.id?admin.article.status.isArticle||admin.article.update(!1,!0):(admin.article.add(!1,!0),admin.article.status.isArticle=!1))},clearDraftTimer:function(){""!==admin.article.autoSaveDraftTimer&&(window.clearInterval(admin.article.autoSaveDraftTimer),admin.article.autoSaveDraftTimer="")},validate:function(){var t=admin.editors.articleEditor.getContent();if(""===$("#title").val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#title").focus().val("");else{if(""!==t.replace(/\s/g,""))return!0;$("#tipMsg").text(Label.contentEmptyLabel)}return!1},unPublish:function(a){var i=this;i._addDisabled(),$.ajax({url:latkeConfig.servePath+"/console/article/unpublish/"+admin.article.status.id,type:"PUT",cache:!1,success:function(t,e){a?$("#tipMsg").text(Label.autoSaveLabel):($("#tipMsg").text(t.msg),t.sc&&(admin.selectTab("article/draft-list"),admin.article.status.id=void 0,admin.article.isConfirm=!1))},complete:function(t,e){i._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),i.unPublish())}})},trimUniqueArray:function(t){for(var e=(t=t.toString()).split(","),a=0;a<e.length;a++)e[a]=e[a].replace(/(^\s*)|(\s*$)/g,""),""===e[a]&&(e.splice(a,1),a--);return $.unique(e).toString()},prePost:function(){if($("#loadMsg").text(Label.loadingLabel),admin.article.content="",admin.editors.articleEditor.getContent){var t=admin.editors.articleEditor.getContent();"#article/article"===window.location.hash&&""!==t.replace(/\s/g,"")&&confirm(Label.editorPostLabel)&&admin.article.clear(),$("#tipMsg").text(""),$("#loadMsg").text("")}},_addDisabled:function(){$("#unSubmitArticle").attr("disabled","disabled"),$("#saveArticle").attr("disabled","disabled"),$("#submitArticle").attr("disabled","disabled")},_removeDisabled:function(){$("#unSubmitArticle").removeAttr("disabled"),$("#saveArticle").removeAttr("disabled"),$("#submitArticle").removeAttr("disabled")}},admin.register.article={obj:admin.article,init:admin.article.init,refresh:function(){admin.editors.abstractEditor.setContent(""),admin.editors.articleEditor.setContent(""),$("#loadMsg").text(""),$("#tipMsg").text(Label.uploadMsg)}}; function getUUID(){var a=(new Date).getTime(),t="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=(a+16*Math.random())%16|0;return a=Math.floor(a/16),("x"==t?e:3&e|8).toString(16)});return t=t.replace(new RegExp("-","g"),"")}admin.article={isConfirm:!0,status:{id:void 0,isArticle:void 0,articleHadBeenPublished:void 0},content:"",autoSaveDraftTimer:"",AUTOSAVETIME:6e4,get:function(t,e){this.status.id=t,this.status.isArticle=e,admin.selectTab("article/article")},getAndSet:function(){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/article/"+admin.article.status.id,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){$("#title").val(e.article.articleTitle),admin.article.status.articleHadBeenPublished=e.article.articleHadBeenPublished,admin.editors.articleEditor.setContent(e.article.articleContent),admin.editors.abstractEditor.setContent(e.article.articleAbstract),admin.article.content=admin.editors.articleEditor.getContent();for(var a=e.article.articleTags,i="",l=0;l<a.length;l++)0===l?i=a[l].tagTitle:i+=","+a[l].tagTitle;$("#tag").val(i),$("#permalink").val(e.article.articlePermalink),$("#viewPwd").val(e.article.articleViewPwd),$("#articleCommentable").prop("checked",e.article.articleCommentable);var s=e.article.signs;$(".signs button").each(function(t){parseInt(e.article.articleSignId)===parseInt(s[t].oId)?$("#articleSign"+s[t].oId).addClass("selected"):$("#articleSign"+s[t].oId).removeClass("selected")}),admin.article.setStatus(),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(t,a,e){confirm(Label.confirmRemoveLabel+Label.articleLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/article/"+t,type:"DELETE",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc?admin[a+"List"].getList(1):$("#loadMsg").text("")}}))},add:function(a,i){if(admin.article.validate()){var l=this;l._addDisabled(),$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t="";$(".signs button").each(function(){"selected"===this.className&&(t=this.id.substr(this.id.length-1,1))});var e=admin.editors.articleEditor.getContent(),s=admin.editors.abstractEditor.getContent();if($("#articleThumbnail").prop("checked")){var r=$(".thumbnail__img").css("background-image");e="![]("+r.substring(5,r.length-2).replace("w/768","w/960").replace("h/432","h/540")+")\n\n"+e}var n={article:{articleTitle:$("#title").val(),articleContent:e,articleAbstract:s,articleTags:this.trimUniqueArray($("#tag").val()).toString(),articlePermalink:$("#permalink").val(),articleIsPublished:a,articleSignId:t,postToCommunity:$("#postToCommunity").prop("checked"),articleCommentable:$("#articleCommentable").prop("checked"),articleViewPwd:$("#viewPwd").val()}};$.ajax({url:latkeConfig.servePath+"/console/article/",type:"POST",cache:!1,data:JSON.stringify(n),success:function(t,e){if(i)return $("#tipMsg").text(Label.autoSaveLabel),void(admin.article.status.id=t.oId);$("#tipMsg").text(t.msg),t.sc&&(a?(admin.article.status.id=void 0,admin.selectTab("article/article-list")):admin.selectTab("article/draft-list"),admin.article.isConfirm=!1)},complete:function(t,e){l._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),l.add(a))}})}},update:function(a,i){if(admin.article.validate()){var l=this;l._addDisabled(),$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t="";$(".signs button").each(function(){"selected"===this.className&&(t=this.id.substr(this.id.length-1,1))});var e=admin.editors.articleEditor.getContent(),s=admin.editors.abstractEditor.getContent();if($("#articleThumbnail").prop("checked")){var r=$(".thumbnail__img").css("background-image");e="![]("+r.substring(5,r.length-2).replace("w/768","w/960").replace("h/432","h/540")+") \n\n"+e}var n={article:{oId:this.status.id,articleTitle:$("#title").val(),articleContent:e,articleAbstract:s,articleTags:this.trimUniqueArray($("#tag").val()).toString(),articlePermalink:$("#permalink").val(),articleIsPublished:a,articleSignId:t,articleCommentable:$("#articleCommentable").prop("checked"),articleViewPwd:$("#viewPwd").val(),postToCommunity:$("#postToCommunity").prop("checked")}};$.ajax({url:latkeConfig.servePath+"/console/article/",type:"PUT",cache:!1,data:JSON.stringify(n),success:function(t,e){i?$("#tipMsg").text(Label.autoSaveLabel):($("#tipMsg").text(t.msg),t.sc&&(a?admin.selectTab("article/article-list"):admin.selectTab("article/draft-list"),$("#tipMsg").text(Label.updateSuccLabel),admin.article.status.id=void 0,admin.article.isConfirm=!1))},complete:function(t,e){l._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),l.update(a))}})}},setStatus:function(){$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){$("#tagCheckboxPanel>span").remove("");for(var a="",i=0;i<t.tags.length;i++)a+="<span>"+t.tags[i].tagTitle+"</span>";$("#tagCheckboxPanel").html(a+'<div class="fn__clear"></div>'),$("#loadMsg").text("")}}else $("#loadMsg").text("")}}),this.status?this.status.isArticle?($("#unSubmitArticle").show(),$("#saveArticle").hide(),$("#submitArticle").show()):($("#submitArticle").show(),$("#unSubmitArticle").hide(),$("#saveArticle").show()):($("#submitArticle").show(),$("#unSubmitArticle").hide(),$("#saveArticle").show(),$("#postToCommunityPanel").show())},clear:function(){this.status={id:void 0,isArticle:void 0,articleHadBeenPublished:void 0},this.setStatus(),$("#title").val(""),admin.editors.articleEditor.setContent(""),admin.editors.abstractEditor.setContent(""),$("#tag").val(""),$("#tagCheckboxPanel").hide().find("span").removeClass("selected"),$("#permalink").val(""),$("#articleCammentable").prop("checked",!0),$("#postToCommunity").prop("checked",!0),$(".signs button").each(function(t){this.className=0===t?"selected":""}),$("#articleThumbnail").prop("checked")&&$("#articleThumbnail").click()},init:function(t){$(".signs button").click(function(t){$(".signs button").removeClass("selected"),$(this).addClass("selected")}),$("#tipMsg").text(Label.uploadMsg),$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){for(var a=[],i=0;i<t.tags.length;i++)a.push(t.tags[i].tagTitle);$("#tag").completed({height:160,buttonText:Label.selectLabel,data:a}),$("#loadMsg").text("")}}else $("#loadMsg").text("")}}),$("#submitArticle").click(function(){admin.article.status.id?admin.article.update(!0):admin.article.add(!0)}),$("#saveArticle").click(function(){admin.article.status.id?admin.article.update(admin.article.status.isArticle):admin.article.add(!1)}),admin.editors.articleEditor=new SoloEditor({id:"articleContent",height:500,fun:t,previewShow:!0,resize:!1}),admin.editors.abstractEditor=new SoloEditor({id:"abstract",height:200,previewShow:!1,resize:!0}),admin.article.clearDraftTimer(),admin.article.autoSaveDraftTimer=setInterval(function(){admin.article._autoSaveToDraft()},admin.article.AUTOSAVETIME),$("#articleThumbnailBtn").click(function(){$.ajax({url:latkeConfig.servePath+"/console/thumbs?n=1&w=768&h=432",type:"GET",cache:!1,success:function(t,e){t.sc?$("#articleThumbnailBtn").prev().css("background-image","url("+t.data[0]+")"):$("#loadMsg").text(t.msg)}})}).click()},_autoSaveToDraft:function(){""!==$("#title").val().replace(/\s/g,"")&&""!==admin.editors.articleEditor.getContent().replace(/\s/g,"")&&(admin.article.status.id?admin.article.status.isArticle||admin.article.update(!1,!0):(admin.article.add(!1,!0),admin.article.status.isArticle=!1))},clearDraftTimer:function(){""!==admin.article.autoSaveDraftTimer&&(window.clearInterval(admin.article.autoSaveDraftTimer),admin.article.autoSaveDraftTimer="")},validate:function(){var t=admin.editors.articleEditor.getContent();if(""===$("#title").val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#title").focus().val("");else{if(""!==t.replace(/\s/g,""))return!0;$("#tipMsg").text(Label.contentEmptyLabel)}return!1},unPublish:function(a){var i=this;i._addDisabled(),$.ajax({url:latkeConfig.servePath+"/console/article/unpublish/"+admin.article.status.id,type:"PUT",cache:!1,success:function(t,e){a?$("#tipMsg").text(Label.autoSaveLabel):($("#tipMsg").text(t.msg),t.sc&&(admin.selectTab("article/draft-list"),admin.article.status.id=void 0,admin.article.isConfirm=!1))},complete:function(t,e){i._removeDisabled(),$("#loadMsg").text(""),403===t.status&&($.get("/admin-index.do"),i.unPublish())}})},trimUniqueArray:function(t){for(var e=(t=t.toString()).split(","),a=0;a<e.length;a++)e[a]=e[a].replace(/(^\s*)|(\s*$)/g,""),""===e[a]&&(e.splice(a,1),a--);return $.unique(e).toString()},prePost:function(){if($("#loadMsg").text(Label.loadingLabel),admin.article.content="",admin.editors.articleEditor.getContent){var t=admin.editors.articleEditor.getContent();"#article/article"===window.location.hash&&""!==t.replace(/\s/g,"")&&confirm(Label.editorPostLabel)&&admin.article.clear(),$("#tipMsg").text(""),$("#loadMsg").text("")}},_addDisabled:function(){$("#unSubmitArticle").attr("disabled","disabled"),$("#saveArticle").attr("disabled","disabled"),$("#submitArticle").attr("disabled","disabled")},_removeDisabled:function(){$("#unSubmitArticle").removeAttr("disabled"),$("#saveArticle").removeAttr("disabled"),$("#submitArticle").removeAttr("disabled")}},admin.register.article={obj:admin.article,init:admin.article.init,refresh:function(){admin.editors.abstractEditor.setContent(""),admin.editors.articleEditor.setContent(""),$("#loadMsg").text(""),$("#tipMsg").text(Label.uploadMsg)}};
admin.comment={open:function(e,t){this.getList(e,t),$("#"+t+"Comments").dialog("open")},getList:function(c,i){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#"+i+"Comments").html("");var e="article";"page"===i&&(e="page"),$.ajax({url:latkeConfig.servePath+"/console/comments/"+e+"/"+c,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){for(var a=e.comments,n="",m=0;m<a.length;m++){var o="<a target='_blank' href='"+a[m].commentURL+"'>",l=a[m].commentContent,s=Util.replaceEmString(l);"http://"===a[m].commentURL&&(o="<a target='_blank'>"),n+="<div class='comment-title'><span class='fn__left'>"+o+a[m].commentName+"</a>",a[m].commentOriginalCommentName&&(n+="@"+a[m].commentOriginalCommentName),n+="</span><span title='"+Label.removeLabel+"' class='fn__right deleteIcon' onclick=\"admin.comment.del('"+a[m].oId+"', '"+i+"', '"+c+"')\"></span><span class='fn__right'><a href='mailto:"+a[m].commentEmail+"'>"+a[m].commentEmail+"</a>&nbsp;&nbsp;"+$.bowknot.getDate(a[m].commentTime)+"&nbsp;</span><div class='fn__clear'></div></div><div class='fn__margin12'>"+s+"</div>"}""===n&&(n=Label.noCommentLabel),$("#"+i+"Comments").html(n),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(e,a,n){if(confirm(Label.confirmRemoveLabel+Label.commentLabel+"?")){$("#loadMsg").text(Label.loadingLabel);var t="article";"page"===a&&(t="page"),$.ajax({url:latkeConfig.servePath+"/console/"+t+"/comment/"+e,type:"DELETE",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&admin.comment.getList(n,a),$("#loadMsg").text("")}})}}}; admin.comment={open:function(e,t){this.getList(e,t),$("#"+t+"Comments").dialog("open")},getList:function(c,i){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#"+i+"Comments").html("");var e="article";"page"===i&&(e="page"),$.ajax({url:latkeConfig.servePath+"/console/comments/"+e+"/"+c,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){for(var a=e.comments,n="",m=0;m<a.length;m++){var o="<a target='_blank' href='"+a[m].commentURL+"'>",s=a[m].commentContent,l=Util.replaceEmString(s);"http://"===a[m].commentURL&&(o="<a target='_blank'>"),n+="<div class='comment-title'><span class='fn__left'>"+o+a[m].commentName+"</a>",a[m].commentOriginalCommentName&&(n+="@"+a[m].commentOriginalCommentName),n+="</span><span title='"+Label.removeLabel+"' class='fn__right deleteIcon' onclick=\"admin.comment.del('"+a[m].oId+"', '"+i+"', '"+c+"')\"></span><span class='fn__right'>&nbsp;&nbsp;"+$.bowknot.getDate(a[m].commentTime)+"&nbsp;</span><div class='fn__clear'></div></div><div class='fn__margin12'>"+l+"</div>"}""===n&&(n=Label.noCommentLabel),$("#"+i+"Comments").html(n),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(e,a,n){if(confirm(Label.confirmRemoveLabel+Label.commentLabel+"?")){$("#loadMsg").text(Label.loadingLabel);var t="article";"page"===a&&(t="page"),$.ajax({url:latkeConfig.servePath+"/console/"+t+"/comment/"+e,type:"DELETE",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&admin.comment.getList(n,a),$("#loadMsg").text("")}})}}};
admin.articleList={tablePagination:new TablePaginate("article"),init:function(t){this.tablePagination.buildTable([{text:Label.titleLabel,index:"title",minWidth:110,style:"padding-left: 12px;font-size:14px;"},{text:Label.authorLabel,index:"author",width:150,style:"padding-left: 12px;"},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"},{text:Label.viewLabel,width:60,index:"articleViewCount",style:"padding-left: 12px;"},{text:Label.dateLabel,index:"date",width:90,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(t);var e=this;$("#articleListBtn").click(function(){e.getList(t)})},syncToHacpai:function(t){$.ajax({url:latkeConfig.servePath+"/console/article/push2rhy?id="+t,type:"GET",cache:!1,success:function(t,e){$("#tipMsg").text(Label.pushSuccLabel)}})},getList:function(c){var o=this;$("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/articles/status/published/"+c+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE+"?k="+$("#articleListInput").val(),type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){for(var a=t.articles,i=[],l=0;l<a.length;l++){i[l]={},i[l].title='<a href="'+latkeConfig.servePath+a[l].articlePermalink+"\" target='_blank' title='"+a[l].articleTitle+"' class='no-underline'>"+a[l].articleTitle+"</a><span class='table-tag'>"+a[l].articleTags+"</span>",i[l].date=$.bowknot.getDate(a[l].articleCreateTime),i[l].comments=a[l].articleCommentCount,i[l].articleViewCount=a[l].articleViewCount,i[l].author=a[l].authorName;var n=a[l].articlePutTop?Label.cancelPutTopLabel:Label.putTopLabel;i[l].expendRow="<a href='javascript:void(0)' onclick=\"admin.article.get('"+a[l].oId+"', true)\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.article.del('"+a[l].oId+"', 'article', '"+encodeURIComponent(a[l].articleTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.articleList.syncToHacpai('"+a[l].oId+"')\">"+Label.pushToHacpaiLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.articleList.popTop(this, '"+a[l].oId+"')\">"+n+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+a[l].oId+"', 'article')\">"+Label.commentLabel+"</a>"}o.tablePagination.updateTablePagination(i,c,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},popTop:function(t,e){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var a=$(t),i="canceltop",l=Label.putTopLabel;a.html()===Label.putTopLabel&&(i="puttop",l=Label.cancelPutTopLabel),$.ajax({url:latkeConfig.servePath+"/console/article/"+i+"/"+e,type:"PUT",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc&&a.html(l),$("#loadMsg").text("")}})}},admin.register["article-list"]={obj:admin.articleList,init:admin.articleList.init,refresh:admin.articleList.getList}; admin.articleList={tablePagination:new TablePaginate("article"),init:function(t){this.tablePagination.buildTable([{text:Label.titleLabel,index:"title",minWidth:110,style:"padding-left: 12px;font-size:14px;"},{text:Label.authorLabel,index:"author",width:150,style:"padding-left: 12px;"},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"},{text:Label.viewLabel,width:60,index:"articleViewCount",style:"padding-left: 12px;"},{text:Label.dateLabel,index:"date",width:90,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(t);var e=this;$("#articleListBtn").click(function(){e.getList(t)})},syncToHacpai:function(t){$.ajax({url:latkeConfig.servePath+"/console/article/push2rhy?id="+t,type:"GET",cache:!1,success:function(t,e){$("#tipMsg").text(Label.pushSuccLabel)}})},getList:function(c){var o=this;$("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/articles/status/published/"+c+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE+"?k="+$("#articleListInput").val(),type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){for(var a=t.articles,i=[],l=0;l<a.length;l++){i[l]={},i[l].title='<a href="'+latkeConfig.servePath+a[l].articlePermalink+"\" target='_blank' title='"+a[l].articleTitle+"' class='no-underline'>"+a[l].articleTitle+"</a><span class='table-tag'>"+a[l].articleTags+"</span>",i[l].date=$.bowknot.getDate(a[l].articleCreateTime),i[l].comments=a[l].articleCommentCount,i[l].articleViewCount=a[l].articleViewCount,i[l].author=a[l].authorName;var n=a[l].articlePutTop?Label.cancelPutTopLabel:Label.putTopLabel;i[l].expendRow="<a href='javascript:void(0)' onclick=\"admin.article.get('"+a[l].oId+"', true)\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.article.del('"+a[l].oId+"', 'article', '"+encodeURIComponent(a[l].articleTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.articleList.syncToHacpai('"+a[l].oId+"')\">"+Label.pushToHacpaiLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.articleList.popTop(this, '"+a[l].oId+"')\">"+n+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+a[l].oId+"', 'article')\">"+Label.commentLabel+"</a>"}o.tablePagination.updateTablePagination(i,c,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},popTop:function(t,e){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var a=$(t),i="canceltop",l=Label.putTopLabel;a.html()===Label.putTopLabel&&(i="puttop",l=Label.cancelPutTopLabel),$.ajax({url:latkeConfig.servePath+"/console/article/"+i+"/"+e,type:"PUT",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc&&a.html(l),$("#loadMsg").text("")}})}},admin.register["article-list"]={obj:admin.articleList,init:admin.articleList.init,refresh:admin.articleList.getList};
admin.draftList={tablePagination:new TablePaginate("draft"),init:function(t){this.tablePagination.buildTable([{text:Label.titleLabel,index:"title",minWidth:110,style:"padding-left: 12px;font-size:14px;"},{text:Label.authorLabel,index:"author",width:150,style:"padding-left: 12px;"},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"},{text:Label.viewLabel,width:60,index:"articleViewCount",style:"padding-left: 12px;"},{text:Label.dateLabel,index:"date",width:90,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(t)},getList:function(n){$("#loadMsg").text(Label.loadingLabel);var d=this;$.ajax({url:latkeConfig.servePath+"/console/articles/status/unpublished/"+n+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){for(var a=t.articles,i=[],l=0;l<a.length;l++)i[l]={},i[l].tags=a[l].articleTags,i[l].date=$.bowknot.getDate(a[l].articleCreateTime),i[l].comments=a[l].articleCommentCount,i[l].articleViewCount=a[l].articleViewCount,i[l].author=a[l].authorName,i[l].title="<a class='no-underline' href='"+latkeConfig.servePath+a[l].articlePermalink+"' target='_blank'>"+a[l].articleTitle+"</a><span class='table-tag'>"+a[l].articleTags+"</span>",i[l].expendRow="<a href='javascript:void(0)' onclick=\"admin.article.get('"+a[l].oId+"', false);\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.article.del('"+a[l].oId+"', 'draft', '"+encodeURIComponent(a[l].articleTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+a[l].oId+"', 'draft')\">"+Label.commentLabel+"</a>";d.tablePagination.updateTablePagination(i,n,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},admin.register["draft-list"]={obj:admin.draftList,init:admin.draftList.init,refresh:admin.draftList.getList}; admin.draftList={tablePagination:new TablePaginate("draft"),init:function(t){this.tablePagination.buildTable([{text:Label.titleLabel,index:"title",minWidth:110,style:"padding-left: 12px;font-size:14px;"},{text:Label.authorLabel,index:"author",width:150,style:"padding-left: 12px;"},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"},{text:Label.viewLabel,width:60,index:"articleViewCount",style:"padding-left: 12px;"},{text:Label.dateLabel,index:"date",width:90,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(t)},getList:function(n){$("#loadMsg").text(Label.loadingLabel);var d=this;$.ajax({url:latkeConfig.servePath+"/console/articles/status/unpublished/"+n+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){for(var a=t.articles,i=[],l=0;l<a.length;l++)i[l]={},i[l].tags=a[l].articleTags,i[l].date=$.bowknot.getDate(a[l].articleCreateTime),i[l].comments=a[l].articleCommentCount,i[l].articleViewCount=a[l].articleViewCount,i[l].author=a[l].authorName,i[l].title="<a class='no-underline' href='"+latkeConfig.servePath+a[l].articlePermalink+"' target='_blank'>"+a[l].articleTitle+"</a><span class='table-tag'>"+a[l].articleTags+"</span>",i[l].expendRow="<a href='javascript:void(0)' onclick=\"admin.article.get('"+a[l].oId+"', false);\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.article.del('"+a[l].oId+"', 'draft', '"+encodeURIComponent(a[l].articleTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+a[l].oId+"', 'draft')\">"+Label.commentLabel+"</a>";d.tablePagination.updateTablePagination(i,n,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},admin.register["draft-list"]={obj:admin.draftList,init:admin.draftList.init,refresh:admin.draftList.getList};
admin.pageList={tablePagination:new TablePaginate("page"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},id:"",type:"link",init:function(e){this.tablePagination.buildTable([{text:"",index:"pageOrder",width:60,style:"padding-left: 12px;font-size:14px;"},{style:"padding-left: 12px;",text:Label.titleLabel,index:"pageTitle",width:300},{style:"padding-left: 12px;",text:Label.permalinkLabel,index:"pagePermalink",minWidth:100},{style:"padding-left: 12px;",text:Label.openMethodLabel,index:"pageTarget",width:120},{style:"padding-left: 12px;",text:Label.typeLabel,index:"pageType",width:80},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(e),admin.editors.pageEditor=new SoloEditor({id:"pageContent"}),$(".fn-type").click(function(){var e=$(this);e.hasClass("selected")||($(".fn-type").removeClass("selected"),e.addClass("selected"),admin.pageList.type=e.data("type"),"page"===admin.pageList.type?$("#pagePagePanel").slideDown():$("#pagePagePanel").slideUp())})},getList:function(p){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var l=this;$.ajax({url:latkeConfig.servePath+"/console/pages/"+p+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=e.pages,n=[];admin.pageList.pageInfo.currentCount=t.length,admin.pageList.pageInfo.pageCount=0===e.pagination.paginationPageCount?1:e.pagination.paginationPageCount;for(var i=0;i<t.length;i++){n[i]={},0===i?1===t.length?n[i].pageOrder="":n[i].pageOrder='<div class="table-center" style="width:14px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'down\');" class="icon-move-down"></span></div>':i===t.length-1?n[i].pageOrder='<div class="table-center" style="width:14px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> </div>':n[i].pageOrder='<div class="table-center" style="width:38px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>';var g="";""!==t[i].pageIcon&&(g="<img class='navigation-icon' src='"+t[i].pageIcon+"'/> "),n[i].pageTitle=g+"<a class='no-underline' href='"+t[i].pagePermalink+"' target='_blank'>"+t[i].pageTitle+"</a>",n[i].pagePermalink="<a class='no-underline' href='"+t[i].pagePermalink+"' target='_blank'>"+t[i].pagePermalink+"</a>",n[i].pageTarget=t[i].pageOpenTarget,n[i].pageType=t[i].pageType,n[i].comments=t[i].pageCommentCount,n[i].expendRow="<span><a href='"+t[i].pagePermalink+"' target='_blank'>"+Label.viewLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.pageList.get('"+t[i].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.pageList.del('"+t[i].oId+"', '"+encodeURIComponent(t[i].pageTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+t[i].oId+"', 'page')\">"+Label.commentLabel+"</a></span>"}l.tablePagination.updateTablePagination(n,p,e.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},get:function(t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/page/"+t,type:"GET",cache:!1,success:function(e,a){$("#tipMsg").text(e.msg),e.sc&&(admin.pageList.id=t,$("#pageTitle").val(e.page.pageTitle),$("#pagePermalink").val(e.page.pagePermalink),$("#pageTarget").val(e.page.pageOpenTarget),$("#pageIcon").val(e.page.pageIcon),"page"===e.page.pageType?$($(".fn-type").get(1)).click():$($(".fn-type").get(0)).click(),$("#pageCommentable").prop("checked",e.page.pageCommentable),admin.editors.pageEditor.setContent(e.page.pageContent)),$("#loadMsg").text("")}})},del:function(e,a){confirm(Label.confirmRemoveLabel+Label.navLabel+'"'+Util.htmlDecode(a)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/page/"+e,type:"DELETE",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.pageList.pageInfo.currentPage;1===admin.pageList.pageInfo.currentCount&&1!==admin.pageList.pageInfo.pageCount&&admin.pageList.pageInfo.currentPage===admin.pageList.pageInfo.pageCount&&(admin.pageList.pageInfo.pageCount--,t=admin.pageList.pageInfo.pageCount);var n=window.location.hash.split("/");t==n[n.length-1]?admin.pageList.getList(t):admin.setHashByPage(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=admin.editors.pageEditor.getContent(),a=$("#pagePermalink").val().replace(/(^\s*)|(\s*$)/g,"");"link"===admin.pageList.type&&(a=Util.proessURL(a));var t={page:{pageTitle:$("#pageTitle").val(),pageContent:e,pagePermalink:a,pageCommentable:$("#pageCommentable").prop("checked"),pageType:admin.pageList.type,pageOpenTarget:$("#pageTarget").val(),pageIcon:$("#pageIcon").val()}};$.ajax({url:latkeConfig.servePath+"/console/page/",type:"POST",cache:!1,data:JSON.stringify(t),success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){admin.pageList.id="",$("#pagePermalink").val(""),$("#pageTitle").val(""),$("#pageIcon").val(""),$("#pageCommentable").prop("cheked",!1),$("#pageTarget").val("_self"),$($(".fn-type").get(0)).click(),admin.editors.pageEditor.setContent(""),admin.pageList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.pageList.pageInfo.currentPage===admin.pageList.pageInfo.pageCount&&admin.pageList.pageInfo.pageCount++;var t=window.location.hash.split("/");admin.pageList.pageInfo.pageCount==t[t.length-1]?admin.pageList.getList(admin.pageList.pageInfo.pageCount):admin.setHashByPage(admin.pageList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},update:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=admin.editors.pageEditor.getContent(),a=$("#pagePermalink").val().replace(/(^\s*)|(\s*$)/g,"");"link"===admin.pageList.type&&(a=Util.proessURL(a));var t={page:{pageTitle:$("#pageTitle").val(),oId:this.id,pageContent:e,pagePermalink:a,pageCommentable:$("#pageCommentable").prop("checked"),pageType:admin.pageList.type,pageOpenTarget:$("#pageTarget").val(),pageIcon:$("#pageIcon").val()}};$.ajax({url:latkeConfig.servePath+"/console/page/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(e,a){$("#tipMsg").text(e.msg),e.sc&&(admin.pageList.id="",admin.pageList.getList(admin.pageList.pageInfo.currentPage),$("#pageTitle").val(""),$("#pageIcon").val(""),$("#pagePermalink").val(""),$("#pageCommentable").prop("cheked",!1),$("#pageTarget").val("_self"),$($(".fn-type").get(0)).click(),admin.editors.pageEditor.setContent("")),$("#loadMsg").text("")}})}},validate:function(){if(""===$("#pageTitle").val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#pageTitle").focus();else{if("link"!==admin.pageList.type||""!==$("#pagePermalink").val().replace(/\s/g,""))return!0;$("#tipMsg").text(Label.linkEmptyLabel)}return!1},submit:function(){""!==this.id?this.update():this.add()},changeOrder:function(e,a,t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var n={oId:e.toString(),direction:t};$.ajax({url:latkeConfig.servePath+"/console/page/order/",type:"PUT",cache:!1,data:JSON.stringify(n),success:function(e,a){$("#tipMsg").text(e.msg),admin.pageList.getList(admin.pageList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["page-list"]={obj:admin.pageList,init:admin.pageList.init,refresh:admin.pageList.getList}; admin.pageList={tablePagination:new TablePaginate("page"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},id:"",type:"link",init:function(e){this.tablePagination.buildTable([{text:"",index:"pageOrder",width:60,style:"padding-left: 12px;font-size:14px;"},{style:"padding-left: 12px;",text:Label.titleLabel,index:"pageTitle",width:300},{style:"padding-left: 12px;",text:Label.permalinkLabel,index:"pagePermalink",minWidth:100},{style:"padding-left: 12px;",text:Label.openMethodLabel,index:"pageTarget",width:120},{style:"padding-left: 12px;",text:Label.typeLabel,index:"pageType",width:80},{text:Label.commentLabel,index:"comments",width:80,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.tablePagination.initCommentsDialog(),this.getList(e),admin.editors.pageEditor=new SoloEditor({id:"pageContent"}),$(".fn-type").click(function(){var e=$(this);e.hasClass("selected")||($(".fn-type").removeClass("selected"),e.addClass("selected"),admin.pageList.type=e.data("type"),"page"===admin.pageList.type?$("#pagePagePanel").slideDown():$("#pagePagePanel").slideUp())})},getList:function(p){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var l=this;$.ajax({url:latkeConfig.servePath+"/console/pages/"+p+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=e.pages,n=[];admin.pageList.pageInfo.currentCount=t.length,admin.pageList.pageInfo.pageCount=0===e.pagination.paginationPageCount?1:e.pagination.paginationPageCount;for(var i=0;i<t.length;i++){n[i]={},0===i?1===t.length?n[i].pageOrder="":n[i].pageOrder='<div class="table-center" style="width:14px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'down\');" class="icon-move-down"></span></div>':i===t.length-1?n[i].pageOrder='<div class="table-center" style="width:14px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> </div>':n[i].pageOrder='<div class="table-center" style="width:38px"> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> <span onclick="admin.pageList.changeOrder('+t[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>';var g="";""!==t[i].pageIcon&&(g="<img class='navigation-icon' src='"+t[i].pageIcon+"'/> "),n[i].pageTitle=g+"<a class='no-underline' href='"+t[i].pagePermalink+"' target='_blank'>"+t[i].pageTitle+"</a>",n[i].pagePermalink="<a class='no-underline' href='"+t[i].pagePermalink+"' target='_blank'>"+t[i].pagePermalink+"</a>",n[i].pageTarget=t[i].pageOpenTarget,n[i].pageType=t[i].pageType,n[i].comments=t[i].pageCommentCount,n[i].expendRow="<span><a href='"+t[i].pagePermalink+"' target='_blank'>"+Label.viewLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.pageList.get('"+t[i].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.pageList.del('"+t[i].oId+"', '"+encodeURIComponent(t[i].pageTitle)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.comment.open('"+t[i].oId+"', 'page')\">"+Label.commentLabel+"</a></span>"}l.tablePagination.updateTablePagination(n,p,e.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},get:function(t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/page/"+t,type:"GET",cache:!1,success:function(e,a){$("#tipMsg").text(e.msg),e.sc&&(admin.pageList.id=t,$("#pageTitle").val(e.page.pageTitle),$("#pagePermalink").val(e.page.pagePermalink),$("#pageTarget").val(e.page.pageOpenTarget),$("#pageIcon").val(e.page.pageIcon),"page"===e.page.pageType?$($(".fn-type").get(1)).click():$($(".fn-type").get(0)).click(),$("#pageCommentable").prop("checked",e.page.pageCommentable),admin.editors.pageEditor.setContent(e.page.pageContent)),$("#loadMsg").text("")}})},del:function(e,a){confirm(Label.confirmRemoveLabel+Label.navLabel+'"'+Util.htmlDecode(a)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/page/"+e,type:"DELETE",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.pageList.pageInfo.currentPage;1===admin.pageList.pageInfo.currentCount&&1!==admin.pageList.pageInfo.pageCount&&admin.pageList.pageInfo.currentPage===admin.pageList.pageInfo.pageCount&&(admin.pageList.pageInfo.pageCount--,t=admin.pageList.pageInfo.pageCount);var n=window.location.hash.split("/");t==n[n.length-1]?admin.pageList.getList(t):admin.setHashByPage(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=admin.editors.pageEditor.getContent(),a=$("#pagePermalink").val().replace(/(^\s*)|(\s*$)/g,"");"link"===admin.pageList.type&&(a=Util.proessURL(a));var t={page:{pageTitle:$("#pageTitle").val(),pageContent:e,pagePermalink:a,pageCommentable:$("#pageCommentable").prop("checked"),pageType:admin.pageList.type,pageOpenTarget:$("#pageTarget").val(),pageIcon:$("#pageIcon").val()}};$.ajax({url:latkeConfig.servePath+"/console/page/",type:"POST",cache:!1,data:JSON.stringify(t),success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){admin.pageList.id="",$("#pagePermalink").val(""),$("#pageTitle").val(""),$("#pageIcon").val(""),$("#pageCommentable").prop("cheked",!1),$("#pageTarget").val("_self"),$($(".fn-type").get(0)).click(),admin.editors.pageEditor.setContent(""),admin.pageList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.pageList.pageInfo.currentPage===admin.pageList.pageInfo.pageCount&&admin.pageList.pageInfo.pageCount++;var t=window.location.hash.split("/");admin.pageList.pageInfo.pageCount==t[t.length-1]?admin.pageList.getList(admin.pageList.pageInfo.pageCount):admin.setHashByPage(admin.pageList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},update:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=admin.editors.pageEditor.getContent(),a=$("#pagePermalink").val().replace(/(^\s*)|(\s*$)/g,"");"link"===admin.pageList.type&&(a=Util.proessURL(a));var t={page:{pageTitle:$("#pageTitle").val(),oId:this.id,pageContent:e,pagePermalink:a,pageCommentable:$("#pageCommentable").prop("checked"),pageType:admin.pageList.type,pageOpenTarget:$("#pageTarget").val(),pageIcon:$("#pageIcon").val()}};$.ajax({url:latkeConfig.servePath+"/console/page/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(e,a){$("#tipMsg").text(e.msg),e.sc&&(admin.pageList.id="",admin.pageList.getList(admin.pageList.pageInfo.currentPage),$("#pageTitle").val(""),$("#pageIcon").val(""),$("#pagePermalink").val(""),$("#pageCommentable").prop("cheked",!1),$("#pageTarget").val("_self"),$($(".fn-type").get(0)).click(),admin.editors.pageEditor.setContent("")),$("#loadMsg").text("")}})}},validate:function(){if(""===$("#pageTitle").val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#pageTitle").focus();else{if("link"!==admin.pageList.type||""!==$("#pagePermalink").val().replace(/\s/g,""))return!0;$("#tipMsg").text(Label.linkEmptyLabel)}return!1},submit:function(){""!==this.id?this.update():this.add()},changeOrder:function(e,a,t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var n={oId:e.toString(),direction:t};$.ajax({url:latkeConfig.servePath+"/console/page/order/",type:"PUT",cache:!1,data:JSON.stringify(n),success:function(e,a){$("#tipMsg").text(e.msg),admin.pageList.getList(admin.pageList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["page-list"]={obj:admin.pageList,init:admin.pageList.init,refresh:admin.pageList.getList};
admin.others={init:function(){$("#tabOthers").tabs(),$.ajax({url:latkeConfig.servePath+"/console/reply/notification/template",type:"GET",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&($("#replayEmailTemplateTitle").val(e.replyNotificationTemplate.subject),$("#replayEmailTemplateBody").val(e.replyNotificationTemplate.body)),$("#loadMsg").text("")}})},removeUnusedTags:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/tag/unused",type:"DELETE",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg)}})},exportSQL:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/sql",type:"GET",cache:!1,success:function(e,t){e.sc?$("#tipMsg").text(e.msg):window.location=latkeConfig.servePath+"/console/export/sql"}})},exportJSON:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/json",type:"GET",cache:!1,success:function(e,t){e.sc?$("#tipMsg").text(e.msg):window.location=latkeConfig.servePath+"/console/export/json"}})},exportHexo:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/hexo",type:"GET",cache:!1,success:function(e,t){e.sc?$("#tipMsg").text(e.msg):window.location=latkeConfig.servePath+"/console/export/hexo"}})},getUnusedTags:function(){$.ajax({url:latkeConfig.servePath+"/console/tag/unused",type:"GET",cache:!1,success:function(e,t){($("#tipMsg").text(e.msg),e.sc)?e.unusedTags.length:$("#loadMsg").text("")}})},update:function(){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e={replyNotificationTemplate:{subject:$("#replayEmailTemplateTitle").val(),body:$("#replayEmailTemplateBody").val()}};$.ajax({url:latkeConfig.servePath+"/console/reply/notification/template",type:"PUT",cache:!1,data:JSON.stringify(e),success:function(e,t){$("#tipMsg").text(e.msg),$("#loadMsg").text("")}})}},admin.register.others={obj:admin.others,init:admin.others.init,refresh:function(){admin.clearTip()}}; admin.others={init:function(){$("#tabOthers").tabs()},removeUnusedTags:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/tag/unused",type:"DELETE",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg)}})},exportSQL:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/sql",type:"GET",cache:!1,success:function(t,e){t.sc?$("#tipMsg").text(t.msg):window.location=latkeConfig.servePath+"/console/export/sql"}})},exportJSON:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/json",type:"GET",cache:!1,success:function(t,e){t.sc?$("#tipMsg").text(t.msg):window.location=latkeConfig.servePath+"/console/export/json"}})},exportHexo:function(){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/export/hexo",type:"GET",cache:!1,success:function(t,e){t.sc?$("#tipMsg").text(t.msg):window.location=latkeConfig.servePath+"/console/export/hexo"}})},getUnusedTags:function(){$.ajax({url:latkeConfig.servePath+"/console/tag/unused",type:"GET",cache:!1,success:function(t,e){($("#tipMsg").text(t.msg),t.sc)?t.unusedTags.length:$("#loadMsg").text("")}})}},admin.register.others={obj:admin.others,init:admin.others.init,refresh:function(){admin.clearTip()}};
admin.linkList={tablePagination:new TablePaginate("link"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},id:"",init:function(i){this.tablePagination.buildTable([{text:"",index:"linkOrder",width:60},{style:"padding-left: 12px;",text:Label.linkTitleLabel,index:"linkTitle",width:230},{style:"padding-left: 12px;",text:Label.urlLabel,index:"linkAddress",minWidth:180},{style:"padding-left: 12px;",text:Label.linkDescriptionLabel,index:"linkDescription",width:360}]),this.tablePagination.initPagination(),this.getList(i),$("#updateLink").dialog({title:$("#updateLink").data("title"),width:700,height:290,modal:!0,hideFooter:!0})},getList:function(l){$("#loadMsg").text(Label.loadingLabel),0===l&&(l=1),this.pageInfo.currentPage=l;var s=this;$.ajax({url:latkeConfig.servePath+"/console/links/"+l+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){var n=i.links,t=[];admin.linkList.pageInfo.currentCount=n.length,admin.linkList.pageInfo.pageCount=0===i.pagination.paginationPageCount?1:i.pagination.paginationPageCount;for(var a=0;a<n.length;a++)t[a]={},0===a?1===n.length?t[a].linkOrder="":t[a].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'down\');" class="icon-move-down"></span> </div>':a===n.length-1?t[a].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'up\');" class="icon-move-up"></span> </div>':t[a].linkOrder='<div class="table-center" style="width:38px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'up\');" class="icon-move-up"></span> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'down\');" class="icon-move-down"></span> </div>',t[a].linkTitle=n[a].linkTitle,t[a].linkAddress="<a target='_blank' class='no-underline' href='"+n[a].linkAddress+"'>"+n[a].linkAddress+"</a>",t[a].linkDescription=n[a].linkDescription,t[a].expendRow="<span><a href='"+n[a].linkAddress+"' target='_blank'>"+Label.viewLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.linkList.get('"+n[a].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.linkList.del('"+n[a].oId+"', '"+encodeURIComponent(n[a].linkTitle)+"')\">"+Label.removeLabel+"</a></span>";s.tablePagination.updateTablePagination(t,l,i.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var i={link:{linkTitle:$("#linkTitle").val(),linkAddress:$("#linkAddress").val(),linkDescription:$("#linkDescription").val()}};$.ajax({url:latkeConfig.servePath+"/console/link/",type:"POST",cache:!1,data:JSON.stringify(i),success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){$("#linkTitle").val(""),$("#linkAddress").val(""),$("#linkDescription").val(""),admin.linkList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.linkList.pageInfo.currentPage===admin.linkList.pageInfo.pageCount&&admin.linkList.pageInfo.pageCount++;var n=window.location.hash.split("/");admin.linkList.pageInfo.pageCount!==parseInt(n[n.length-1])&&admin.setHashByPage(admin.linkList.pageInfo.pageCount),admin.linkList.getList(admin.linkList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},get:function(n){$("#loadMsg").text(Label.loadingLabel),$("#updateLink").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/link/"+n,type:"GET",cache:!1,success:function(i,e){$("#tipMsg").text(i.msg),i.sc&&(admin.linkList.id=n,$("#linkTitleUpdate").val(i.link.linkTitle),$("#linkAddressUpdate").val(i.link.linkAddress),$("#linkDescriptionUpdate").val(i.link.linkDescription)),$("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var i={link:{linkTitle:$("#linkTitleUpdate").val(),oId:this.id,linkAddress:$("#linkAddressUpdate").val(),linkDescription:$("#linkDescriptionUpdate").val()}};$.ajax({url:latkeConfig.servePath+"/console/link/",type:"PUT",cache:!1,data:JSON.stringify(i),success:function(i,e){$("#updateLink").dialog("close"),$("#tipMsg").text(i.msg),i.sc&&admin.linkList.getList(admin.linkList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(i,e){confirm(Label.confirmRemoveLabel+Label.permalinkLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/link/"+i,type:"DELETE",cache:!1,success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){var n=admin.linkList.pageInfo.currentPage;1===admin.linkList.pageInfo.currentCount&&1!==admin.linkList.pageInfo.pageCount&&admin.linkList.pageInfo.currentPage===admin.linkList.pageInfo.pageCount&&(admin.linkList.pageInfo.pageCount--,n=admin.linkList.pageInfo.pageCount);var t=window.location.hash.split("/");n!==parseInt(t[t.length-1])&&admin.setHashByPage(n),admin.linkList.getList(n),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},validate:function(i){if(i||(i=""),""===$("#linkTitle"+i).val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#linkTitle"+i).focus().val("");else if(""===$("#linkAddress"+i).val().replace(/\s/g,""))$("#tipMsg").text(Label.addressEmptyLabel),$("#linkAddress"+i).focus().val("");else{if(/^\w+:\/\//.test($("#linkAddress"+i).val()))return!0;$("#tipMsg").text(Label.addressInvalidLabel),$("#linkAddress"+i).focus().val("")}return!1},changeOrder:function(i,e,n){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={oId:i.toString(),direction:n};$.ajax({url:latkeConfig.servePath+"/console/link/order/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(i,e){$("#tipMsg").text(i.msg),admin.linkList.getList(admin.linkList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["link-list"]={obj:admin.linkList,init:admin.linkList.init,refresh:admin.linkList.getList}; admin.linkList={tablePagination:new TablePaginate("link"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},id:"",init:function(i){this.tablePagination.buildTable([{text:"",index:"linkOrder",width:60},{style:"padding-left: 12px;",text:Label.linkTitleLabel,index:"linkTitle",width:230},{style:"padding-left: 12px;",text:Label.urlLabel,index:"linkAddress",minWidth:180},{style:"padding-left: 12px;",text:Label.linkDescriptionLabel,index:"linkDescription",width:360}]),this.tablePagination.initPagination(),this.getList(i),$("#updateLink").dialog({title:$("#updateLink").data("title"),width:700,height:290,modal:!0,hideFooter:!0})},getList:function(l){$("#loadMsg").text(Label.loadingLabel),0===l&&(l=1),this.pageInfo.currentPage=l;var s=this;$.ajax({url:latkeConfig.servePath+"/console/links/"+l+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){var n=i.links,t=[];admin.linkList.pageInfo.currentCount=n.length,admin.linkList.pageInfo.pageCount=0===i.pagination.paginationPageCount?1:i.pagination.paginationPageCount;for(var a=0;a<n.length;a++)t[a]={},0===a?1===n.length?t[a].linkOrder="":t[a].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'down\');" class="icon-move-down"></span> </div>':a===n.length-1?t[a].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'up\');" class="icon-move-up"></span> </div>':t[a].linkOrder='<div class="table-center" style="width:38px"> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'up\');" class="icon-move-up"></span> <span onclick="admin.linkList.changeOrder('+n[a].oId+", "+a+', \'down\');" class="icon-move-down"></span> </div>',t[a].linkTitle=n[a].linkTitle,t[a].linkAddress="<a target='_blank' class='no-underline' href='"+n[a].linkAddress+"'>"+n[a].linkAddress+"</a>",t[a].linkDescription=n[a].linkDescription,t[a].expendRow="<span><a href='"+n[a].linkAddress+"' target='_blank'>"+Label.viewLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.linkList.get('"+n[a].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.linkList.del('"+n[a].oId+"', '"+encodeURIComponent(n[a].linkTitle)+"')\">"+Label.removeLabel+"</a></span>";s.tablePagination.updateTablePagination(t,l,i.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var i={link:{linkTitle:$("#linkTitle").val(),linkAddress:$("#linkAddress").val(),linkDescription:$("#linkDescription").val()}};$.ajax({url:latkeConfig.servePath+"/console/link/",type:"POST",cache:!1,data:JSON.stringify(i),success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){$("#linkTitle").val(""),$("#linkAddress").val(""),$("#linkDescription").val(""),admin.linkList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.linkList.pageInfo.currentPage===admin.linkList.pageInfo.pageCount&&admin.linkList.pageInfo.pageCount++;var n=window.location.hash.split("/");admin.linkList.pageInfo.pageCount!==parseInt(n[n.length-1])&&admin.setHashByPage(admin.linkList.pageInfo.pageCount),admin.linkList.getList(admin.linkList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},get:function(n){$("#loadMsg").text(Label.loadingLabel),$("#updateLink").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/link/"+n,type:"GET",cache:!1,success:function(i,e){$("#tipMsg").text(i.msg),i.sc&&(admin.linkList.id=n,$("#linkTitleUpdate").val(i.link.linkTitle),$("#linkAddressUpdate").val(i.link.linkAddress),$("#linkDescriptionUpdate").val(i.link.linkDescription)),$("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var i={link:{linkTitle:$("#linkTitleUpdate").val(),oId:this.id,linkAddress:$("#linkAddressUpdate").val(),linkDescription:$("#linkDescriptionUpdate").val()}};$.ajax({url:latkeConfig.servePath+"/console/link/",type:"PUT",cache:!1,data:JSON.stringify(i),success:function(i,e){$("#updateLink").dialog("close"),$("#tipMsg").text(i.msg),i.sc&&admin.linkList.getList(admin.linkList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(i,e){confirm(Label.confirmRemoveLabel+Label.permalinkLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/link/"+i,type:"DELETE",cache:!1,success:function(i,e){if($("#tipMsg").text(i.msg),i.sc){var n=admin.linkList.pageInfo.currentPage;1===admin.linkList.pageInfo.currentCount&&1!==admin.linkList.pageInfo.pageCount&&admin.linkList.pageInfo.currentPage===admin.linkList.pageInfo.pageCount&&(admin.linkList.pageInfo.pageCount--,n=admin.linkList.pageInfo.pageCount);var t=window.location.hash.split("/");n!==parseInt(t[t.length-1])&&admin.setHashByPage(n),admin.linkList.getList(n),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},validate:function(i){if(i||(i=""),""===$("#linkTitle"+i).val().replace(/\s/g,""))$("#tipMsg").text(Label.titleEmptyLabel),$("#linkTitle"+i).focus().val("");else if(""===$("#linkAddress"+i).val().replace(/\s/g,""))$("#tipMsg").text(Label.addressEmptyLabel),$("#linkAddress"+i).focus().val("");else{if(/^\w+:\/\//.test($("#linkAddress"+i).val()))return!0;$("#tipMsg").text(Label.addressInvalidLabel),$("#linkAddress"+i).focus().val("")}return!1},changeOrder:function(i,e,n){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={oId:i.toString(),direction:n};$.ajax({url:latkeConfig.servePath+"/console/link/order/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(i,e){$("#tipMsg").text(i.msg),admin.linkList.getList(admin.linkList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["link-list"]={obj:admin.linkList,init:admin.linkList.init,refresh:admin.linkList.getList};
admin.preference={locale:"",init:function(){$("#tabPreference").tabs(),$.ajax({url:latkeConfig.servePath+"/console/preference/",type:"GET",cache:!1,success:function(result,textStatus){if($("#tipMsg").text(result.msg),result.sc){var preference=result.preference;$("#metaKeywords").val(preference.metaKeywords),$("#metaDescription").val(preference.metaDescription),$("#blogTitle").val(preference.blogTitle),$("#blogSubtitle").val(preference.blogSubtitle),$("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount),$("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount),$("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount),$("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount),$("#articleListDisplayCount").val(preference.articleListDisplayCount),$("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize),$("#localeString").val(preference.localeString),$("#timeZoneId").val(preference.timeZoneId),$("#noticeBoard").val(preference.noticeBoard),$("#footerContent").val(preference.footerContent),$("#htmlHead").val(preference.htmlHead),$("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount),$("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount),$("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount),$("#customVars").val(preference.customVars),"true"===preference.enableArticleUpdateHint?$("#enableArticleUpdateHint").attr("checked","checked"):$("#enableArticleUpdateHint").removeAttr("checked"),"true"===preference.allowVisitDraftViaPermalink?$("#allowVisitDraftViaPermalink").attr("checked","checked"):$("allowVisitDraftViaPermalink").removeAttr("checked"),"true"===preference.allowRegister?$("#allowRegister").attr("checked","checked"):$("#allowRegister").removeAttr("checked"),"true"===preference.commentable?$("#commentable").attr("checked","checked"):$("commentable").removeAttr("checked"),admin.preference.locale=preference.localeString,$("#skinMain").data("skinDirName",preference.skinDirName);for(var skins=eval("("+preference.skins+")"),skinsHTML="",i=0;i<skins.length;i++){var selectedClass="";skins[i].skinName===preference.skinName&&skins[i].skinDirName===preference.skinDirName&&(selectedClass+=" selected"),skinsHTML+='<div class="fn__left skinItem'+selectedClass+'"><div class="ft__center">'+skins[i].skinName+'</div><img class="skinPreview" src="'+latkeConfig.staticServePath+"/skins/"+skins[i].skinDirName+'/preview.png"/><div><button class="update small" data-name="'+skins[i].skinDirName+'">'+Label.enableLabel+'</button><button class="small" onclick="window.open(\''+latkeConfig.servePath+"?skin="+skins[i].skinName+"')\">"+Label.previewLabel+"</button></div></div>"}$("#skinMain").append(skinsHTML+"<div class='fn__clear'></div>"),$(".skinItem .update").click(function(){$(".skinItem").removeClass("selected"),$(this).closest(".skinItem").addClass("selected"),$("#skinMain").data("skinDirName",$(this).data("name")),admin.preference.update()});for(var signs=eval("("+preference.signs+")"),j=1;j<signs.length;j++)$("#preferenceSign"+j).val(signs[j].signHTML);$("#articleListDisplay").val(preference.articleListStyle),$("#feedOutputMode").val(preference.feedOutputMode),$("#feedOutputCnt").val(preference.feedOutputCnt),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},validate:function(){return/^\d+$/.test($("#mostUsedTagDisplayCount").val())?/^\d+$/.test($("#recentCommentDisplayCount").val())?/^\d+$/.test($("#mostCommentArticleDisplayCount").val())?/^\d+$/.test($("#mostViewArticleDisplayCount").val())?/^\d+$/.test($("#articleListDisplayCount").val())?/^\d+$/.test($("#articleListPaginationWindowSize").val())?/^\d+$/.test($("#randomArticlesDisplayCount").val())?/^\d+$/.test($("#relevantArticlesDisplayCount").val())?!!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())||($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.externalRelevantArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#externalRelevantArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.relevantArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#relevantArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.randomArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#randomArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.windowSizeLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#articleListPaginationWindowSize").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.pageSizeLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#articleListDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexMostViewArticleDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostViewArticleDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexMostCommentArticleDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostCommentArticleDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexRecentCommentDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#recentCommentDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexTagDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostUsedTagDisplayCount").focus(),!1)},update:function(){if(admin.preference.validate()){$("#tipMsg").text(""),$("#loadMsg").text(Label.loadingLabel);var e=[{oId:0,signHTML:""},{oId:1,signHTML:$("#preferenceSign1").val()},{oId:2,signHTML:$("#preferenceSign2").val()},{oId:3,signHTML:$("#preferenceSign3").val()}],t={preference:{metaKeywords:$("#metaKeywords").val(),metaDescription:$("#metaDescription").val(),blogTitle:$("#blogTitle").val(),blogSubtitle:$("#blogSubtitle").val(),mostCommentArticleDisplayCount:$("#mostCommentArticleDisplayCount").val(),mostViewArticleDisplayCount:$("#mostViewArticleDisplayCount").val(),recentCommentDisplayCount:$("#recentCommentDisplayCount").val(),mostUsedTagDisplayCount:$("#mostUsedTagDisplayCount").val(),articleListDisplayCount:$("#articleListDisplayCount").val(),articleListPaginationWindowSize:$("#articleListPaginationWindowSize").val(),skinDirName:$("#skinMain").data("skinDirName"),localeString:$("#localeString").val(),timeZoneId:$("#timeZoneId").val(),noticeBoard:$("#noticeBoard").val(),footerContent:$("#footerContent").val(),htmlHead:$("#htmlHead").val(),externalRelevantArticlesDisplayCount:$("#externalRelevantArticlesDisplayCount").val(),relevantArticlesDisplayCount:$("#relevantArticlesDisplayCount").val(),randomArticlesDisplayCount:$("#randomArticlesDisplayCount").val(),enableArticleUpdateHint:$("#enableArticleUpdateHint").prop("checked"),signs:e,allowVisitDraftViaPermalink:$("#allowVisitDraftViaPermalink").prop("checked"),articleListStyle:$("#articleListDisplay").val(),feedOutputMode:$("#feedOutputMode").val(),feedOutputCnt:$("#feedOutputCnt").val(),commentable:$("#commentable").prop("checked"),allowRegister:$("#allowRegister").prop("checked"),customVars:$("#customVars").val()}};$.ajax({url:latkeConfig.servePath+"/console/preference/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&$("#localeString").val()!==admin.preference.locale&&window.location.reload(),$("#loadMsg").text("")}})}}},admin.register.preference={obj:admin.preference,init:admin.preference.init,refresh:function(){admin.clearTip()}}; admin.preference={locale:"",init:function(){$("#tabPreference").tabs(),$.ajax({url:latkeConfig.servePath+"/console/preference/",type:"GET",cache:!1,success:function(result,textStatus){if($("#tipMsg").text(result.msg),result.sc){var preference=result.preference;$("#metaKeywords").val(preference.metaKeywords),$("#metaDescription").val(preference.metaDescription),$("#blogTitle").val(preference.blogTitle),$("#blogSubtitle").val(preference.blogSubtitle),$("#mostCommentArticleDisplayCount").val(preference.mostCommentArticleDisplayCount),$("#mostViewArticleDisplayCount").val(preference.mostViewArticleDisplayCount),$("#recentCommentDisplayCount").val(preference.recentCommentDisplayCount),$("#mostUsedTagDisplayCount").val(preference.mostUsedTagDisplayCount),$("#articleListDisplayCount").val(preference.articleListDisplayCount),$("#articleListPaginationWindowSize").val(preference.articleListPaginationWindowSize),$("#localeString").val(preference.localeString),$("#timeZoneId").val(preference.timeZoneId),$("#noticeBoard").val(preference.noticeBoard),$("#footerContent").val(preference.footerContent),$("#htmlHead").val(preference.htmlHead),$("#externalRelevantArticlesDisplayCount").val(preference.externalRelevantArticlesDisplayCount),$("#relevantArticlesDisplayCount").val(preference.relevantArticlesDisplayCount),$("#randomArticlesDisplayCount").val(preference.randomArticlesDisplayCount),$("#customVars").val(preference.customVars),"true"===preference.enableArticleUpdateHint?$("#enableArticleUpdateHint").attr("checked","checked"):$("#enableArticleUpdateHint").removeAttr("checked"),"true"===preference.allowVisitDraftViaPermalink?$("#allowVisitDraftViaPermalink").attr("checked","checked"):$("allowVisitDraftViaPermalink").removeAttr("checked"),"true"===preference.allowRegister?$("#allowRegister").attr("checked","checked"):$("#allowRegister").removeAttr("checked"),"true"===preference.commentable?$("#commentable").attr("checked","checked"):$("commentable").removeAttr("checked"),admin.preference.locale=preference.localeString,$("#skinMain").data("skinDirName",preference.skinDirName);for(var skins=eval("("+preference.skins+")"),skinsHTML="",i=0;i<skins.length;i++){var selectedClass="";skins[i].skinName===preference.skinName&&skins[i].skinDirName===preference.skinDirName&&(selectedClass+=" selected"),skinsHTML+='<div class="fn__left skinItem'+selectedClass+'"><div class="ft__center">'+skins[i].skinName+'</div><img class="skinPreview" src="'+latkeConfig.staticServePath+"/skins/"+skins[i].skinDirName+'/preview.png"/><div><button class="update small" data-name="'+skins[i].skinDirName+'">'+Label.enableLabel+'</button><button class="small" onclick="window.open(\''+latkeConfig.servePath+"?skin="+skins[i].skinName+"')\">"+Label.previewLabel+"</button></div></div>"}$("#skinMain").append(skinsHTML+"<div class='fn__clear'></div>"),$(".skinItem .update").click(function(){$(".skinItem").removeClass("selected"),$(this).closest(".skinItem").addClass("selected"),$("#skinMain").data("skinDirName",$(this).data("name")),admin.preference.update()});for(var signs=eval("("+preference.signs+")"),j=1;j<signs.length;j++)$("#preferenceSign"+j).val(signs[j].signHTML);$("#articleListDisplay").val(preference.articleListStyle),$("#feedOutputMode").val(preference.feedOutputMode),$("#feedOutputCnt").val(preference.feedOutputCnt),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},validate:function(){return/^\d+$/.test($("#mostUsedTagDisplayCount").val())?/^\d+$/.test($("#recentCommentDisplayCount").val())?/^\d+$/.test($("#mostCommentArticleDisplayCount").val())?/^\d+$/.test($("#mostViewArticleDisplayCount").val())?/^\d+$/.test($("#articleListDisplayCount").val())?/^\d+$/.test($("#articleListPaginationWindowSize").val())?/^\d+$/.test($("#randomArticlesDisplayCount").val())?/^\d+$/.test($("#relevantArticlesDisplayCount").val())?!!/^\d+$/.test($("#externalRelevantArticlesDisplayCount").val())||($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.externalRelevantArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#externalRelevantArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.relevantArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#relevantArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.randomArticlesDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#randomArticlesDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.windowSizeLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#articleListPaginationWindowSize").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.pageSizeLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#articleListDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexMostViewArticleDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostViewArticleDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexMostCommentArticleDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostCommentArticleDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexRecentCommentDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#recentCommentDisplayCount").focus(),!1):($("#tipMsg").text("["+Label.paramSettingsLabel+" - "+Label.indexTagDisplayCntLabel+"] "+Label.nonNegativeIntegerOnlyLabel),$("#mostUsedTagDisplayCount").focus(),!1)},update:function(){if(admin.preference.validate()){$("#tipMsg").text(""),$("#loadMsg").text(Label.loadingLabel);var e=[{oId:0,signHTML:""},{oId:1,signHTML:$("#preferenceSign1").val()},{oId:2,signHTML:$("#preferenceSign2").val()},{oId:3,signHTML:$("#preferenceSign3").val()}],t={preference:{metaKeywords:$("#metaKeywords").val(),metaDescription:$("#metaDescription").val(),blogTitle:$("#blogTitle").val(),blogSubtitle:$("#blogSubtitle").val(),mostCommentArticleDisplayCount:$("#mostCommentArticleDisplayCount").val(),mostViewArticleDisplayCount:$("#mostViewArticleDisplayCount").val(),recentCommentDisplayCount:$("#recentCommentDisplayCount").val(),mostUsedTagDisplayCount:$("#mostUsedTagDisplayCount").val(),articleListDisplayCount:$("#articleListDisplayCount").val(),articleListPaginationWindowSize:$("#articleListPaginationWindowSize").val(),skinDirName:$("#skinMain").data("skinDirName"),localeString:$("#localeString").val(),timeZoneId:$("#timeZoneId").val(),noticeBoard:$("#noticeBoard").val(),footerContent:$("#footerContent").val(),htmlHead:$("#htmlHead").val(),externalRelevantArticlesDisplayCount:$("#externalRelevantArticlesDisplayCount").val(),relevantArticlesDisplayCount:$("#relevantArticlesDisplayCount").val(),randomArticlesDisplayCount:$("#randomArticlesDisplayCount").val(),enableArticleUpdateHint:$("#enableArticleUpdateHint").prop("checked"),signs:e,allowVisitDraftViaPermalink:$("#allowVisitDraftViaPermalink").prop("checked"),articleListStyle:$("#articleListDisplay").val(),feedOutputMode:$("#feedOutputMode").val(),feedOutputCnt:$("#feedOutputCnt").val(),commentable:$("#commentable").prop("checked"),allowRegister:$("#allowRegister").prop("checked"),customVars:$("#customVars").val()}};$.ajax({url:latkeConfig.servePath+"/console/preference/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&$("#localeString").val()!==admin.preference.locale&&window.location.reload(),$("#loadMsg").text("")}})}}},admin.register.preference={obj:admin.preference,init:admin.preference.init,refresh:function(){admin.clearTip()}};
admin.pluginList={tablePagination:new TablePaginate("plugin"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},init:function(t){this.tablePagination.buildTable([{style:"padding-left: 12px;",text:Label.pluginNameLabel,index:"name",width:230},{style:"padding-left: 12px;",text:Label.statusLabel,index:"status",minWidth:80},{style:"padding-left: 12px;",text:Label.authorLabel,index:"author",width:200},{style:"padding-left: 12px;",text:Label.versionLabel,index:"version",width:120}]),this.tablePagination.initPagination(),$("#pluginSetting").dialog({width:700,height:180,modal:!0,hideFooter:!0}),this.getList(t)},getList:function(n){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var l=this;$.ajax({url:latkeConfig.servePath+"/console/plugins/"+n+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){admin.pluginList.pageInfo.currentPage=n;for(var a=t.plugins,i=0;i<a.length;i++)a[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('"+a[i].oId+"', '"+a[i].status+"')\">","ENABLED"===a[i].status?(a[i].status=Label.enabledLabel,a[i].expendRow+=Label.disableLabel):(a[i].status=Label.disabledLabel,a[i].expendRow+=Label.enableLabel),a[i].expendRow+="</a> ","{}"!=a[i].setting&&(a[i].expendRow+="<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('"+a[i].oId+"')\"> "+Label.settingLabel+" </a> ");l.tablePagination.updateTablePagination(t.plugins,n,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},toSetting:function(t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e={oId:t};$.ajax({url:latkeConfig.servePath+"/console/plugin/toSetting",type:"POST",cache:!1,data:JSON.stringify(e),success:function(t,e){$("#tipMsg").text(t.msg),$("#pluginSetting").html(t),$("#pluginSetting").dialog("open"),$("#loadMsg").text("")}})},changeStatus:function(t,e){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var a={oId:t,status:e="ENABLED"===e?"DISABLED":"ENABLED"};$.ajax({url:latkeConfig.servePath+"/console/plugin/status/",type:"PUT",cache:!1,data:JSON.stringify(a),success:function(t,e){$("#tipMsg").text(t.msg),t.sc?($("#loadMsg").text(""),window.location.reload()):$("#loadMsg").text("")}})}},admin.register["plugin-list"]={obj:admin.pluginList,init:admin.pluginList.init,refresh:function(){$("#loadMsg").text("")}}; admin.pluginList={tablePagination:new TablePaginate("plugin"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},init:function(t){this.tablePagination.buildTable([{style:"padding-left: 12px;",text:Label.pluginNameLabel,index:"name",width:230},{style:"padding-left: 12px;",text:Label.statusLabel,index:"status",minWidth:80},{style:"padding-left: 12px;",text:Label.authorLabel,index:"author",width:200},{style:"padding-left: 12px;",text:Label.versionLabel,index:"version",width:120}]),this.tablePagination.initPagination(),$("#pluginSetting").dialog({width:700,height:180,modal:!0,hideFooter:!0}),this.getList(t)},getList:function(n){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var l=this;$.ajax({url:latkeConfig.servePath+"/console/plugins/"+n+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){admin.pluginList.pageInfo.currentPage=n;for(var a=t.plugins,i=0;i<a.length;i++)a[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.pluginList.changeStatus('"+a[i].oId+"', '"+a[i].status+"')\">","ENABLED"===a[i].status?(a[i].status=Label.enabledLabel,a[i].expendRow+=Label.disableLabel):(a[i].status=Label.disabledLabel,a[i].expendRow+=Label.enableLabel),a[i].expendRow+="</a> ","{}"!=a[i].setting&&(a[i].expendRow+="<a href='javascript:void(0)' onclick=\"admin.pluginList.toSetting('"+a[i].oId+"')\"> "+Label.settingLabel+" </a> ");l.tablePagination.updateTablePagination(t.plugins,n,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},toSetting:function(t){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e={oId:t};$.ajax({url:latkeConfig.servePath+"/console/plugin/toSetting",type:"POST",cache:!1,data:JSON.stringify(e),success:function(t,e){$("#tipMsg").text(t.msg),$("#pluginSetting").html(t),$("#pluginSetting").dialog("open"),$("#loadMsg").text("")}})},changeStatus:function(t,e){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var a={oId:t,status:e="ENABLED"===e?"DISABLED":"ENABLED"};$.ajax({url:latkeConfig.servePath+"/console/plugin/status/",type:"PUT",cache:!1,data:JSON.stringify(a),success:function(t,e){$("#tipMsg").text(t.msg),t.sc?($("#loadMsg").text(""),window.location.reload()):$("#loadMsg").text("")}})}},admin.register["plugin-list"]={obj:admin.pluginList,init:admin.pluginList.init,refresh:function(){$("#loadMsg").text("")}};
admin.userList={tablePagination:new TablePaginate("user"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},userInfo:{oId:"",userRole:""},init:function(e){this.tablePagination.buildTable([{style:"padding-left: 12px;",text:Label.userNameLabel,index:"userName",width:230},{style:"padding-left: 12px;",text:Label.commentEmailLabel,index:"userEmail",minWidth:180},{style:"padding-left: 12px;",text:Label.roleLabel,index:"isAdmin",width:120}]),this.tablePagination.initPagination(),this.getList(e),$("#userUpdate").dialog({width:700,height:450,modal:!0,hideFooter:!0})},getList:function(i){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),this.pageInfo.currentPage=i;var n=this;$.ajax({url:latkeConfig.servePath+"/console/users/"+i+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=e.users,s=[];if(admin.userList.pageInfo.currentCount=t.length,admin.userList.pageInfo.pageCount=e.pagination.paginationPageCount,t.length<1)return $("#tipMsg").text("No user "+Label.reportIssueLabel),void $("#loadMsg").text("");$("#tipMsg").text(Label.uploadMsg);for(var u=0;u<t.length;u++)s[u]={},s[u].userName=t[u].userName,s[u].userEmail=t[u].userEmail,"adminRole"===t[u].userRole?(s[u].isAdmin="&nbsp;"+Label.administratorLabel,s[u].expendRow="<a href='javascript:void(0)' onclick=\"admin.userList.get('"+t[u].oId+"', '"+t[u].userRole+"')\">"+Label.updateLabel+"</a>"):(s[u].expendRow="<a href='javascript:void(0)' onclick=\"admin.userList.get('"+t[u].oId+"', '"+t[u].userRole+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.userList.del('"+t[u].oId+"', '"+encodeURIComponent(t[u].userName)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.userList.changeRole('"+t[u].oId+"')\">"+Label.changeRoleLabel+"</a>","defaultRole"===t[u].userRole?s[u].isAdmin=Label.commonUserLabel:s[u].isAdmin=Label.visitorUserLabel),n.tablePagination.updateTablePagination(s,i,e.pagination);$("#loadMsg").text("")}else $("#loadMsg").text("")}})},get:function(s,u){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#userUpdate").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/user/"+s,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=$("#userEmailUpdate");$("#userNameUpdate").val(e.user.userName).data("userInfo",{oId:s,userRole:u}),t.val(e.user.userEmail),$("#userURLUpdate").val(e.user.userURL),$("#userAvatarUpdate").val(e.user.userAvatar),$("#userB3KeyUpdate").val(e.user.userB3Key),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=$("#userNameUpdate").data("userInfo"),a={userName:$("#userNameUpdate").val(),oId:e.oId,userEmail:$("#userEmailUpdate").val(),userURL:$("#userURLUpdate").val(),userRole:e.userRole,userAvatar:$("#userAvatarUpdate").val(),userB3Key:$("#userB3KeyUpdate").val()};$.ajax({url:latkeConfig.servePath+"/console/user/",type:"PUT",cache:!1,data:JSON.stringify(a),success:function(e,a){$("#userUpdate").dialog("close"),$("#tipMsg").text(e.msg),e.sc&&admin.userList.getList(admin.userList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(e,a){confirm(Label.confirmRemoveLabel+Label.userLabel+'"'+Util.htmlDecode(a)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/user/"+e,type:"DELETE",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.userList.pageInfo.currentPage;1===admin.userList.pageInfo.currentCount&&1!==admin.userList.pageInfo.pageCount&&admin.userList.pageInfo.currentPage===admin.userList.pageInfo.pageCount&&(admin.userList.pageInfo.pageCount--,t=admin.userList.pageInfo.pageCount);var s=window.location.hash.split("/");t!==parseInt(s[s.length-1])&&admin.setHashByPage(t),admin.userList.getList(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},changeRole:function(e){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/changeRole/"+e,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.userList.pageInfo.currentPage;1===admin.userList.pageInfo.currentCount&&1!==admin.userList.pageInfo.pageCount&&admin.userList.pageInfo.currentPage===admin.userList.pageInfo.pageCount&&(admin.userList.pageInfo.pageCount--,t=admin.userList.pageInfo.pageCount);var s=window.location.hash.split("/");t!==parseInt(s[s.length-1])&&admin.setHashByPage(t),admin.userList.getList(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},validate:function(e){e||(e="");var a=$("#userName"+e).val().replace(/(^\s*)|(\s*$)/g,"");if(a.length<2||20<a.length)$("#tipMsg").text(Label.nameTooLongLabel),$("#userName"+e).focus();else if(""===$("#userEmail"+e).val().replace(/\s/g,""))$("#tipMsg").text(Label.mailCannotEmptyLabel),$("#userEmail"+e).focus();else{if(/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test($("#userEmail"+e).val()))return!0;$("#tipMsg").text(Label.mailInvalidLabel),$("#userEmail"+e).focus()}return!1}},admin.register["user-list"]={obj:admin.userList,init:admin.userList.init,refresh:admin.userList.getList}; admin.userList={tablePagination:new TablePaginate("user"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},userInfo:{oId:"",userRole:""},init:function(e){this.tablePagination.buildTable([{style:"padding-left: 12px;",text:Label.userNameLabel,index:"userName",width:230},{style:"padding-left: 12px;",text:Label.roleLabel,index:"isAdmin",width:120}]),this.tablePagination.initPagination(),this.getList(e),$("#userUpdate").dialog({width:700,height:450,modal:!0,hideFooter:!0})},getList:function(n){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),this.pageInfo.currentPage=n;var o=this;$.ajax({url:latkeConfig.servePath+"/console/users/"+n+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=e.users,s=[];if(admin.userList.pageInfo.currentCount=t.length,admin.userList.pageInfo.pageCount=e.pagination.paginationPageCount,t.length<1)return $("#tipMsg").text("No user "+Label.reportIssueLabel),void $("#loadMsg").text("");$("#tipMsg").text(Label.uploadMsg);for(var i=0;i<t.length;i++)s[i]={},s[i].userName=t[i].userName,"adminRole"===t[i].userRole?(s[i].isAdmin="&nbsp;"+Label.administratorLabel,s[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.userList.get('"+t[i].oId+"', '"+t[i].userRole+"')\">"+Label.updateLabel+"</a>"):(s[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.userList.get('"+t[i].oId+"', '"+t[i].userRole+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.userList.del('"+t[i].oId+"', '"+encodeURIComponent(t[i].userName)+"')\">"+Label.removeLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.userList.changeRole('"+t[i].oId+"')\">"+Label.changeRoleLabel+"</a>","defaultRole"===t[i].userRole?s[i].isAdmin=Label.commonUserLabel:s[i].isAdmin=Label.visitorUserLabel),o.tablePagination.updateTablePagination(s,n,e.pagination);$("#loadMsg").text("")}else $("#loadMsg").text("")}})},get:function(e,a){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#userUpdate").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/user/"+e,type:"GET",cache:!1,success:function(e,a){$("#tipMsg").text(e.msg),e.sc&&($("#userURLUpdate").val(e.user.userURL),$("#userAvatarUpdate").val(e.user.userAvatar),$("#userB3KeyUpdate").val(e.user.userB3Key)),$("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var e=$("#userNameUpdate").data("userInfo"),a={userName:$("#userNameUpdate").val(),oId:e.oId,userURL:$("#userURLUpdate").val(),userRole:e.userRole,userAvatar:$("#userAvatarUpdate").val(),userB3Key:$("#userB3KeyUpdate").val()};$.ajax({url:latkeConfig.servePath+"/console/user/",type:"PUT",cache:!1,data:JSON.stringify(a),success:function(e,a){$("#userUpdate").dialog("close"),$("#tipMsg").text(e.msg),e.sc&&admin.userList.getList(admin.userList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(e,a){confirm(Label.confirmRemoveLabel+Label.userLabel+'"'+Util.htmlDecode(a)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/user/"+e,type:"DELETE",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.userList.pageInfo.currentPage;1===admin.userList.pageInfo.currentCount&&1!==admin.userList.pageInfo.pageCount&&admin.userList.pageInfo.currentPage===admin.userList.pageInfo.pageCount&&(admin.userList.pageInfo.pageCount--,t=admin.userList.pageInfo.pageCount);var s=window.location.hash.split("/");t!==parseInt(s[s.length-1])&&admin.setHashByPage(t),admin.userList.getList(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},changeRole:function(e){$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/changeRole/"+e,type:"GET",cache:!1,success:function(e,a){if($("#tipMsg").text(e.msg),e.sc){var t=admin.userList.pageInfo.currentPage;1===admin.userList.pageInfo.currentCount&&1!==admin.userList.pageInfo.pageCount&&admin.userList.pageInfo.currentPage===admin.userList.pageInfo.pageCount&&(admin.userList.pageInfo.pageCount--,t=admin.userList.pageInfo.pageCount);var s=window.location.hash.split("/");t!==parseInt(s[s.length-1])&&admin.setHashByPage(t),admin.userList.getList(t),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},validate:function(e){e||(e="");var a=$("#userName"+e).val().replace(/(^\s*)|(\s*$)/g,"");return!(a.length<2||20<a.length)||($("#tipMsg").text(Label.nameTooLongLabel),$("#userName"+e).focus(),!1)}},admin.register["user-list"]={obj:admin.userList,init:admin.userList.init,refresh:admin.userList.getList};
admin.categoryList={tablePagination:new TablePaginate("category"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},init:function(t){this.tablePagination.buildTable([{text:"",index:"linkOrder",width:60},{style:"padding-left: 12px;",text:Label.titleLabel,index:"categoryTitle",width:230},{style:"padding-left: 12px;",text:"URI",index:"categoryURI",width:230},{style:"padding-left: 12px;",text:Label.descriptionLabel,index:"categoryDesc",minWidth:180}]),this.tablePagination.initPagination(),this.getList(t),$("#categoryUpdate").dialog({title:$("#categoryUpdate").data("title"),width:700,height:358,modal:!0,hideFooter:!0}),$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){for(var a=[],o=0;o<t.tags.length;o++)a.push(t.tags[o].tagTitle);$("#categoryTags").completed({height:160,buttonText:Label.selectLabel,data:a}),$("#loadMsg").text("")}}else $("#loadMsg").text("")}})},getList:function(g){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),this.pageInfo.currentPage=g;var n=this;$.ajax({url:latkeConfig.servePath+"/console/categories/"+g+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){var a=t.categories,o=[];admin.categoryList.pageInfo.currentCount=a.length,admin.categoryList.pageInfo.pageCount=0===t.pagination.paginationPageCount?1:t.pagination.paginationPageCount;for(var i=0;i<a.length;i++)o[i]={},0===i?1===a.length?o[i].linkOrder="":o[i].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>':i===a.length-1?o[i].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> </div>':o[i].linkOrder='<div class="table-center" style="width:38px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>',o[i].categoryTitle=a[i].categoryTitle,o[i].categoryURI=a[i].categoryURI,o[i].categoryDesc=a[i].categoryDescription,o[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.categoryList.get('"+a[i].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.categoryList.del('"+a[i].oId+"', '"+encodeURIComponent(a[i].categoryTitle)+"')\">"+Label.removeLabel+"</a> ";n.tablePagination.updateTablePagination(o,g,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={categoryTitle:$("#categoryName").val(),categoryTags:$("#categoryTags").val(),categoryURI:$("#categoryURI").val(),categoryDescription:$("#categoryDesc").val()};$.ajax({url:latkeConfig.servePath+"/console/category/",type:"POST",cache:!1,data:JSON.stringify(t),success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){$("#categoryName").val(""),$("#categoryTags").val(""),$("#categoryURI").val(""),$("#categoryDesc").val(""),admin.categoryList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.categoryList.pageInfo.currentPage===admin.categoryList.pageInfo.pageCount&&admin.categoryList.pageInfo.pageCount++;var a=window.location.hash.split("/");admin.categoryList.pageInfo.pageCount!==parseInt(a[a.length-1])&&admin.setHashByPage(admin.categoryList.pageInfo.pageCount),admin.categoryList.getList(admin.categoryList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},get:function(a){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#categoryUpdate").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/category/"+a,type:"GET",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc&&($("#categoryNameUpdate").val(t.categoryTitle).data("oId",a),$("#categoryURIUpdate").val(t.categoryURI),$("#categoryDescUpdate").val(t.categoryDescription),$("#categoryTagsUpdate").val(t.categoryTags)),$("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={categoryTitle:$("#categoryNameUpdate").val(),oId:$("#categoryNameUpdate").data("oId"),categoryTags:$("#categoryTagsUpdate").val(),categoryURI:$("#categoryURIUpdate").val(),categoryDescription:$("#categoryDescUpdate").val()};$.ajax({url:latkeConfig.servePath+"/console/category/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(t,e){$("#categoryUpdate").dialog("close"),$("#tipMsg").text(t.msg),t.sc&&admin.categoryList.getList(admin.categoryList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(t,e){confirm(Label.confirmRemoveLabel+Label.categoryLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/category/"+t,type:"DELETE",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){var a=admin.categoryList.pageInfo.currentPage;1===admin.categoryList.pageInfo.currentCount&&1!==admin.categoryList.pageInfo.pageCount&&admin.categoryList.pageInfo.currentPage===admin.categoryList.pageInfo.pageCount&&(admin.categoryList.pageInfo.pageCount--,a=admin.categoryList.pageInfo.pageCount);var o=window.location.hash.split("/");a!==parseInt(o[o.length-1])&&admin.setHashByPage(a),admin.categoryList.getList(a),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},validate:function(t){t||(t="");var e=$("#categoryName"+t).val().replace(/(^\s*)|(\s*$)/g,"");if(e.length<2||32<e.length)$("#tipMsg").text(Label.categoryTooLongLabel),$("#categoryName"+t).focus();else{if(""!==$.trim($("#categoryTags"+t).val()))return!0;$("#tipMsg").text(Label.tagsEmptyLabel),$("#categoryTags"+t).focus()}return!1},changeOrder:function(t,e,a){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var o={oId:t.toString(),direction:a};$.ajax({url:latkeConfig.servePath+"/console/category/order/",type:"PUT",cache:!1,data:JSON.stringify(o),success:function(t,e){$("#tipMsg").text(t.msg),admin.categoryList.getList(admin.categoryList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["category-list"]={obj:admin.categoryList,init:admin.categoryList.init,refresh:admin.categoryList.getList}; admin.categoryList={tablePagination:new TablePaginate("category"),pageInfo:{currentCount:1,pageCount:1,currentPage:1},init:function(t){this.tablePagination.buildTable([{text:"",index:"linkOrder",width:60},{style:"padding-left: 12px;",text:Label.titleLabel,index:"categoryTitle",width:230},{style:"padding-left: 12px;",text:"URI",index:"categoryURI",width:230},{style:"padding-left: 12px;",text:Label.descriptionLabel,index:"categoryDesc",minWidth:180}]),this.tablePagination.initPagination(),this.getList(t),$("#categoryUpdate").dialog({title:$("#categoryUpdate").data("title"),width:700,height:358,modal:!0,hideFooter:!0}),$.ajax({url:latkeConfig.servePath+"/console/tags",type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){if(!(t.tags.length<=0)){for(var a=[],o=0;o<t.tags.length;o++)a.push(t.tags[o].tagTitle);$("#categoryTags").completed({height:160,buttonText:Label.selectLabel,data:a}),$("#loadMsg").text("")}}else $("#loadMsg").text("")}})},getList:function(g){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),this.pageInfo.currentPage=g;var n=this;$.ajax({url:latkeConfig.servePath+"/console/categories/"+g+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){var a=t.categories,o=[];admin.categoryList.pageInfo.currentCount=a.length,admin.categoryList.pageInfo.pageCount=0===t.pagination.paginationPageCount?1:t.pagination.paginationPageCount;for(var i=0;i<a.length;i++)o[i]={},0===i?1===a.length?o[i].linkOrder="":o[i].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>':i===a.length-1?o[i].linkOrder='<div class="table-center" style="width:14px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> </div>':o[i].linkOrder='<div class="table-center" style="width:38px"> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'up\');" class="icon-move-up"></span> <span onclick="admin.categoryList.changeOrder('+a[i].oId+", "+i+', \'down\');" class="icon-move-down"></span> </div>',o[i].categoryTitle=a[i].categoryTitle,o[i].categoryURI=a[i].categoryURI,o[i].categoryDesc=a[i].categoryDescription,o[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.categoryList.get('"+a[i].oId+"')\">"+Label.updateLabel+"</a> <a href='javascript:void(0)' onclick=\"admin.categoryList.del('"+a[i].oId+"', '"+encodeURIComponent(a[i].categoryTitle)+"')\">"+Label.removeLabel+"</a> ";n.tablePagination.updateTablePagination(o,g,t.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},add:function(){if(this.validate()){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={categoryTitle:$("#categoryName").val(),categoryTags:$("#categoryTags").val(),categoryURI:$("#categoryURI").val(),categoryDescription:$("#categoryDesc").val()};$.ajax({url:latkeConfig.servePath+"/console/category/",type:"POST",cache:!1,data:JSON.stringify(t),success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){$("#categoryName").val(""),$("#categoryTags").val(""),$("#categoryURI").val(""),$("#categoryDesc").val(""),admin.categoryList.pageInfo.currentCount===Label.PAGE_SIZE&&admin.categoryList.pageInfo.currentPage===admin.categoryList.pageInfo.pageCount&&admin.categoryList.pageInfo.pageCount++;var a=window.location.hash.split("/");admin.categoryList.pageInfo.pageCount!==parseInt(a[a.length-1])&&admin.setHashByPage(admin.categoryList.pageInfo.pageCount),admin.categoryList.getList(admin.categoryList.pageInfo.pageCount),$("#loadMsg").text("")}else $("#loadMsg").text("")}})}},get:function(a){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$("#categoryUpdate").dialog("open"),$.ajax({url:latkeConfig.servePath+"/console/category/"+a,type:"GET",cache:!1,success:function(t,e){$("#tipMsg").text(t.msg),t.sc&&($("#categoryNameUpdate").val(t.categoryTitle).data("oId",a),$("#categoryURIUpdate").val(t.categoryURI),$("#categoryDescUpdate").val(t.categoryDescription),$("#categoryTagsUpdate").val(t.categoryTags)),$("#loadMsg").text("")}})},update:function(){if(this.validate("Update")){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var t={categoryTitle:$("#categoryNameUpdate").val(),oId:$("#categoryNameUpdate").data("oId"),categoryTags:$("#categoryTagsUpdate").val(),categoryURI:$("#categoryURIUpdate").val(),categoryDescription:$("#categoryDescUpdate").val()};$.ajax({url:latkeConfig.servePath+"/console/category/",type:"PUT",cache:!1,data:JSON.stringify(t),success:function(t,e){$("#categoryUpdate").dialog("close"),$("#tipMsg").text(t.msg),t.sc&&admin.categoryList.getList(admin.categoryList.pageInfo.currentPage),$("#loadMsg").text("")}})}},del:function(t,e){confirm(Label.confirmRemoveLabel+Label.categoryLabel+'"'+Util.htmlDecode(e)+'"?')&&($("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text(""),$.ajax({url:latkeConfig.servePath+"/console/category/"+t,type:"DELETE",cache:!1,success:function(t,e){if($("#tipMsg").text(t.msg),t.sc){var a=admin.categoryList.pageInfo.currentPage;1===admin.categoryList.pageInfo.currentCount&&1!==admin.categoryList.pageInfo.pageCount&&admin.categoryList.pageInfo.currentPage===admin.categoryList.pageInfo.pageCount&&(admin.categoryList.pageInfo.pageCount--,a=admin.categoryList.pageInfo.pageCount);var o=window.location.hash.split("/");a!==parseInt(o[o.length-1])&&admin.setHashByPage(a),admin.categoryList.getList(a),$("#loadMsg").text("")}else $("#loadMsg").text("")}}))},validate:function(t){t||(t="");var e=$("#categoryName"+t).val().replace(/(^\s*)|(\s*$)/g,"");if(e.length<2||32<e.length)$("#tipMsg").text(Label.categoryTooLongLabel),$("#categoryName"+t).focus();else{if(""!==$.trim($("#categoryTags"+t).val()))return!0;$("#tipMsg").text(Label.tagsEmptyLabel),$("#categoryTags"+t).focus()}return!1},changeOrder:function(t,e,a){$("#loadMsg").text(Label.loadingLabel),$("#tipMsg").text("");var o={oId:t.toString(),direction:a};$.ajax({url:latkeConfig.servePath+"/console/category/order/",type:"PUT",cache:!1,data:JSON.stringify(o),success:function(t,e){$("#tipMsg").text(t.msg),admin.categoryList.getList(admin.categoryList.pageInfo.currentPage),$("#loadMsg").text("")}})}},admin.register["category-list"]={obj:admin.categoryList,init:admin.categoryList.init,refresh:admin.categoryList.getList};
admin.commentList={tablePagination:new TablePaginate("comment"),pageInfo:{currentPage:1},init:function(e){this.tablePagination.buildTable([{text:Label.commentContentLabel,index:"content",minWidth:174,style:"padding-left: 12px;"},{text:Label.authorLabel,index:"title",style:"padding-left: 12px;",width:154},{text:Label.dateLabel,index:"date",width:60,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.getList(e)},getList:function(m){var l=this;$("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/comments/"+m+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){l.pageInfo.currentPage=m;for(var a=e.comments,n=[],i=0;i<a.length;i++){var o="Article";"pageComment"===a[i].type&&(o="Page"),n[i]={},n[i].content='<div class="content-reset">'+Util.replaceEmString(a[i].commentContent)+"</div><span class='table-tag'> on &nbsp;&nbsp;</span><a href='"+latkeConfig.servePath+a[i].commentSharpURL+"' target='_blank'>"+a[i].commentTitle+"</a>",n[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.commentList.del('"+a[i].oId+"', '"+o+"')\">"+Label.removeLabel+"</a>",n[i].title="<img class='small-head' src='"+a[i].commentThumbnailURL+"'/>","http://"===a[i].commentURL?n[i].title+=a[i].commentName:n[i].title+="<a href='"+a[i].commentURL+"' target='_blank' class='no-underline'>"+a[i].commentName+"</a>",n[i].title+="<br/><a href='mailto:"+a[i].commentEmail+"'>"+a[i].commentEmail+"</a>",n[i].date=$.bowknot.getDate(a[i].commentTime)}l.tablePagination.updateTablePagination(n,m,e.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(e,t){confirm(Label.confirmRemoveLabel+Label.commentLabel+"?")&&($("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/"+t.toLowerCase()+"/comment/"+e,type:"DELETE",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&admin.commentList.getList(admin.commentList.pageInfo.currentPage),$("#loadMsg").text("")}}))}},admin.register["comment-list"]={obj:admin.commentList,init:admin.commentList.init,refresh:admin.commentList.getList}; admin.commentList={tablePagination:new TablePaginate("comment"),pageInfo:{currentPage:1},init:function(e){this.tablePagination.buildTable([{text:Label.commentContentLabel,index:"content",minWidth:174,style:"padding-left: 12px;"},{text:Label.authorLabel,index:"title",style:"padding-left: 12px;",width:154},{text:Label.dateLabel,index:"date",width:60,style:"padding-left: 12px;"}]),this.tablePagination.initPagination(),this.getList(e)},getList:function(l){var m=this;$("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/comments/"+l+"/"+Label.PAGE_SIZE+"/"+Label.WINDOW_SIZE,type:"GET",cache:!1,success:function(e,t){if($("#tipMsg").text(e.msg),e.sc){m.pageInfo.currentPage=l;for(var a=e.comments,n=[],i=0;i<a.length;i++){var o="Article";"pageComment"===a[i].type&&(o="Page"),n[i]={},n[i].content='<div class="content-reset">'+Util.replaceEmString(a[i].commentContent)+"</div><span class='table-tag'> on &nbsp;&nbsp;</span><a href='"+latkeConfig.servePath+a[i].commentSharpURL+"' target='_blank'>"+a[i].commentTitle+"</a>",n[i].expendRow="<a href='javascript:void(0)' onclick=\"admin.commentList.del('"+a[i].oId+"', '"+o+"')\">"+Label.removeLabel+"</a>",n[i].title="<img class='small-head' src='"+a[i].commentThumbnailURL+"'/>","http://"===a[i].commentURL?n[i].title+=a[i].commentName:n[i].title+="<a href='"+a[i].commentURL+"' target='_blank' class='no-underline'>"+a[i].commentName+"</a>",n[i].title+="<br/>",n[i].date=$.bowknot.getDate(a[i].commentTime)}m.tablePagination.updateTablePagination(n,l,e.pagination),$("#loadMsg").text("")}else $("#loadMsg").text("")}})},del:function(e,t){confirm(Label.confirmRemoveLabel+Label.commentLabel+"?")&&($("#loadMsg").text(Label.loadingLabel),$.ajax({url:latkeConfig.servePath+"/console/"+t.toLowerCase()+"/comment/"+e,type:"DELETE",cache:!1,success:function(e,t){$("#tipMsg").text(e.msg),e.sc&&admin.commentList.getList(admin.commentList.pageInfo.currentPage),$("#loadMsg").text("")}}))}},admin.register["comment-list"]={obj:admin.commentList,init:admin.commentList.init,refresh:admin.commentList.getList};
var plugins={};admin.plugin={plugins:[],add:function(t){t.isInit=!1,t.hash=t.path.replace("/","#")+"/"+t.id,this.plugins.push(t);var a=this._analysePath(t.path);t.index&&a.length<2&&this._addNew(t,a)},setCurByHash:function(t){for(var a=this.plugins,e=0;e<a.length;e++){var n=a[e],i=this._analysePath(n.path),s=!1;n.index&&-1<window.location.hash.indexOf(n.hash)?s=!0:(n.path.replace("/","#")===window.location.hash||"#main"===window.location.hash&&-1<n.path.indexOf("/main/panel"))&&(s=!0),s&&(n.isInit?plugins[n.id].refresh&&plugins[n.id].refresh(t.page):(n.index?2===i.length&&this._addNew(n,i):this._addToExist(n,i),plugins[n.id].init(t.page),n.isInit=!0))}},_analysePath:function(t){var a=t.split("/");return a.splice(0,1),a},_addNew:function(t,a){if(2===a.length)return t.target=$("#tabPreference li").get(t.index-1),void $("#tabPreference").tabs("add",t);""===a[0]?t.target=$("#tabs>ul>li").get(t.index-1):"article"===a[0]?t.target=$("#tabArticleMgt>li").get(t.index-1):"tools"===a[0]&&(admin.tools.push("#"+t.id),t.target=$("#tabTools>li").get(t.index-1)),t.target||alert("data.index is error!"),$("#tabs").tabs("add",t)},_addToExist:function(t,a){switch(a[0]){case"main":$("#mainPanel"+a[1].charAt(5)).append(t.content);break;case"tools":case"article":2===a.length?$("#tabsPanel_"+a[1]).append(t.content):$("#tabPreferencePanel_"+a[2]).append(t.content);break;case"comment-list":$("#tabsPanel_comment-list").append(t.content)}}}; var plugins={};admin.plugin={plugins:[],add:function(t){t.isInit=!1,t.hash=t.path.replace("/","#")+"/"+t.id,this.plugins.push(t);var a=this._analysePath(t.path);t.index&&a.length<2&&this._addNew(t,a)},setCurByHash:function(t){for(var a=this.plugins,e=0;e<a.length;e++){var n=a[e],i=this._analysePath(n.path),s=!1;n.index&&-1<window.location.hash.indexOf(n.hash)?s=!0:(n.path.replace("/","#")===window.location.hash||"#main"===window.location.hash&&-1<n.path.indexOf("/main/panel"))&&(s=!0),s&&(n.isInit?plugins[n.id].refresh&&plugins[n.id].refresh(t.page):(n.index?2===i.length&&this._addNew(n,i):this._addToExist(n,i),plugins[n.id].init(t.page),n.isInit=!0))}},_analysePath:function(t){var a=t.split("/");return a.splice(0,1),a},_addNew:function(t,a){if(2===a.length)return t.target=$("#tabPreference li").get(t.index-1),void $("#tabPreference").tabs("add",t);""===a[0]?t.target=$("#tabs>ul>li").get(t.index-1):"article"===a[0]?t.target=$("#tabArticleMgt>li").get(t.index-1):"tools"===a[0]&&(admin.tools.push("#"+t.id),t.target=$("#tabTools>li").get(t.index-1)),t.target||alert("data.index is error!"),$("#tabs").tabs("add",t)},_addToExist:function(t,a){switch(a[0]){case"main":$("#mainPanel"+a[1].charAt(5)).append(t.content);break;case"tools":case"article":2===a.length?$("#tabsPanel_"+a[1]).append(t.content):$("#tabPreferencePanel_"+a[2]).append(t.content);break;case"comment-list":$("#tabsPanel_comment-list").append(t.content)}}};
admin.main={},admin.register.main={obj:admin.main,init:function(){admin.clearTip()},refresh:function(){admin.clearTip()}}; admin.main={},admin.register.main={obj:admin.main,init:function(){admin.clearTip()},refresh:function(){admin.clearTip()}};
admin.about={init:function(){$.ajax({url:"https://rhythm.b3log.org/version/solo/latest/"+Label.version,type:"GET",cache:!1,dataType:"jsonp",success:function(a,t){var e=a.soloVersion;e===Label.version?$("#aboutLatest").text(Label.upToDateLabel):$("#aboutLatest").html(Label.outOfDateLabel+"<a href='"+a.soloDownload+"'>"+e+"</a>")},complete:function(a,t){admin.clearTip()}})}},admin.register.about={obj:admin.about,init:admin.about.init,refresh:function(){admin.clearTip()}}; admin.about={init:function(){$.ajax({url:"https://rhythm.b3log.org/version/solo/latest/"+Label.version,type:"GET",cache:!1,dataType:"jsonp",success:function(a,t){var e=a.soloVersion;e===Label.version?$("#aboutLatest").text(Label.upToDateLabel):$("#aboutLatest").html(Label.outOfDateLabel+"<a href='"+a.soloDownload+"'>"+e+"</a>")},complete:function(a,t){admin.clearTip()}})}},admin.register.about={obj:admin.about,init:admin.about.init,refresh:function(){admin.clearTip()}};
\ No newline at end of file
...@@ -79,8 +79,7 @@ admin.comment = { ...@@ -79,8 +79,7 @@ admin.comment = {
commentsHTML += "@" + comments[i].commentOriginalCommentName; commentsHTML += "@" + comments[i].commentOriginalCommentName;
} }
commentsHTML += "</span><span title='" + Label.removeLabel + "' class='fn__right deleteIcon' onclick=\"admin.comment.del('" commentsHTML += "</span><span title='" + Label.removeLabel + "' class='fn__right deleteIcon' onclick=\"admin.comment.del('"
+ comments[i].oId + "', '" + fromId + "', '" + onId + "')\"></span><span class='fn__right'><a href='mailto:" + comments[i].oId + "', '" + fromId + "', '" + onId + "')\"></span><span class='fn__right'>&nbsp;&nbsp;"
+ comments[i].commentEmail + "'>" + comments[i].commentEmail + "</a>&nbsp;&nbsp;"
+ $.bowknot.getDate(comments[i].commentTime) + $.bowknot.getDate(comments[i].commentTime)
+ "&nbsp;</span><div class='fn__clear'></div></div><div class='fn__margin12'>" + "&nbsp;</span><div class='fn__clear'></div></div><div class='fn__margin12'>"
+ contentHTML + "</div>"; + contentHTML + "</div>";
......
...@@ -101,8 +101,7 @@ admin.commentList = { ...@@ -101,8 +101,7 @@ admin.commentList = {
"' target='_blank' class='no-underline'>" + comments[i].commentName + "' target='_blank' class='no-underline'>" + comments[i].commentName +
"</a>"; "</a>";
} }
commentsData[i].title += "<br/><a href='mailto:" + comments[i].commentEmail + commentsData[i].title += "<br/>";
"'>" + comments[i].commentEmail + "</a>";
commentsData[i].date = $.bowknot.getDate(comments[i].commentTime); commentsData[i].date = $.bowknot.getDate(comments[i].commentTime);
} }
......
...@@ -23,31 +23,13 @@ ...@@ -23,31 +23,13 @@
* @version 1.3.0.0, Nov 11, 2017 * @version 1.3.0.0, Nov 11, 2017
*/ */
/* oterhs 相关操作 */ /* others 相关操作 */
admin.others = { admin.others = {
/* /*
* @description 初始化 * @description 初始化
*/ */
init: function () { init: function () {
$("#tabOthers").tabs(); $("#tabOthers").tabs();
$.ajax({
url: latkeConfig.servePath + "/console/reply/notification/template",
type: "GET",
cache: false,
success: function (result, textStatus) {
$("#tipMsg").text(result.msg);
if (!result.sc) {
$("#loadMsg").text("");
return;
}
$("#replayEmailTemplateTitle").val(result.replyNotificationTemplate.subject);
$("#replayEmailTemplateBody").val(result.replyNotificationTemplate.body);
$("#loadMsg").text("");
}
});
}, },
/* /*
* @description 移除未使用的标签 * @description 移除未使用的标签
...@@ -149,31 +131,6 @@ admin.others = { ...@@ -149,31 +131,6 @@ admin.others = {
} }
} }
}); });
},
/*
* @description 跟新回复提醒邮件模版
*/
update: function () {
$("#loadMsg").text(Label.loadingLabel);
$("#tipMsg").text("");
var requestJSONObject = {
"replyNotificationTemplate": {
"subject": $("#replayEmailTemplateTitle").val(),
"body": $("#replayEmailTemplateBody").val()
}
};
$.ajax({
url: latkeConfig.servePath + "/console/reply/notification/template",
type: "PUT",
cache: false,
data: JSON.stringify(requestJSONObject),
success: function (result, textStatus) {
$("#tipMsg").text(result.msg);
$("#loadMsg").text("");
}
});
} }
}; };
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.2.5, Feb 10, 2019 * @version 1.1.2.6, Mar 3, 2019
*/ */
/* user-list 相关操作 */ /* user-list 相关操作 */
...@@ -45,11 +45,6 @@ admin.userList = { ...@@ -45,11 +45,6 @@ admin.userList = {
text: Label.userNameLabel, text: Label.userNameLabel,
index: 'userName', index: 'userName',
width: 230, width: 230,
}, {
style: 'padding-left: 12px;',
text: Label.commentEmailLabel,
index: 'userEmail',
minWidth: 180,
}, { }, {
style: 'padding-left: 12px;', style: 'padding-left: 12px;',
text: Label.roleLabel, text: Label.roleLabel,
...@@ -79,7 +74,7 @@ admin.userList = { ...@@ -79,7 +74,7 @@ admin.userList = {
$.ajax({ $.ajax({
url: latkeConfig.servePath + '/console/users/' + pageNum + '/' + url: latkeConfig.servePath + '/console/users/' + pageNum + '/' +
Label.PAGE_SIZE + '/' + Label.WINDOW_SIZE, Label.PAGE_SIZE + '/' + Label.WINDOW_SIZE,
type: 'GET', type: 'GET',
cache: false, cache: false,
success: function (result, textStatus) { success: function (result, textStatus) {
...@@ -103,7 +98,6 @@ admin.userList = { ...@@ -103,7 +98,6 @@ admin.userList = {
for (var i = 0; i < users.length; i++) { for (var i = 0; i < users.length; i++) {
userData[i] = {} userData[i] = {}
userData[i].userName = users[i].userName userData[i].userName = users[i].userName
userData[i].userEmail = users[i].userEmail
if ('adminRole' === users[i].userRole) { if ('adminRole' === users[i].userRole) {
userData[i].isAdmin = '&nbsp;' + Label.administratorLabel userData[i].isAdmin = '&nbsp;' + Label.administratorLabel
...@@ -121,8 +115,7 @@ admin.userList = { ...@@ -121,8 +115,7 @@ admin.userList = {
users[i].oId + '\')">' + Label.changeRoleLabel + '</a>' users[i].oId + '\')">' + Label.changeRoleLabel + '</a>'
if ('defaultRole' === users[i].userRole) { if ('defaultRole' === users[i].userRole) {
userData[i].isAdmin = Label.commonUserLabel userData[i].isAdmin = Label.commonUserLabel
} } else {
else {
userData[i].isAdmin = Label.visitorUserLabel userData[i].isAdmin = Label.visitorUserLabel
} }
} }
...@@ -155,12 +148,6 @@ admin.userList = { ...@@ -155,12 +148,6 @@ admin.userList = {
return return
} }
var $userEmailUpdate = $('#userEmailUpdate')
$('#userNameUpdate').val(result.user.userName).data('userInfo', {
'oId': id,
'userRole': userRole,
})
$userEmailUpdate.val(result.user.userEmail)
$('#userURLUpdate').val(result.user.userURL) $('#userURLUpdate').val(result.user.userURL)
$('#userAvatarUpdate').val(result.user.userAvatar) $('#userAvatarUpdate').val(result.user.userAvatar)
$('#userB3KeyUpdate').val(result.user.userB3Key) $('#userB3KeyUpdate').val(result.user.userB3Key)
...@@ -181,7 +168,6 @@ admin.userList = { ...@@ -181,7 +168,6 @@ admin.userList = {
var requestJSONObject = { var requestJSONObject = {
'userName': $('#userNameUpdate').val(), 'userName': $('#userNameUpdate').val(),
'oId': userInfo.oId, 'oId': userInfo.oId,
'userEmail': $('#userEmailUpdate').val(),
'userURL': $('#userURLUpdate').val(), 'userURL': $('#userURLUpdate').val(),
'userRole': userInfo.userRole, 'userRole': userInfo.userRole,
'userAvatar': $('#userAvatarUpdate').val(), 'userAvatar': $('#userAvatarUpdate').val(),
...@@ -297,16 +283,10 @@ admin.userList = { ...@@ -297,16 +283,10 @@ admin.userList = {
if (2 > userName.length || userName.length > 20) { if (2 > userName.length || userName.length > 20) {
$('#tipMsg').text(Label.nameTooLongLabel) $('#tipMsg').text(Label.nameTooLongLabel)
$('#userName' + status).focus() $('#userName' + status).focus()
} else if ($('#userEmail' + status).val().replace(/\s/g, '') === '') {
$('#tipMsg').text(Label.mailCannotEmptyLabel)
$('#userEmail' + status).focus()
} else if (!/^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(
$('#userEmail' + status).val())) {
$('#tipMsg').text(Label.mailInvalidLabel)
$('#userEmail' + status).focus()
} else { } else {
return true return true
} }
return false return false
}, },
} }
......
Subproject commit e4e32efbc543f0133131addf383b9cc573d9ec56 Subproject commit 3991aa69213dc450b1ea2c0c36601367de7cb68b
...@@ -122,12 +122,11 @@ public abstract class AbstractTestCase { ...@@ -122,12 +122,11 @@ public abstract class AbstractTestCase {
public void init() throws Exception { public void init() throws Exception {
final InitService initService = getInitService(); final InitService initService = getInitService();
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_EMAIL, "test@gmail.com");
requestJSONObject.put(User.USER_NAME, "Solo"); requestJSONObject.put(User.USER_NAME, "Solo");
requestJSONObject.put(UserExt.USER_B3_KEY, "pass"); requestJSONObject.put(UserExt.USER_B3_KEY, "pass");
initService.init(requestJSONObject); initService.init(requestJSONObject);
final UserQueryService userQueryService = getUserQueryService(); final UserQueryService userQueryService = getUserQueryService();
Assert.assertNotNull(userQueryService.getUserByEmailOrUserName("test@gmail.com")); Assert.assertNotNull(userQueryService.getUserByName("Solo"));
} }
/** /**
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.mail;
import org.b3log.latke.Latkes;
import org.b3log.solo.mail.MailService.Message;
import org.testng.annotations.Test;
/**
* {@link MailService} test case.
*
* @author <a href="https://hacpai.com/member/jiangzezhou">zezhou jiang</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.4, Dec 2, 2018
*/
public final class MailServiceTestCase {
static {
Latkes.init();
}
/**
* Tests mail sending.
*
* @throws Exception exception
*/
//@Test
public void testSendMail() throws Exception {
System.out.println("testSendMail");
final MailService mailService = MailServiceFactory.getMailService();
final Message message = new Message();
message.setFrom("b3log.solo@gmail.com");
message.setSubject("Latke Mail Service[local] Test");
message.setHtmlBody("<htmL><body>测试</body><html>");
message.addRecipient("d@b3log.org");
mailService.send(message);
Thread.sleep(10000); // Waiting for sending....
}
}
\ No newline at end of file
...@@ -49,51 +49,6 @@ public class PreferenceConsoleTestCase extends AbstractTestCase { ...@@ -49,51 +49,6 @@ public class PreferenceConsoleTestCase extends AbstractTestCase {
super.init(); super.init();
} }
/**
* getReplyNotificationTemplate.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/reply/notification/template");
mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse();
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "sc\":true"));
}
/**
* updateReplyNotificationTemplate.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "getReplyNotificationTemplate")
public void updateReplyNotificationTemplate() throws Exception {
final JSONObject p = getPreferenceQueryService().getReplyNotificationTemplate();
final MockHttpServletRequest request = mockRequest();
request.setRequestURI("/console/reply/notification/template");
request.setMethod("PUT");
final JSONObject requestJSON = new JSONObject();
requestJSON.put("replyNotificationTemplate", p);
final BufferedReader reader = new BufferedReader(new StringReader(requestJSON.toString()));
request.setReader(reader);
mockAdminLogin(request);
final MockHttpServletResponse response = mockResponse();
mockDispatcherServletService(request, response);
final String content = response.body();
Assert.assertTrue(StringUtils.contains(content, "sc\":true"));
}
/** /**
* getSigns. * getSigns.
* *
......
...@@ -49,7 +49,6 @@ public class CommentRepositoryImplTestCase extends AbstractTestCase { ...@@ -49,7 +49,6 @@ public class CommentRepositoryImplTestCase extends AbstractTestCase {
comment.put(Comment.COMMENT_CONTENT, "comment1 content"); comment.put(Comment.COMMENT_CONTENT, "comment1 content");
comment.put(Comment.COMMENT_CREATED, new Date().getTime()); comment.put(Comment.COMMENT_CREATED, new Date().getTime());
comment.put(Comment.COMMENT_EMAIL, "test@gmail.com");
comment.put(Comment.COMMENT_NAME, "comment1 name"); comment.put(Comment.COMMENT_NAME, "comment1 name");
comment.put(Comment.COMMENT_ON_ID, "comment1 on id"); comment.put(Comment.COMMENT_ON_ID, "comment1 on id");
comment.put(Comment.COMMENT_ON_TYPE, "comment1 on type"); comment.put(Comment.COMMENT_ON_TYPE, "comment1 on type");
......
...@@ -51,7 +51,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase { ...@@ -51,7 +51,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
final JSONObject another = new JSONObject(); final JSONObject another = new JSONObject();
another.put(User.USER_NAME, "test1"); another.put(User.USER_NAME, "test1");
another.put(User.USER_EMAIL, "test1@gmail.com");
another.put(User.USER_URL, "https://b3log.org"); another.put(User.USER_URL, "https://b3log.org");
another.put(User.USER_ROLE, Role.DEFAULT_ROLE); another.put(User.USER_ROLE, Role.DEFAULT_ROLE);
another.put(UserExt.USER_AVATAR, ""); another.put(UserExt.USER_AVATAR, "");
...@@ -66,7 +65,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase { ...@@ -66,7 +65,6 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
JSONObject admin = new JSONObject(); JSONObject admin = new JSONObject();
admin.put(User.USER_NAME, "test"); admin.put(User.USER_NAME, "test");
admin.put(User.USER_EMAIL, "test@gmail.com");
admin.put(User.USER_URL, "https://b3log.org"); admin.put(User.USER_URL, "https://b3log.org");
admin.put(User.USER_ROLE, Role.ADMIN_ROLE); admin.put(User.USER_ROLE, Role.ADMIN_ROLE);
admin.put(UserExt.USER_AVATAR, ""); admin.put(UserExt.USER_AVATAR, "");
...@@ -87,13 +85,13 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase { ...@@ -87,13 +85,13 @@ public final class UserRepositoryImplTestCase extends AbstractTestCase {
final JSONArray users = result.getJSONArray(Keys.RESULTS); final JSONArray users = result.getJSONArray(Keys.RESULTS);
Assert.assertEquals(users.length(), 1); Assert.assertEquals(users.length(), 1);
Assert.assertEquals(users.getJSONObject(0).getString(User.USER_EMAIL), "test1@gmail.com"); Assert.assertEquals(users.getJSONObject(0).getString(User.USER_NAME), "test1");
final JSONObject notFound = userRepository.getByEmail("not.found@gmail.com"); final JSONObject notFound = userRepository.getByUserName("not.found");
Assert.assertNull(notFound); Assert.assertNull(notFound);
final JSONObject found = userRepository.getByEmail("test1@gmail.com"); final JSONObject found = userRepository.getByUserName("test1");
Assert.assertNotNull(found); Assert.assertNotNull(found);
Assert.assertEquals(found.getString(User.USER_EMAIL), "test1@gmail.com"); Assert.assertEquals(found.getString(User.USER_NAME), "test1");
} }
} }
...@@ -74,8 +74,7 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase { ...@@ -74,8 +74,7 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
final String articleId = articles.get(0).getString(Keys.OBJECT_ID); final String articleId = articles.get(0).getString(Keys.OBJECT_ID);
requestJSONObject.put(Keys.OBJECT_ID, articleId); requestJSONObject.put(Keys.OBJECT_ID, articleId);
requestJSONObject.put(Comment.COMMENT_NAME, "comment name"); requestJSONObject.put(Comment.COMMENT_NAME, "Solo");
requestJSONObject.put(Comment.COMMENT_EMAIL, "comment email");
requestJSONObject.put(Comment.COMMENT_URL, "comment URL"); requestJSONObject.put(Comment.COMMENT_URL, "comment URL");
requestJSONObject.put(Comment.COMMENT_CONTENT, "comment content"); requestJSONObject.put(Comment.COMMENT_CONTENT, "comment content");
...@@ -123,8 +122,7 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase { ...@@ -123,8 +122,7 @@ public class CommentMgmtServiceTestCase extends AbstractTestCase {
final String pageId = pages.getJSONObject(0).getString(Keys.OBJECT_ID); final String pageId = pages.getJSONObject(0).getString(Keys.OBJECT_ID);
requestJSONObject.put(Keys.OBJECT_ID, pageId); requestJSONObject.put(Keys.OBJECT_ID, pageId);
requestJSONObject.put(Comment.COMMENT_NAME, "comment name"); requestJSONObject.put(Comment.COMMENT_NAME, "Solo");
requestJSONObject.put(Comment.COMMENT_EMAIL, "comment email");
requestJSONObject.put(Comment.COMMENT_URL, "comment URL"); requestJSONObject.put(Comment.COMMENT_URL, "comment URL");
requestJSONObject.put(Comment.COMMENT_CONTENT, "comment content"); requestJSONObject.put(Comment.COMMENT_CONTENT, "comment content");
......
...@@ -61,24 +61,4 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase { ...@@ -61,24 +61,4 @@ public class PreferenceMgmtServiceTestCase extends AbstractTestCase {
preference = preferenceQueryService.getPreference(); preference = preferenceQueryService.getPreference();
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "updated blog title"); Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "updated blog title");
} }
/**
* Update Reply Notification Template.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void updateReplyNotificationTemplate() throws Exception {
final PreferenceMgmtService preferenceMgmtService = getPreferenceMgmtService();
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Option.DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
replyNotificationTemplate.put("subject", "updated subject");
preferenceMgmtService.updateReplyNotificationTemplate(replyNotificationTemplate);
replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.getString("subject"), "updated subject");
}
} }
...@@ -54,17 +54,4 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase { ...@@ -54,17 +54,4 @@ public class PreferenceQueryServiceTestCase extends AbstractTestCase {
Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Solo 的个人博客"); Assert.assertEquals(preference.getString(Option.ID_C_BLOG_TITLE), "Solo 的个人博客");
} }
/**
* Get Reply Notification Template.
*
* @throws Exception exception
*/
@Test(dependsOnMethods = "init")
public void getReplyNotificationTemplate() throws Exception {
final PreferenceQueryService preferenceQueryService = getPreferenceQueryService();
final JSONObject replyNotificationTemplate = preferenceQueryService.getReplyNotificationTemplate();
Assert.assertEquals(replyNotificationTemplate.toString(), Option.DefaultPreference.DEFAULT_REPLY_NOTIFICATION_TEMPLATE);
}
} }
...@@ -48,7 +48,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase { ...@@ -48,7 +48,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1name"); requestJSONObject.put(User.USER_NAME, "user1name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
final String id = userMgmtService.addUser(requestJSONObject); final String id = userMgmtService.addUser(requestJSONObject);
Assert.assertNotNull(id); Assert.assertNotNull(id);
...@@ -65,7 +64,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase { ...@@ -65,7 +64,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
JSONObject requestJSONObject = new JSONObject(); JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user2name"); requestJSONObject.put(User.USER_NAME, "user2name");
requestJSONObject.put(User.USER_EMAIL, "test2@gmail.com");
requestJSONObject.put(User.USER_ROLE, Role.ADMIN_ROLE); requestJSONObject.put(User.USER_ROLE, Role.ADMIN_ROLE);
final String id = userMgmtService.addUser(requestJSONObject); final String id = userMgmtService.addUser(requestJSONObject);
...@@ -91,7 +89,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase { ...@@ -91,7 +89,6 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1 name"); requestJSONObject.put(User.USER_NAME, "user1 name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
try { try {
final String id = userMgmtService.addUser(requestJSONObject); final String id = userMgmtService.addUser(requestJSONObject);
...@@ -110,8 +107,7 @@ public class UserMgmtServiceTestCase extends AbstractTestCase { ...@@ -110,8 +107,7 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
final UserMgmtService userMgmtService = getUserMgmtService(); final UserMgmtService userMgmtService = getUserMgmtService();
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "username"); requestJSONObject.put(User.USER_NAME, "<script></script>");
requestJSONObject.put(User.USER_EMAIL, "<script></script>");
final String id = userMgmtService.addUser(requestJSONObject); final String id = userMgmtService.addUser(requestJSONObject);
} }
...@@ -125,11 +121,11 @@ public class UserMgmtServiceTestCase extends AbstractTestCase { ...@@ -125,11 +121,11 @@ public class UserMgmtServiceTestCase extends AbstractTestCase {
public void removeUser() throws Exception { public void removeUser() throws Exception {
final UserMgmtService userMgmtService = getUserMgmtService(); final UserMgmtService userMgmtService = getUserMgmtService();
final JSONObject user = getUserQueryService().getUserByEmailOrUserName("test1@gmail.com"); final JSONObject user = getUserQueryService().getUserByName("user1name");
Assert.assertNotNull(user); Assert.assertNotNull(user);
userMgmtService.removeUser(user.getString(Keys.OBJECT_ID)); userMgmtService.removeUser(user.getString(Keys.OBJECT_ID));
Assert.assertNull(getUserQueryService().getUserByEmailOrUserName("test1@gmail.com")); Assert.assertNull(getUserQueryService().getUserByName("user1name"));
} }
} }
...@@ -47,7 +47,6 @@ public class UserQueryServiceTestCase extends AbstractTestCase { ...@@ -47,7 +47,6 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
final JSONObject requestJSONObject = new JSONObject(); final JSONObject requestJSONObject = new JSONObject();
requestJSONObject.put(User.USER_NAME, "user1name"); requestJSONObject.put(User.USER_NAME, "user1name");
requestJSONObject.put(User.USER_EMAIL, "test1@gmail.com");
final String id = userMgmtService.addUser(requestJSONObject); final String id = userMgmtService.addUser(requestJSONObject);
Assert.assertNotNull(id); Assert.assertNotNull(id);
...@@ -58,25 +57,21 @@ public class UserQueryServiceTestCase extends AbstractTestCase { ...@@ -58,25 +57,21 @@ public class UserQueryServiceTestCase extends AbstractTestCase {
/** /**
* Get User. * Get User.
*
* @throws Exception exception
*/ */
@Test(dependsOnMethods = "addUser") @Test(dependsOnMethods = "addUser")
public void getUser() throws Exception { public void getUser() {
final UserQueryService userQueryService = getUserQueryService(); final UserQueryService userQueryService = getUserQueryService();
Assert.assertNull(userQueryService.getUser("not found")); Assert.assertNull(userQueryService.getUser("not found"));
} }
/** /**
* Get User By Email. * Get User By Name.
*
* @throws Exception exception
*/ */
@Test(dependsOnMethods = "addUser") @Test(dependsOnMethods = "addUser")
public void getUserByEmail() throws Exception { public void getUserByName() {
final UserQueryService userQueryService = getUserQueryService(); final UserQueryService userQueryService = getUserQueryService();
final JSONObject user = userQueryService.getUserByEmailOrUserName("test1@gmail.com"); final JSONObject user = userQueryService.getUserByName("user1name");
Assert.assertNotNull(user); Assert.assertNotNull(user);
} }
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-2019, b3log.org & hacpai.com
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package org.b3log.solo.util;
import org.b3log.latke.Latkes;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Locale;
/**
* {@link org.b3log.solo.util.Solos} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1, Mar 11, 2018
* @since 0.6.1
*/
public final class SolosTestCase {
/**
* Test method for {@linkplain Solos#getGravatarURL(String, String)}.
*/
@Test
public void getGravatarURL() {
Latkes.init();
final String gravatarURL = Solos.getGravatarURL("test@b3log.org", "128");
Assert.assertEquals(gravatarURL, Solos.GRAVATAR + "bd7e4673cf7fa4b4777353008c86e093?s=128");
}
}
...@@ -17,16 +17,28 @@ ...@@ -17,16 +17,28 @@
# #
# #
# Description: Solo mail configurations. # Description: Solo logging configurations for test.
# Version: 1.0.0.4, Jul 19, 2017 # Version: 1.0.0.0, Mar 3, 2019
# Author: Liang Ding # Author: <a href="http://88250.b3log.org">Liang Ding</a>
# #
mail.user={{EMAIL_ADDRESS}} log4j.rootLogger=INFO,stdout
mail.password={{EMAIL_PASSWORD}}
mail.debug=false log4j.logger.org.b3log.solo=INFO
mail.smtp.host={{SMTP_HOST}} log4j.logger.org.b3log.latke=WARN
mail.smtp.port={{SMTP_PROT}} log4j.logger.org.b3log.latke.util.freemarker.Templates=ERROR
mail.smtp.socketFactory.class=javax.net.ssl.SSLSocketFactory log4j.logger.org.b3log.latke.repository.jdbc.util=WARN
mail.smtp.socketFactory.fallback=false
mail.smtp.socketFactory.port={{SMTP_SOCKETFACTORY_PORT}} log4j.logger.org.eclipse.jetty=WARN
log4j.logger.freemarker=WARN
log4j.logger.com.mchange=WARN
log4j.logger.com.alibaba=WARN
# Print only messages of level ERROR or above in the package noModule.
log4j.logger.noModule=ERROR
# Console appender
log4j.appender.stdout.Encoding=UTF-8
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%-5p]-[%d{yyyy-MM-dd HH:mm:ss}]-[%c:%L]: %m%n
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment