更新样式 #2
@ -79,43 +79,45 @@ public class BlogUpdateServiceImpl implements BlogUpdateService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String genSoloBlogReadme(final String repoFullName) {
|
private String genSoloBlogReadme(final String repoFullName) {
|
||||||
final StringBuilder bodyBuilder = new StringBuilder("### 最新\n");
|
final StringBuilder bodyBuilder = new StringBuilder("### 最新文章\n");
|
||||||
try {
|
try {
|
||||||
List<SyndEntry> entries = FeedXmlUtil.parseXml(blogConfigure.getRss());
|
List<SyndEntry> entries = FeedXmlUtil.parseXml(blogConfigure.getRss());
|
||||||
for (SyndEntry syndEntry: entries){
|
for (SyndEntry syndEntry: entries){
|
||||||
String des = syndEntry.getDescription().getValue();
|
bodyBuilder.append("\n* \uD83D\uDCDD [")
|
||||||
des = des.replaceAll("\n", "\n > ");
|
.append(syndEntry.getTitle())
|
||||||
bodyBuilder.append("\n* \uD83D\uDCDD [").append(syndEntry.getTitle()).append("](").append(syndEntry.getLink())
|
.append("](")
|
||||||
.append(") \n > ").append(des);
|
.append(syndEntry.getLink())
|
||||||
|
.append(") \n ");
|
||||||
}
|
}
|
||||||
} catch (FeedException | MalformedURLException e) {
|
} catch (FeedException | MalformedURLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
bodyBuilder.append("\n\n");
|
bodyBuilder.append("\n\n");
|
||||||
|
|
||||||
String ret = "### Hey \uD83D\uDC4B, I'm [ZEEKLING](https://www.zeekling.cn)! \n" +
|
String ret = "### Hey \uD83D\uDC4B, I'm [${title}](${home})! \n" +
|
||||||
"![Github Stats](https://github-readme-stats.vercel.app/api?username=zeekling&show_icons=true) \n" +
|
"\n![Github Stats](https://github-readme-stats.vercel.app/api?username=${username}&show_icons=true) \n\n" +
|
||||||
"### 我在[小令童鞋](https://www.zeekling.cn)的近期动态\n" +
|
"### 我在博客[${title}](${home})的近期动态\n" +
|
||||||
"\n" +
|
"⭐️ Star [个人主页](https://github.com/${username}) 后会自动更新" +
|
||||||
"⭐️ Star [个人主页](https://github.com/zeekling/zeekling) 后会自动更新" +
|
"\n\n<p align=\"center\"><img alt=\"${title}\" src=\"${favicon}\"></p>" +
|
||||||
"\n<p align=\"center\"><img alt=\"${title}\" src=\"${favicon}\"></p><h2 align=\"center\">" +
|
"<h2 align=\"center\"> ${title} </h2>\n" +
|
||||||
"${title}\n" +
|
|
||||||
"</h2>\n" +
|
|
||||||
"\n" +
|
"\n" +
|
||||||
"<h4 align=\"center\">${subtitle}</h4>\n" +
|
"<h4 align=\"center\">${subtitle}</h4>\n" +
|
||||||
"<p align=\"center\">" +
|
"<p align=\"center\">" +
|
||||||
"<a title=\"${title}\" target=\"_blank\" href=\"https://github.com/${repoFullName}\"><img src=\"https://img.shields.io/github/last-commit/${repoFullName}.svg?style=flat-square&color=FF9900\"></a>\n" +
|
"<a title=\"${title}\" target=\"_blank\" href=\"https://github.com/${repoFullName}\"><img src=\"https://img.shields.io/github/last-commit/${repoFullName}.svg?style=flat-square&color=FF9900\"></a>\n" +
|
||||||
"<a title=\"GitHub repo size in bytes\" target=\"_blank\" href=\"https://github.com/${repoFullName}\"><img src=\"https://img.shields.io/github/repo-size/${repoFullName}.svg?style=flat-square\"></a>\n" +
|
"<a title=\"GitHub repo size in bytes\" target=\"_blank\" href=\"https://github.com/${repoFullName}\"><img src=\"https://img.shields.io/github/repo-size/${repoFullName}.svg?style=flat-square\"></a>\n" +
|
||||||
"<a title=\"Hits\" target=\"_blank\" href=\"https://github.com/zeekling/hits\"><img src=\"https://hits.b3log.org/${repoFullName}.svg\"></a>" +
|
"<a title=\"Hits\" target=\"_blank\" href=\"https://github.com/${username}/hits\">" +
|
||||||
|
"<img src=\"https://hits.b3log.org/${repoFullName}.svg\"></a>" +
|
||||||
"</p>\n" +
|
"</p>\n" +
|
||||||
"\n" +
|
"\n" +
|
||||||
"${body}\n\n" +
|
"${body}\n\n" +
|
||||||
"\n" ;
|
"\n";
|
||||||
ret = ret.replace("${title}", blogConfigure.getClientTitle()).
|
ret = ret.replace("${title}", blogConfigure.getClientTitle()).
|
||||||
replace("${subtitle}", blogConfigure.getClientSubtitle()).
|
replace("${subtitle}", blogConfigure.getClientSubtitle()).
|
||||||
replace("${favicon}", blogConfigure.getFavicon()).
|
replace("${favicon}", blogConfigure.getFavicon()).
|
||||||
replace("${repoFullName}", repoFullName).
|
replace("${repoFullName}", repoFullName).
|
||||||
replace("${body}", bodyBuilder.toString());
|
replace("${body}", bodyBuilder.toString()).
|
||||||
|
replace("${username}", blogConfigure.getRepoName()).
|
||||||
|
replace("${home}", blogConfigure.getHome());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ public class BlogUpdateTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void updateGitHub(){
|
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);
|
BlogUpdateService updateService = new BlogUpdateServiceImpl(configPath);
|
||||||
int res = updateService.update();
|
int res = updateService.update();
|
||||||
if (res == 0){
|
if (res == 0){
|
||||||
|
Loading…
Reference in New Issue
Block a user