This repository has been archived by the owner on Aug 9, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
v1.1.0; add spinners, add some more validation, more info to README
- Loading branch information
0 parents
commit d85dd6b
Showing
20 changed files
with
1,439 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,3 @@ | ||
node_modules | ||
.DS_Store | ||
test |
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,70 @@ | ||
# Create Flarum Extension by ReFlar | ||
|
||
Create a Flarum extension from a boilerplate in minutes! | ||
|
||
[![asciicast](https://asciinema.org/a/177728.png)](https://asciinema.org/a/177728) | ||
|
||
## Quick Overview | ||
|
||
Using `npx` (npx comes with npm 5.2+ and higher): | ||
```sh | ||
npx @reflar/create-flarum-extension [dir] | ||
``` | ||
|
||
Normally: | ||
```sh | ||
npm install -g @reflar/create-flarum-extension | ||
create-flarum-extension [dir] | ||
``` | ||
|
||
|
||
## Creating an Extension | ||
|
||
|
||
**You’ll need to have Node >= 8 on your local development machine (but it’s not required on the server).** You can use [n](https://www.npmjs.com/package/n) to interactively manager your node versions. | ||
|
||
To create a new app, run a single command: | ||
|
||
``` | ||
npx @reflar/create-flarum-extension my-extension | ||
``` | ||
*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [quick overview for older npm versions](#quick-overview))* | ||
|
||
It will create a directory called `my-extension` inside the current folder. | ||
Inside that directory, it will generate the initial project structure: | ||
|
||
``` | ||
my-extension | ||
├── .gitignore | ||
├── bootstrap.php | ||
├── composer.json | ||
├── README.md | ||
├── LICENSE.md | ||
├── js | ||
│ ├── admin | ||
│ │ ├── Gulpfile.js | ||
│ │ ├── package.json | ||
│ │ └── src | ||
│ │ └── main.js | ||
│ └── forum | ||
│ ├── Gulpfile.js | ||
│ ├── package.json | ||
│ └── src | ||
│ └── main.js | ||
├── less | ||
│ ├── admin.less | ||
│ └── app.less | ||
├── locale | ||
│ └── en.yml | ||
└── src | ||
└── Listeners | ||
└── AddClientAssets.php | ||
``` | ||
|
||
## Flarum Resources | ||
|
||
- [Unofficial Flarum API Docs](https://discuss.flarum.org/d/4421-flarum-php-api-docs) - @datitisev | ||
- [Extension development - first read](https://discuss.flarum.org/d/1662-extension-developer-first-read) - @luceos | ||
- [Extension development - using composer](https://discuss.flarum.org/d/1608-extension-development-using-composer-repositories-path) - @luceos | ||
- [Extension development - different workflows](https://discuss.flarum.org/d/6320-extension-developers-show-us-your-workflow) | ||
- [Extension development - namespace tips](https://discuss.flarum.org/d/9625-flarum-extension-namespacing-tips) |
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,19 @@ | ||
# <%= extensionName %> | ||
|
||
--- | ||
|
||
![License](https://img.shields.io/badge/license-<%= license %>-blue.svg) [![Latest Stable Version](https://img.shields.io/packagist/v/<%= packageName %>.svg)](https://packagist.org/packages/<%= packageName %>) | ||
|
||
A [Flarum](http://flarum.org) extension. <%= packageDescription %> | ||
|
||
### Installation | ||
|
||
Install it with composer: | ||
|
||
```sh | ||
composer require <%= packageName %> | ||
``` | ||
|
||
### Links | ||
|
||
- [Packagist](https://packagist.org/packages/<%= packageName %>) |
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,19 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of <%= packageName %>. | ||
* | ||
* Copyright (c) 2018 <% authorName %>. | ||
* | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace <%= namespace %>; | ||
|
||
use Illuminate\Contracts\Events\Dispatcher; | ||
|
||
return function (Dispatcher $events) { | ||
$events->subscribe(Listeners\AddClientAssets::class); | ||
}; |
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 @@ | ||
{ | ||
"name": "<%= packageName %>", | ||
"description": "<%= packageDescription %>", | ||
"keywords": [ | ||
"flarum" | ||
], | ||
"type": "flarum-extension", | ||
"license": "<%= license %>", | ||
"require": { | ||
"flarum/core": "^0.1.0-beta-7" | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "<%= authorName %>", | ||
"email": "<%= authorEmail %>", | ||
"role": "Developer" | ||
} | ||
], | ||
"autoload": { | ||
"psr-4": { | ||
"<%= packageNamespace %>": "src/" | ||
} | ||
}, | ||
"extra": { | ||
"flarum-extension": { | ||
"title": "<%= extensionName %>", | ||
"icon": { | ||
"name": "", | ||
"backgroundColor": "", | ||
"color": "" | ||
} | ||
}, | ||
"flagrow": { | ||
"discuss": "" | ||
} | ||
} | ||
} |
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 @@ | ||
node_modules | ||
vendor | ||
composer.lock |
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 @@ | ||
var gulp = require('flarum-gulp'); | ||
|
||
gulp({ | ||
modules: { | ||
'<%= packageName %>': [ | ||
'src/**/*.js', | ||
] | ||
} | ||
}); |
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,8 @@ | ||
{ | ||
"private": true, | ||
"devDependencies": { | ||
"gulp": "^3.9.1", | ||
"flarum-gulp": "^0.2.0" | ||
}, | ||
"dependencies": {} | ||
} |
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,5 @@ | ||
import app from 'flarum/app'; | ||
|
||
app.initializers.add('<%= packageName %>', () => { | ||
console.log('Hello, admin!'); | ||
}); |
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 @@ | ||
var gulp = require('flarum-gulp'); | ||
|
||
gulp({ | ||
modules: { | ||
'<%= packageName %>': [ | ||
'src/**/*.js', | ||
] | ||
} | ||
}); |
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,8 @@ | ||
{ | ||
"private": true, | ||
"devDependencies": { | ||
"gulp": "^3.9.1", | ||
"flarum-gulp": "^0.2.0" | ||
}, | ||
"dependencies": {} | ||
} |
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,5 @@ | ||
import app from 'flarum/app'; | ||
|
||
app.initializers.add('<%= packageName %>', () => { | ||
console.log('Hello, forum!'); | ||
}); |
Empty file.
Empty file.
Empty file.
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,70 @@ | ||
<?php | ||
|
||
/** | ||
* This file is part of <%= packageName %>. | ||
* | ||
* Copyright (c) 2018 <% authorName %>. | ||
* | ||
* | ||
* For the full copyright and license information, please view the LICENSE.md | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace <%= namespace %>\Listener; | ||
|
||
use DirectoryIterator; | ||
use Flarum\Event\ConfigureLocales; | ||
use Flarum\Event\ConfigureWebApp; | ||
use Illuminate\Contracts\Events\Dispatcher; | ||
|
||
class AddClientAssets | ||
{ | ||
/** | ||
* Subscribes to the Flarum events. | ||
* | ||
* @param Dispatcher $events | ||
*/ | ||
public function subscribe(Dispatcher $events) | ||
{ | ||
$events->listen(ConfigureWebApp::class, [$this, 'configureWebApp']); | ||
<% if (useLocale) { %>$events->listen(ConfigureLocales::class, [$this, 'addLocales']);<% } %> | ||
} | ||
|
||
/** | ||
* Modifies the client view for forum/admin. | ||
* | ||
* @param ConfigureWebApp $event | ||
*/ | ||
public function configureWebApp(ConfigureWebApp $event) | ||
{ | ||
<% if (admin) { %>if ($event->isAdmin()) { | ||
$event->addAssets([ | ||
<% if (useJs) { %>__DIR__.'/../../js/admin/dist/extension.js',<% } %> | ||
<% if (useCss) { %>__DIR__.'/../../less/admin.less',<% } %> | ||
]); | ||
$event->addBootstrapper('<%= packageName %>/main'); | ||
}<% } %> | ||
|
||
<% if (forum) { %>if ($event->isForum()) { | ||
$event->addAssets([ | ||
<% if (useJs) { %>__DIR__.'/../../js/forum/dist/extension.js',<% } %> | ||
<% if (useCss) { %>__DIR__.'/../../less/app.less',<% } %> | ||
]); | ||
$event->addBootstrapper('<%= packageName %>/main'); | ||
}<% } %> | ||
} | ||
<% if (useLocale) { %> | ||
/** | ||
* Provides i18n files. | ||
* | ||
* @param ConfigureLocales $event | ||
*/ | ||
public function addLocales(ConfigureLocales $event) | ||
{ | ||
foreach (new DirectoryIterator(__DIR__.'/../../locale') as $file) { | ||
if ($file->isFile() && in_array($file->getExtension(), ['yml', 'yaml'])) { | ||
$event->locales->addTranslations($file->getBasename('.'.$file->getExtension()), $file->getPathname()); | ||
} | ||
} | ||
}<% } %> | ||
} |
Oops, something went wrong.