Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
a883b06e
Unverified
Commit
a883b06e
authored
May 21, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
同步 GitHub solo-blog 仓库功能 #125
parent
7268a935
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
4 deletions
+20
-4
src/main/java/org/b3log/solo/model/Option.java
src/main/java/org/b3log/solo/model/Option.java
+6
-1
src/main/java/org/b3log/solo/service/CronMgmtService.java
src/main/java/org/b3log/solo/service/CronMgmtService.java
+2
-1
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+7
-1
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
...in/java/org/b3log/solo/service/PreferenceMgmtService.java
+5
-1
No files found.
src/main/java/org/b3log/solo/model/Option.java
View file @
a883b06e
...
...
@@ -20,7 +20,7 @@ import org.json.JSONObject;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/hzchendou">hzchendou</a>
* @version 1.
6.0.6, Apr 6
, 2020
* @version 1.
7.0.0, May 20
, 2020
* @since 0.6.0
*/
public
final
class
Option
{
...
...
@@ -103,6 +103,11 @@ public final class Option {
*/
public
static
final
String
ID_C_SYNC_GITHUB
=
"syncGitHub"
;
/**
* Key of GitHub PAT (personal access token).
*/
public
static
final
String
ID_C_GITHUB_PAT
=
"githubPAT"
;
/**
* Key of enable sync (pull) GitHub. 拉取并展示仓库 https://hacpai.com/article/1557238327458
* https://github.com/b3log/solo/issues/12825
...
...
src/main/java/org/b3log/solo/service/CronMgmtService.java
View file @
a883b06e
...
...
@@ -27,7 +27,7 @@ import java.util.concurrent.TimeUnit;
* Cron management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
4, Apr 18, 2019
* @version 1.0.0.
5, May 20, 2020
* @since 2.9.7
*/
@Service
...
...
@@ -106,6 +106,7 @@ public class CronMgmtService {
articleMgmtService
.
refreshGitHub
();
userMgmtService
.
refreshUSite
();
exportService
.
exportHacPai
();
exportService
.
exportGitHub
();
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Executes cron failed"
,
e
);
}
finally
{
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
a883b06e
...
...
@@ -47,7 +47,7 @@ import java.util.List;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.4
0, Apr 3
0, 2020
* @version 1.5.2.4
1, May 2
0, 2020
* @since 0.4.0
*/
@Service
...
...
@@ -526,6 +526,12 @@ public class InitService {
syncGitHubOpt
.
put
(
Option
.
OPTION_VALUE
,
DefaultPreference
.
DEFAULT_SYNC_GITHUB
);
optionRepository
.
add
(
syncGitHubOpt
);
final
JSONObject
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
pullGitHubOpt
=
new
JSONObject
();
pullGitHubOpt
.
put
(
Keys
.
OBJECT_ID
,
Option
.
ID_C_PULL_GITHUB
);
pullGitHubOpt
.
put
(
Option
.
OPTION_CATEGORY
,
Option
.
CATEGORY_C_PREFERENCE
);
...
...
src/main/java/org/b3log/solo/service/PreferenceMgmtService.java
View file @
a883b06e
...
...
@@ -35,7 +35,7 @@ import java.util.Locale;
* Preference management service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.4.0.
7, Apr 15
, 2020
* @version 1.4.0.
8, May 20
, 2020
* @since 0.4.0
*/
@Service
...
...
@@ -207,6 +207,9 @@ public class PreferenceMgmtService {
syncGitHubOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_SYNC_GITHUB
));
optionRepository
.
update
(
Option
.
ID_C_SYNC_GITHUB
,
syncGitHubOpt
);
final
String
githubPATVal
=
preference
.
optString
(
Option
.
ID_C_GITHUB_PAT
);
emptyPreferenceOptSave
(
Option
.
ID_C_GITHUB_PAT
,
githubPATVal
);
final
JSONObject
pullGitHubOpt
=
optionRepository
.
get
(
Option
.
ID_C_PULL_GITHUB
);
pullGitHubOpt
.
put
(
Option
.
OPTION_VALUE
,
preference
.
optString
(
Option
.
ID_C_PULL_GITHUB
));
optionRepository
.
update
(
Option
.
ID_C_PULL_GITHUB
,
pullGitHubOpt
);
...
...
@@ -268,6 +271,7 @@ public class PreferenceMgmtService {
private
void
emptyPreferenceOptSave
(
final
String
optID
,
final
String
val
)
throws
Exception
{
// 该方法用于向后兼容,如果数据库中不存在该配置项则创建再保存
JSONObject
opt
=
optionRepository
.
get
(
optID
);
if
(
null
==
opt
)
{
opt
=
new
JSONObject
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment