Commit 4fe9d288 authored by Van's avatar Van

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

parents d6354ff1 910824c9
...@@ -56,23 +56,23 @@ ...@@ -56,23 +56,23 @@
### 开始使用 ### 开始使用
![init](https://user-images.githubusercontent.com/873584/52908896-800a2d80-32b9-11e9-9702-43bab360651d.png) ![start](https://user-images.githubusercontent.com/873584/54970301-9001e500-4fbc-11e9-83de-bf3841adecff.png)
### 后台首页 ### 后台首页
![console-index](https://user-images.githubusercontent.com/873584/52255442-85788700-294d-11e9-8c8e-38bdcba6736c.png) ![console](https://user-images.githubusercontent.com/873584/54970489-4796f700-4fbd-11e9-837b-93394ff80304.png)
### 编辑文章 ### 编辑文章
![article](https://user-images.githubusercontent.com/873584/52255441-85788700-294d-11e9-8fb4-f72e353a76de.png) ![post](https://user-images.githubusercontent.com/873584/54970405-ea9b4100-4fbc-11e9-9e05-5f5e4b94d2b8.png)
### 选择皮肤 ### 选择皮肤
![skin](https://user-images.githubusercontent.com/873584/52255444-85788700-294d-11e9-9c21-8758bad2c3b4.png) ![skin](https://user-images.githubusercontent.com/873584/54970463-22a28400-4fbd-11e9-953e-6922a12f5f11.png)
### 前台界面 ### 前台界面
![index](https://user-images.githubusercontent.com/873584/52255333-19961e80-294d-11e9-85c4-92bc508864a4.png) ![index](https://user-images.githubusercontent.com/873584/54970236-5a5cfc00-4fbc-11e9-8d04-d7a517f78839.png)
## 安装 ## 安装
...@@ -98,7 +98,8 @@ docker pull b3log/solo ...@@ -98,7 +98,8 @@ docker pull b3log/solo
* 使用 MySQL * 使用 MySQL
先手动建库(字符集使用 `utf8mb4`,排序规则 `utf8mb4_general_ci`),然后启动容器: 先手动建库(库名 `solo`,字符集使用 `utf8mb4`,排序规则 `utf8mb4_general_ci`),然后启动容器:
```shell ```shell
docker run --detach --name solo --network=host \ docker run --detach --name solo --network=host \
--env RUNTIME_DB="MYSQL" \ --env RUNTIME_DB="MYSQL" \
...@@ -110,7 +111,7 @@ docker pull b3log/solo ...@@ -110,7 +111,7 @@ docker pull b3log/solo
``` ```
为了简单,使用了主机网络模式来连接主机上的 MySQL。 为了简单,使用了主机网络模式来连接主机上的 MySQL。
* 使用 H2 Databse * 使用 H2 Database
```shell ```shell
docker run --detach --name solo --volume ~/solo_h2/:/opt/solo/h2/ --publish 8080:8080 \ docker run --detach --name solo --volume ~/solo_h2/:/opt/solo/h2/ --publish 8080:8080 \
......
...@@ -74,7 +74,7 @@ ...@@ -74,7 +74,7 @@
</scm> </scm>
<properties> <properties>
<org.b3log.latke.version>2.4.47</org.b3log.latke.version> <org.b3log.latke.version>2.4.48</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>
......
...@@ -107,7 +107,7 @@ public final class Starter { ...@@ -107,7 +107,7 @@ public final class Starter {
final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows"); final boolean isWindows = System.getProperty("os.name").toLowerCase().contains("windows");
final String cmdSyntax = isWindows ? "java -cp \"WEB-INF/lib/*;WEB-INF/classes\" org.b3log.solo.Starter" final String cmdSyntax = isWindows ? "java -cp \"WEB-INF/lib/*;WEB-INF/classes\" org.b3log.solo.Starter"
: "java -cp \"WEB-INF/lib/*:WEB-INF/classes\" org.b3log.solo.Starter"; : "java -cp \"WEB-INF/lib/*:WEB-INF/classes\" org.b3log.solo.Starter";
final String header = "\nSolo 是一款小而美的 Java 博客系统。\n\n"; final String header = "\nSolo 是一款小而美的博客系统,专为程序员设计。\n\n";
final String footer = "\n提需求或报告缺陷请到项目网站: https://github.com/b3log/solo\n\n"; final String footer = "\n提需求或报告缺陷请到项目网站: https://github.com/b3log/solo\n\n";
try { try {
commandLine = commandLineParser.parse(options, args); commandLine = commandLineParser.parse(options, args);
......
...@@ -48,7 +48,7 @@ import org.json.JSONObject; ...@@ -48,7 +48,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://hacpai.com/member/armstrong">ArmstrongCN</a> * @author <a href="https://hacpai.com/member/armstrong">ArmstrongCN</a>
* @version 1.0.2.18, Feb 21, 2019 * @version 1.0.2.19, Mar 27, 2019
* @since 0.3.1 * @since 0.3.1
*/ */
@Singleton @Singleton
...@@ -124,7 +124,7 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> { ...@@ -124,7 +124,7 @@ public class B3ArticleSender extends AbstractEventListener<JSONObject> {
put("article", article). put("article", article).
put("client", client); put("client", client);
final HttpResponse response = HttpRequest.post("https://rhythm.b3log.org/api/article").bodyText(requestJSONObject.toString()). final HttpResponse response = HttpRequest.post("https://rhythm.b3log.org/api/article").bodyText(requestJSONObject.toString()).
connectionTimeout(3000).timeout(7000). connectionTimeout(3000).timeout(7000).trustAllCerts(true).
contentTypeJson().header("User-Agent", Solos.USER_AGENT).send(); contentTypeJson().header("User-Agent", Solos.USER_AGENT).send();
LOGGER.log(Level.INFO, "Pushed an article [title={0}] to Rhy, response [{1}]", title, response.toString()); LOGGER.log(Level.INFO, "Pushed an article [title={0}] to Rhy, response [{1}]", title, response.toString());
......
...@@ -43,7 +43,7 @@ import org.json.JSONObject; ...@@ -43,7 +43,7 @@ import org.json.JSONObject;
* This listener is responsible for sending comment to B3log Rhythm. Sees <a href="https://hacpai.com/b3log">B3log 构思</a> for more details. * This listener is responsible for sending comment to B3log Rhythm. Sees <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.1.5, Feb 9, 2019 * @version 1.0.1.6, Mar 27, 2019
* @since 0.5.5 * @since 0.5.5
*/ */
@Singleton @Singleton
...@@ -116,6 +116,7 @@ public class B3CommentSender extends AbstractEventListener<JSONObject> { ...@@ -116,6 +116,7 @@ public class B3CommentSender extends AbstractEventListener<JSONObject> {
put("client", client); put("client", client);
HttpRequest.post("https://rhythm.b3log.org/api/comment").bodyText(requestJSONObject.toString()). HttpRequest.post("https://rhythm.b3log.org/api/comment").bodyText(requestJSONObject.toString()).
connectionTimeout(3000).timeout(7000).trustAllCerts(true).
header("User-Agent", Solos.USER_AGENT).contentTypeJson().sendAsync(); header("User-Agent", Solos.USER_AGENT).contentTypeJson().sendAsync();
LOGGER.log(Level.DEBUG, "Pushed a comment to Sym"); LOGGER.log(Level.DEBUG, "Pushed a comment to Sym");
} catch (final Exception e) { } catch (final Exception e) {
......
...@@ -47,7 +47,7 @@ import java.util.Date; ...@@ -47,7 +47,7 @@ import java.util.Date;
* Receiving articles and comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details. * Receiving articles and comments from B3log community. Visits <a href="https://hacpai.com/b3log">B3log 构思</a> for more details.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.0.1.0, Feb 18, 2019 * @version 2.0.1.1, Mar 26, 2019
* @since 0.5.5 * @since 0.5.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -153,7 +153,9 @@ public class B3Receiver { ...@@ -153,7 +153,9 @@ public class B3Receiver {
final JSONObject articleAuthor = userRepository.getByUserName(articleAuthorName); final JSONObject articleAuthor = userRepository.getByUserName(articleAuthorName);
if (null == articleAuthor) { if (null == articleAuthor) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not found user [" + articleAuthorName + "]"); final String msg = "Not found user [" + articleAuthorName + "]";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
...@@ -162,18 +164,21 @@ public class B3Receiver { ...@@ -162,18 +164,21 @@ public class B3Receiver {
final String key = articleAuthor.optString(UserExt.USER_B3_KEY); final String key = articleAuthor.optString(UserExt.USER_B3_KEY);
if (!StringUtils.equals(key, b3Key)) { if (!StringUtils.equals(key, b3Key)) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Wrong key"); final String msg = "Wrong key";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
final JSONObject symArticle = requestJSONObject.optJSONObject(Article.ARTICLE); final JSONObject symArticle = requestJSONObject.optJSONObject(Article.ARTICLE);
final String title = symArticle.optString("title");
final String articleId = symArticle.optString("id"); final String articleId = symArticle.optString("id");
final JSONObject oldArticle = articleQueryService.getArticleById(articleId); final JSONObject oldArticle = articleQueryService.getArticleById(articleId);
if (null == oldArticle) { if (null == oldArticle) {
final JSONObject article = new JSONObject(). final JSONObject article = new JSONObject().
put(Keys.OBJECT_ID, symArticle.optString("id")). put(Keys.OBJECT_ID, symArticle.optString("id")).
put(Article.ARTICLE_TITLE, symArticle.optString("title")). put(Article.ARTICLE_TITLE, title).
put(Article.ARTICLE_CONTENT, symArticle.optString("content")). put(Article.ARTICLE_CONTENT, symArticle.optString("content")).
put(Article.ARTICLE_TAGS_REF, symArticle.optString("tags")); put(Article.ARTICLE_TAGS_REF, symArticle.optString("tags"));
article.put(Article.ARTICLE_AUTHOR_ID, articleAuthor.getString(Keys.OBJECT_ID)); article.put(Article.ARTICLE_AUTHOR_ID, articleAuthor.getString(Keys.OBJECT_ID));
...@@ -187,6 +192,7 @@ public class B3Receiver { ...@@ -187,6 +192,7 @@ public class B3Receiver {
article.put(Article.ARTICLE_CONTENT, content); article.put(Article.ARTICLE_CONTENT, content);
final JSONObject addRequest = new JSONObject().put(Article.ARTICLE, article); final JSONObject addRequest = new JSONObject().put(Article.ARTICLE, article);
articleMgmtService.addArticle(addRequest); articleMgmtService.addArticle(addRequest);
LOGGER.log(Level.INFO, "Added an article [" + title + "] via Sym");
return; return;
} }
...@@ -199,6 +205,7 @@ public class B3Receiver { ...@@ -199,6 +205,7 @@ public class B3Receiver {
oldArticle.put(Common.POST_TO_COMMUNITY, false); // Do not send to rhythm oldArticle.put(Common.POST_TO_COMMUNITY, false); // Do not send to rhythm
final JSONObject updateRequest = new JSONObject().put(Article.ARTICLE, oldArticle); final JSONObject updateRequest = new JSONObject().put(Article.ARTICLE, oldArticle);
articleMgmtService.updateArticle(updateRequest); articleMgmtService.updateArticle(updateRequest);
LOGGER.log(Level.INFO, "Updated an article [" + title + "] via Sym");
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, e.getMessage(), e); LOGGER.log(Level.ERROR, e.getMessage(), e);
ret.put(Keys.CODE, 1).put(Keys.MSG, e.getMessage()); ret.put(Keys.CODE, 1).put(Keys.MSG, e.getMessage());
...@@ -257,7 +264,9 @@ public class B3Receiver { ...@@ -257,7 +264,9 @@ public class B3Receiver {
final JSONObject articleAuthor = userRepository.getByUserName(articleAuthorName); final JSONObject articleAuthor = userRepository.getByUserName(articleAuthorName);
if (null == articleAuthor) { if (null == articleAuthor) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not found user [" + articleAuthorName + "]"); final String msg = "Not found user [" + articleAuthorName + "]";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
...@@ -266,7 +275,9 @@ public class B3Receiver { ...@@ -266,7 +275,9 @@ public class B3Receiver {
final String key = articleAuthor.optString(UserExt.USER_B3_KEY); final String key = articleAuthor.optString(UserExt.USER_B3_KEY);
if (!StringUtils.equals(key, b3Key)) { if (!StringUtils.equals(key, b3Key)) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Wrong key"); final String msg = "Wrong key";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
...@@ -275,7 +286,9 @@ public class B3Receiver { ...@@ -275,7 +286,9 @@ public class B3Receiver {
final JSONObject article = articleRepository.get(articleId); final JSONObject article = articleRepository.get(articleId);
if (null == article) { if (null == article) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not found the specified article [id=" + articleId + "]"); final String msg = "Not found the specified article [id=" + articleId + "]";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
...@@ -298,6 +311,7 @@ public class B3Receiver { ...@@ -298,6 +311,7 @@ public class B3Receiver {
addUserReq.put(UserExt.USER_B3_KEY, ""); addUserReq.put(UserExt.USER_B3_KEY, "");
try { try {
userMgmtService.addUser(addUserReq); userMgmtService.addUser(addUserReq);
LOGGER.log(Level.INFO, "Created a user [role=" + Role.VISITOR_ROLE + "] via Sym comment");
} catch (final Exception e) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Adds a user [" + commentName + "] failed", e); LOGGER.log(Level.ERROR, "Adds a user [" + commentName + "] failed", e);
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
...@@ -309,7 +323,9 @@ public class B3Receiver { ...@@ -309,7 +323,9 @@ public class B3Receiver {
if (!optionQueryService.allowComment() || !article.optBoolean(Article.ARTICLE_COMMENTABLE)) { if (!optionQueryService.allowComment() || !article.optBoolean(Article.ARTICLE_COMMENTABLE)) {
ret.put(Keys.CODE, 1); ret.put(Keys.CODE, 1);
ret.put(Keys.MSG, "Not allow comment"); final String msg = "Not allow comment";
ret.put(Keys.MSG, msg);
LOGGER.log(Level.WARN, msg);
return; return;
} }
......
...@@ -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.7, Mar 4, 2019 * @version 1.0.0.8, Mar 27, 2019
* @since 2.9.5 * @since 2.9.5
*/ */
@RequestProcessor @RequestProcessor
...@@ -202,6 +202,16 @@ public class OAuthProcessor { ...@@ -202,6 +202,16 @@ public class OAuthProcessor {
LOGGER.log(Level.ERROR, "Register via oauth failed", e); LOGGER.log(Level.ERROR, "Register via oauth failed", e);
context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
} else {
user.put(UserExt.USER_GITHUB_ID, openId);
try {
userMgmtService.updateUser(user);
} catch (final Exception e) {
LOGGER.log(Level.ERROR, "Update user GitHub id failed", e);
context.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return; return;
} }
} }
......
...@@ -53,7 +53,7 @@ import java.util.stream.Collectors; ...@@ -53,7 +53,7 @@ import java.util.stream.Collectors;
* Export service. * Export service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.3, Mar 19, 2019 * @version 1.1.0.4, Mar 27, 2019
* @since 2.5.0 * @since 2.5.0
*/ */
@Service @Service
...@@ -240,7 +240,8 @@ public class ExportService { ...@@ -240,7 +240,8 @@ public class ExportService {
bodyBuilder.append("### 热议\n").append(mostCmtBuilder); bodyBuilder.append("### 热议\n").append(mostCmtBuilder);
} }
final HttpResponse response = HttpRequest.post("https://hacpai.com/github/repos").connectionTimeout(7000).timeout(60000).header("User-Agent", Solos.USER_AGENT). final HttpResponse response = HttpRequest.post("https://hacpai.com/github/repos").
connectionTimeout(7000).timeout(60000).trustAllCerts(true).header("User-Agent", Solos.USER_AGENT).
form("userName", userName, form("userName", userName,
"userB3Key", userB3Ke, "userB3Key", userB3Ke,
"clientName", "Solo", "clientName", "Solo",
......
...@@ -48,7 +48,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -48,7 +48,7 @@ import javax.servlet.http.HttpServletResponse;
* @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/DASHU">DASHU</a> * @author <a href="https://hacpai.com/member/DASHU">DASHU</a>
* @author <a href="https://github.com/nanolikeyou">nanolikeyou</a> * @author <a href="https://github.com/nanolikeyou">nanolikeyou</a>
* @version 1.1.0.17, Mar 20, 2019 * @version 1.1.0.18, Mar 27, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -156,7 +156,8 @@ public class UserMgmtService { ...@@ -156,7 +156,8 @@ public class UserMgmtService {
* "userName": "", * "userName": "",
* "userRole": "", * "userRole": "",
* "userURL": "", * "userURL": "",
* "userB3Key": "" * "userB3Key": "",
* "userGitHubId": "" // optional
* @throws ServiceException service exception * @throws ServiceException service exception
*/ */
public void updateUser(final JSONObject requestJSONObject) throws ServiceException { public void updateUser(final JSONObject requestJSONObject) throws ServiceException {
...@@ -192,6 +193,11 @@ public class UserMgmtService { ...@@ -192,6 +193,11 @@ public class UserMgmtService {
final String userB3Key = requestJSONObject.optString(UserExt.USER_B3_KEY); final String userB3Key = requestJSONObject.optString(UserExt.USER_B3_KEY);
oldUser.put(UserExt.USER_B3_KEY, userB3Key); oldUser.put(UserExt.USER_B3_KEY, userB3Key);
final String userGitHubId = requestJSONObject.optString(UserExt.USER_GITHUB_ID);
if (StringUtils.isNotBlank(userGitHubId)) {
oldUser.put(UserExt.USER_GITHUB_ID, userGitHubId);
}
userRepository.update(oldUserId, oldUser); userRepository.update(oldUserId, oldUser);
transaction.commit(); transaction.commit();
} catch (final RepositoryException e) { } catch (final RepositoryException e) {
......
...@@ -36,9 +36,9 @@ ...@@ -36,9 +36,9 @@
<a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a> <a class="github__link" href="javascript:$('ul').slideToggle()">查看 GitHub 数据使用说明</a>
<div class="github__text"> <div class="github__text">
<ul> <ul>
<li>获取用户名、昵称、头像用于账号初始化</li> <li>获取用户名、头像等用于初始化</li>
<li>获取公开仓库信息用于展示</li> <li>获取公开仓库信息用于展示</li>
<li>不会对你的数据进行任何写入操作</li> <li>不会对你的已有数据进行写入</li>
</ul> </ul>
</div> </div>
<label class="github__check"> <label class="github__check">
......
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