Skip to content

Commit

Permalink
Backport empty plugin stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
trasher committed Dec 8, 2016
1 parent 869b28e commit 792acdc
Show file tree
Hide file tree
Showing 17 changed files with 2,059 additions and 409 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
log_filter.settings.php
dist/
vendor/
.gh_token
*.min.*

66 changes: 66 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
language: php

env:
- DB=mysql

before_script:
- composer self-update
- if [[ ${TRAVIS_PHP_VERSION:0:3} == "5.4" ]]; then sed -e "s|.*"consolidation/robo".*$||" -i composer.json && composer update; fi
- composer install -o
# - mysql -u root -e 'create database glpitest;'
# - php tools/cliinstall.php --lang=en_US --db=glpitest --user=root --tests
- pear install pear/PHP_CodeSniffer
- phpenv rehash

script:
# - mysql -u root -e 'select version();'
# - phpunit --verbose
- phpcs -p --ignore=vendor --ignore=js --ignore=css --standard=tools/phpcs-rules.xml .

matrix:
include:
- php: 5.4
addons:
mariadb: 5.5
- php: 5.5
addons:
mariadb: 5.5
# - php: 5.6
# addons:
# mariadb: 5.5
# - php: 5.6
# addons:
# mariadb: 10.0
- php: 5.6
addons:
mariadb: 10.1
# - php: 7.0
# addons:
# mariadb: 10.0
- php: 7.0
addons:
mariadb: 10.1
# - php: 7.1
# addons:
# mariadb: 10.0
- php: 7.1
addons:
mariadb: 10.1
- php: nightly
addons:
mariadb: 10.1
allow_failures:
- php: nightly

cache:
directories:
- $HOME/.composer/cache

#notifications:
# irc:
# channels:
# - "irc.freenode.org#channel"
# on_success: change
# on_failure: always
# use_notice: true
# skip_join: true
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Genericobject GLPi plugin

[![Join the chat at https://gitter.im/TECLIB/genericobject](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/TECLIB/genericobject?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

The genericobject plugin allows to extends GLPi to manage new types of objects.


See [Wiki](https://github.com/pluginsGLPI/genericobject/wiki/) for Usage and customisation

Contributing
------------
## Contributing

* Open a ticket for each bug/feature so it can be discussed
* Follow [development guidelines](http://glpi-developer-documentation.readthedocs.io/en/latest/plugins.html)
Expand Down
13 changes: 13 additions & 0 deletions RoboFile.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/

require_once 'RoboFilePlugin.php';

class RoboFile extends RoboFilePlugin
{
//Own plugin's robo stuff
}
146 changes: 146 additions & 0 deletions RoboFilePlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
<?php
/**
* This is project's console commands configuration for Robo task runner.
*
* @see http://robo.li/
*/
class RoboFilePlugin extends \Robo\Tasks
{
/**
* Minify all
*
* @return void
*/
public function minify()
{
$this->minifyCSS()
->minifyJS();
}

/**
* Minify CSS stylesheets
*
* @return void
*/
public function minifyCSS()
{
$css_dir = __DIR__ . '/css';
if (is_dir($css_dir)) {
foreach(glob("$css_dir/*.css") as $css_file) {
if (!$this->endsWith($css_file, 'min.css')) {
$this->taskMinify($css_file)
->to(str_replace('.css', '.min.css', $css_file))
->type('css')
->run();
}
}
}
return $this;
}

/**
* Minify JavaScript files stylesheets
*
* @return void
*/
public function minifyJS()
{
$js_dir = __DIR__ . '/js';
if (is_dir($js_dir)) {
foreach(glob("$js_dir/*.js") as $js_file) {
if (!$this->endsWith($js_file, 'min.js')) {
$this->taskMinify($js_file)
->to(str_replace('.js', '.min.js', $js_file))
->type('js')
->run();
}
}
}
return $this;
}

/**
* Extract translatable strings
*
* @return void
*/
public function localesExtract()
{
$this->_exec('tools/extract_template.sh');
return $this;
}

/**
* Push locales to transifex
*
* @return void
*/
public function localesPush()
{
$this->_exec('tx push -s');
return $this;
}

/**
* Pull locales from transifex.
*
* @return void
*/
public function localesPull($percent = 70)
{
$this->_exec('tx pull -s --minimum-perc=' .$percent);
return $this;
}

/**
* Build MO files
*
* @return void
*/
public function localesMo()
{
$this->_exec('./tools/release --compile-mo');
return $this;
}

/**
* Extract and send locales
*
* @return void
*/
public function localesSend()
{
$this->localesExtract()
->localesPush();
return $this;
}

/**
* Retrieve locales and generate mo files
*
* @return void
*/
public function localesGenerate($percent = 70) {
$this->localesPull($percent)
->localesMo();
return $this;
}

/**
* Checks if a string ends with another string
*
* @param string $haystack Full string
* @param string $needle Ends string
*
* @return boolean
* @see http://stackoverflow.com/a/834355
*/
private function endsWith($haystack, $needle) {
$length = strlen($needle);
if ($length == 0) {
return true;
}

return (substr($haystack, -$length) === $needle);
}
}
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"require-dev": {
"consolidation/robo": "dev-master@dev",
"patchwork/jsqueeze": "~1.0",
"natxet/CssMin": "~3.0"
}
}
Loading

0 comments on commit 792acdc

Please sign in to comment.