Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
cms_sys
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
西魏
cms_sys
Commits
ae904c15
Commit
ae904c15
authored
Dec 02, 2020
by
guwd
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、增加配置html
parent
075caec9
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
34 deletions
+46
-34
GeneraterAction.java
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
+9
-6
MCmsAction.java
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
+13
-8
ContentBizImpl.java
src/main/java/net/mingsoft/cms/biz/impl/ContentBizImpl.java
+12
-7
CmsParserUtil.java
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
+12
-13
No files found.
src/main/java/net/mingsoft/cms/action/GeneraterAction.java
View file @
ae904c15
...
...
@@ -100,6 +100,9 @@ public class GeneraterAction extends BaseAction {
@Value
(
"${ms.manager.path}"
)
private
String
managerPath
;
@Value
(
"${ms.diy.html-dir:html}"
)
private
String
htmlDir
;
/**
* /**
* 更新主页
...
...
@@ -131,7 +134,7 @@ public class GeneraterAction extends BaseAction {
if
(!
FileUtil
.
exist
(
ParserUtil
.
buildTempletPath
()))
{
return
ResultData
.
build
().
error
(
getResString
(
"templet.file"
));
}
else
{
CmsParserUtil
.
generate
(
tmpFileName
,
generateFileName
);
CmsParserUtil
.
generate
(
tmpFileName
,
generateFileName
,
htmlDir
);
return
ResultData
.
build
().
success
();
}
}
...
...
@@ -185,7 +188,7 @@ public class GeneraterAction extends BaseAction {
continue
;
}
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
()
,
htmlDir
);
break
;
case
"2"
:
// 单页
if
(
articleIdList
.
size
()
==
0
)
{
...
...
@@ -195,7 +198,7 @@ public class GeneraterAction extends BaseAction {
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
articleIdList
.
add
(
columnArticleIdBean
);
}
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
,
htmlDir
);
break
;
}
}
...
...
@@ -226,7 +229,7 @@ public class GeneraterAction extends BaseAction {
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
PageBean
page
=
new
PageBean
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
// 生成所有栏目的文章
...
...
@@ -258,7 +261,7 @@ public class GeneraterAction extends BaseAction {
}
// 有符合条件的就更新
if
(
articleIdList
.
size
()
>
0
)
{
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
,
htmlDir
);
}
}
...
...
@@ -277,7 +280,7 @@ public class GeneraterAction extends BaseAction {
public
String
viewIndex
(
HttpServletRequest
request
,
@PathVariable
String
position
,
HttpServletResponse
response
)
{
AppEntity
app
=
BasicUtil
.
getApp
();
// 组织主页预览地址
String
indexPosition
=
app
.
getAppHostUrl
()
+
File
.
separator
+
ParserUtil
.
HTML
+
File
.
separator
+
app
.
getAppDir
()
String
indexPosition
=
app
.
getAppHostUrl
()
+
File
.
separator
+
htmlDir
+
File
.
separator
+
app
.
getAppDir
()
+
File
.
separator
+
position
+
ParserUtil
.
HTML_SUFFIX
;
return
"redirect:"
+
indexPosition
;
}
...
...
src/main/java/net/mingsoft/cms/action/web/MCmsAction.java
View file @
ae904c15
...
...
@@ -46,6 +46,7 @@ import net.mingsoft.mdiy.entity.ModelEntity;
import
net.mingsoft.mdiy.util.ParserUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -102,6 +103,10 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
private
IModelBiz
modelBiz
;
@Value
(
"${ms.diy.html-dir:html}"
)
private
String
htmlDir
;
/**
* 动态列表页
*/
...
...
@@ -121,7 +126,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
);
content
=
CmsParserUtil
.
generate
(
ParserUtil
.
INDEX
+
ParserUtil
.
HTM_SUFFIX
,
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
...
...
@@ -179,7 +184,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
);
content
=
CmsParserUtil
.
generate
(
columnArticles
.
get
(
0
).
getCategoryListUrl
(),
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
...
...
@@ -281,7 +286,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
);
content
=
CmsParserUtil
.
generate
(
column
.
getCategoryUrl
(),
map
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
...
...
@@ -332,7 +337,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
int
typeId
=
0
;
String
categoryIds
=
BasicUtil
.
getString
(
"categoryId"
);
//当传递了栏目编号,但不是栏目集合
if
(
!
StringUtil
.
is
Blank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
))
{
if
(
StringUtils
.
isNot
Blank
(
categoryIds
)
&&
!
categoryIds
.
contains
(
","
))
{
typeId
=
Integer
.
parseInt
(
categoryIds
);
}
...
...
@@ -385,7 +390,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
}
// 保存至自定义字段集合
if
(
!
StringUtil
.
is
Blank
(
value
))
{
if
(
StringUtils
.
isNot
Blank
(
value
))
{
diyFieldName
.
put
(
entry
.
getKey
(),
value
);
//判断请求中的是否是自定义模型中的字段
if
(
filedStr
.
contains
(
entry
.
getKey
()))
{
...
...
@@ -430,7 +435,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
params
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
params
.
put
(
ParserUtil
.
PAGE
,
page
);
params
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
params
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
//动态解析
params
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
...
...
@@ -473,7 +478,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
params
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
params
.
put
(
ParserUtil
.
PAGE
,
page
);
params
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
params
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
//动态解析
params
.
put
(
ParserUtil
.
IS_DO
,
false
);
//设置动态请求的模块路径
...
...
@@ -483,7 +488,7 @@ public class MCmsAction extends net.mingsoft.cms.action.BaseAction {
String
content
=
""
;
try
{
//根据模板路径,参数生成
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
params
);
content
=
CmsParserUtil
.
generate
(
SEARCH
+
ParserUtil
.
HTM_SUFFIX
,
params
,
htmlDir
);
}
catch
(
TemplateNotFoundException
e
)
{
e
.
printStackTrace
();
}
catch
(
MalformedTemplateNameException
e
)
{
...
...
src/main/java/net/mingsoft/cms/biz/impl/ContentBizImpl.java
View file @
ae904c15
...
...
@@ -41,6 +41,7 @@ import org.apache.commons.lang3.StringUtils;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
net.mingsoft.base.biz.impl.BaseBizImpl
;
import
net.mingsoft.base.dao.IBaseDao
;
...
...
@@ -73,6 +74,9 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
@Autowired
private
ICategoryDao
categoryDao
;
@Value
(
"${ms.diy.html-dir:html}"
)
private
String
htmlDir
;
@Override
protected
IBaseDao
getDao
()
{
...
...
@@ -128,7 +132,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
PageBean
page
=
new
PageBean
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
...
...
@@ -148,7 +152,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
articleIdList
=
queryIdsByCategoryIdForParser
(
contentBean
);
// 有符合条件的就更新
if
(
articleIdList
.
size
()
>
0
)
{
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
,
htmlDir
);
}
}
}
...
...
@@ -180,7 +184,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
PageBean
page
=
new
PageBean
();
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
...
...
@@ -190,7 +194,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
switch
(
column
.
getCategoryType
())
{
//TODO 暂时先用字符串代替
case
"1"
:
// 列表
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
());
CmsParserUtil
.
generateList
(
column
,
articleIdList
.
size
()
,
htmlDir
);
break
;
case
"2"
:
// 单页
if
(
articleIdList
.
size
()==
0
){
...
...
@@ -200,7 +204,7 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
BeanUtil
.
copyProperties
(
column
,
columnArticleIdBean
,
copyOptions
);
articleIdList
.
add
(
columnArticleIdBean
);
}
CmsParserUtil
.
generateBasic
(
articleIdList
);
CmsParserUtil
.
generateBasic
(
articleIdList
,
htmlDir
);
break
;
}
}
...
...
@@ -224,13 +228,13 @@ public class ContentBizImpl extends BaseBizImpl<IContentDao, ContentEntity> imp
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
}
//设置生成的路径
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
//设置站点编号
if
(
BasicUtil
.
getWebsiteApp
()
!=
null
){
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
String
read
=
ParserUtil
.
rendering
(
templatePath
,
map
);
FileUtil
.
writeString
(
read
,
ParserUtil
.
buildHtmlPath
(
targetPath
),
net
.
mingsoft
.
base
.
constant
.
Const
.
UTF8
);
FileUtil
.
writeString
(
read
,
ParserUtil
.
buildHtmlPath
(
targetPath
,
htmlDir
),
net
.
mingsoft
.
base
.
constant
.
Const
.
UTF8
);
}
}
\ No newline at end of file
src/main/java/net/mingsoft/cms/util/CmsParserUtil.java
View file @
ae904c15
...
...
@@ -31,7 +31,6 @@ import java.util.concurrent.ExecutorService;
* 文章解析工具类
*/
public
class
CmsParserUtil
extends
ParserUtil
{
/**
* 封面
*/
...
...
@@ -48,14 +47,14 @@ public class CmsParserUtil extends ParserUtil {
* 生成后的路径,默认生成的html文件,所以不能带.html后缀,
* @throws IOException
*/
public
static
void
generate
(
String
templatePath
,
String
targetPath
)
throws
IOException
{
public
static
void
generate
(
String
templatePath
,
String
targetPath
,
String
htmlDir
)
throws
IOException
{
Map
<
String
,
Object
>
map
=
new
HashMap
<
String
,
Object
>();
map
.
put
(
IS_DO
,
false
);
CategoryEntity
column
=
new
CategoryEntity
();
//内容管理栏目编码
map
.
put
(
COLUMN
,
column
);
String
content
=
CmsParserUtil
.
generate
(
templatePath
,
map
);
FileUtil
.
writeString
(
content
,
ParserUtil
.
buildHtmlPath
(
targetPath
),
Const
.
UTF8
);
String
content
=
CmsParserUtil
.
generate
(
templatePath
,
map
,
htmlDir
);
FileUtil
.
writeString
(
content
,
ParserUtil
.
buildHtmlPath
(
targetPath
,
htmlDir
),
Const
.
UTF8
);
}
/**
...
...
@@ -67,7 +66,7 @@ public class CmsParserUtil extends ParserUtil {
* @throws ParseException
* @throws IOException
*/
public
static
void
generateList
(
CategoryEntity
column
,
int
articleIdTotal
)
public
static
void
generateList
(
CategoryEntity
column
,
int
articleIdTotal
,
String
htmlDir
)
throws
TemplateNotFoundException
,
MalformedTemplateNameException
,
ParseException
,
IOException
{
try
{
// 文章的栏目模型编号
...
...
@@ -86,7 +85,7 @@ public class CmsParserUtil extends ParserUtil {
map
.
put
(
ParserUtil
.
APP_DIR
,
BasicUtil
.
getWebsiteApp
().
getAppDir
());
}
map
.
put
(
ParserUtil
.
HTML
,
ParserUtil
.
HTML
);
map
.
put
(
ParserUtil
.
HTML
,
htmlDir
);
map
.
put
(
ParserUtil
.
URL
,
BasicUtil
.
getUrl
());
map
.
put
(
ParserUtil
.
PAGE
,
page
);
...
...
@@ -122,7 +121,7 @@ public class CmsParserUtil extends ParserUtil {
//文章列表页没有写文章列表标签,总数为0
if
(
totalPageSize
<=
0
)
{
// 数据库中第一页是从开始0*size
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
String
read
=
ParserUtil
.
rendering
(
File
.
separator
+
column
.
getCategoryListUrl
(),
parserParams
);
...
...
@@ -135,11 +134,11 @@ public class CmsParserUtil extends ParserUtil {
// 数据库中第一页是从开始0*size
// 首页路径index.html
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
);
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
}
else
{
// 其他路径list-2.html
columnListPath
=
ParserUtil
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
);
.
buildHtmlPath
(
column
.
getCategoryPath
()
+
File
.
separator
+
ParserUtil
.
PAGE_LIST
+
pageNo
,
htmlDir
);
}
// 设置分页的起始位置
page
.
setPageNo
(
pageNo
);
...
...
@@ -164,7 +163,7 @@ public class CmsParserUtil extends ParserUtil {
* @throws MalformedTemplateNameException
* @throws TemplateNotFoundException
*/
public
static
void
generateBasic
(
List
<
CategoryBean
>
articleIdList
)
{
public
static
void
generateBasic
(
List
<
CategoryBean
>
articleIdList
,
String
htmlDir
)
{
Map
<
Object
,
Object
>
contentModelMap
=
new
HashMap
<
Object
,
Object
>();
ModelEntity
contentModel
=
null
;
...
...
@@ -211,10 +210,10 @@ public class CmsParserUtil extends ParserUtil {
generateIds
.
add
(
articleId
);
//如果是封面就生成index.html
if
(
Integer
.
parseInt
(
articleIdList
.
get
(
artId
).
getCategoryType
())
==
COLUMN_TYPE_COVER
)
{
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
ParserUtil
.
INDEX
,
htmlDir
);
}
else
{
// 组合文章路径如:html/站点id/栏目id/文章id.html
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
);
writePath
=
ParserUtil
.
buildHtmlPath
(
articleColumnPath
+
File
.
separator
+
articleId
,
htmlDir
);
}
Map
<
String
,
Object
>
parserParams
=
new
HashMap
<
String
,
Object
>();
...
...
@@ -262,7 +261,7 @@ public class CmsParserUtil extends ParserUtil {
String
content
=
null
;
try
{
SpringUtil
.
setRequest
(
request
);
content
=
CmsParserUtil
.
generate
(
columnUrl
,
cloneMap
);
content
=
CmsParserUtil
.
generate
(
columnUrl
,
cloneMap
,
htmlDir
);
FileUtil
.
writeString
(
content
,
finalWritePath
,
Const
.
UTF8
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
...
...
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