Skip to content

Commit

Permalink
fix: post links on user feed, add profile feed
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland committed Dec 20, 2023
1 parent ae70a6b commit 6391780
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_backend.yml@1.x
with:
enable_backend_testing: false
enable_phpstan: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@main
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
with:
enable_bundlewatch: false
enable_prettier: true
Expand Down
20 changes: 19 additions & 1 deletion js/src/forum/addFeedIcons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import app from 'flarum/forum/app';
import { extend } from 'flarum/common/extend';
import IndexPage from 'flarum/forum/components/IndexPage';
import type Mithril from 'mithril';
import DiscussionPage from 'flarum/forum/components/DiscussionPage';
import DiscussionControls from 'flarum/forum/utils/DiscussionControls';
import LinkButton from 'flarum/common/components/LinkButton';
import Discussion from 'flarum/common/models/Discussion';
import UserPage from 'flarum/forum/components/UserPage';
import type User from 'flarum/common/models/User';

export default function addFeedIcons() {
extend(IndexPage.prototype, 'actionItems', function (items: ItemList<Mithril.Children>) {
Expand Down Expand Up @@ -42,4 +43,21 @@ export default function addFeedIcons() {
</LinkButton>
);
});

extend(UserPage.prototype, 'navItems', function (this: UserPage, items) {
if (!app.forum.attribute('ianm-syndication.plugin.forum-icons')) {
return;
}

const format = app.forum.attribute('ianm-syndication.plugin.forum-format');
const url = app.forum.attribute('baseUrl') + '/' + format + '/u/' + this.user.username() + '/posts';

items.add(
'rss-feed',
<LinkButton icon="fas fa-rss" href={url} external={true} target="_blank">
{app.translator.trans('ianm-syndication.forum.discussion.feed_link')}
</LinkButton>,
40
);
});
}
6 changes: 5 additions & 1 deletion src/Controller/UserPostsFeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
namespace IanM\FlarumFeeds\Controller;

use DateTime;
use Flarum\Discussion\Discussion;
use Flarum\Http\SlugManager;
use Flarum\Post\CommentPost;
use Flarum\Post\PostRepository;
use Flarum\User\UserRepository;
Expand Down Expand Up @@ -73,14 +75,16 @@ protected function getFeedContent(Request $request): array
$entries = [];
$lastModified = null;

$slugger = resolve(SlugManager::class);

/** @var CommentPost $post */
foreach ($posts as $post) {
$entries[] = [
'title' => $post->discussion->user_id === $user->id
? $post->discussion->title
: $this->translator->trans('ianm-syndication.forum.feeds.entries.user_posts.title_reply', ['{discussion}' => $post->discussion->title]),
'content' => $this->summarize($this->stripHTML($post->formatContent($request))),
'link' => $this->url->to('forum')->route('discussion', ['id' => $post->discussion->slug, 'near' => $post->number]),
'link' => $this->url->to('forum')->route('discussion', ['id' => $slugger->forResource(Discussion::class)->toSlug($post->discussion), 'near' => $post->number]),
'id' => $this->url->to('forum')->route('discussion', ['id' => $post->discussion->id, 'near' => $post->number]),
'pubdate' => $this->parseDate($post->created_at->format(DateTime::RFC3339)),
'author' => $username,
Expand Down

0 comments on commit 6391780

Please sign in to comment.