Skip to content

Commit

Permalink
Update for Flarum beta 16
Browse files Browse the repository at this point in the history
  • Loading branch information
clarkwinkelmann committed Mar 21, 2021
1 parent 98ed930 commit df2af7c
Show file tree
Hide file tree
Showing 52 changed files with 1,274 additions and 1,372 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md → LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Clark Winkelmann
Copyright (c) 2019-2021 Clark Winkelmann

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ You can let users change the fish names or choose the placement of the fish them

All aspects of the game are controlled via Flarum permissions.

The extensions comes with a starting pack of (public domain image) fishes that you can include when creating a new round.
The extension comes with a starting pack of (public domain image) fish that you can include when creating a new round.

## Installation

Expand Down
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
],
"support": {
"issues": "https://github.com/clarkwinkelmann/catch-the-fish/issues",
"source": "https://github.com/clarkwinkelmann/catch-the-fish"
"source": "https://github.com/clarkwinkelmann/catch-the-fish",
"forum": "https://discuss.flarum.org/d/19532"
},
"require": {
"flarum/core": "^0.1.0-beta.14"
"flarum/core": "^0.1.0-beta.16"
},
"extra": {
"flarum-extension": {
"title": "Catch the fish",
"category": "feature",
"icon": {
"name": "fas fa-fish",
"backgroundColor": "#90d71b",
Expand Down
67 changes: 57 additions & 10 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
namespace ClarkWinkelmann\CatchTheFish;

use ClarkWinkelmann\CatchTheFish\Controllers;
use ClarkWinkelmann\CatchTheFish\Extend as CTFExtend;
use ClarkWinkelmann\CatchTheFish\Extenders\ApiControllerIncludes;
use ClarkWinkelmann\CatchTheFish\Serializers\FishSerializer;
use ClarkWinkelmann\CatchTheFish\Serializers\RoundSerializer;
use Flarum\Api\Controller;
use Flarum\Api\Serializer;
use Flarum\Discussion\Discussion;
use Flarum\Extend;
use Flarum\Foundation\Application;
use Flarum\Post\Post;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
use Illuminate\Contracts\Events\Dispatcher;

return [
(new Extend\Frontend('forum'))
Expand All @@ -20,6 +23,7 @@
->route('/catch-the-fish/rounds/{id}', 'catch-the-fish-round'),
(new Extend\Frontend('admin'))
->js(__DIR__ . '/js/dist/admin.js'),

(new Extend\Routes('api'))
->get('/catch-the-fish/rounds', 'catchthefish.api.rounds.index', Controllers\RoundIndexController::class)
->post('/catch-the-fish/rounds', 'catchthefish.api.rounds.store', Controllers\RoundStoreController::class)
Expand All @@ -35,19 +39,62 @@
->post('/catch-the-fish/fishes/{id:[0-9]+}/place', 'catchthefish.api.fishes.place', Controllers\FishPlaceController::class)
->post('/catch-the-fish/fishes/{id:[0-9]+}/image', 'catchthefish.api.fishes.image', Controllers\FishImageController::class)
->get('/catch-the-fish/rounds/{id:[0-9]+}/rankings', 'catchthefish.api.rankings.index', Controllers\RankingIndexController::class),

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

(new Extend\Model(Discussion::class))
->relationship('catchTheFishFishes', new ConfigureFishesRelationship('discussion_id_placement')),
(new Extend\Model(Post::class))
->relationship('catchTheFishFishes', new ConfigureFishesRelationship('post_id_placement')),
(new Extend\Model(User::class))
->relationship('catchTheFishFishes', new ConfigureFishesRelationship('user_id_placement'))
->relationship('catchTheFishBasket', new ConfigureBasketRelationship()),
new CTFExtend\Policies(),
new CTFExtend\ForumRelationship(),
new CTFExtend\ResourceFishRelationship(),
new CTFExtend\UserFishBasketRelationship(),
function (Dispatcher $events, Application $app) {
$app->register(Providers\StorageServiceProvider::class);
},

(new Extend\ApiSerializer(Serializer\ForumSerializer::class))
->hasMany('catchTheFishActiveRounds', RoundSerializer::class)
->attributes(ForumAttributes::class),

(new Extend\ApiController(Controller\ShowForumController::class))
->addInclude('catchTheFishActiveRounds.ranking', function (): bool {
return resolve(SettingsRepositoryInterface::class)->get('catch-the-fish.alertRound', true);
})
->prepareDataForSerialization(LoadRoundsRelationship::class),

(new Extend\Policy())
->modelPolicy(Fish::class, Access\FishPolicy::class)
->modelPolicy(Round::class, Access\RoundPolicy::class),

(new Extend\ApiSerializer(Serializer\DiscussionSerializer::class))
->hasMany('catchTheFishFishes', FishSerializer::class),
(new Extend\ApiSerializer(Serializer\PostSerializer::class))
->hasMany('catchTheFishFishes', FishSerializer::class),
(new Extend\ApiSerializer(Serializer\UserSerializer::class))
->hasMany('catchTheFishFishes', FishSerializer::class),

(new ApiControllerIncludes([
Controller\ListDiscussionsController::class,
Controller\ShowDiscussionController::class,
Controller\UpdateDiscussionController::class,
Controller\ListPostsController::class,
Controller\ShowPostController::class,
Controller\UpdateUserController::class,
Controller\ListUsersController::class,
Controller\ShowUserController::class,
Controller\UpdateUserController::class,
]))
->addInclude('catchTheFishFishes.lastUserPlacement')
->addInclude('catchTheFishFishes.lastUserNaming'),

(new Extend\ApiController(Controller\ShowDiscussionController::class))
->addInclude('posts.catchTheFishFishes.lastUserPlacement')
->addInclude('posts.catchTheFishFishes.lastUserNaming'),

(new Extend\ApiSerializer(Serializer\CurrentUserSerializer::class))
->hasMany('catchTheFishBasket', FishSerializer::class),

(new Extend\ApiController(Controller\ShowUserController::class))
->addInclude('catchTheFishBasket'),

(new Extend\ServiceProvider())
->register(Providers\StorageServiceProvider::class),
];
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.

Loading

0 comments on commit df2af7c

Please sign in to comment.