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
e8c69eb5
Commit
e8c69eb5
authored
Nov 11, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
✨
#12372
parent
7a74d407
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
8 deletions
+31
-8
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+9
-8
src/main/webapp/admin-others.ftl
src/main/webapp/admin-others.ftl
+1
-0
src/main/webapp/js/admin/others.js
src/main/webapp/js/admin/others.js
+21
-0
No files found.
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
e8c69eb5
...
@@ -408,7 +408,7 @@ public class AdminConsole {
...
@@ -408,7 +408,7 @@ public class AdminConsole {
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
inputStream
);
response
.
setContentType
(
"application/zip"
);
response
.
setContentType
(
"application/zip"
);
final
String
fileName
=
"solo-
"
+
date
+
".sql
.zip"
;
final
String
fileName
=
"solo-
sql-"
+
date
+
"
.zip"
;
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
...
@@ -462,7 +462,7 @@ public class AdminConsole {
...
@@ -462,7 +462,7 @@ public class AdminConsole {
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
inputStream
);
response
.
setContentType
(
"application/zip"
);
response
.
setContentType
(
"application/zip"
);
final
String
fileName
=
"solo-
"
+
date
+
".json
.zip"
;
final
String
fileName
=
"solo-
json-"
+
date
+
"
.zip"
;
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
...
@@ -498,12 +498,13 @@ public class AdminConsole {
...
@@ -498,12 +498,13 @@ public class AdminConsole {
final
String
tmpDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
final
String
tmpDir
=
System
.
getProperty
(
"java.io.tmpdir"
);
final
String
date
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMddHHmmss"
);
final
String
date
=
DateFormatUtils
.
format
(
new
Date
(),
"yyyyMMddHHmmss"
);
String
localFilePath
=
tmpDir
+
File
.
separator
+
"solo-
"
+
date
+
"-hexo/"
;
String
localFilePath
=
tmpDir
+
File
.
separator
+
"solo-
hexo-"
+
date
;
LOGGER
.
trace
(
localFilePath
);
LOGGER
.
trace
(
localFilePath
);
final
File
localFile
=
new
File
(
localFilePath
);
final
File
localFile
=
new
File
(
localFilePath
);
final
File
postDir
=
new
File
(
localFilePath
+
"posts"
);
final
File
passwordDir
=
new
File
(
localFilePath
+
"passwords"
);
final
File
postDir
=
new
File
(
localFilePath
+
File
.
separator
+
"posts"
);
final
File
draftDir
=
new
File
(
localFilePath
+
"drafts"
);
final
File
passwordDir
=
new
File
(
localFilePath
+
File
.
separator
+
"passwords"
);
final
File
draftDir
=
new
File
(
localFilePath
+
File
.
separator
+
"drafts"
);
try
{
try
{
if
(!
postDir
.
mkdirs
())
{
if
(!
postDir
.
mkdirs
())
{
...
@@ -532,7 +533,7 @@ public class AdminConsole {
...
@@ -532,7 +533,7 @@ public class AdminConsole {
IOUtils
.
closeQuietly
(
inputStream
);
IOUtils
.
closeQuietly
(
inputStream
);
response
.
setContentType
(
"application/zip"
);
response
.
setContentType
(
"application/zip"
);
final
String
fileName
=
"solo-
"
+
date
+
".hexo
.zip"
;
final
String
fileName
=
"solo-
hexo-"
+
date
+
"
.zip"
;
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment; filename=\""
+
fileName
+
"\""
);
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
final
ServletOutputStream
outputStream
=
response
.
getOutputStream
();
...
@@ -575,7 +576,7 @@ public class AdminConsole {
...
@@ -575,7 +576,7 @@ public class AdminConsole {
final
String
text
=
article
.
optString
(
"front"
)
+
"\n----\n"
+
article
.
optString
(
"content"
);
final
String
text
=
article
.
optString
(
"front"
)
+
"\n----\n"
+
article
.
optString
(
"content"
);
try
{
try
{
final
OutputStream
output
=
new
FileOutputStream
(
dirPath
+
filename
);
final
OutputStream
output
=
new
FileOutputStream
(
dirPath
+
File
.
separator
+
filename
);
IOUtils
.
write
(
text
.
getBytes
(
"UTF-8"
),
output
);
IOUtils
.
write
(
text
.
getBytes
(
"UTF-8"
),
output
);
IOUtils
.
closeQuietly
(
output
);
IOUtils
.
closeQuietly
(
output
);
}
catch
(
final
Exception
e
)
{
}
catch
(
final
Exception
e
)
{
...
...
src/main/webapp/admin-others.ftl
View file @
e8c69eb5
...
@@ -51,6 +51,7 @@
...
@@ -51,6 +51,7 @@
<button class="margin12" onclick="admin.others.exportSQL();">${exportSQLLabel}</button>
<button class="margin12" onclick="admin.others.exportSQL();">${exportSQLLabel}</button>
</#if>
</#if>
<button class="margin12" onclick="admin.others.exportJSON();">${exportJSONLabel}</button>
<button class="margin12" onclick="admin.others.exportJSON();">${exportJSONLabel}</button>
<button class="margin12" onclick="admin.others.exportHexo();">${exportHexoLabel}</button>
</div>
</div>
</div>
</div>
${plugins}
${plugins}
src/main/webapp/js/admin/others.js
View file @
e8c69eb5
...
@@ -105,6 +105,27 @@ admin.others = {
...
@@ -105,6 +105,27 @@ admin.others = {
}
}
});
});
},
},
/*
* @description 导出数据为 Hexo Markdown 文件
*/
exportHexo
:
function
()
{
$
(
"
#tipMsg
"
).
text
(
""
);
$
.
ajax
({
url
:
latkeConfig
.
servePath
+
"
/console/export/hexo
"
,
type
:
"
GET
"
,
cache
:
false
,
success
:
function
(
result
,
textStatus
)
{
// AJAX 下载文件的话这里会发两次请求,用 sc 来判断是否是文件,如果没有 sc 说明文件可以下载(实际上就是 result)
if
(
!
result
.
sc
)
{
// 再发一次请求进行正式下载
window
.
location
=
latkeConfig
.
servePath
+
"
/console/export/hexo
"
;
}
else
{
$
(
"
#tipMsg
"
).
text
(
result
.
msg
);
}
}
});
},
/*
/*
* 获取未使用的标签。
* 获取未使用的标签。
* XXX: Not used this function yet.
* XXX: Not used this function yet.
...
...
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