Commit bf08b255 authored by Cédric Anne's avatar Cédric Anne Committed by Johan Cwiklinski

Use webpack for JS/CSS libs

parent 039c53ee
......@@ -28,6 +28,25 @@ shared: &shared
key: composer-install-{{ .Environment.CIRCLE_JOB }}-{{ checksum "composer.lock.bak" }}-{{ epoch }}
paths:
- ./vendor
- restore_cache:
keys:
- npm-cache-{{ .Environment.CIRCLE_JOB }}
- restore_cache:
keys:
- npm-install-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
- npm-install-{{ .Environment.CIRCLE_JOB }}
- run:
name: npm install
command: |
npm install
- save_cache:
key: npm-cache-{{ .Environment.CIRCLE_JOB }}-{{ epoch }}
paths:
- /home/circleci/.npm/_cacache/
- save_cache:
key: npm-install-{{ .Environment.CIRCLE_JOB }}-{{ checksum "package-lock.json" }}
paths:
- ./node_modules
- run:
name: PHP Parallel Lint
command: vendor/bin/parallel-lint --exclude files --exclude plugins --exclude vendor --exclude tools/vendor .
......@@ -36,7 +55,9 @@ shared: &shared
command: vendor/bin/security-checker security:check
- run:
name: Coding standards
command: if [[ $(php --version|grep "7\.3") ]]; then vendor/bin/phpcs -d memory_limit=512M -p -n vendor/bin/phpcs -d memory_limit=512M -p --standard=vendor/glpi-project/coding-standard/GlpiStandard/ --ignore=/vendor/,/plugins/,/files/,/lib/,/config/,/tests/config,/css/tiny_mce,/.git ./; else echo "No CS for this version"; fi
command: |
if [[ $(php --version|grep "7\.3") ]]; then vendor/bin/phpcs -d memory_limit=512M -p -n --extensions=php --standard=vendor/glpi-project/coding-standard/GlpiStandard/ --ignore=/.git/,/config/,/files/,/lib/,/node_modules/,/plugins/,/public/index.php,/src/,/tests/config/,/vendor/ ./; else echo "No CS for this version"; fi
if [[ $(php --version|grep "7\.3") ]]; then node_modules/.bin/eslint ./js && node_modules/.bin/eslint --env=node --parser-options=ecmaVersion:6 --rule 'indent: ["error", 4]' ./webpack.config.js && echo "ESLint found no errors"; else echo "No CS for this version"; fi
- run:
name: Update DB
command: |
......
{
"env": {
"browser": true,
"jquery": true
},
"extends": "eslint:recommended",
"globals": {
"CFG_GLPI": true,
"tinyMCE": true
},
"parserOptions": {
"ecmaVersion": 5
},
"rules": {
"indent": [
"error",
3,
{
"SwitchCase": 1
}
],
"linebreak-style": [
"error",
"unix"
],
"no-console": [
"error",
{
"allow": [
"warn",
"error"
]
}
],
"no-unused-vars": [
"error",
{
"vars": "local"
}
],
"quotes": [
"off",
"single"
],
"semi": [
"error",
"always"
]
}
}
......@@ -26,6 +26,6 @@ phpunit.xml
/css/compiled/
!/css/tiny_mce/**/*.min.css
/js/*.min.js
# ignore incomplete locale, fallback to ru.js
# see https://github.com/glpi-project/glpi/issues/3788
/lib/tiny_mce/langs/ru_RU.js
/node_modules/
/public/build/
/public/lib/
![GLPI Logo](https://raw.githubusercontent.com/glpi-project/glpi/master/pics/logos/logo-GLPI-250-black.png)
## How to install?
Installation procedure is entirely automated; there is an [installation documentation](https://readthedocs.org/projects/glpi-install/) you should rely on.
When you are using the source code, there are extra steps, to get all third party libraries installed.
First, [download and install composer](https://getcomposer.org/), a PHP dependency management tool. Once done, go to the GLPI directory and just run:
```bash
$ composer install --no-dev
```
The `--no-dev` flag will prevent development dependencies (such as [atoum, the unit test tool](https://atoum.org)) to be installed. Of course, if you plan to develop on this instance, you must have them installed.
Second, [download and install npm](https://www.npmjs.com/), a JS dependency management tool.
Once done, go to the GLPI directory and run following command to retrieve dependencies from npm repository:
```bash
$ npm install
```
Then, you run the following command to build dependencies into files used by GLPI:
```bash
$ npm run-script build
```
You can use `npm run-script build-dev` if you want to build dependencies for a development use.
......@@ -101,25 +101,6 @@ We are working on a [markdown version](https://github.com/glpi-project/doc)
* [Plugin development documentation](http://glpi-developer-documentation.readthedocs.io/en/master/plugins/index.html)
## Used JS libraries
* [Chartist.js v0.10.1](https://github.com/gionkunz/chartist-js) MIT/WTFPL
* [chartist-plugin-legend v0.6.0](https://github.com/CodeYellowBV/chartist-plugin-legend) ISC
* [chartist-plugin-tooltip v0.0.17](https://github.com/tmmdata/chartist-plugin-tooltip) MIT
* [Font-Awesome v5.5.0](https://github.com/FortAwesome/Font-Awesome) MIT
* [fuzzy v0.1.3](https://github.com/mattyork/fuzzy) MIT
* [gridstack.js v unknow-dev](https://github.com/gridstack/gridstack.js) MIT
* [htmLawed v1.2.4](http://www.bioinformatics.org/phplabware/internal_utilities/htmLawed/) LGPL3/GPL2+
* [jQuery v1.12.4](https://github.com/jquery/jquery) MIT
* [jQuery UI v1.10.4](https://github.com/jquery/jquery-ui) MIT
* jQuery plugins *
* [Leaflet v1.3.4](https://github.com/Leaflet/Leaflet) BSD2S
* [PrismJS v1.15.0](https://github.com/PrismJS/prism) MIT
* [spin.js v2.3.2](https://github.com/fgnass/spin.js) MIT
* [TinyMCE v4.9.0](https://github.com/tinymce/tinymce) LGPL2.1
* [Underscore.js v1.8.3](https://github.com/jashkenas/underscore) MIT
* [Lodash v4.17.11](https://github.com/lodash/lodash) MIT
## Support
GLPI is a living software. Improvements are continuously made, new functionalities are being developed, and issues are being fixed.
......
......@@ -35,8 +35,9 @@ include ('../inc/includes.php');
header("Content-Type: text/html; charset=UTF-8");
Html::header_nocache();
echo Html::css("lib/prism/prism.css");
echo Html::script("lib/prism/prism.js");
echo Html::css("public/lib/prismjs/themes/prism-coy.css");
echo Html::script("public/lib/prismjs/components/prism-core.js");
echo Html::script("public/lib/prismjs/components/prism-json.js");
$infos = Telemetry::getTelemetryInfos();
echo "<p>" . __("We only collect the following data : plugins usage, performance and responsiveness statistics about user interface features, memory, and hardware configuration.") . "</p>";
......
......@@ -893,7 +893,7 @@ $ curl -X GET \
Ex:
```javascript
```json
...
"criteria":
[
......@@ -945,7 +945,7 @@ $ curl -X GET \
Ex:
```javascript
```json
...
"metacriteria":
[
......@@ -986,7 +986,7 @@ $ curl -X GET \
* **Returns**:
* 200 (OK) with all rows data with this format:
```javascript
```json
{
"totalcount": ":numberofresults_without_pagination",
"range": ":start-:end",
......@@ -1220,7 +1220,7 @@ Uploading a file requires use of 'multipart/data' content_type. The input data m
Examples usage (CURL):
```shell
```bash
$ curl -X POST \
-H 'Content-Type: multipart/form-data' \
-H "Session-Token: 83af7e620c83a50a18d3eac2f6ed05a3ca0bea62" \
......@@ -1411,7 +1411,7 @@ We provide in root .htaccess of GLPI an example to enable API URL rewriting.
You need to uncomment (removing #) theses lines:
```apache
```apacheconf
#<IfModule mod_rewrite.c>
# RewriteEngine On
# RewriteCond %{REQUEST_FILENAME} !-f
......
......@@ -28,6 +28,26 @@
* along with GLPI. If not, see <http://www.gnu.org/licenses/>.
* ---------------------------------------------------------------------
*/
.ui-state-default,
.ui-widget-content .ui-state-default,
.ui-widget-header .ui-state-default {
border: 1px solid #FFF;
background-color: #e6e6e6;
color: #555555;
}
.ui-state-active,
.ui-widget-content .ui-state-active,
.ui-widget-header .ui-state-active {
border: 1px solid #FFF;
background-color: #ffffff;
color: #212121;
}
.ui-state-active a,
.ui-state-active a:link,
.ui-state-active a:visited {
color: #212121;
}
.ui-dialog { z-index: 1000 !important ;}
.ui-widget-overlay.glpi_modal { z-index: 2000 !important ;}
.glpi_modal { z-index: 5000 !important ;}
......
......@@ -2272,8 +2272,13 @@ abstract class API extends CommonGLPI {
*/
public function inlineDocumentation($file) {
self::header(true, __("API Documentation"));
echo Html::css("lib/prism/prism.css");
echo Html::script("lib/prism/prism.js");
echo Html::css("public/lib/prismjs/themes/prism-coy.css");
echo Html::script("public/lib/prismjs/components/prism-core.js");
echo Html::script("public/lib/prismjs/components/prism-apacheconf.js");
echo Html::script("public/lib/prismjs/components/prism-bash.js");
echo Html::script("public/lib/prismjs/components/prism-clike.js");
echo Html::script("public/lib/prismjs/components/prism-json.js");
echo Html::script("public/lib/prismjs/components/prism-nginx.js");
echo "<div class='documentation'>";
$documentation = file_get_contents(GLPI_ROOT.'/'.$file);
......
......@@ -1109,7 +1109,7 @@ class Entity extends CommonTreeDropdown {
echo "<script type='text/javascript'>";
echo " $(function() {
$.getScript('{$CFG_GLPI["root_doc"]}/lib/jqueryplugins/jstree/jstree.min.js').done(function(data, textStatus, jqxhr) {
$.getScript('{$CFG_GLPI["root_doc"]}/public/lib/jstree/jstree.js').done(function(data, textStatus, jqxhr) {
$('#tree_projectcategory$rand')
// call `.jstree` with the options object
.jstree({
......
This diff is collapsed.
......@@ -188,8 +188,8 @@ class KnowbaseItem_Revision extends CommonDBTM {
echo "</tr>";
}
echo Html::script("lib/jqueryplugins/prettytextdiff/diff_match_patch.js");
echo Html::script("lib/jqueryplugins/prettytextdiff/jquery.pretty-text-diff.js");
echo Html::script("public/lib/diff-match-patch/index.js");
echo Html::script("public/lib/jquery-prettytextdiff/jquery.pretty-text-diff.js");
echo "<script type='text/javascript'>
$(function() {
$('.restore').on('click', function(e) {
......
......@@ -85,7 +85,7 @@ if (!file_exists(GLPI_CONFIG_DIR . "/config_db.php")) {
// Appel CSS
echo Html::scss('main_styles');
// font awesome icons
echo Html::css('lib/font-awesome/css/all.css');
echo Html::css('public/lib/fontawesome-free/css/all.css');
// CFG
echo Html::scriptBlock("
......@@ -95,10 +95,10 @@ if (!file_exists(GLPI_CONFIG_DIR . "/config_db.php")) {
};
");
echo Html::script('lib/jquery/js/jquery.js');
echo Html::script('lib/jqueryplugins/select2/js/select2.full.js');
echo Html::script("lib/fuzzy/fuzzy-min.js");
echo Html::css('lib/jqueryplugins/select2/css/select2.css');
echo Html::script('public/lib/jquery/jquery.js');
echo Html::script('public/lib/select2/js/select2.full.js');
echo Html::script("public/lib/fuzzy/fuzzy.js");
echo Html::css('public/lib/select2/css/select2.css');
echo Html::script('js/common.js');
echo "</head>";
......
......@@ -63,16 +63,16 @@ function header_html($etape) {
};
");
// LIBS
echo Html::script("lib/jquery/js/jquery.js");
echo Html::script('lib/jquery/js/jquery-ui-1.10.4.custom.js');
echo Html::script("lib/jqueryplugins/select2/js/select2.js");
echo Html::script("lib/fuzzy/fuzzy-min.js");
// LIBS
echo Html::script("public/lib/jquery/jquery.js");
echo Html::script('public/lib/jquery-ui-dist/jquery-ui.js');
echo Html::script("public/lib/select2/js/select2.full.js");
echo Html::script("public/lib/fuzzy/fuzzy.js");
echo Html::script("js/common.js");
// CSS
echo Html::css('lib/jquery/css/smoothness/jquery-ui-1.10.4.custom.css');
echo Html::css("lib/jqueryplugins/select2/css/select2.css");
echo Html::css('public/lib/jquery-ui-dist/jquery-ui.css');
echo Html::css("public/lib/select2/css/select2.css");
echo Html::css("css/style_install.css");
echo "</head>";
echo "<body>";
......
......@@ -523,11 +523,11 @@ echo "<meta http-equiv='Content-Script-Type' content='text/javascript'>";
echo "<meta http-equiv='Content-Style-Type' content='text/css'>";
echo "<title>Setup GLPI</title>";
//JS
echo Html::script("lib/jquery/js/jquery.js");
echo Html::script('lib/jquery/js/jquery-ui-1.10.4.custom.js');
echo Html::script("public/lib/jquery/jquery.js");
echo Html::script('public/lib/jquery-ui-dist/jquery-ui.js');
// CSS
echo "<link rel='stylesheet' href='../css/style_install.css' type='text/css' media='screen' >";
echo Html::css('lib/jquery/css/smoothness/jquery-ui-1.10.4.custom.css');
echo Html::css('public/lib/jquery-ui-dist/jquery-ui.css');
echo "</head>";
echo "<body>";
echo "<div id='principal'>";
......
......@@ -33,7 +33,7 @@ var timeoutglobalvar;
if (typeof(String.prototype.normalize) !== 'function') {
$.ajax({
type: "GET",
url: CFG_GLPI.root_doc + "/lib/unorm/unorm.js",
url: CFG_GLPI.root_doc + "/public/lib/unorm/unorm.js",
dataType: "script",
cache: true
});
......@@ -215,8 +215,8 @@ function checkAsCheckboxes(reference_id, container_id) {
* Usage: $form.find('input[type="checkbox"]').shiftSelectable();
*/
$.fn.shiftSelectable = function() {
var lastChecked,
$boxes = this;
var lastChecked;
var $boxes = this;
// prevent html selection
document.onkeydown = function(e) {
......@@ -242,11 +242,11 @@ $.fn.shiftSelectable = function() {
if (evt.shiftKey) {
evt.preventDefault();
var start = $boxes.index(selected_checkbox),
end = $boxes.index(lastChecked);
var start = $boxes.index(selected_checkbox);
var end = $boxes.index(lastChecked);
$boxes.slice(Math.min(start, end), Math.max(start, end) + 1)
.prop('checked', $(lastChecked).is(':checked'))
.trigger('change');
.prop('checked', $(lastChecked).is(':checked'))
.trigger('change');
}
lastChecked = selected_checkbox;
......@@ -267,8 +267,8 @@ function showHideDiv(id, img_name, img_src_close, img_src_open) {
if (img_name !== '') {
var _awesome = img_src_close.match(/^fa-/);
var _deco,
_img;
var _deco;
var _img;
if (!_awesome) {
_img = $('img[name=' + img_name + ']');
if (_elt.is(':visible')) {
......@@ -383,9 +383,9 @@ function submitGetLink(target, fields) {
myInput.setAttribute("value", fields[name]);
myForm.appendChild(myInput);
}
document.body.appendChild(myForm);
myForm.submit();
document.body.removeChild(myForm);
document.body.appendChild(myForm);
myForm.submit();
document.body.removeChild(myForm);
}
......@@ -434,13 +434,13 @@ function massiveUpdateCheckbox(criterion, reference) {
if (typeof(value) == 'undefined') {
return false;
}
$(criterion).each(function() {
$(criterion).each(function() {
if (typeof(reference) == 'undefined') {
value = !$(this).prop('checked');
}
$(this).prop('checked', value);
});
return true;
$(this).prop('checked', value);
});
return true;
}
/**
......@@ -829,9 +829,11 @@ var initMap = function(parent_elt, map_id, height) {
//add map, set a default arbitrary location
parent_elt.append($('<div id="'+map_id+'" style="height: ' + height + '"></div>'));
/* global L */
var map = L.map(map_id, {fullscreenControl: true}).setView([43.6112422, 3.8767337], 6);
//setup tiles and © messages
/* global L */
L.tileLayer('https://{s}.tile.osm.org/{z}/{x}/{y}.png', {
attribution: '&copy; <a href=\'https://osm.org/copyright\'>OpenStreetMap</a> contributors'
}).addTo(map);
......@@ -846,7 +848,7 @@ var showMapForLocation = function(elt) {
return;
}
_dialog = $('<div id="location_map_dialog"/>');
var _dialog = $('<div id="location_map_dialog"/>');
_dialog.appendTo('body').dialog({
close: function() {
$(this).dialog('destroy').remove();
......@@ -875,9 +877,11 @@ var showMapForLocation = function(elt) {
});
} else {
var _markers = [];
_marker = L.marker([data.lat, data.lng]);
/* global L */
var _marker = L.marker([data.lat, data.lng]);
_markers.push(_marker);
/* global L */
var _group = L.featureGroup(_markers).addTo(map_elt);
map_elt.fitBounds(
_group.getBounds(), {
......@@ -939,7 +943,7 @@ var templateResult = function(result) {
if (text.indexOf('>') !== -1 || text.indexOf('<') !== -1) {
// escape text, if it contains chevrons (can already be escaped prior to this point :/)
text = jQuery.fn.select2.defaults.defaults.escapeMarkup(text);
}