Skip to content

Commit

Permalink
Flarum 1.0 (#4)
Browse files Browse the repository at this point in the history
* Update for 1.0

* Rename filterer to better reflect its purpose

* Apply fixes from StyleCI

* Add is:followeduser gambit, integrate filter into fof/user-directory

* Apply fixes from StyleCI

* Correct negate query

* Apply fixes from StyleCI

* Add screenshot for user-directory integration

Co-authored-by: Ian Morland <[email protected]>
  • Loading branch information
imorland and imorland authored May 26, 2021
1 parent 9b08be4 commit 2d30d91
Show file tree
Hide file tree
Showing 29 changed files with 192 additions and 56 deletions.
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Ian Morland
Copyright (c) 2021 Ian Morland

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@ A [Flarum](http://flarum.org) extension. Follow users and be notified of new dis
Building on top of `fof/follow-tags`, this extension allows for following of individual users.

### Features
- Requires Flarum beta 15 or above
- Adds a 'Followed User' badge to users that _you_ follow, forum wide
- Adds A 'Followed Users' filter to the following filter
- Permission for which groups can be followed
- User preference to block followers
- Notifications for 'Followed', 'Unfollowed', 'Followed User Started Discussion' and 'Followed User Posted'
- Integration with `fof/user-directory`
- Provides a search gambit `is:followeduser`
- [Developers] events dispatched for `Following` and `Unfollowing`

##### Discussion list
![image](https://user-images.githubusercontent.com/16573496/102770472-2161df00-437c-11eb-8274-6f73d58b1042.png)

##### Following dropdown
![image](https://user-images.githubusercontent.com/16573496/102770549-40f90780-437c-11eb-801e-a7fb9e08e704.png)

##### `fof/user-directory` integration
![image](https://user-images.githubusercontent.com/16573496/119695069-ba25ea80-be45-11eb-9f0e-ff7545f29261.png)

##### Notification preferences
![image](https://user-images.githubusercontent.com/16573496/102770611-55d59b00-437c-11eb-8d57-408770c34d69.png)

Expand All @@ -28,10 +33,10 @@ Building on top of `fof/follow-tags`, this extension allows for following of ind

### Installation

Install manually with composer:
Install with composer:

```sh
composer require ianm/follow-users
composer require ianm/follow-users:"*"
```

`fof/follow-tags` *must* be enabled *before* this extension is enabled.
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"forum": "https://discuss.flarum.org/d/25701"
},
"require": {
"flarum/core": "^0.1.0-beta.16",
"fof/follow-tags": "^0.7.1"
"flarum/core": "^1.0.0",
"fof/follow-tags": "^1.0.0"
},
"authors": [
{
Expand All @@ -29,15 +29,16 @@
},
"extra": {
"flarum-extension": {
"title": "IM Follow Users",
"title": "Follow Users",
"category": "feature",
"icon": {
"name": "fas fa-user-friends",
"backgroundColor": "#0072e3",
"color": "#fff"
},
"optional-dependencies": [
"fof/follow-tags"
"fof/follow-tags",
"fof/user-directory"
]
},
"flagrow": {
Expand Down
12 changes: 10 additions & 2 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand All @@ -23,6 +23,8 @@
use Flarum\Discussion\Filter\DiscussionFilterer;
use Flarum\Extend;
use Flarum\User\Event\Saving;
use Flarum\User\Filter\UserFilterer;
use Flarum\User\Search\UserSearcher;
use Flarum\User\User;

return [
Expand Down Expand Up @@ -62,7 +64,13 @@
->subscribe(Listeners\QueueNotificationJobs::class),

(new Extend\Filter(DiscussionFilterer::class))
->addFilter(Query\FollowUsersFilter::class),
->addFilter(Query\FollowUsersDiscussionFilter::class),

(new Extend\Filter(UserFilterer::class))
->addFilter(Query\FollowedUsersFilterGambit::class),

(new Extend\SimpleFlarumSearch(UserSearcher::class))
->addGambit(Query\FollowedUsersFilterGambit::class),

(new Extend\User())
->registerPreference('blocksFollow', 'boolval', false),
Expand Down
51 changes: 30 additions & 21 deletions js/package-lock.json

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

2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
},
"devDependencies": {
"flarum": "0.1.0-beta.16",
"prettier": "^2.2.1"
"prettier": "^2.3.0"
}
}
2 changes: 1 addition & 1 deletion js/src/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import app from 'flarum/app';
import app from 'flarum/common/app';
import * as follow_tags from '@fof-follow-tags';
import followingPageOptions from '../common/helpers/followingPageOptions';

Expand Down
31 changes: 31 additions & 0 deletions js/src/forum/addFollowingUsers.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { extend } from 'flarum/common/extend';
import * as follow_tags from '@fof-follow-tags';
import * as user_directory from '@fof-user-directory';
import DiscussionListState from 'flarum/common/states/DiscussionListState';
import followingPageOptions from '../common/helpers/followingPageOptions';
import Separator from 'flarum/common/components/Separator';

export default function () {
if (app.initializers.has('fof/follow-tags')) {
Expand All @@ -26,4 +28,33 @@ export default function () {
}
});
}

if (app.initializers.has('fof-user-directory')) {
extend(user_directory.UserDirectoryPage.prototype, 'groupItems', function (items) {
items.add(
'follow-users',
user_directory.CheckableButton.component(
{
className: 'GroupFilterButton',
icon: 'fas fa-user-friends',
checked: this.enabledSpecialGroupFilters['ianm-follow-users'] === 'is:followeduser',
onclick: () => {
const id = 'ianm-follow-users';
if (this.enabledSpecialGroupFilters[id] === 'is:followeduser') {
this.enabledSpecialGroupFilters[id] = '';
} else {
this.enabledSpecialGroupFilters[id] = 'is:followeduser';
}

this.changeParams(this.params().sort);
},
},
app.translator.trans('ianm-follow-users.forum.filter.following')
),
65
);

items.add('seperator', Separator.component(), 50);
});
}
}
2 changes: 1 addition & 1 deletion js/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const config = require('flarum-webpack-config')({
useExtensions: ['fof-follow-tags']
useExtensions: ['fof-follow-tags', 'fof-user-directory']
});

module.exports = config;
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion migrations/0000_00_00_000001_set_default_permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
3 changes: 3 additions & 0 deletions resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ ianm-follow-users:
badge:
label: Followed user

filter:
following: Followed users

email:
new_discussion_by_user_subject: "[Follow User] {title}"
new_follower_subject: "[Follow User] You have a new follower!"
Expand Down
2 changes: 1 addition & 1 deletion src/Access/UserPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Following.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Events/Unfollowing.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/SendNotificationWhenDiscussionIsStarted.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/SendNotificationWhenFollowerPosted.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/SendNotificationWhenUserIsFollowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
2 changes: 1 addition & 1 deletion src/Jobs/SendNotificationWhenUserIsUnfollowed.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* This file is part of ianm/follow-users
*
* Copyright (c) 2020 Ian Morland.
* Copyright (c) Ian Morland.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
Expand Down
Loading

0 comments on commit 2d30d91

Please sign in to comment.