Update for composer branch

This commit is contained in:
Toby Zerner 2015-10-11 17:02:19 +10:30
parent 751dddd940
commit 57ed9dad5f
15 changed files with 739 additions and 81 deletions

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

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

@ -1,10 +1,33 @@
{
"name": "flarum/emoji",
"description": "Convert text and unicode emoji into Twemoji.",
"type": "flarum-extension",
"license": "MIT",
"authors": [
{
"name": "Toby Zerner",
"email": "toby.zerner@gmail.com"
}
],
"support": {
"issues": "https://github.com/flarum/core/issues",
"source": "https://github.com/flarum/emoji"
},
"require": {
"flarum/core": "^0.1.0-beta.3"
},
"autoload": {
"psr-4": {
"Flarum\\Emoji\\": "src/"
}
},
"scripts": {
"style": "phpcs --standard=PSR2 -np src"
"extra": {
"flarum-extension": {
"title": "Emoji",
"icon": {
"image": "icon.svg",
"backgroundColor": "#FECC4D"
}
}
}
}

@ -1,25 +0,0 @@
{
"name": "emoji",
"title": "Emoji",
"description": "Convert text and unicode emoji into Twemoji.",
"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/emoji",
"issues": "https://github.com/flarum/core/issues"
},
"icon": {
"name": "smile-o",
"backgroundColor": "#FFC700",
"color": "#000"
}
}

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><svg xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 47.5 47.5" style="enable-background:new 0 0 47.5 47.5;" xml:space="preserve" version="1.1" id="svg2"><metadata id="metadata8"><rdf:RDF><cc:Work rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage"/></cc:Work></rdf:RDF></metadata><defs id="defs6"><clipPath id="clipPath16" clipPathUnits="userSpaceOnUse"><path id="path18" d="M 0,38 38,38 38,0 0,0 0,38 Z"/></clipPath></defs><g transform="matrix(1.25,0,0,-1.25,0,47.5)" id="g10"><g id="g12"><g clip-path="url(#clipPath16)" id="g14"><g transform="translate(36,19)" id="g20"><path id="path22" style="fill:#ffcc4d;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0,0 c 0,-9.389 -7.611,-17 -17,-17 -9.389,0 -17,7.611 -17,17 0,9.389 7.611,17 17,17 C -7.611,17 0,9.389 0,0"/></g><g transform="translate(19,16)" id="g24"><path id="path26" style="fill:#664500;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0,0 c -3.623,0 -6.027,0.422 -9,1 -0.679,0.131 -2,0 -2,-2 0,-4 4.595,-9 11,-9 6.404,0 11,5 11,9 C 11,1 9.679,1.132 9,1 6.027,0.422 3.623,0 0,0"/></g><g transform="translate(11,24)" id="g28"><path id="path30" style="fill:#664500;fill-opacity:1;fill-rule:nonzero;stroke:none" d="M 0,0 C 0,0 0,2 2,2 4,2 4,0 4,0 l 0,-2 c 0,0 0,-2 -2,-2 -2,0 -2,2 -2,2 l 0,2 z"/></g><g transform="translate(23,24)" id="g32"><path id="path34" style="fill:#664500;fill-opacity:1;fill-rule:nonzero;stroke:none" d="M 0,0 C 0,0 0,2 2,2 4,2 4,0 4,0 l 0,-2 c 0,0 0,-2 -2,-2 -2,0 -2,2 -2,2 l 0,2 z"/></g><g transform="translate(10,15)" id="g36"><path id="path38" style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none" d="m 0,0 c 0,0 3,-1 9,-1 6,0 9,1 9,1 0,0 -2,-4 -9,-4 -7,0 -9,4 -9,4"/></g></g></g></g></svg>

After

(image error) Size: 1.9 KiB

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

@ -2,7 +2,7 @@ var gulp = require('flarum-gulp');
gulp({
modules: {
'emoji': 'src/**/*.js'
'flarum/emoji': 'src/**/*.js'
},
files: [
'bower_components/twemoji/index.js'

@ -1,6 +1,6 @@
{
"name": "flarum-emoji",
"devDependencies": {
"twemoji": "https://raw.githubusercontent.com/twitter/twemoji/gh-pages/twemoji.min.js"
"twemoji": "https://raw.githubusercontent.com/twitter/twemoji/gh-pages/twemoji.js"
}
}

File diff suppressed because one or more lines are too long

@ -4,7 +4,7 @@ import { override } from 'flarum/extend';
import app from 'flarum/app';
import Post from 'flarum/models/Post';
app.initializers.add('emoji', () => {
app.initializers.add('flarum-emoji', () => {
override(Post.prototype, 'contentHtml', function(original) {
const contentHtml = original();

@ -1,2 +0,0 @@
emoji:

@ -0,0 +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}/js"
if [ -f bower.json ]; then
bower install
fi
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

@ -0,0 +1,39 @@
<?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\Emoji\Listener;
use Flarum\Event\ConfigureClientView;
use Illuminate\Contracts\Events\Dispatcher;
class AddClientAssets
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(ConfigureClientView::class, [$this, 'addAssets']);
}
/**
* @param ConfigureClientView $event
*/
public function addAssets(ConfigureClientView $event)
{
if ($event->isForum()) {
$event->addAssets([
__DIR__ . '/../../js/forum/dist/extension.js',
__DIR__ . '/../../less/forum/extension.less'
]);
$event->addBootstrapper('flarum/emoji/main');
}
}
}

@ -8,19 +8,25 @@
* file that was distributed with this source code.
*/
namespace Flarum\Emoji\Listeners;
namespace Flarum\Emoji\Listener;
use Flarum\Events\FormatterConfigurator;
use Flarum\Event\ConfigureFormatter;
use Illuminate\Contracts\Events\Dispatcher;
class AddEmoticons
class FormatEmoticons
{
/**
* @param Dispatcher $events
*/
public function subscribe(Dispatcher $events)
{
$events->listen(FormatterConfigurator::class, [$this, 'addEmoticons']);
$events->listen(ConfigureFormatter::class, [$this, 'addEmoticons']);
}
public function addEmoticons(FormatterConfigurator $event)
/**
* @param ConfigureFormatter $event
*/
public function addEmoticons(ConfigureFormatter $event)
{
$event->configurator->Emoticons->add(':)', '&#x1f604;');
$event->configurator->Emoticons->add(':D', '&#x1f603;');

@ -1,39 +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\Emoji\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('emoji/main');
}
}