Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ on: [workflow_dispatch, push, pull_request]

jobs:
run:
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@1.x
uses: flarum/framework/.github/workflows/REUSABLE_frontend.yml@2.x
with:
enable_bundlewatch: false
enable_prettier: true
enable_typescript: false
enable_typescript: true

frontend_directory: ./js
backend_directory: .
js_package_manager: npm
main_git_branch: 1.x
main_git_branch: 2.x

secrets:
bundlewatch_github_token: ${{ secrets.BUNDLEWATCH_GITHUB_TOKEN }}
16 changes: 7 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,25 @@
"url": "https://github.com/android-com-pl/my-tags?sponsor=1"
}
],
"require": {
"php": "^8.0",
"flarum/core": "^1.8",
"fof/follow-tags": "*"
},
"authors": [
{
"name": "Rafał Całka",
"homepage": "https://github.com/rafaucau",
"role": "Developer"
},
{
"name": "Szymon Kilar",
"role": "Developer"
}
],
"autoload": {
"psr-4": {
"Acpl\\MyTags\\": "src/"
}
},
"require": {
"php": "^8.2",
"flarum/core": "^2.0.0-beta",
"fof/follow-tags": "^2.0.0-beta"
},
"prefer-stable": true,
"minimum-stability": "beta",
"extra": {
"flarum-extension": {
"title": "My Tags",
Expand Down
50 changes: 40 additions & 10 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,53 @@

namespace Acpl\MyTags;

use Flarum\Api\Controller\ShowForumController;
use Flarum\Api\Context;
use Flarum\Api\Endpoint;
use Flarum\Api\Resource;
use Flarum\Api\Schema;
use Flarum\Extend;
use Flarum\Tags\Tag;

return [
(new Extend\Frontend('forum'))->js(__DIR__.'/js/dist/forum.js')
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
(new Extend\Frontend('admin'))->js(__DIR__.'/js/dist/admin.js'),

(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js'),

new Extend\Locales(__DIR__.'/locale'),

(new Extend\ApiController(ShowForumController::class))
->prepareDataForSerialization(LoadForumTagsRelationship::class),
(new Extend\ApiResource(Resource\ForumResource::class))
->fields(fn () => [
Schema\Relationship\ToMany::make('myFollowedTags')
->type('tags')
->includable()
->get(function ($model, Context $context) {
$actor = $context->getActor();
if ($actor->isGuest()) {
return [];
}

$followedTags = Tag::query()
->join('tag_user', function ($join) use ($actor) {
$join->on('tag_user.tag_id', '=', 'tags.id')
->where('tag_user.user_id', '=', $actor->id)
->whereIn('tag_user.subscription', ['follow', 'lurk']);
})
->select('tags.*')
->whereVisibleTo($actor)
->withStateFor($actor)
->get();

return $followedTags->all();
}),
])
->endpoint('show', function (Endpoint\Show $endpoint) {
return $endpoint->addDefaultInclude(['myFollowedTags']);
}),

(new Extend\Settings())
->serializeToForum(
'my-tags.enable-placeholder',
'acpl-my-tags.enable-placeholder',
fn ($value) => ! empty($value)
),
->serializeToForum('my-tags.enable-placeholder', 'acpl-my-tags.enable-placeholder')
->default('my-tags.enable-placeholder', false),
];
2 changes: 1 addition & 1 deletion js/dist/admin.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/admin.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/dist/forum.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading