Skip to content

Commit

Permalink
🎨 提供手动同步GitHub仓库功能 closed #113
Browse files Browse the repository at this point in the history
  • Loading branch information
adlered committed Dec 16, 2020
1 parent 5644d87 commit 3344dcb
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 0 deletions.
Empty file added git
Empty file.
22 changes: 22 additions & 0 deletions src/main/java/org/b3log/solo/bolo/prop/BackupService.java
Expand Up @@ -94,6 +94,28 @@ public class BackupService {
@Inject
private ImportService importService;

@RequestProcessing(value = "/prop/backup/github/do/upload", method = {HttpMethod.GET})
public void uploadBackupToGithub(final RequestContext context) {
if (!Solos.isAdminLoggedIn(context)) {
context.sendError(HttpServletResponse.SC_UNAUTHORIZED);

return;
}

try {
exportService.exportGitHub();

context.renderJSON().renderCode(200);
context.renderJSON().renderMsg("Exported backup to GitHub manual successfully.");

return ;
} catch (final Exception e) {
context.sendError(500);

return ;
}
}

@RequestProcessing(value = "/prop/backup/hacpai/do/upload", method = {HttpMethod.GET})
public void uploadBackupToHacpai(final RequestContext context) {
if (!Solos.isAdminLoggedIn(context)) {
Expand Down
30 changes: 30 additions & 0 deletions src/main/webapp/admin/admin-tool-box.ftl
Expand Up @@ -40,6 +40,23 @@
}
});
}
function backupToGithub() {
$.ajax({
type: 'GET',
url: 'prop/backup/github/do/upload',
async: false,
success: function (res) {
alert("备份成功!");
},
error: function (e) {
if (e.status === 404) {
alert("抱歉,当前 Bolo 版本不支持该功能!小提示:重启服务端,等待 5 分钟后,Bolo 会自动备份文章到链滴(功能开启的情况下)。");
} else {
alert("备份失败!请检查偏好设置,并确定链滴用户名和 B3log Key 设置正确。");
}
}
});
}
function refreshUsite() {
$.ajax({
type: 'GET',
Expand Down Expand Up @@ -119,6 +136,19 @@
</td>
</tr>
</tbody>
<tbody class="table-oddRow">
<tr class="table-hasExpend">
<td style="padding-left: 20px; padding-right: 20px;">
手动上传文章备份至GitHub
</td>
<td>
手动将你的<b>公开</b>文章备份上传至GitHub
</td>
<td style="padding-right: 20px;">
<button onclick="backupToGithub()" style="float:right">确定备份</button>
</td>
</tr>
</tbody>
</table>
</div>
</div>
Expand Down
Empty file added ssh
Empty file.

0 comments on commit 3344dcb

Please sign in to comment.