Update for composer branch

This commit is contained in:
Toby Zerner 2015-10-13 12:29:22 +10:30
parent d76e27559e
commit d333a60aa4
18 changed files with 244 additions and 153 deletions

View File

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

View File

@ -1,5 +1,17 @@
<?php
require __DIR__.'/vendor/autoload.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.
*/
return 'Flarum\Embed\Extension';
use Flarum\Embed\Listener;
use Illuminate\Contracts\Events\Dispatcher;
return function (Dispatcher $events) {
$events->subscribe(Listener\AddEmbedRoute::class);
};

View File

@ -1,7 +1,35 @@
{
"name": "flarum/embed",
"description": "Embed Flarum discussions as comments for your blog.",
"type": "flarum-extension",
"keywords": ["discussion"],
"license": "MIT",
"authors": [
{
"name": "Toby Zerner",
"email": "toby.zerner@gmail.com"
}
],
"support": {
"issues": "https://github.com/flarum/core/issues",
"source": "https://github.com/flarum/embed"
},
"require": {
"flarum/core": "^0.1.0-beta.3"
},
"autoload": {
"psr-4": {
"Flarum\\Embed\\": "src/"
}
},
"extra": {
"flarum-extension": {
"title": "Embed",
"icon": {
"name": "code",
"backgroundColor": "#B9D233",
"color": "#fff"
}
}
}
}

View File

@ -1,21 +0,0 @@
{
"name": "embed",
"title": "Embed",
"description": "Embed Flarum discussions as comments for your blog.",
"keywords": [],
"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"
},
"icon": {
"name": "code",
"backgroundColor": "#D0E800",
"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: {
'embed': 'src/**/*.js'
}
});

View File

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

View File

@ -1,5 +0,0 @@
import app from 'flarum/app';
app.initializers.add('embed', () => {
});

View File

@ -5,6 +5,6 @@ gulp({
'bower_components/iframe-resizer/js/iframeResizer.contentWindow.min.js'
],
modules: {
'embed': 'src/**/*.js'
'flarum/embed': 'src/**/*.js'
}
});

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@ import Composer from 'flarum/components/Composer';
import ModalManager from 'flarum/components/ModalManager';
import AlertManager from 'flarum/components/AlertManager';
import DiscussionPage from 'embed/components/DiscussionPage';
import DiscussionPage from 'flarum/embed/components/DiscussionPage';
app.initializers.add('boot', () => {
override(m, 'route', function(original, root, arg1, arg2, vdom) {

View File

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

View File

@ -1,44 +0,0 @@
#!/usr/bin/env bash
cd $(dirname $0)
base="${PWD}/.."
cd $base
if [ ! -f flarum.json ]; then
echo "Could not find flarum.json file!"
exit 1
fi
extension=$(php <<CODE
<?php
\$flarum = json_decode(file_get_contents('flarum.json'), true);
echo array_key_exists('name', \$flarum) ? \$flarum['name'] : '';
CODE
)
release=/tmp/${extension}
rm -rf ${release}
mkdir ${release}
git archive --format zip --worktree-attributes HEAD > ${release}/release.zip
cd ${release}
unzip release.zip -d ./
rm release.zip
bash "${base}/scripts/compile.sh"
wait
# Delete files
rm -rf ${release}/scripts
rm -rf `find . -type d -name node_modules`
rm -rf `find . -type d -name bower_components`
# Finally, create the release archive
cd ${release}
find . -type d -exec chmod 0750 {} +
find . -type f -exec chmod 0644 {} +
chmod 0775 .
zip -r ${extension}.zip ./
mv ${extension}.zip ${base}/${extension}.zip

View File

@ -1,13 +1,27 @@
#!/usr/bin/env bash
# This script compiles the extension so that it can be used in a Flarum
# installation. It should be run from the root directory of the extension.
base=$PWD
cd $base
composer install --prefer-dist --optimize-autoloader --ignore-platform-reqs --no-dev
cd "${base}/js"
cd "${base}/js/forum"
npm install
gulp --production
if [ -f bower.json ]; then
bower install
fi
cd "${base}/js/admin"
npm install
gulp --production
for app in forum admin; do
cd "${base}/js"
if [ -d $app ]; then
cd $app
if [ -f bower.json ]; then
bower install
fi
npm install
gulp --production
fi
done

View File

@ -10,28 +10,26 @@
namespace Flarum\Embed;
use Flarum\Forum\Actions\DiscussionAction as DiscussionAction;
use Psr\Http\Message\ServerRequestInterface as Request;
use Flarum\Forum\Controller\DiscussionController as BaseDiscussionController;
use Psr\Http\Message\ServerRequestInterface;
class ClientAction extends DiscussionAction
class DiscussionController extends BaseDiscussionController
{
/**
* {@inheritdoc}
*
* @return ClientView
*/
public function render(Request $request, array $routeParams = [])
public function render(ServerRequestInterface $request)
{
$view = parent::render($request, $routeParams);
$view = parent::render($request);
$view->addBootstrapper('embed/main');
$view->addBootstrapper('flarum/embed/main');
$view->setLayout(__DIR__.'/../views/embed.blade.php');
return $view;
}
/**
* @inheritdoc
* {@inheritdoc}
*/
protected function getAssets()
{

View File

@ -1,12 +0,0 @@
<?php namespace Flarum\Embed;
use Flarum\Support\Extension as BaseExtension;
use Illuminate\Events\Dispatcher;
class Extension extends BaseExtension
{
public function listen(Dispatcher $events)
{
$events->subscribe('Flarum\Embed\Listeners\AddClientAssets');
}
}

View File

@ -0,0 +1,33 @@
<?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\Embed\Listener;
use Flarum\Event\ConfigureForumRoutes;
use Illuminate\Contracts\Events\Dispatcher;
class AddEmbedRoute
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureForumRoutes::class, [$this, 'addEmbedRoute']);
}
/**
* @param ConfigureForumRoutes $event
*/
public function addEmbedRoute(ConfigureForumRoutes $event)
{
$event->get('/embed/{id:\d+}', 'embed.discussion', 'Flarum\Embed\DiscussionController');
}
}

View File

@ -1,31 +0,0 @@
<?php namespace Flarum\Embed\Listeners;
use Flarum\Events\RegisterLocales;
use Flarum\Events\BuildClientView;
use Flarum\Events\RegisterForumRoutes;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
{
public function subscribe(Dispatcher $events)
{
$events->listen(RegisterLocales::class, [$this, 'addLocale']);
$events->listen(BuildClientView::class, [$this, 'addAssets']);
$events->listen(RegisterForumRoutes::class, [$this, 'addEmbedRoute']);
}
public function addLocale(RegisterLocales $event)
{
$event->addTranslations('en', __DIR__.'/../../locale/en.yml');
}
public function addAssets(BuildClientView $event)
{
}
public function addEmbedRoute(RegisterForumRoutes $event)
{
$event->get('/embed/{id:\d+}', 'embed.discussion', 'Flarum\Embed\ClientAction');
}
}