generated from halo-dev/plugin-starter
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/main' into feature/telemetry
- Loading branch information
Showing
7 changed files
with
157 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Publish plugin API module to Maven | ||
|
||
on: | ||
release: | ||
types: [ published ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: Extract version from GitHub tag | ||
id: extract_version | ||
run: | | ||
tag_name=${{ github.event.release.tag_name }} | ||
VERSION=${tag_name#v} | ||
echo "Extracted Version: $VERSION" | ||
echo "VERSION=$VERSION" >> $GITHUB_ENV | ||
- name: Build with Gradle | ||
run: ./gradlew clean build -Pversion=${{ env.VERSION }} | ||
|
||
- name: Push to Maven | ||
env: | ||
OSSR_USERNAME: ${{ secrets.MAVEN_USERNAME }} | ||
OSSR_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} | ||
run: ./gradlew :api:publish -Pversion=${{ env.VERSION }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
app/src/main/java/run/halo/feed/provider/TagPostRssProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package run.halo.feed.provider; | ||
|
||
import org.springframework.lang.NonNull; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.reactive.function.server.ServerRequest; | ||
import reactor.core.publisher.Flux; | ||
import reactor.core.publisher.Mono; | ||
import run.halo.app.content.PostContentService; | ||
import run.halo.app.extension.ListResult; | ||
import run.halo.app.extension.ReactiveExtensionClient; | ||
import run.halo.app.infra.ExternalLinkProcessor; | ||
import run.halo.app.infra.ExternalUrlSupplier; | ||
import run.halo.app.infra.SystemInfoGetter; | ||
import run.halo.app.plugin.ReactiveSettingFetcher; | ||
import run.halo.feed.BasicProp; | ||
import run.halo.feed.RSS2; | ||
import run.halo.feed.RssRouteItem; | ||
import run.halo.feed.service.PostService; | ||
|
||
@Component | ||
public class TagPostRssProvider extends AbstractPostRssProvider implements RssRouteItem { | ||
|
||
public TagPostRssProvider(PostService postService, ReactiveExtensionClient client, | ||
ExternalLinkProcessor externalLinkProcessor, ReactiveSettingFetcher settingFetcher, | ||
PostContentService postContentService, ExternalUrlSupplier externalUrlSupplier, | ||
SystemInfoGetter systemInfoGetter) { | ||
super(postService, client, externalLinkProcessor, settingFetcher, postContentService, | ||
externalUrlSupplier, systemInfoGetter); | ||
} | ||
|
||
@Override | ||
public Mono<String> pathPattern() { | ||
return BasicProp.getBasicProp(settingFetcher) | ||
.filter(BasicProp::isEnableCategories) | ||
.map(prop -> "/tags/{slug}.xml"); | ||
} | ||
|
||
@Override | ||
@NonNull | ||
public String displayName() { | ||
return "标签文章订阅"; | ||
} | ||
|
||
@Override | ||
public String description() { | ||
return "按标签订阅站点文章"; | ||
} | ||
|
||
public Mono<RSS2> handler(ServerRequest request) { | ||
var slug = request.pathVariable("slug"); | ||
return super.handler(request) | ||
.flatMap(rss2 -> postService.getTagBySlug(slug) | ||
.doOnNext(tag -> { | ||
var displayName = tag.getSpec().getDisplayName(); | ||
var permalink = tag.getStatusOrDefault().getPermalink(); | ||
rss2.setTitle("标签:" + displayName + " - " + rss2.getTitle()); | ||
rss2.setLink(externalLinkProcessor.processLink(permalink)); | ||
}) | ||
.thenReturn(rss2) | ||
); | ||
} | ||
|
||
@Override | ||
protected Flux<PostWithContent> listPosts(ServerRequest request) { | ||
var tagSlug = request.pathVariable("slug"); | ||
return listPostsByFunc(basicProp -> | ||
postService.listPostByTagSlug(basicProp.getOutputNum(), tagSlug) | ||
.flatMapIterable(ListResult::getItems) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters