Compare commits

..

No commits in common. "master" and "v0.3.0" have entirely different histories.

9 changed files with 54 additions and 117 deletions

8
.gitignore vendored
View File

@ -1,6 +1,2 @@
# Do not index node.js modules that are used for building *.zip
node_modules *.gz
package-lock.json
# Do not index releases
release

View File

@ -23,9 +23,8 @@
* SOFTWARE. * SOFTWARE.
*/ */
namespace Mibew\Mibew\Plugin\OperatorStatus\Controller; namespace Everyx\Mibew\Plugin\OperatorStatus\Controller;
use Mibew\Settings;
use Mibew\Controller\AbstractController; use Mibew\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
@ -60,7 +59,7 @@ class OperatorStatusController extends AbstractController
} }
/** /**
* Returns true or false of whether any operators is online or not. * Returns true or false of whether an operator is online or not.
* *
* @param Request $request * @param Request $request
* @return Response Rendered page content * @return Response Rendered page content
@ -73,25 +72,6 @@ class OperatorStatusController extends AbstractController
return $this->prepareResponse($is_online, $callback); return $this->prepareResponse($is_online, $callback);
} }
/**
* Returns true or false of whether any operators in specificed group is online or not.
*
* @param Request $request
* @return Response Rendered page content
*/
public function isOperatorGroupOnlineAction(Request $request)
{
$is_online = false;
$group_id = $request->attributes->get('group_id');
if (Settings::get('enablegroups') == '1') {
$is_online = has_online_operators($group_id);
}
$callback = $request->query->get('callback');
return $this->prepareResponse($is_online, $callback);
}
/** /**
* Returns prepared response: JSONP or plain text. * Returns prepared response: JSONP or plain text.
* *

View File

@ -23,7 +23,7 @@
* SOFTWARE. * SOFTWARE.
*/ */
namespace Mibew\Mibew\Plugin\OperatorStatus; namespace Everyx\Mibew\Plugin\OperatorStatus;
/** /**
* Main plugin class. * Main plugin class.
@ -46,6 +46,6 @@ class Plugin extends \Mibew\Plugin\AbstractPlugin implements \Mibew\Plugin\Plugi
*/ */
public static function getVersion() public static function getVersion()
{ {
return '0.4.0'; return '0.3.0';
} }
} }

View File

@ -1,26 +1,21 @@
# Mibew Operator Status plugin # mibew-operator-status-plugin
Plugin for Mibew, get statement based on the availability of operators. Plugin for Mibew, get statement based on the availability of operators.
# Usage # Useage
1. Get any operators online status: 1. Get any operators online status:
* request URL: `<MIBEW-BASE-URL>/opstatus`. * request URL:`<MIBEW-BASE-URL>/opstatus`.
* return `true` when any operators is online and `false` when not. * return `true` when any operators is online and `false` when not.
2. Get any operators online status in specificed group: 2. Get an operator online status by operator code:
* request URL: `<MIBEW-BASE-URL>/opstatus/group/<GROUP-ID>`.
* return `true` when any operators in this group is online and `false` when not.
3. Get an operator online status by operator code:
* Request URL: `<MIBEW-BASE-URL>/opstatus/<OPERATOR-CODE>`. * Request URL: `<MIBEW-BASE-URL>/opstatus/<OPERATOR-CODE>`.
* return `true` when operator is online or `false` when not. * return `true` when operator is online or `false` when not.
4. Use callback parameter: 3. Use callback parameter:
Just insert `<script>` tag and set `src` to URL above and add `callback` parameter Just inset `<script>` tag and set `src` to URL above and add `callback` parameter
* `<MIBEW-BASE-URL>/opstatus?callback=<CALLBACK_FUNCTION>` * `<MIBEW-BASE-URL>/opstatus?callback=<CALLBACK_FUNCTION>`
* `<MIBEW-BASE-URL>/opstatus/<OPERATOR-CODE>?callback=<CALLBACK_FUNCTION>` * `<MIBEW-BASE-URL>/opstatus/<OPERATOR-CODE>?callback=<CALLBACK_FUNCTION>`
@ -33,7 +28,7 @@ Plugin for Mibew, get statement based on the availability of operators.
# Install # Install
1. Get the archive with the plugin sources. You can download it from the [official site](https://mibew.org/plugins#mibew-operator-status) or build the plugin from sources. 1. Get the archive with the plugin sources from [release page](https://github.com/everyx/mibew-operator-status-plugin/releases):
2. Untar/unzip the plugin's archive. 2. Untar/unzip the plugin's archive.
@ -58,16 +53,6 @@ plugins:
... ...
``` ```
# Build from sources
1. Obtain a copy of the repository using `git clone`, download button, or another way.
2. Install [node.js](http://nodejs.org/) and [npm](https://www.npmjs.org/).
3. Install [Gulp](http://gulpjs.com/).
4. Install npm dependencies using `npm install`.
5. Run Gulp to build the sources using `gulp default`.
Finally `.tar.gz` and `.zip` archives of the ready-to-use Plugin will be available in release directory.
# License # License
[MIT](LICENSE) [MIT](LICENSE)

22
build.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
author='Everyx'
tmp_dir='/tmp'
working_dir=`echo $PWD`
target_dir="$tmp_dir/$author/Mibew/Plugin/OperatorStatus"
mkdir -p $target_dir
shopt -s extglob
cp -R !(*.sh) $target_dir
shopt -u extglob
version=`cat Plugin.php|grep -Po "(?<=return ')(\d.){2}\d{1}"`
cd $tmp_dir
tar -czvf $working_dir/mibew-operator-status-plugin.$version.tar.gz $author
zip -r $working_dir/mibew-operator-status-plugin.$version.zip $author
rm -rf $plugin_root_dir

15
composer.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "everyx/mibew-operator-status-plugin",
"description": "An operator status plugin for Mibew 2.0.",
"license": "MIT",
"authors": [
{
"name": "everyx",
"email": "lunt.luo@gmail.com"
}
],
"autoload": {
"psr-0": {"Everyx\\Mibew\\Plugin\\OperatorStatus\\": ""}
},
"target-dir": "Everyx/Mibew/Plugin/OperatorStatus"
}

View File

@ -1,44 +0,0 @@
var eventStream = require('event-stream'),
gulp = require('gulp'),
chmod = require('gulp-chmod'),
zip = require('gulp-zip'),
tar = require('gulp-tar'),
gzip = require('gulp-gzip'),
rename = require('gulp-rename');
gulp.task('prepare-release', function() {
var version = require('./package.json').version;
return eventStream.merge(
getSources()
.pipe(zip('operator-status-plugin-' + version + '.zip')),
getSources()
.pipe(tar('operator-status-plugin-' + version + '.tar'))
.pipe(gzip())
)
.pipe(chmod(0644))
.pipe(gulp.dest('release'));
});
// Builds and packs plugins sources
gulp.task('default', gulp.series('prepare-release'));
/**
* Returns files stream with the plugin sources.
*
* @returns {Object} Stream with VinylFS files.
*/
var getSources = function() {
return gulp.src([
'Controller/*',
'LICENSE',
'Plugin.php',
'README.md',
'routing.yml'
],
{base: './'}
)
.pipe(rename(function(path) {
path.dirname = 'Mibew/Mibew/Plugin/OperatorStatus/' + path.dirname;
}));
}

View File

@ -1,12 +0,0 @@
{
"version": "0.4.0",
"devDependencies": {
"event-stream": "3.3.4",
"gulp": "^4.0.0",
"gulp-chmod": "~3.0.0",
"gulp-gzip": "~1.1.0",
"gulp-rename": "~1.2.2",
"gulp-tar": "~3.1.0",
"gulp-zip": "~3.0.2"
}
}

View File

@ -1,14 +1,9 @@
mibew_operator_status_has_online_operators: everyx_operator_status_has_online_operators:
path: /opstatus path: /opstatus
defaults: defaults:
_controller: Mibew\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::hasOnlineOperatorsAction _controller: Everyx\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::hasOnlineOperatorsAction
mibew_operator_status_has_online_group_operators: everyx_operator_status_is_operator_online:
path: /opstatus/group/{group_id}
defaults:
_controller: Mibew\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::isOperatorGroupOnlineAction
mibew_operator_status_is_operator_online:
path: /opstatus/{opcode} path: /opstatus/{opcode}
defaults: defaults:
_controller: Mibew\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::isOperatorOnlineAction _controller: Everyx\Mibew\Plugin\OperatorStatus\Controller\OperatorStatusController::isOperatorOnlineAction