-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ba8cca8
Showing
14 changed files
with
174 additions
and
0 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,22 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2019 Stichting Flarum (Flarum Foundation) | ||
Copyright (c) 2014-2019 Toby Zerner ([email protected]) | ||
|
||
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: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,27 @@ | ||
## Topic Starter Label | ||
|
||
![License](https://img.shields.io/badge/license-MIT-blue.svg) | ||
|
||
A [Flarum](http://flarum.org) extension. Extension adds a label to the discussion author | ||
|
||
|
||
![Topic Starter Label](https://i.imgur.com/yOLYb11.png) | ||
|
||
|
||
### Installation | ||
|
||
```sh | ||
composer require dem13n/topic-starter-label | ||
``` | ||
|
||
### Updating | ||
|
||
```sh | ||
composer update dem13n/topic-starter-label | ||
php flarum cache:clear | ||
``` | ||
|
||
### Links | ||
|
||
- [Packagist](https://packagist.org/packages/dem13n/topic-starter-label) | ||
"# Topic Starter Label" |
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,32 @@ | ||
{ | ||
"name": "dem13n/topic-starter-label", | ||
"description": "Adds a label to the discussion author", | ||
"type": "flarum-extension", | ||
"keywords": ["discussion"], | ||
"license": "MIT", | ||
"authors": [ | ||
{ | ||
"name": "Dem13n", | ||
"email": "[email protected]" | ||
} | ||
], | ||
"require": { | ||
"flarum/core": "^0.1.0-beta.15" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Dem13n\\Topic\\Starter\\Label\\": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "Topic Starter Label", | ||
"category": "discussion", | ||
"icon": { | ||
"name": "fas fa-crown", | ||
"backgroundColor": "#2B6205", | ||
"color": "#fff" | ||
} | ||
} | ||
} | ||
} |
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,11 @@ | ||
<?php | ||
|
||
use Flarum\Extend; | ||
|
||
return [ | ||
(new Extend\Frontend('forum')) | ||
->js(__DIR__ . '/js/dist/forum.js') | ||
->css(__DIR__ . '/less/forum.less'), | ||
|
||
new Extend\Locales(__DIR__ . '/locale'), | ||
]; |
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 @@ | ||
node_modules/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,10 @@ | ||
/* | ||
* This file is part of Flarum. | ||
* | ||
* (c) Toby Zerner <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
export * from './src/forum'; |
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,13 @@ | ||
{ | ||
"private": true, | ||
"name": "@dem13n/topic-starter-label", | ||
"dependencies": { | ||
"flarum-webpack-config": "0.1.0-beta.10", | ||
"webpack": "^4.43.0", | ||
"webpack-cli": "^3.3.11" | ||
}, | ||
"scripts": { | ||
"dev": "webpack --mode development --watch", | ||
"build": "webpack --mode production" | ||
} | ||
} |
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,37 @@ | ||
import {extend} from 'flarum/extend'; | ||
import app from 'flarum/app'; | ||
import PostUser from 'flarum/components/PostUser'; | ||
|
||
function checkFP(post) { | ||
const firstPost = post.discussion().firstPost(); | ||
if (firstPost) { | ||
return (firstPost.id() !== post.id()); | ||
} else { | ||
return true; | ||
} | ||
} | ||
|
||
app.initializers.add('dem13n-topic-starter-label', () => { | ||
|
||
extend(PostUser.prototype, 'view', function (vnode) { | ||
|
||
const routeName = app.current.get('routeName'); | ||
|
||
if (routeName === 'discussion' || routeName === 'discussion.near') { | ||
|
||
const post = this.attrs.post; | ||
const postAuthor = post.user().id(); | ||
const discussionAuthor = post.discussion().user().id(); | ||
|
||
if (!discussionAuthor && !postAuthor) { | ||
return; | ||
} | ||
|
||
if (postAuthor === discussionAuthor && checkFP(post)) { | ||
vnode.children.push( | ||
<span className="topicStarter">{app.translator.trans('dem13n.forum.topic_starter')}</span> | ||
); | ||
} | ||
} | ||
}); | ||
}); |
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,3 @@ | ||
const config = require('flarum-webpack-config'); | ||
|
||
module.exports = config(); |
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,9 @@ | ||
.topicStarter { | ||
margin-left: 10px; | ||
padding: 1px 10px 3px 10px; | ||
background: @primary-color; | ||
color: white; | ||
border-radius: 4px; | ||
font-size: 14px; | ||
display: inline; | ||
} |
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,3 @@ | ||
dem13n: | ||
forum: | ||
topic_starter: Topic starter |
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,3 @@ | ||
dem13n: | ||
forum: | ||
topic_starter: Автор темы |