Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
slm-fileview
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
jenkins
slm-fileview
Commits
d787813b
Commit
d787813b
authored
Dec 25, 2020
by
kl
Committed by
kl
Dec 25, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新增配置项office.preview.switch.disabled,控制offic文件预览切换开关
parent
4a3886e4
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
26 additions
and
3 deletions
+26
-3
application.properties
jodconverter-web/src/main/config/application.properties
+3
-0
freemarker_implicit.ftl
jodconverter-web/src/main/config/freemarker_implicit.ftl
+1
-0
ConfigConstants.java
...r-web/src/main/java/cn/keking/config/ConfigConstants.java
+10
-0
ConfigRefreshComponent.java
...rc/main/java/cn/keking/config/ConfigRefreshComponent.java
+3
-0
OfficeFilePreviewImpl.java
...in/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
+1
-0
PdfFilePreviewImpl.java
.../main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
+1
-0
PictureFilePreviewImpl.java
...n/java/cn/keking/service/impl/PictureFilePreviewImpl.java
+2
-0
officePicture.ftl
jodconverter-web/src/main/resources/web/officePicture.ftl
+3
-1
pdf.ftl
jodconverter-web/src/main/resources/web/pdf.ftl
+2
-2
No files found.
jodconverter-web/src/main/config/application.properties
View file @
d787813b
...
@@ -53,6 +53,9 @@ simText = ${KK_SIMTEXT:txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log
...
@@ -53,6 +53,9 @@ simText = ${KK_SIMTEXT:txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log
media
=
${KK_MEDIA:mp3,wav,mp4,flv}
media
=
${KK_MEDIA:mp3,wav,mp4,flv}
#office类型文档(word ppt)样式,默认为图片(image),可配置为pdf(预览时也有按钮切换)
#office类型文档(word ppt)样式,默认为图片(image),可配置为pdf(预览时也有按钮切换)
office.preview.type
=
${KK_OFFICE_PREVIEW_TYPE:image}
office.preview.type
=
${KK_OFFICE_PREVIEW_TYPE:image}
#是否关闭office预览切换开关,默认为false,可配置为true关闭
office.preview.switch.disabled
=
${KK_OFFICE_PREVIEW_SWITCH_DISABLED:false}
#是否禁止下载转换生成的pdf文件
#是否禁止下载转换生成的pdf文件
pdf.download.disable
=
${KK_PDF_DOWNLOAD_DISABLE:true}
pdf.download.disable
=
${KK_PDF_DOWNLOAD_DISABLE:true}
...
...
jodconverter-web/src/main/config/freemarker_implicit.ftl
View file @
d787813b
[#ftl]
[#ftl]
[#-- @implicitly included --]
[#-- @implicitly included --]
[#-- @ftlvariable name="switchDisabled" type="String" --]
[#-- @ftlvariable name="imgurls" type="String" --]
[#-- @ftlvariable name="imgurls" type="String" --]
[#-- @ftlvariable name="watermarkAngle" type="String" --]
[#-- @ftlvariable name="watermarkAngle" type="String" --]
[#-- @ftlvariable name="watermarkHeight" type="String" --]
[#-- @ftlvariable name="watermarkHeight" type="String" --]
...
...
jodconverter-web/src/main/java/cn/keking/config/ConfigConstants.java
View file @
d787813b
...
@@ -20,6 +20,7 @@ public class ConfigConstants {
...
@@ -20,6 +20,7 @@ public class ConfigConstants {
private
static
String
[]
SIM_TEXT
=
{};
private
static
String
[]
SIM_TEXT
=
{};
private
static
String
[]
MEDIA
=
{};
private
static
String
[]
MEDIA
=
{};
private
static
String
OFFICE_PREVIEW_TYPE
;
private
static
String
OFFICE_PREVIEW_TYPE
;
private
static
String
OFFICE_PREVIEW_SWITCH_DISABLED
;
private
static
String
FTP_USERNAME
;
private
static
String
FTP_USERNAME
;
private
static
String
FTP_PASSWORD
;
private
static
String
FTP_PASSWORD
;
private
static
String
FTP_CONTROL_ENCODING
;
private
static
String
FTP_CONTROL_ENCODING
;
...
@@ -32,6 +33,7 @@ public class ConfigConstants {
...
@@ -32,6 +33,7 @@ public class ConfigConstants {
public
static
final
String
DEFAULT_TXT_TYPE
=
"txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd"
;
public
static
final
String
DEFAULT_TXT_TYPE
=
"txt,html,htm,asp,jsp,xml,json,properties,md,gitignore,log,java,py,c,cpp,sql,sh,bat,m,bas,prg,cmd"
;
public
static
final
String
DEFAULT_MEDIA_TYPE
=
"mp3,wav,mp4,flv"
;
public
static
final
String
DEFAULT_MEDIA_TYPE
=
"mp3,wav,mp4,flv"
;
public
static
final
String
DEFAULT_OFFICE_PREVIEW_TYPE
=
"image"
;
public
static
final
String
DEFAULT_OFFICE_PREVIEW_TYPE
=
"image"
;
public
static
final
String
DEFAULT_OFFICE_PREVIEW_SWITCH_DISABLED
=
"false"
;
public
static
final
String
DEFAULT_FTP_USERNAME
=
null
;
public
static
final
String
DEFAULT_FTP_USERNAME
=
null
;
public
static
final
String
DEFAULT_FTP_PASSWORD
=
null
;
public
static
final
String
DEFAULT_FTP_PASSWORD
=
null
;
public
static
final
String
DEFAULT_FTP_CONTROL_ENCODING
=
"UTF-8"
;
public
static
final
String
DEFAULT_FTP_CONTROL_ENCODING
=
"UTF-8"
;
...
@@ -202,4 +204,12 @@ public class ConfigConstants {
...
@@ -202,4 +204,12 @@ public class ConfigConstants {
PDF_DOWNLOAD_DISABLE
=
pdfDownloadDisable
;
PDF_DOWNLOAD_DISABLE
=
pdfDownloadDisable
;
}
}
public
static
String
getOfficePreviewSwitchDisabled
()
{
return
OFFICE_PREVIEW_SWITCH_DISABLED
;
}
@Value
(
"${office.preview.switch.disabled:true}"
)
public
static
void
setOfficePreviewSwitchDisabled
(
String
officePreviewSwitchDisabled
)
{
OFFICE_PREVIEW_SWITCH_DISABLED
=
officePreviewSwitchDisabled
;
}
}
}
jodconverter-web/src/main/java/cn/keking/config/ConfigRefreshComponent.java
View file @
d787813b
...
@@ -38,6 +38,7 @@ public class ConfigRefreshComponent {
...
@@ -38,6 +38,7 @@ public class ConfigRefreshComponent {
String
[]
textArray
;
String
[]
textArray
;
String
[]
mediaArray
;
String
[]
mediaArray
;
String
officePreviewType
;
String
officePreviewType
;
String
officePreviewSwitchDisabled
;
String
ftpUsername
;
String
ftpUsername
;
String
ftpPassword
;
String
ftpPassword
;
String
ftpControlEncoding
;
String
ftpControlEncoding
;
...
@@ -54,6 +55,7 @@ public class ConfigRefreshComponent {
...
@@ -54,6 +55,7 @@ public class ConfigRefreshComponent {
text
=
properties
.
getProperty
(
"simText"
,
ConfigConstants
.
DEFAULT_TXT_TYPE
);
text
=
properties
.
getProperty
(
"simText"
,
ConfigConstants
.
DEFAULT_TXT_TYPE
);
media
=
properties
.
getProperty
(
"media"
,
ConfigConstants
.
DEFAULT_MEDIA_TYPE
);
media
=
properties
.
getProperty
(
"media"
,
ConfigConstants
.
DEFAULT_MEDIA_TYPE
);
officePreviewType
=
properties
.
getProperty
(
"office.preview.type"
,
ConfigConstants
.
DEFAULT_OFFICE_PREVIEW_TYPE
);
officePreviewType
=
properties
.
getProperty
(
"office.preview.type"
,
ConfigConstants
.
DEFAULT_OFFICE_PREVIEW_TYPE
);
officePreviewSwitchDisabled
=
properties
.
getProperty
(
"office.preview.switch.disabled"
,
ConfigConstants
.
DEFAULT_OFFICE_PREVIEW_TYPE
);
ftpUsername
=
properties
.
getProperty
(
"ftp.username"
,
ConfigConstants
.
DEFAULT_FTP_USERNAME
);
ftpUsername
=
properties
.
getProperty
(
"ftp.username"
,
ConfigConstants
.
DEFAULT_FTP_USERNAME
);
ftpPassword
=
properties
.
getProperty
(
"ftp.password"
,
ConfigConstants
.
DEFAULT_FTP_PASSWORD
);
ftpPassword
=
properties
.
getProperty
(
"ftp.password"
,
ConfigConstants
.
DEFAULT_FTP_PASSWORD
);
ftpControlEncoding
=
properties
.
getProperty
(
"ftp.control.encoding"
,
ConfigConstants
.
DEFAULT_FTP_CONTROL_ENCODING
);
ftpControlEncoding
=
properties
.
getProperty
(
"ftp.control.encoding"
,
ConfigConstants
.
DEFAULT_FTP_CONTROL_ENCODING
);
...
@@ -71,6 +73,7 @@ public class ConfigRefreshComponent {
...
@@ -71,6 +73,7 @@ public class ConfigRefreshComponent {
ConfigConstants
.
setFtpControlEncodingValue
(
ftpControlEncoding
);
ConfigConstants
.
setFtpControlEncodingValue
(
ftpControlEncoding
);
ConfigConstants
.
setBaseUrlValue
(
baseUrl
);
ConfigConstants
.
setBaseUrlValue
(
baseUrl
);
ConfigConstants
.
setTrustHostValue
(
trustHost
);
ConfigConstants
.
setTrustHostValue
(
trustHost
);
ConfigConstants
.
setOfficePreviewSwitchDisabled
(
officePreviewSwitchDisabled
);
ConfigConstants
.
setPdfDownloadDisableValue
(
pdfDownloadDisable
);
ConfigConstants
.
setPdfDownloadDisableValue
(
pdfDownloadDisable
);
setWatermarkConfig
(
properties
);
setWatermarkConfig
(
properties
);
bufferedReader
.
close
();
bufferedReader
.
close
();
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/OfficeFilePreviewImpl.java
View file @
d787813b
...
@@ -54,6 +54,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
...
@@ -54,6 +54,7 @@ public class OfficeFilePreviewImpl implements FilePreview {
boolean
isHtml
=
suffix
.
equalsIgnoreCase
(
"xls"
)
||
suffix
.
equalsIgnoreCase
(
"xlsx"
);
boolean
isHtml
=
suffix
.
equalsIgnoreCase
(
"xls"
)
||
suffix
.
equalsIgnoreCase
(
"xlsx"
);
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
(
isHtml
?
"html"
:
"pdf"
);
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
(
isHtml
?
"html"
:
"pdf"
);
String
outFilePath
=
FILE_DIR
+
pdfName
;
String
outFilePath
=
FILE_DIR
+
pdfName
;
model
.
addAttribute
(
"switchDisabled"
,
ConfigConstants
.
getOfficePreviewSwitchDisabled
());
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
// 判断之前是否已转换过,如果转换过,直接返回,否则执行转换
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
String
filePath
;
String
filePath
;
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PdfFilePreviewImpl.java
View file @
d787813b
...
@@ -44,6 +44,7 @@ public class PdfFilePreviewImpl implements FilePreview {
...
@@ -44,6 +44,7 @@ public class PdfFilePreviewImpl implements FilePreview {
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
String
baseUrl
=
BaseUrlFilter
.
getBaseUrl
();
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
"pdf"
;
String
pdfName
=
fileName
.
substring
(
0
,
fileName
.
lastIndexOf
(
"."
)
+
1
)
+
"pdf"
;
String
outFilePath
=
FILE_DIR
+
pdfName
;
String
outFilePath
=
FILE_DIR
+
pdfName
;
model
.
addAttribute
(
"switchDisabled"
,
ConfigConstants
.
getOfficePreviewSwitchDisabled
());
if
(
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_IMAGE
.
equals
(
officePreviewType
)
||
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_ALL_IMAGES
.
equals
(
officePreviewType
))
{
if
(
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_IMAGE
.
equals
(
officePreviewType
)
||
OfficeFilePreviewImpl
.
OFFICE_PREVIEW_TYPE_ALL_IMAGES
.
equals
(
officePreviewType
))
{
//当文件不存在时,就去下载
//当文件不存在时,就去下载
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
if
(!
fileUtils
.
listConvertedFiles
().
containsKey
(
pdfName
)
||
!
ConfigConstants
.
isCacheEnabled
())
{
...
...
jodconverter-web/src/main/java/cn/keking/service/impl/PictureFilePreviewImpl.java
View file @
d787813b
package
cn
.
keking
.
service
.
impl
;
package
cn
.
keking
.
service
.
impl
;
import
cn.keking.config.ConfigConstants
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.FileAttribute
;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.model.ReturnResponse
;
import
cn.keking.service.FilePreview
;
import
cn.keking.service.FilePreview
;
...
@@ -33,6 +34,7 @@ public class PictureFilePreviewImpl implements FilePreview {
...
@@ -33,6 +34,7 @@ public class PictureFilePreviewImpl implements FilePreview {
public
String
filePreviewHandle
(
String
url
,
Model
model
,
FileAttribute
fileAttribute
)
{
public
String
filePreviewHandle
(
String
url
,
Model
model
,
FileAttribute
fileAttribute
)
{
String
fileKey
=
(
String
)
RequestContextHolder
.
currentRequestAttributes
().
getAttribute
(
"fileKey"
,
0
);
String
fileKey
=
(
String
)
RequestContextHolder
.
currentRequestAttributes
().
getAttribute
(
"fileKey"
,
0
);
List
<
String
>
imgUrls
=
Lists
.
newArrayList
(
url
);
List
<
String
>
imgUrls
=
Lists
.
newArrayList
(
url
);
model
.
addAttribute
(
"switchDisabled"
,
ConfigConstants
.
getOfficePreviewSwitchDisabled
());
try
{
try
{
imgUrls
.
clear
();
imgUrls
.
clear
();
imgUrls
.
addAll
(
fileUtils
.
getImgCache
(
fileKey
));
imgUrls
.
addAll
(
fileUtils
.
getImgCache
(
fileKey
));
...
...
jodconverter-web/src/main/resources/web/officePicture.ftl
View file @
d787813b
...
@@ -34,7 +34,9 @@
...
@@ -34,7 +34,9 @@
</div>
</div>
</
#
list>
</
#
list>
</div>
</div>
<img
src=
"images/pdf.svg"
width=
"63"
height=
"63"
style=
"position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;"
alt=
"使用PDF预览"
title=
"使用PDF预览"
onclick=
"changePreviewType('pdf')"
/>
<
#
if
"
false
"
==
switchDisabled
>
<img
src=
"images/pdf.svg"
width=
"63"
height=
"63"
style=
"position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;"
alt=
"使用PDF预览"
title=
"使用PDF预览"
onclick=
"changePreviewType('pdf')"
/>
</
#
if>
<script
src=
"js/watermark.js"
type=
"text/javascript"
></script>
<script
src=
"js/watermark.js"
type=
"text/javascript"
></script>
<script>
<script>
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
...
...
jodconverter-web/src/main/resources/web/pdf.ftl
View file @
d787813b
...
@@ -23,9 +23,9 @@
...
@@ -23,9 +23,9 @@
<
#
assign
finalUrl=
"${baseUrl}${pdfUrl}"
>
<
#
assign
finalUrl=
"${baseUrl}${pdfUrl}"
>
</
#
if>
</
#
if>
<iframe
src=
""
width=
"100%"
frameborder=
"0"
></iframe>
<iframe
src=
""
width=
"100%"
frameborder=
"0"
></iframe>
<
#
if
"
false
"
==
switchDisabled
>
<img
src=
"images/jpg.svg"
width=
"63"
height=
"63"
style=
"position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;"
alt=
"使用图片预览"
title=
"使用图片预览"
onclick=
"goForImage()"
/>
<img
src=
"images/jpg.svg"
width=
"63"
height=
"63"
style=
"position: fixed; cursor: pointer; top: 40%; right: 48px; z-index: 999;"
alt=
"使用图片预览"
title=
"使用图片预览"
onclick=
"goForImage()"
/>
</
#
if>
</body>
</body>
<script
src=
"js/watermark.js"
type=
"text/javascript"
></script>
<script
src=
"js/watermark.js"
type=
"text/javascript"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
...
...
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