From 174d35dc968a4f31bec4e7c3eb0a37c5f3493297 Mon Sep 17 00:00:00 2001 From: zeekling Date: Fri, 15 Apr 2022 20:07:04 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zeekling/blog/BlogUpdateServiceImpl.java | 56 ++++++++++--------- .../com/zeekling/blog/BlogUpdateTest.java | 2 +- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/zeekling/blog/BlogUpdateServiceImpl.java b/src/main/java/com/zeekling/blog/BlogUpdateServiceImpl.java index eb51cb5..d5c2876 100644 --- a/src/main/java/com/zeekling/blog/BlogUpdateServiceImpl.java +++ b/src/main/java/com/zeekling/blog/BlogUpdateServiceImpl.java @@ -79,43 +79,45 @@ public class BlogUpdateServiceImpl implements BlogUpdateService { } private String genSoloBlogReadme(final String repoFullName) { - final StringBuilder bodyBuilder = new StringBuilder("### 最新\n"); + final StringBuilder bodyBuilder = new StringBuilder("### 最新文章\n"); try { List entries = FeedXmlUtil.parseXml(blogConfigure.getRss()); for (SyndEntry syndEntry: entries){ - String des = syndEntry.getDescription().getValue(); - des = des.replaceAll("\n", "\n > "); - bodyBuilder.append("\n* \uD83D\uDCDD [").append(syndEntry.getTitle()).append("](").append(syndEntry.getLink()) - .append(") \n > ").append(des); + bodyBuilder.append("\n* \uD83D\uDCDD [") + .append(syndEntry.getTitle()) + .append("](") + .append(syndEntry.getLink()) + .append(") \n "); } } catch (FeedException | MalformedURLException e) { e.printStackTrace(); } bodyBuilder.append("\n\n"); - String ret = "### Hey \uD83D\uDC4B, I'm [ZEEKLING](https://www.zeekling.cn)! \n" + - "![Github Stats](https://github-readme-stats.vercel.app/api?username=zeekling&show_icons=true) \n" + - "### 我在[小令童鞋](https://www.zeekling.cn)的近期动态\n" + - "\n" + - "⭐️ Star [个人主页](https://github.com/zeekling/zeekling) 后会自动更新" + - "\n

\"${title}\"

" + - "${title}\n" + - "

\n" + - "\n" + - "

${subtitle}

\n" + - "

" + - "\n" + - "\n" + - "" + - "

\n" + - "\n" + - "${body}\n\n" + - "\n" ; + String ret = "### Hey \uD83D\uDC4B, I'm [${title}](${home})! \n" + + "\n![Github Stats](https://github-readme-stats.vercel.app/api?username=${username}&show_icons=true) \n\n" + + "### 我在博客[${title}](${home})的近期动态\n" + + "⭐️ Star [个人主页](https://github.com/${username}) 后会自动更新" + + "\n\n

\"${title}\"

" + + "

${title}

\n" + + "\n" + + "

${subtitle}

\n" + + "

" + + "\n" + + "\n" + + "" + + "" + + "

\n" + + "\n" + + "${body}\n\n" + + "\n"; ret = ret.replace("${title}", blogConfigure.getClientTitle()). - replace("${subtitle}", blogConfigure.getClientSubtitle()). - replace("${favicon}", blogConfigure.getFavicon()). - replace("${repoFullName}", repoFullName). - replace("${body}", bodyBuilder.toString()); + replace("${subtitle}", blogConfigure.getClientSubtitle()). + replace("${favicon}", blogConfigure.getFavicon()). + replace("${repoFullName}", repoFullName). + replace("${body}", bodyBuilder.toString()). + replace("${username}", blogConfigure.getRepoName()). + replace("${home}", blogConfigure.getHome()); return ret; } diff --git a/src/test/java/com/zeekling/blog/BlogUpdateTest.java b/src/test/java/com/zeekling/blog/BlogUpdateTest.java index 30d9cce..c09ef8c 100644 --- a/src/test/java/com/zeekling/blog/BlogUpdateTest.java +++ b/src/test/java/com/zeekling/blog/BlogUpdateTest.java @@ -14,7 +14,7 @@ public class BlogUpdateTest { @Test public void updateGitHub(){ - String configPath = "/home/zeek/project/github_zeekling/src/main/resources/blog.properties"; + String configPath = "/home/zeekling/project/ling/github_zeekling/src/main/resources/blog.properties"; BlogUpdateService updateService = new BlogUpdateServiceImpl(configPath); int res = updateService.update(); if (res == 0){