Update for composer branch

This commit is contained in:
Toby Zerner 2015-10-12 15:09:39 +10:30
parent c472be9336
commit 853e718b3e
13 changed files with 45 additions and 125 deletions

View File

@ -2,3 +2,5 @@
composer.phar
.DS_Store
Thumbs.db
bower_components
node_modules

View File

@ -9,6 +9,9 @@
* file that was distributed with this source code.
*/
require __DIR__.'/vendor/autoload.php';
use Flarum\BBCode\Listener;
use Illuminate\Contracts\Events\Dispatcher;
return 'Flarum\BBCode\Extension';
return function (Dispatcher $events) {
$events->subscribe(Listener\FormatBBCode::class);
};

View File

@ -1,10 +1,35 @@
{
"name": "flarum/bbcode",
"description": "Allow posts to be formatted with BBCode.",
"type": "flarum-extension",
"keywords": ["formatting"],
"license": "MIT",
"authors": [
{
"name": "Toby Zerner",
"email": "toby.zerner@gmail.com"
}
],
"support": {
"issues": "https://github.com/flarum/core/issues",
"source": "https://github.com/flarum/bbcode"
},
"require": {
"flarum/core": "^0.1.0-beta.3"
},
"autoload": {
"psr-4": {
"Flarum\\BBCode\\": "src/"
}
},
"scripts": {
"style": "phpcs --standard=PSR2 -np src"
"extra": {
"flarum-extension": {
"title": "BBCode",
"icon": {
"name": "bold",
"backgroundColor": "#238C59",
"color": "#fff"
}
}
}
}

View File

@ -1,25 +0,0 @@
{
"name": "bbcode",
"title": "BBCode",
"description": "Allow posts to be formatted with BBCode.",
"keywords": ["discussions"],
"version": "0.1.0-beta.2",
"author": {
"name": "Toby Zerner",
"email": "toby@flarum.org",
"homepage": "http://tobyzerner.com"
},
"license": "MIT",
"require": {
"flarum": ">=0.1.0-beta.2"
},
"support": {
"source": "https://github.com/flarum/bbcode",
"issues": "https://github.com/flarum/core/issues"
},
"icon": {
"name": "bold",
"backgroundColor": "#3F8A32",
"color": "#fff"
}
}

View File

@ -1,3 +0,0 @@
bower_components
node_modules
dist

View File

@ -1,7 +0,0 @@
var gulp = require('flarum-gulp');
gulp({
modules: {
'bbcode': 'src/**/*.js'
}
});

View File

@ -1,7 +0,0 @@
{
"private": true,
"devDependencies": {
"gulp": "^3.8.11",
"flarum-gulp": "^0.1.0"
}
}

View File

@ -1,6 +0,0 @@
import { extend } from 'flarum/extend';
import app from 'flarum/app';
app.initializers.add('bbcode', function() {
// TODO
});

View File

@ -1,2 +0,0 @@
bbcode:
# hello_world: "Hello, world!"

View File

@ -1,23 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\BBCode;
use Flarum\Support\Extension as BaseExtension;
use Illuminate\Events\Dispatcher;
class Extension extends BaseExtension
{
public function listen(Dispatcher $events)
{
$events->subscribe('Flarum\BBCode\Listeners\AddClientAssets');
$events->subscribe('Flarum\BBCode\Listeners\AddBBCodeFormatter');
}
}

View File

@ -8,19 +8,25 @@
* file that was distributed with this source code.
*/
namespace Flarum\BBCode\Listeners;
namespace Flarum\BBCode\Listener;
use Flarum\Events\FormatterConfigurator;
use Flarum\Event\ConfigureFormatter;
use Illuminate\Contracts\Events\Dispatcher;
class AddBBCodeFormatter
class FormatBBCode
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(FormatterConfigurator::class, [$this, 'addBBCodeFormatter']);
$events->listen(ConfigureFormatter::class, [$this, 'addBBCodeFormatter']);
}
public function addBBCodeFormatter(FormatterConfigurator $event)
/**
* @param ConfigureFormatter $event
*/
public function addBBCodeFormatter(ConfigureFormatter $event)
{
$event->configurator->BBCodes->addFromRepository('B');
$event->configurator->BBCodes->addFromRepository('I');

View File

@ -1,43 +0,0 @@
<?php
/*
* This file is part of Flarum.
*
* (c) Toby Zerner <toby.zerner@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Flarum\BBCode\Listeners;
use Flarum\Events\RegisterLocales;
use Flarum\Events\BuildClientView;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
{
public function subscribe(Dispatcher $events)
{
$events->listen(RegisterLocales::class, [$this, 'addLocale']);
$events->listen(BuildClientView::class, [$this, 'addAssets']);
}
public function addLocale(RegisterLocales $event)
{
$event->addTranslations('en', __DIR__.'/../../locale/en.yml');
}
public function addAssets(BuildClientView $event)
{
$event->forumAssets([
__DIR__.'/../../js/forum/dist/extension.js',
__DIR__.'/../../less/forum/extension.less'
]);
$event->forumBootstrapper('bbcode/main');
$event->forumTranslations([
// 'bbcode.hello_world'
]);
}
}