Commit 1c9c8514 authored by Liang Ding's avatar Liang Ding

同步 GitHub solo-blog 仓库功能 Fix #125

parent 3f7c4c84
......@@ -265,10 +265,6 @@ public class ExportService {
return;
}
if (!preference.optBoolean(Option.ID_C_SYNC_GITHUB)) {
return;
}
String pat = preference.optString(Option.ID_C_GITHUB_PAT);
if (StringUtils.isBlank(pat)) {
return;
......
/*
* Solo - A small and beautiful blogging system written in Java.
* Copyright (c) 2010-present, b3log.org
*
* Solo is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
* See the Mulan PSL v2 for more details.
*/
package org.b3log.solo.upgrade;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.b3log.latke.Keys;
import org.b3log.latke.ioc.BeanManager;
import org.b3log.latke.repository.Transaction;
import org.b3log.solo.model.Option;
import org.b3log.solo.repository.OptionRepository;
import org.json.JSONObject;
/**
* Upgrade script from v4.1.0 to v4.2.0.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.0, May 21, 2020
* @since 4.2.0
*/
public final class V410_420 {
/**
* Logger.
*/
private static final Logger LOGGER = LogManager.getLogger(V410_420.class);
/**
* Performs upgrade from v4.1.0 to v4.2.0.
*
* @throws Exception upgrade fails
*/
public static void perform() throws Exception {
final String fromVer = "4.1.0";
final String toVer = "4.2.0";
LOGGER.log(Level.INFO, "Upgrading from version [" + fromVer + "] to version [" + toVer + "]....");
final BeanManager beanManager = BeanManager.getInstance();
final OptionRepository optionRepository = beanManager.getReference(OptionRepository.class);
try {
final Transaction transaction = optionRepository.beginTransaction();
JSONObject githubPATOpt = optionRepository.get(Option.ID_C_GITHUB_PAT);
if (null == githubPATOpt) {
githubPATOpt = new JSONObject();
githubPATOpt.put(Keys.OBJECT_ID, Option.ID_C_GITHUB_PAT);
githubPATOpt.put(Option.OPTION_CATEGORY, Option.CATEGORY_C_PREFERENCE);
githubPATOpt.put(Option.OPTION_VALUE, "");
optionRepository.add(githubPATOpt);
}
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 + "]");
}
}
}
......@@ -146,6 +146,10 @@
${customVars1Label}
<input id="customVars" class="normalInput" type="text"/>
</label>
<label>
${githubPATLabel}
<input id="githubPAT" class="normalInput" type="text"/>
</label>
<label>
<div class="fn__flex-inline">
${enableArticleUpdateHint1Label}
......
This diff is collapsed.
......@@ -14,7 +14,7 @@
*
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.0.5, Apr 6, 2020
* @version 1.3.0.6, May 20, 2020
*/
/* preference 相关操作 */
......@@ -59,6 +59,7 @@ admin.preference = {
$('#relevantArticlesDisplayCount').val(preference.relevantArticlesDisplayCount)
$('#randomArticlesDisplayCount').val(preference.randomArticlesDisplayCount)
$('#customVars').val(preference.customVars)
$('#githubPAT').val(preference.githubPAT)
'true' === preference.enableArticleUpdateHint ? $('#enableArticleUpdateHint').attr('checked', 'checked') : $('#enableArticleUpdateHint').removeAttr('checked')
'true' === preference.allowVisitDraftViaPermalink ? $('#allowVisitDraftViaPermalink').attr('checked', 'checked') : $('#allowVisitDraftViaPermalink').removeAttr('checked')
......@@ -214,6 +215,7 @@ admin.preference = {
'showCodeBlockLn': $('#showCodeBlockLn').prop('checked'),
'commentable': $('#commentable').prop('checked'),
'customVars': $('#customVars').val(),
'githubPAT': $('#githubPAT').val(),
'footnotes': $('#footnotes').prop('checked'),
'showToC': $('#showToC').prop('checked'),
'autoSpace': $('#autoSpace').prop('checked'),
......
......@@ -43,6 +43,7 @@ hljsThemeLabel=hljs theme:
tocLabel=ToC
removeUnusedArchivesLabel=Remove Unused Archives
syncGitHubLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">Backup all articles to HacPai</a>:
githubPATLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">Export public articles to GitHub repo via PAT (personal access token)</a>:
pullGitHubLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">Allow to pull GitHub repositories</a>:
queryUserFailedLabel=Query user info failed
commentContentLabel=Content
......
......@@ -43,6 +43,7 @@ hljsThemeLabel=\u4EE3\u7801\u9AD8\u4EAE\u4E3B\u9898\uFF1A
tocLabel=\u76EE\u5F55
removeUnusedArchivesLabel=\u79FB\u9664\u672A\u4F7F\u7528\u5B58\u6863
syncGitHubLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">\u5907\u4EFD\u6240\u6709\u6587\u7AE0\u5230\u793E\u533A</a>\uFF1A
githubPATLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">\u901A\u8FC7 PAT (personal access token) \u5BFC\u51FA\u516C\u5F00\u6587\u7AE0\u5230 GitHub \u4ED3\u5E93</a>\uFF1A
pullGitHubLabel=<a href="https://hacpai.com/article/1557238327458" target="_blank">\u62C9\u53D6 GitHub \u4ED3\u5E93\u4FE1\u606F</a>\uFF1A
queryUserFailedLabel=\u67E5\u8BE2\u7528\u6237\u4FE1\u606F\u5931\u8D25
commentContentLabel=\u8BC4\u8BBA\u5185\u5BB9
......
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