Commit e5203ff0 authored by Liang Ding's avatar Liang Ding

🎨 #12293 摘要解析

parent 37671498
...@@ -65,6 +65,10 @@ public class ImportService { ...@@ -65,6 +65,10 @@ public class ImportService {
@Inject @Inject
private UserQueryService userQueryService; private UserQueryService userQueryService;
/**
* Imports markdowns files as articles. See <a href="https://hacpai.com/article/1498490209748">Solo 支持 Hexo/Jekyll 数据导入</a> for
* more details.
*/
public void importMarkdowns() { public void importMarkdowns() {
new Thread(() -> { new Thread(() -> {
final ServletContext servletContext = SoloServletListener.getServletContext(); final ServletContext servletContext = SoloServletListener.getServletContext();
...@@ -162,7 +166,8 @@ public class ImportService { ...@@ -162,7 +166,8 @@ public class ImportService {
final String content = StringUtils.substringAfter(fileContent, frontMatter); final String content = StringUtils.substringAfter(fileContent, frontMatter);
ret.put(Article.ARTICLE_CONTENT, content); ret.put(Article.ARTICLE_CONTENT, content);
ret.put(Article.ARTICLE_ABSTRACT, Article.getAbstract(content)); final String abs = parseAbstract(elems, content);
ret.put(Article.ARTICLE_ABSTRACT, abs);
final Date date = parseDate(elems); final Date date = parseDate(elems);
ret.put(Article.ARTICLE_CREATE_DATE, date); ret.put(Article.ARTICLE_CREATE_DATE, date);
...@@ -187,6 +192,21 @@ public class ImportService { ...@@ -187,6 +192,21 @@ public class ImportService {
return ret; return ret;
} }
private String parseAbstract(final Map map, final String content) {
String ret = (String) map.get("description");
if (null == ret) {
ret = (String) map.get("summary");
}
if (null == ret) {
ret = (String) map.get("abstract");
}
if (StringUtils.isNotBlank(ret)) {
return ret;
}
return Article.getAbstract(content);
}
private Date parseDate(final Map map) { private Date parseDate(final Map map) {
Object date = map.get("date"); Object date = map.get("date");
if (null == date) { if (null == date) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment