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
d08d21b1
Unverified
Commit
d08d21b1
authored
Jan 14, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#19 静态站点生成
parent
766343ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
22 deletions
+13
-22
src/main/java/org/b3log/solo/processor/console/StaticSiteConsole.java
...a/org/b3log/solo/processor/console/StaticSiteConsole.java
+11
-20
src/main/resources/static-site/README.md
src/main/resources/static-site/README.md
+2
-2
No files found.
src/main/java/org/b3log/solo/processor/console/StaticSiteConsole.java
View file @
d08d21b1
...
@@ -51,7 +51,7 @@ import java.util.List;
...
@@ -51,7 +51,7 @@ import java.util.List;
* Static site console request processing. HTML 静态站点生成 https://github.com/88250/solo/issues/19
* Static site console request processing. HTML 静态站点生成 https://github.com/88250/solo/issues/19
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
0, Jan 13
, 2020
* @version 1.0.0.
1, Jan 14
, 2020
* @since 3.9.0
* @since 3.9.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -147,27 +147,19 @@ public class StaticSiteConsole {
...
@@ -147,27 +147,19 @@ public class StaticSiteConsole {
}
}
/**
/**
*
Name of generate directory
.
*
Source root directory path
.
*/
*/
private
static
final
String
STATIC_SITE
=
"static-site"
;
private
static
String
rootPath
;
/**
* Source directory path.
*/
private
static
String
sourcePath
;
static
{
static
{
sourcePath
=
StaticSiteConsole
.
class
.
getResource
(
"/repository.json"
).
getPath
();
rootPath
=
StaticSiteConsole
.
class
.
getResource
(
"/repository.json"
).
getPath
();
sourcePath
=
StringUtils
.
substringBeforeLast
(
sourcePath
,
"repository.json"
);
rootPath
=
StringUtils
.
substringBeforeLast
(
rootPath
,
"/repository.json"
);
if
(
StringUtils
.
contains
(
sourcePath
,
"/target/classes/"
))
{
sourcePath
=
StringUtils
.
replace
(
sourcePath
,
"classes"
,
"solo"
);
}
}
}
/**
/**
* Path of generate directory.
* Path of generate directory.
*/
*/
private
static
final
String
staticSitePath
=
StaticSiteConsole
.
class
.
getResource
(
"/"
).
getPath
()
+
STATIC_SITE
;
private
static
final
String
staticSitePath
=
StaticSiteConsole
.
class
.
getResource
(
"/"
).
getPath
()
+
"static-site"
;
private
static
void
genCategories
()
throws
Exception
{
private
static
void
genCategories
()
throws
Exception
{
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
final
BeanManager
beanManager
=
BeanManager
.
getInstance
();
...
@@ -289,28 +281,28 @@ public class StaticSiteConsole {
...
@@ -289,28 +281,28 @@ public class StaticSiteConsole {
private
static
void
genSkins
()
throws
Exception
{
private
static
void
genSkins
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/skins"
));
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/skins"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/skins"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/skins"
));
FileUtils
.
copyDirectory
(
new
File
(
sourcePath
+
"
skins"
),
new
File
(
staticSitePath
+
"/skins"
));
FileUtils
.
copyDirectory
(
new
File
(
rootPath
+
"/
skins"
),
new
File
(
staticSitePath
+
"/skins"
));
LOGGER
.
log
(
Level
.
INFO
,
"Generated skins"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated skins"
);
}
}
private
static
void
genJS
()
throws
Exception
{
private
static
void
genJS
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/js"
));
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/js"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/js"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/js"
));
FileUtils
.
copyDirectory
(
new
File
(
sourcePath
+
"
js"
),
new
File
(
staticSitePath
+
"/js"
));
FileUtils
.
copyDirectory
(
new
File
(
rootPath
+
"/
js"
),
new
File
(
staticSitePath
+
"/js"
));
LOGGER
.
log
(
Level
.
INFO
,
"Generated js"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated js"
);
}
}
private
static
void
genImages
()
throws
Exception
{
private
static
void
genImages
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/images"
));
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/images"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/images"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/images"
));
FileUtils
.
copyDirectory
(
new
File
(
sourcePath
+
"
images"
),
new
File
(
staticSitePath
+
"/images"
));
FileUtils
.
copyDirectory
(
new
File
(
rootPath
+
"/
images"
),
new
File
(
staticSitePath
+
"/images"
));
LOGGER
.
log
(
Level
.
INFO
,
"Generated images"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated images"
);
}
}
private
static
void
genPlugins
()
throws
Exception
{
private
static
void
genPlugins
()
throws
Exception
{
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
deleteDirectory
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
forceMkdir
(
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
copyDirectory
(
new
File
(
sourcePath
+
"
plugins"
),
new
File
(
staticSitePath
+
"/plugins"
));
FileUtils
.
copyDirectory
(
new
File
(
rootPath
+
"/
plugins"
),
new
File
(
staticSitePath
+
"/plugins"
));
genURI
(
"/plugins/kanbanniang/assets/model.json"
);
genURI
(
"/plugins/kanbanniang/assets/model.json"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated plugins"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated plugins"
);
...
@@ -318,8 +310,7 @@ public class StaticSiteConsole {
...
@@ -318,8 +310,7 @@ public class StaticSiteConsole {
private
static
void
genFile
(
final
String
file
)
throws
Exception
{
private
static
void
genFile
(
final
String
file
)
throws
Exception
{
FileUtils
.
forceMkdirParent
(
new
File
(
staticSitePath
+
"/"
+
file
));
FileUtils
.
forceMkdirParent
(
new
File
(
staticSitePath
+
"/"
+
file
));
final
String
staticSitePath
=
StaticSiteConsole
.
class
.
getResource
(
"/"
+
STATIC_SITE
).
toURI
().
getPath
();
FileUtils
.
copyFile
(
new
File
(
rootPath
+
"/"
+
file
),
new
File
(
staticSitePath
+
"/"
+
file
));
FileUtils
.
copyFile
(
new
File
(
sourcePath
+
"/"
+
file
),
new
File
(
staticSitePath
+
"/"
+
file
));
LOGGER
.
log
(
Level
.
INFO
,
"Generated a file ["
+
file
+
"]"
);
LOGGER
.
log
(
Level
.
INFO
,
"Generated a file ["
+
file
+
"]"
);
}
}
...
...
src/main/resources/static-site/README.md
View file @
d08d21b1
我的静态博客
站点。
本目录用于存放生成的静态
站点。
愉快地使用
[
Solo
](
https://solo.b3log.org
)
博客系统生成 ❤
每次生成前会清空该目录,所以请勿手工放置任何文件到该目录中。
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