1717 */
1818package org .b3log .solo .bolo .prop ;
1919
20+ import static pers .adlered .blog_platform_export_tool .Launcher .run ;
21+
22+ import java .io .File ;
23+ import java .nio .charset .StandardCharsets ;
24+ import java .util .List ;
25+
26+ import javax .servlet .ServletContext ;
27+ import javax .servlet .http .HttpServletResponse ;
28+
2029import org .apache .commons .fileupload .FileItem ;
2130import org .apache .commons .fileupload .disk .DiskFileItemFactory ;
2231import org .apache .commons .fileupload .servlet .ServletFileUpload ;
3241import org .b3log .solo .SoloServletListener ;
3342import org .b3log .solo .bolo .tool .DeleteFolder ;
3443import org .b3log .solo .model .Article ;
44+ import org .b3log .solo .model .Option ;
3545import org .b3log .solo .repository .UserRepository ;
36- import org .b3log .solo .service .*;
46+ import org .b3log .solo .service .ArticleMgmtService ;
47+ import org .b3log .solo .service .ExportService ;
48+ import org .b3log .solo .service .ImportService ;
49+ import org .b3log .solo .service .InitService ;
50+ import org .b3log .solo .service .OptionQueryService ;
3751import org .b3log .solo .util .Solos ;
3852import org .json .JSONObject ;
3953import org .zeroturnaround .zip .ZipUtil ;
40- import pers .adlered .blog_platform_export_tool .module .TranslateResult ;
4154
42- import javax .servlet .ServletContext ;
43- import javax .servlet .http .HttpServletResponse ;
44- import java .io .File ;
45- import java .nio .charset .StandardCharsets ;
46- import java .util .List ;
47-
48- import static pers .adlered .blog_platform_export_tool .Launcher .run ;
55+ import pers .adlered .blog_platform_export_tool .module .TranslateResult ;
4956
5057/**
5158 * <h3>bolo-solo</h3>
52- * <p>备份服务</p>
59+ * <p>
60+ * 备份服务
61+ * </p>
5362 *
5463 * @author : https://github.com/adlered
5564 * @date : 2020-01-05 13:39
@@ -119,7 +128,7 @@ public void syncGitHubRepos(final RequestContext context) {
119128 }
120129 }
121130
122- @ RequestProcessing (value = "/prop/backup/github/do/upload" , method = {HttpMethod .GET })
131+ @ RequestProcessing (value = "/prop/backup/github/do/upload" , method = { HttpMethod .GET })
123132 public void uploadBackupToGithub (final RequestContext context ) {
124133 if (!Solos .isAdminLoggedIn (context )) {
125134 context .sendError (HttpServletResponse .SC_UNAUTHORIZED );
@@ -128,8 +137,15 @@ public void uploadBackupToGithub(final RequestContext context) {
128137 }
129138
130139 try {
131- exportService .exportGitHub ();
132-
140+ boolean enableAutoFlushGitHubProfile ;
141+ try {
142+ enableAutoFlushGitHubProfile = optionQueryService
143+ .getOptionById (Option .ID_C_ENABLE_AUTO_FLUSH_BLOG_TO_GITHUB_PROFILE )
144+ .optBoolean (Option .OPTION_VALUE );
145+ } catch (Exception e ) {
146+ enableAutoFlushGitHubProfile = false ;
147+ }
148+ exportService .exportGitHub (enableAutoFlushGitHubProfile );
133149 context .renderJSON ().renderCode (200 );
134150 context .renderJSON ().renderMsg ("Exported backup to GitHub manual successfully." );
135151
@@ -141,7 +157,7 @@ public void uploadBackupToGithub(final RequestContext context) {
141157 }
142158 }
143159
144- @ RequestProcessing (value = "/prop/backup/hacpai/do/upload" , method = {HttpMethod .GET })
160+ @ RequestProcessing (value = "/prop/backup/hacpai/do/upload" , method = { HttpMethod .GET })
145161 public void uploadBackupToHacpai (final RequestContext context ) {
146162 if (!Solos .isAdminLoggedIn (context )) {
147163 context .sendError (HttpServletResponse .SC_UNAUTHORIZED );
@@ -163,7 +179,7 @@ public void uploadBackupToHacpai(final RequestContext context) {
163179 }
164180 }
165181
166- @ RequestProcessing (value = "/import/cnblogs" , method = {HttpMethod .POST })
182+ @ RequestProcessing (value = "/import/cnblogs" , method = { HttpMethod .POST })
167183 public void importFromCnblogs (final RequestContext context ) {
168184 if (!Solos .isAdminLoggedIn (context )) {
169185 context .sendError (HttpServletResponse .SC_UNAUTHORIZED );
@@ -198,7 +214,8 @@ public void importFromCnblogs(final RequestContext context) {
198214 article .put (Article .ARTICLE_ABSTRACT , "" );
199215 article .put (Article .ARTICLE_CONTENT , content );
200216 article .put (Article .ARTICLE_TAGS_REF , "待分类" );
201- final String permalink = "/articles/" + DateFormatUtils .format (i .getDate (), "yyyy/MM/dd" ) + "/" + article .optString (Keys .OBJECT_ID ) + ".html" ;
217+ final String permalink = "/articles/" + DateFormatUtils .format (i .getDate (), "yyyy/MM/dd" ) + "/"
218+ + article .optString (Keys .OBJECT_ID ) + ".html" ;
202219 article .put (Article .ARTICLE_PERMALINK , permalink );
203220 article .put (Article .ARTICLE_STATUS , Article .ARTICLE_STATUS_C_PUBLISHED );
204221 article .put (Article .ARTICLE_SIGN_ID , "1" );
@@ -242,7 +259,7 @@ public void importFromCnblogs(final RequestContext context) {
242259 return ;
243260 }
244261
245- @ RequestProcessing (value = "/import/markdown" , method = {HttpMethod .POST })
262+ @ RequestProcessing (value = "/import/markdown" , method = { HttpMethod .POST })
246263 public void importFromMarkdown (final RequestContext context ) {
247264 if (!Solos .isAdminLoggedIn (context )) {
248265 context .sendError (HttpServletResponse .SC_UNAUTHORIZED );
0 commit comments