chore: upgrade flexmark version. (#695)

* chore: upgrade flexmark version.

* fix: test case.
pull/696/head
Ryan Wang 2020-03-19 17:01:17 +08:00 committed by GitHub
parent a70780c5df
commit 26fdbb2cf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 40 additions and 75 deletions

View File

@ -6,11 +6,14 @@ plugins {
} }
group = 'run.halo.app' group = 'run.halo.app'
archivesBaseName = 'halo'
version = '1.3.0-beta.3' version = '1.3.0-beta.3'
sourceCompatibility = '1.8'
description = 'Halo, An excellent open source blog publishing application.' description = 'Halo, An excellent open source blog publishing application.'
java {
archivesBaseName = 'halo'
sourceCompatibility = JavaVersion.VERSION_1_8
}
repositories { repositories {
maven { maven {
url 'https://maven.aliyun.com/nexus/content/groups/public' url 'https://maven.aliyun.com/nexus/content/groups/public'
@ -55,7 +58,7 @@ ext {
set('httpclientVersion', "4.5.12") set('httpclientVersion', "4.5.12")
set('dataformatYamlVersion', "2.10.3") set('dataformatYamlVersion', "2.10.3")
set('jgitVersion', "5.7.0.202003110725-r") set('jgitVersion', "5.7.0.202003110725-r")
set('flexmarkVersion', "0.42.12") set('flexmarkVersion', "0.60.2")
set('thumbnailatorVersion', "0.4.11") set('thumbnailatorVersion', "0.4.11")
set('image4jVersion', "0.7zensight1") set('image4jVersion', "0.7zensight1")
set('flywayVersion', "6.3.1") set('flywayVersion', "6.3.1")
@ -63,6 +66,7 @@ ext {
set('levelDbVersion', "0.12") set('levelDbVersion', "0.12")
set('jsonVersion', "20190722") set('jsonVersion', "20190722")
set('fastJsonVersion', "1.2.66") set('fastJsonVersion', "1.2.66")
set('annotationsVersion',"3.0.1")
} }
dependencies { dependencies {
@ -87,6 +91,7 @@ dependencies {
implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}" implementation "org.apache.httpcomponents:httpclient:${httpclientVersion}"
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${dataformatYamlVersion}" implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${dataformatYamlVersion}"
implementation "org.eclipse.jgit:org.eclipse.jgit:${jgitVersion}" implementation "org.eclipse.jgit:org.eclipse.jgit:${jgitVersion}"
implementation "com.google.code.findbugs:annotations:${annotationsVersion}"
implementation "com.vladsch.flexmark:flexmark:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-attributes:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-attributes:${flexmarkVersion}"
@ -99,9 +104,10 @@ dependencies {
implementation "com.vladsch.flexmark:flexmark-ext-media-tags:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-media-tags:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-tables:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-tables:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-toc:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-toc:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-superscript:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-yaml-front-matter:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-yaml-front-matter:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-ext-gitlab:${flexmarkVersion}" implementation "com.vladsch.flexmark:flexmark-ext-gitlab:${flexmarkVersion}"
implementation "com.vladsch.flexmark:flexmark-html-parser:${flexmarkVersion}" // implementation "com.vladsch.flexmark:flexmark-html-parser:${flexmarkVersion}"
implementation "net.coobird:thumbnailator:${thumbnailatorVersion}" implementation "net.coobird:thumbnailator:${thumbnailatorVersion}"
implementation "net.sf.image4j:image4j:${image4jVersion}" implementation "net.sf.image4j:image4j:${image4jVersion}"

View File

@ -43,12 +43,6 @@ public class LinkController {
return new LinkDTO().convertFrom(linkService.getById(id)); return new LinkDTO().convertFrom(linkService.getById(id));
} }
@GetMapping("parse")
@ApiOperation("Gets link by parse url")
public LinkDTO getByParse(@RequestParam("url") String url) {
return linkService.getByParse(url);
}
@PostMapping @PostMapping
@ApiOperation("Creates a link") @ApiOperation("Creates a link")
public LinkDTO createBy(@RequestBody @Valid LinkParam linkParam) { public LinkDTO createBy(@RequestBody @Valid LinkParam linkParam) {

View File

@ -9,7 +9,6 @@ import run.halo.app.model.entity.BaseComment;
import run.halo.app.model.entity.BasePost; import run.halo.app.model.entity.BasePost;
import run.halo.app.model.entity.Category; import run.halo.app.model.entity.Category;
import run.halo.app.model.entity.Tag; import run.halo.app.model.entity.Tag;
import run.halo.app.utils.MarkdownUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
@ -129,7 +128,7 @@ public class WordPressConverter implements Converter<Rss, List<PostVO>> {
BasePost post = RelationMapperUtils.convertFrom(item, BasePost.class); BasePost post = RelationMapperUtils.convertFrom(item, BasePost.class);
Date postDate = DateUtil.parseDateTime(item.getPostDate()); Date postDate = DateUtil.parseDateTime(item.getPostDate());
if (StringUtils.isNoneEmpty(post.getFormatContent())) { if (StringUtils.isNoneEmpty(post.getFormatContent())) {
post.setOriginalContent(MarkdownUtils.renderMarkdown(post.getFormatContent())); post.setOriginalContent(post.getFormatContent());
} }
post.setCreateTime(postDate); post.setCreateTime(postDate);
post.setUpdateTime(postDate); post.setUpdateTime(postDate);

View File

@ -1,6 +1,8 @@
package run.halo.app.model.entity; package run.halo.app.model.entity;
import lombok.Data; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
@ -12,12 +14,14 @@ import java.util.Objects;
* *
* @author johnniang * @author johnniang
*/ */
@Getter
@Setter
@ToString(callSuper = true)
@RequiredArgsConstructor
@Entity @Entity
@Table(name = "post_categories", @Table(name = "post_categories",
indexes = {@Index(name = "post_categories_post_id", columnList = "post_id"), indexes = {@Index(name = "post_categories_post_id", columnList = "post_id"),
@Index(name = "post_categories_category_id", columnList = "category_id")}) @Index(name = "post_categories_category_id", columnList = "category_id")})
@Data
@ToString(callSuper = true)
public class PostCategory extends BaseEntity { public class PostCategory extends BaseEntity {
@Id @Id

View File

@ -1,6 +1,8 @@
package run.halo.app.model.entity; package run.halo.app.model.entity;
import lombok.Data; import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.hibernate.annotations.GenericGenerator; import org.hibernate.annotations.GenericGenerator;
@ -13,12 +15,14 @@ import java.util.Objects;
* @author ryanwang * @author ryanwang
* @date 2019-03-12 * @date 2019-03-12
*/ */
@Data @Getter
@Setter
@ToString(callSuper = true)
@RequiredArgsConstructor
@Entity @Entity
@Table(name = "post_tags", @Table(name = "post_tags",
indexes = {@Index(name = "post_tags_post_id", columnList = "post_id"), indexes = {@Index(name = "post_tags_post_id", columnList = "post_id"),
@Index(name = "post_tags_tag_id", columnList = "tag_id")}) @Index(name = "post_tags_tag_id", columnList = "tag_id")})
@ToString(callSuper = true)
public class PostTag extends BaseEntity { public class PostTag extends BaseEntity {
@Id @Id

View File

@ -19,12 +19,6 @@ import java.util.List;
*/ */
public interface LinkService extends CrudService<Link, Integer> { public interface LinkService extends CrudService<Link, Integer> {
String META_NAME = "name";
String META_DESCRIPTION = "description";
String META_CONTENT = "content";
/** /**
* List link dtos. * List link dtos.
* *
@ -66,12 +60,4 @@ public interface LinkService extends CrudService<Link, Integer> {
* @return a list of teams. * @return a list of teams.
*/ */
List<String> listAllTeams(); List<String> listAllTeams();
/**
* Get link by parse url.
*
* @param url url must not be null
* @return link dto
*/
LinkDTO getByParse(@NonNull String url);
} }

View File

@ -1,8 +1,5 @@
package run.halo.app.service.impl; package run.halo.app.service.impl;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.select.Elements;
import org.springframework.data.domain.Example; import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull; import org.springframework.lang.NonNull;
@ -11,7 +8,6 @@ import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import run.halo.app.exception.AlreadyExistsException; import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.exception.BadRequestException;
import run.halo.app.model.dto.LinkDTO; import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link; import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam; import run.halo.app.model.params.LinkParam;
@ -21,7 +17,6 @@ import run.halo.app.service.LinkService;
import run.halo.app.service.base.AbstractCrudService; import run.halo.app.service.base.AbstractCrudService;
import run.halo.app.utils.ServiceUtils; import run.halo.app.utils.ServiceUtils;
import java.io.IOException;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -105,30 +100,6 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
return linkRepository.findAllTeams(); return linkRepository.findAllTeams();
} }
@Override
public LinkDTO getByParse(String url) {
Assert.hasText(url, "Url must not be blank");
LinkDTO linkDTO = new LinkDTO();
linkDTO.setUrl(url);
try {
Document document = Jsoup.connect(url).get();
// Get html title.
linkDTO.setName(document.title());
// Get html metas.
Elements metas = document.head().select("meta");
metas.forEach(element -> {
if (META_DESCRIPTION.equalsIgnoreCase(element.attr(META_NAME))) {
linkDTO.setDescription(element.attr(META_CONTENT));
}
});
} catch (IOException e) {
throw new BadRequestException("获取网站信息失败").setErrorData(e);
}
return linkDTO;
}
@NonNull @NonNull
private List<LinkDTO> convertTo(@Nullable List<Link> links) { private List<LinkDTO> convertTo(@Nullable List<Link> links) {
if (CollectionUtils.isEmpty(links)) { if (CollectionUtils.isEmpty(links)) {

View File

@ -1,6 +1,5 @@
package run.halo.app.utils; package run.halo.app.utils;
import com.vladsch.flexmark.convert.html.FlexmarkHtmlParser;
import com.vladsch.flexmark.ext.attributes.AttributesExtension; import com.vladsch.flexmark.ext.attributes.AttributesExtension;
import com.vladsch.flexmark.ext.autolink.AutolinkExtension; import com.vladsch.flexmark.ext.autolink.AutolinkExtension;
import com.vladsch.flexmark.ext.emoji.EmojiExtension; import com.vladsch.flexmark.ext.emoji.EmojiExtension;
@ -12,6 +11,7 @@ import com.vladsch.flexmark.ext.gfm.tasklist.TaskListExtension;
import com.vladsch.flexmark.ext.gitlab.GitLabExtension; import com.vladsch.flexmark.ext.gitlab.GitLabExtension;
import com.vladsch.flexmark.ext.ins.InsExtension; import com.vladsch.flexmark.ext.ins.InsExtension;
import com.vladsch.flexmark.ext.media.tags.MediaTagsExtension; import com.vladsch.flexmark.ext.media.tags.MediaTagsExtension;
import com.vladsch.flexmark.ext.superscript.SuperscriptExtension;
import com.vladsch.flexmark.ext.tables.TablesExtension; import com.vladsch.flexmark.ext.tables.TablesExtension;
import com.vladsch.flexmark.ext.toc.TocExtension; import com.vladsch.flexmark.ext.toc.TocExtension;
import com.vladsch.flexmark.ext.yaml.front.matter.AbstractYamlFrontMatterVisitor; import com.vladsch.flexmark.ext.yaml.front.matter.AbstractYamlFrontMatterVisitor;
@ -19,8 +19,8 @@ import com.vladsch.flexmark.ext.yaml.front.matter.YamlFrontMatterExtension;
import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.html.HtmlRenderer;
import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.parser.Parser;
import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.util.ast.Node;
import com.vladsch.flexmark.util.options.DataHolder; import com.vladsch.flexmark.util.data.DataHolder;
import com.vladsch.flexmark.util.options.MutableDataSet; import com.vladsch.flexmark.util.data.MutableDataSet;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import run.halo.app.model.support.HaloConst; import run.halo.app.model.support.HaloConst;
@ -32,7 +32,7 @@ import java.util.Map;
* Markdown utils. * Markdown utils.
* *
* @author ryanwang * @author ryanwang
* @date 2019/06/27 * @date 2019-06-27
*/ */
public class MarkdownUtils { public class MarkdownUtils {
@ -48,6 +48,7 @@ public class MarkdownUtils {
MediaTagsExtension.create(), MediaTagsExtension.create(),
TablesExtension.create(), TablesExtension.create(),
TocExtension.create(), TocExtension.create(),
SuperscriptExtension.create(),
YamlFrontMatterExtension.create(), YamlFrontMatterExtension.create(),
GitLabExtension.create()) GitLabExtension.create())
) )
@ -99,15 +100,15 @@ public class MarkdownUtils {
return RENDERER.render(document); return RENDERER.render(document);
} }
/** // /**
* Render html document to markdown document. // * Render html document to markdown document.
* // *
* @param html html document // * @param html html document
* @return markdown document // * @return markdown document
*/ // */
public static String renderMarkdown(String html) { // public static String renderMarkdown(String html) {
return FlexmarkHtmlParser.parse(html); // return FlexmarkHtmlParser.parse(html);
} // }
/** /**
* Get front-matter * Get front-matter

@ -1 +1 @@
Subproject commit c0309ef9c8607cddab14ce6005168cb7b19ef066 Subproject commit 287bebe0bd3dc5d658537eb5b5bc9b906522cb1d