Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
Z
zzfszzy
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
zzfszzy
Commits
a9d4aad4
提交
a9d4aad4
authored
9月 18, 2019
作者:
lizhuo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
--no commit message
上级
45428d05
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
2 行增加
和
116 行删除
+2
-116
EpubResolve.java
...qx.file/src/main/java/com/zrqx/file/util/EpubResolve.java
+2
-116
没有找到文件。
com.zrqx.file/src/main/java/com/zrqx/file/util/EpubResolve.java
浏览文件 @
a9d4aad4
...
...
@@ -341,115 +341,7 @@ public class EpubResolve {
return
alltitle
;
}
/**
*
* @Description: TODO
* @param @param listReferences
* @param @param contentSet
* @param @param book
* @param @param imgtzMap
* @param @param data
* @param @return
* @return Object[]
* @throws @author 李禚
* @date 2016年5月26日
*/
/*
* @SuppressWarnings("unchecked") public Object[] setContent(List<TOCReference>
* listReferences, Set<ArticleLibrary> contentSet, Ebook ebook, Map<String,
* String> imgtzMap, Object[] data) { // 遍历章节的内容 Map<String, TOCReference>
* titles1 = null; Map<String, TOCReference> ids1 = null; for (TOCReference
* spineReference : listReferences) { titles1 = new LinkedMap(); ids1 = new
* LinkedMap(); // 获取所有id Map<String, TOCReference> tmapid =
* getAllId(spineReference, ids1, 0);
*
* // 顶级目录 用resourceId 标识 String resourceId = ""; if
* (spineReference.getFragmentId() != null &&
* !spineReference.getFragmentId().equals("")) { resourceId =
* spineReference.getFragmentId(); } else { resourceId =
* spineReference.getResourceId(); } // jsoup解析,生成dom对象 Document doc =
* getDocument(spineReference); Elements elements =
* doc.select("h1,h2,h3,h4,h5,h6,ul,hr,p,div"); //
* ###################去重复的标题########################### Elements titles = new
* Elements(); Set<String> keys = tmapid.keySet(); for (String key : keys) {
* Element str; try { str = doc.getElementById(key); if (str != null)
* titles.add(str); } catch (Exception e) { continue; }
*
* } // 图注: // Elements select = elements.select("p,img"); for (Element elmt :
* elements) { if (elmt.toString().contains("<img")) { for (Element e :
* elmt.children()) { if (e.toString().contains("<img")) { String imgsrc =
* e.attr("src"); if (imgsrc.contains("../")) { imgsrc = imgsrc.replace("../",
* ""); e.attr("src", imgsrc); } // 将带上一层目录的取消 imgsrc =
* imgsrc.substring(imgsrc.lastIndexOf("/") + 1); String imgtz = "";
*
* String before = ""; String after = ""; if (e.previousElementSibling() !=
* null) { before = e.previousElementSibling().attr("class"); }
*
* if (e.nextElementSibling() != null) { after =
* e.nextElementSibling().attr("class"); } if (StringUtils.anyEquals(before,
* "picture_figure_note,picture_table_note,picture_table_title,picture_figure_title,tableCaption"
* )) { imgtz = e.previousElementSibling().text(); } else if
* (StringUtils.anyEquals(after,
* "picture_figure_note,picture_table_note,picture_table_title,picture_figure_title,tableCaption"
* )) { imgtz = e.nextElementSibling().text(); } imgtzMap.put(imgsrc, imgtz); }
* } } } // 不包含,h标签,直接存储 boolean anyEquals = false; if (titles.size() > 0) {
* anyEquals = StringUtils.anyEquals(titles.get(0).text().replaceAll("[ ]",
* ""), "序,总序,序言,前言,摘要"); } if (!titles.toString().contains("<h") || anyEquals)
* { // 不包含h标签的直接整体存入 ArticleLibrary content = new ArticleLibrary(); // 当前章节标题
* String title = spineReference.getTitle();//
* elements.get(0).toString().contains("<h")?elements.get(0).text():
* content.setName(title);// 标题
*
* // markid content.setMarkid(ebook.getId() + "-" + resourceId); int num = 1;
* content.setText(elements.toString()); // 设置公共信息 setContentCommInfo(content,
* ebook, elements); // content.setAuthor(ebook.getAuthor()); //
* **********将章节内容存入Set集合********* contentSet.add(content); } else if
* (!anyEquals) { Elements es = null; for (int i = 0, tlen = titles.size(); i <
* tlen; i++) {
*
*//**
* 如果属于章节,则保存。 否则直接跳过
*//*
* String str =titles.get(i).text().replaceAll(" ", ""); if
* (chapterList.contains(str)) { // h标签 Element hlabel1 = titles.get(i); Element
* hlabel2 = null; if (i != titles.size() - 1) {
*
* for (int j = i + 1; j < titles.size(); j++) { if
* (chapterList.contains(titles.get(j).text().replaceAll(" ", ""))) { hlabel2 =
* titles.get(j); i = j - 1; break; } } }
*
* // 截取整个大章节中的每个小章节 // 一.xxxx // 1.xxx // 2.xxx // 二.xxxx List<Element>
* subchapter = elements.subList(elements.indexOf(hlabel1), hlabel2 == null ?
* elements.size() : elements.indexOf(hlabel2)); es = new Elements(); // markid
* String markid = ebook.getId() + "-" + (hlabel1.attr("id").equals("") ?
* resourceId : hlabel1.attr("id")); for (Element element : subchapter) { if
* (!element.toString().contains("<h")) { es.add(element); }
*
* }
*
* ArticleLibrary content = new ArticleLibrary(); // 内容信息(6)
* content.setName(hlabel1.text());
*
* // 章节内容 content.setText(es.toString());// 内容 String filterText = es.text();
*
* content.setMarkid(markid);
*
* // 内容相关信息,为正文时才去设置关键字,预览,简介(3) if (!StringUtils.anyEquals(hlabel1.text(),
* "封面,版权页,目录")) { content.setSynopsis(filterText.toString().substring(0,
* filterText.length() > 300 ? 200 : filterText.length())); } // 设置公共信息(6)
* setContentCommInfo(content, ebook, es);
*
* // *********将章节内容存入Set集合**************** //
* content.setAuthor(ebook.getAuthor()); contentSet.add(content); }
*
* } }
*
* } // for循环结束
*
* data[0] = contentSet; data[1] = imgtzMap; return data;
*
* }
*/
/**
* 规则改版解析章节
...
...
@@ -711,13 +603,7 @@ public class EpubResolve {
String
imagePath
=
imgs
.
get
(
0
).
getHref
().
substring
(
0
,
imgs
.
get
(
0
).
getHref
().
lastIndexOf
(
"/"
));
// 创建图书中的图片的保存文件夹
File
imageRes
=
null
;
if
(
imgs
.
size
()
!=
0
)
{
imageRes
=
new
File
(
bookFolderPath
+
"/"
+
imagePath
);
if
(!
imageRes
.
exists
())
{
imageRes
.
mkdirs
();
}
// 将图片保存到磁盘中
InputStream
in
=
null
;
try
{
...
...
@@ -725,7 +611,7 @@ public class EpubResolve {
String
imgName
=
img
.
getHref
().
substring
(
img
.
getHref
().
lastIndexOf
(
"/"
)
+
1
);
in
=
img
.
getInputStream
();
MultipartFile
multipartFile
=
new
MockMultipartFile
(
imgName
,
imgName
,
"image/jpeg"
,
in
);
FileInfo
entity
=
this
.
uploadFile
(
multipartFile
,
rootPath
,
imageRes
.
getPath
()
);
FileInfo
entity
=
this
.
uploadFile
(
multipartFile
,
rootPath
,
bookFolderPath
+
"/"
+
imagePath
);
entityList
.
add
(
entity
);
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论