Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5a13068143 | |||
| b1f30b374f |
@@ -1,3 +1,19 @@
|
|||||||
|
# anian-plugin-friends
|
||||||
|
|
||||||
|
> 基于原作者v1.4.3代码修改
|
||||||
|
|
||||||
|
#### v1.4.3-2
|
||||||
|
1. 新增URL参数author用于查询作者
|
||||||
|
2. 模板参数新增${authors}返回所有作者
|
||||||
|
|
||||||
|
#### v1.4.3-1
|
||||||
|
1. 大幅增加description字段的字符数上限
|
||||||
|
2. 去除description字段内的微博视频提示
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# plugin-friends
|
# plugin-friends
|
||||||
> 1.3.4版本重构朋友圈插件
|
> 1.3.4版本重构朋友圈插件
|
||||||
> 如果使用了之前版本,请清掉之前的所有数据,不然会有问题
|
> 如果使用了之前版本,请清掉之前的所有数据,不然会有问题
|
||||||
@@ -232,4 +248,4 @@ cd path/to/plugin-friends
|
|||||||
|
|
||||||
# Windows
|
# Windows
|
||||||
./gradlew.bat build
|
./gradlew.bat build
|
||||||
```
|
```
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@ repositories {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation platform('run.halo.tools.platform:plugin:2.20.0-SNAPSHOT')
|
implementation platform('run.halo.tools.platform:plugin:2.20.11')
|
||||||
compileOnly 'run.halo.app:api'
|
compileOnly 'run.halo.app:api'
|
||||||
|
|
||||||
testImplementation 'run.halo.app:api'
|
testImplementation 'run.halo.app:api'
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
version=1.3.7
|
version=1.4.3-2
|
||||||
|
|||||||
Generated
+9953
File diff suppressed because it is too large
Load Diff
@@ -25,4 +25,6 @@ public interface FriendFinder {
|
|||||||
Mono<FriendPostVo> getByName(String friendPostName);
|
Mono<FriendPostVo> getByName(String friendPostName);
|
||||||
|
|
||||||
Flux<LinkGroupVo> linkGroupBy();
|
Flux<LinkGroupVo> linkGroupBy();
|
||||||
|
|
||||||
|
Flux<String> listAllAuthors();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,6 +96,22 @@ public class FriendFinderImpl implements FriendFinder {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<String> listAllAuthors() {
|
||||||
|
var listOptions = new ListOptions();
|
||||||
|
// 只查有数据的,排除已删除的
|
||||||
|
var query = isNull("metadata.deletionTimestamp");
|
||||||
|
listOptions.setFieldSelector(FieldSelector.of(query));
|
||||||
|
|
||||||
|
return client.listAll(FriendPost.class, listOptions, defaultSort())
|
||||||
|
// 提取作者名
|
||||||
|
.map(friendPost -> friendPost.getSpec().getAuthor())
|
||||||
|
// 过滤掉空值
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
// 去重
|
||||||
|
.distinct();
|
||||||
|
}
|
||||||
|
|
||||||
private Mono<ListResult<FriendPostVo>> pageFriendPost(ListOptions queryOptions, PageRequest page){
|
private Mono<ListResult<FriendPostVo>> pageFriendPost(ListOptions queryOptions, PageRequest page){
|
||||||
var listOptions = new ListOptions();
|
var listOptions = new ListOptions();
|
||||||
var query = all();
|
var query = all();
|
||||||
@@ -220,6 +236,8 @@ public class FriendFinderImpl implements FriendFinder {
|
|||||||
private Integer page;
|
private Integer page;
|
||||||
private Integer size;
|
private Integer size;
|
||||||
private String linkName;
|
private String linkName;
|
||||||
|
// 作者查询
|
||||||
|
private String author;
|
||||||
private List<String> sort;
|
private List<String> sort;
|
||||||
|
|
||||||
public ListOptions toListOptions() {
|
public ListOptions toListOptions() {
|
||||||
@@ -227,6 +245,10 @@ public class FriendFinderImpl implements FriendFinder {
|
|||||||
if (StringUtils.isNotBlank(linkName)) {
|
if (StringUtils.isNotBlank(linkName)) {
|
||||||
builder.andQuery(equal("spec.linkName", linkName));
|
builder.andQuery(equal("spec.linkName", linkName));
|
||||||
}
|
}
|
||||||
|
// 作者查询
|
||||||
|
if (StringUtils.isNotBlank(author)) {
|
||||||
|
builder.andQuery(equal("spec.author", author));
|
||||||
|
}
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,12 @@ public class FriendPostQuery extends SortableRequest {
|
|||||||
return queryParams.getFirst("linkName");
|
return queryParams.getFirst("linkName");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 作者查询
|
||||||
|
@Nullable
|
||||||
|
public String getAuthor() {
|
||||||
|
return StringUtils.defaultIfBlank(queryParams.getFirst("author"), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public ListOptions toListOptions() {
|
public ListOptions toListOptions() {
|
||||||
var builder = ListOptions.builder(super.toListOptions());
|
var builder = ListOptions.builder(super.toListOptions());
|
||||||
@@ -55,6 +61,11 @@ public class FriendPostQuery extends SortableRequest {
|
|||||||
.filter(StringUtils::isNotBlank)
|
.filter(StringUtils::isNotBlank)
|
||||||
.ifPresent(linkName -> builder.andQuery(equal("spec.linkName", linkName)));
|
.ifPresent(linkName -> builder.andQuery(equal("spec.linkName", linkName)));
|
||||||
|
|
||||||
|
// 作者查询
|
||||||
|
Optional.ofNullable(getAuthor())
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.ifPresent(author -> builder.andQuery(equal("spec.author", author)));
|
||||||
|
|
||||||
return builder.build();
|
return builder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,6 +113,13 @@ public class FriendPostQuery extends SortableRequest {
|
|||||||
.name("keyword")
|
.name("keyword")
|
||||||
.description("CronFriendPost filtered by keyword.")
|
.description("CronFriendPost filtered by keyword.")
|
||||||
.implementation(String.class)
|
.implementation(String.class)
|
||||||
|
.required(false))
|
||||||
|
// 作者查询
|
||||||
|
.parameter(parameterBuilder()
|
||||||
|
.in(ParameterIn.QUERY)
|
||||||
|
.name("author")
|
||||||
|
.description("FriendPost filtered by exact author name.")
|
||||||
|
.implementation(String.class)
|
||||||
.required(false));
|
.required(false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,9 +177,11 @@ public class RssSyncReconciler implements Reconciler<RssSyncReconciler.Request>,
|
|||||||
String description = friendPost.getSpec().getDescription();
|
String description = friendPost.getSpec().getDescription();
|
||||||
//解析html内容转换成文本
|
//解析html内容转换成文本
|
||||||
if (StringUtils.isNotEmpty(description)){
|
if (StringUtils.isNotEmpty(description)){
|
||||||
description = CommonUtils.parseAndTruncateHtml2Text(description, 200);
|
description = CommonUtils.parseAndTruncateHtml2Text(description, 100000);
|
||||||
String regexp = "[ *|\\s*]*";
|
String regexp = "[ *|\\s*]*";
|
||||||
description = description.replaceFirst(regexp, "").trim();
|
description = description.replaceFirst(regexp, "").trim();
|
||||||
|
String weiboVideoRegex = "\\s[^\\s]*的微博视频 视频无法显示,请前往微博视频观看。";
|
||||||
|
description = description.replaceAll(weiboVideoRegex, "");
|
||||||
friendPostSpec.setDescription(description);
|
friendPostSpec.setDescription(description);
|
||||||
}
|
}
|
||||||
client.create(friendPost);
|
client.create(friendPost);
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class FriendRouter {
|
|||||||
.flatMap( templateName -> ServerResponse.ok().render(templateName,
|
.flatMap( templateName -> ServerResponse.ok().render(templateName,
|
||||||
java.util.Map.of(ModelConst.TEMPLATE_ID, templateName,
|
java.util.Map.of(ModelConst.TEMPLATE_ID, templateName,
|
||||||
"friends", friendPostList(request),
|
"friends", friendPostList(request),
|
||||||
|
"authors", friendFinder.listAllAuthors().collectList(),
|
||||||
"title",getFriendTitle())
|
"title",getFriendTitle())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
@@ -65,6 +66,24 @@ public class FriendRouter {
|
|||||||
String linkName = request.queryParam("linkName")
|
String linkName = request.queryParam("linkName")
|
||||||
.filter(StringUtils::isNotBlank)
|
.filter(StringUtils::isNotBlank)
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
// --- 新增:获取 author 参数 ---
|
||||||
|
String author = request.queryParam("author")
|
||||||
|
.filter(StringUtils::isNotBlank)
|
||||||
|
.orElse(null);
|
||||||
|
|
||||||
|
// --- 新增:构建查询参数字符串 ---
|
||||||
|
StringBuilder queryString = new StringBuilder();
|
||||||
|
if (StringUtils.isNotBlank(linkName)) {
|
||||||
|
queryString.append("linkName=").append(linkName);
|
||||||
|
}
|
||||||
|
if (StringUtils.isNotBlank(author)) {
|
||||||
|
if (queryString.length() > 0) {
|
||||||
|
queryString.append("&");
|
||||||
|
}
|
||||||
|
queryString.append("author=").append(author);
|
||||||
|
}
|
||||||
|
final String finalQueryString = queryString.toString();
|
||||||
|
|
||||||
return this.settingFetcher.get("base")
|
return this.settingFetcher.get("base")
|
||||||
.map(item -> item.get("pageSize").asInt(10))
|
.map(item -> item.get("pageSize").asInt(10))
|
||||||
.defaultIfEmpty(10)
|
.defaultIfEmpty(10)
|
||||||
@@ -75,20 +94,44 @@ public class FriendRouter {
|
|||||||
if(StringUtils.isNotBlank(linkName)){
|
if(StringUtils.isNotBlank(linkName)){
|
||||||
params.put("linkName",linkName);
|
params.put("linkName",linkName);
|
||||||
}
|
}
|
||||||
|
// --- 新增:把 author 也放进 params ---
|
||||||
|
if(StringUtils.isNotBlank(author)){
|
||||||
|
params.put("author",author);
|
||||||
|
}
|
||||||
|
|
||||||
return friendFinder.list(params)
|
return friendFinder.list(params)
|
||||||
.map(list -> new UrlContextListResult.Builder<FriendPostVo>()
|
.map(list -> {
|
||||||
.listResult(list)
|
// --- 修改:生成链接时带上查询参数 ---
|
||||||
.nextUrl(PageUrlUtils.nextPageUrl(path, totalPage(list)))
|
String baseNextUrl = PageUrlUtils.nextPageUrl(path, totalPage(list));
|
||||||
.prevUrl(PageUrlUtils.prevPageUrl(path))
|
String basePrevUrl = PageUrlUtils.prevPageUrl(path);
|
||||||
.build()
|
|
||||||
);
|
String nextUrl = appendQueryString(baseNextUrl, finalQueryString);
|
||||||
|
String prevUrl = appendQueryString(basePrevUrl, finalQueryString);
|
||||||
|
|
||||||
|
return new UrlContextListResult.Builder<FriendPostVo>()
|
||||||
|
.listResult(list)
|
||||||
|
.nextUrl(nextUrl)
|
||||||
|
.prevUrl(prevUrl)
|
||||||
|
.build();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- 新增:辅助方法,用于拼接查询参数 ---
|
||||||
|
private String appendQueryString(String url, String queryString) {
|
||||||
|
if (StringUtils.isBlank(queryString)) {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
if (url.contains("?")) {
|
||||||
|
return url + "&" + queryString;
|
||||||
|
} else {
|
||||||
|
return url + "?" + queryString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private int pageNumInPathVariable(ServerRequest request) {
|
private int pageNumInPathVariable(ServerRequest request) {
|
||||||
String page = request.pathVariables().get("page");
|
String page = request.pathVariables().get("page");
|
||||||
return NumberUtils.toInt(page, 1);
|
return NumberUtils.toInt(page, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user