Remove dependency on nodejs and gulp

This commit is contained in:
Frédéric Guillot 2019-07-25 13:05:08 -07:00
parent 9ae185c18e
commit d42dd07054
11 changed files with 602 additions and 269 deletions

View File

@ -19,9 +19,7 @@ composer.json
Dockerfile
Dockerfile.*
Makefile
package.json
Vagrantfile
web.config
node_modules
assets/sass
assets/css/src
assets/vendor

6
.gitattributes vendored
View File

@ -18,14 +18,10 @@ CONTRIBUTING export-ignore
app.json export-ignore
composer.json export-ignore
composer.lock export-ignore
gulpfile.js export-ignore
package.json export-ignore
hooks export-ignore
assets/sass export-ignore
assets/css/src export-ignore
assets/js/components export-ignore
assets/js/core export-ignore
assets/js/polyfills export-ignore
assets/js/src export-ignore
assets/sass export-ignore
assets/vendor export-ignore

View File

@ -98,7 +98,7 @@ class CssCommand extends BaseCommand
{
$this
->setName('css')
->setDescription('Minify CSS')
->setDescription('Minify CSS files')
;
}
@ -114,7 +114,7 @@ class CssCommand extends BaseCommand
$minifier = new Minify\CSS();
foreach ($files as $file) {
$filename = $folder. $file;
$filename = $folder.$file;
if (! file_exists($filename)) {
die("$filename not found\n");
}

112
app/Console/JsCommand.php Normal file
View File

@ -0,0 +1,112 @@
<?php
namespace Kanboard\Console;
use MatthiasMullie\Minify;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
$path = __DIR__ . '/../../libs';
require_once $path . '/minify/src/Minify.php';
require_once $path . '/minify/src/CSS.php';
require_once $path . '/minify/src/JS.php';
require_once $path . '/minify/src/Exception.php';
require_once $path . '/minify/src/Exceptions/BasicException.php';
require_once $path . '/minify/src/Exceptions/FileImportException.php';
require_once $path . '/minify/src/Exceptions/IOException.php';
require_once $path . '/path-converter/src/ConverterInterface.php';
require_once $path . '/path-converter/src/Converter.php';
/**
* Class JsCommand
*
* @package Kanboard\Console
* @author Frederic Guillot
*/
class JsCommand extends BaseCommand
{
const CSS_DIST_PATH = 'assets/js/';
private $appFiles = [
'assets/vendor/textarea-caret/index.js',
'assets/js/polyfills/*.js',
'assets/js/core/base.js',
'assets/js/core/dom.js',
'assets/js/core/html.js',
'assets/js/core/http.js',
'assets/js/core/modal.js',
'assets/js/core/tooltip.js',
'assets/js/core/utils.js',
'assets/js/components/*.js',
'assets/js/core/bootstrap.js',
'assets/js/src/Namespace.js',
'assets/js/src/App.js',
'assets/js/src/BoardCollapsedMode.js',
'assets/js/src/BoardColumnView.js',
'assets/js/src/BoardHorizontalScrolling.js',
'assets/js/src/BoardPolling.js',
'assets/js/src/Column.js',
'assets/js/src/Dropdown.js',
'assets/js/src/Search.js',
'assets/js/src/Swimlane.js',
'assets/js/src/Task.js',
'assets/js/src/BoardDragAndDrop.js',
'assets/js/src/Bootstrap.js'
];
private $vendorFiles = [
'assets/vendor/jquery/jquery-3.3.1.min.js',
'assets/vendor/jquery-ui/jquery-ui.min.js',
'assets/vendor/jquery-ui/i18n/datepicker-*.js',
'assets/vendor/jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.js',
'assets/vendor/jqueryui-timepicker-addon/i18n/jquery-ui-timepicker-addon-i18n.min.js',
'assets/vendor/jqueryui-touch-punch/jquery.ui.touch-punch.min.js',
'assets/vendor/select2/js/select2.min.js',
'assets/vendor/select2/js/i18n/*.js',
'assets/vendor/d3/d3.min.js',
'assets/vendor/c3/c3.min.js',
'assets/vendor/isMobile/isMobile.min.js',
'assets/vendor/marked/marked.min.js',
];
protected function configure()
{
$this
->setName('js')
->setDescription('Minify Javascript files')
;
}
protected function execute(InputInterface $input, OutputInterface $output)
{
$appBundle = $this->concat($this->appFiles);
$vendorBundle = $this->concat($this->vendorFiles);
$minifier = new Minify\JS($appBundle);
file_put_contents('assets/js/app.min.js', $minifier->minify());
file_put_contents('assets/js/vendor.min.js', $vendorBundle);
}
private function concat(array $files)
{
$data = '';
foreach ($files as $pattern) {
foreach (glob($pattern) as $filename) {
echo $filename.PHP_EOL;
if (! file_exists($filename)) {
die("$filename not found\n");
}
$contents = file_get_contents($filename);
if ($contents === false) {
die("Unable to read $filename\n");
}
$data .= $contents;
}
}
return $data;
}
}

View File

@ -25,6 +25,7 @@ use Kanboard\Console\TransitionExportCommand;
use Kanboard\Console\VersionCommand;
use Kanboard\Console\WorkerCommand;
use Kanboard\Console\CssCommand;
use Kanboard\Console\JsCommand;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Symfony\Component\Console\Application;
@ -69,6 +70,7 @@ class CommandProvider implements ServiceProviderInterface
$application->add(new DatabaseVersionCommand($container));
$application->add(new VersionCommand($container));
$application->add(new CssCommand($container));
$application->add(new JsCommand($container));
$container['cli'] = $application;
return $container;

287
assets/js/app.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

9
assets/vendor/text-caret/LICENSE vendored Normal file
View File

@ -0,0 +1,9 @@
The MIT License (MIT)
Copyright (c) 2015 Jonathan Ong me@jongleberry.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

138
assets/vendor/text-caret/index.js vendored Normal file
View File

@ -0,0 +1,138 @@
/* jshint browser: true */
(function () {
// We'll copy the properties below into the mirror div.
// Note that some browsers, such as Firefox, do not concatenate properties
// into their shorthand (e.g. padding-top, padding-bottom etc. -> padding),
// so we have to list every single property explicitly.
var properties = [
'direction', // RTL support
'boxSizing',
'width', // on Chrome and IE, exclude the scrollbar, so the mirror div wraps exactly as the textarea does
'height',
'overflowX',
'overflowY', // copy the scrollbar for IE
'borderTopWidth',
'borderRightWidth',
'borderBottomWidth',
'borderLeftWidth',
'borderStyle',
'paddingTop',
'paddingRight',
'paddingBottom',
'paddingLeft',
// https://developer.mozilla.org/en-US/docs/Web/CSS/font
'fontStyle',
'fontVariant',
'fontWeight',
'fontStretch',
'fontSize',
'fontSizeAdjust',
'lineHeight',
'fontFamily',
'textAlign',
'textTransform',
'textIndent',
'textDecoration', // might not make a difference, but better be safe
'letterSpacing',
'wordSpacing',
'tabSize',
'MozTabSize'
];
var isBrowser = (typeof window !== 'undefined');
var isFirefox = (isBrowser && window.mozInnerScreenX != null);
function getCaretCoordinates(element, position, options) {
if (!isBrowser) {
throw new Error('textarea-caret-position#getCaretCoordinates should only be called in a browser');
}
var debug = options && options.debug || false;
if (debug) {
var el = document.querySelector('#input-textarea-caret-position-mirror-div');
if (el) el.parentNode.removeChild(el);
}
// The mirror div will replicate the textarea's style
var div = document.createElement('div');
div.id = 'input-textarea-caret-position-mirror-div';
document.body.appendChild(div);
var style = div.style;
var computed = window.getComputedStyle ? window.getComputedStyle(element) : element.currentStyle; // currentStyle for IE < 9
var isInput = element.nodeName === 'INPUT';
// Default textarea styles
style.whiteSpace = 'pre-wrap';
if (!isInput)
style.wordWrap = 'break-word'; // only for textarea-s
// Position off-screen
style.position = 'absolute'; // required to return coordinates properly
if (!debug)
style.visibility = 'hidden'; // not 'display: none' because we want rendering
// Transfer the element's properties to the div
properties.forEach(function (prop) {
if (isInput && prop === 'lineHeight') {
// Special case for <input>s because text is rendered centered and line height may be != height
style.lineHeight = computed.height;
} else {
style[prop] = computed[prop];
}
});
if (isFirefox) {
// Firefox lies about the overflow property for textareas: https://bugzilla.mozilla.org/show_bug.cgi?id=984275
if (element.scrollHeight > parseInt(computed.height))
style.overflowY = 'scroll';
} else {
style.overflow = 'hidden'; // for Chrome to not render a scrollbar; IE keeps overflowY = 'scroll'
}
div.textContent = element.value.substring(0, position);
// The second special handling for input type="text" vs textarea:
// spaces need to be replaced with non-breaking spaces - http://stackoverflow.com/a/13402035/1269037
if (isInput)
div.textContent = div.textContent.replace(/\s/g, '\u00a0');
var span = document.createElement('span');
// Wrapping must be replicated *exactly*, including when a long word gets
// onto the next line, with whitespace at the end of the line before (#7).
// The *only* reliable way to do that is to copy the *entire* rest of the
// textarea's content into the <span> created at the caret position.
// For inputs, just '.' would be enough, but no need to bother.
span.textContent = element.value.substring(position) || '.'; // || because a completely empty faux span doesn't render at all
div.appendChild(span);
var coordinates = {
top: span.offsetTop + parseInt(computed['borderTopWidth']),
left: span.offsetLeft + parseInt(computed['borderLeftWidth']),
height: parseInt(computed['lineHeight'])
};
if (debug) {
span.style.backgroundColor = '#aaa';
} else {
document.body.removeChild(div);
}
return coordinates;
}
if (typeof module != 'undefined' && typeof module.exports != 'undefined') {
module.exports = getCaretCoordinates;
} else if(isBrowser) {
window.getCaretCoordinates = getCaretCoordinates;
}
}());

View File

@ -1,64 +0,0 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var src = {
js: [
'node_modules/textarea-caret/index.js',
'assets/js/polyfills/*.js',
'assets/js/core/base.js',
'assets/js/core/!(base|bootstrap)*.js',
'assets/js/components/*.js',
'assets/js/core/bootstrap.js',
'assets/js/src/Namespace.js',
'assets/js/src/!(Namespace|Bootstrap|BoardDragAndDrop)*.js',
'assets/js/src/BoardDragAndDrop.js',
'assets/js/src/Bootstrap.js'
]
};
var vendor = {
js: [
'assets/vendor/jquery/jquery-3.3.1.min.js',
'assets/vendor/jquery-ui/jquery-ui.min.js',
'assets/vendor/jquery-ui/i18n/datepicker-*.js',
'assets/vendor/jqueryui-timepicker-addon/jquery-ui-timepicker-addon.min.js',
'assets/vendor/jqueryui-timepicker-addon/i18n/jquery-ui-timepicker-addon-i18n.min.js',
'assets/vendor/jqueryui-touch-punch/jquery.ui.touch-punch.min.js',
'assets/vendor/select2/js/select2.min.js',
'assets/vendor/select2/js/i18n/*.js',
'assets/vendor/d3/d3.min.js',
'assets/vendor/c3/c3.min.js',
'assets/vendor/isMobile/isMobile.min.js',
'assets/vendor/marked/marked.min.js'
]
};
var dist = {
fonts: 'assets/fonts/',
js: 'assets/js/',
img: 'assets/img/'
};
gulp.task('vendor', function() {
gulp.src(vendor.js)
.pipe(concat('vendor.min.js'))
.pipe(gulp.dest(dist.js))
;
gulp.src('assets/vendor/font-awesome/fonts/*')
.pipe(gulp.dest(dist.fonts));
gulp.src('assets/vendor/jquery-ui/images/*')
.pipe(gulp.dest(dist.css + 'images/'));
});
gulp.task('js', function() {
gulp.src(src.js)
.pipe(concat('app.min.js'))
.pipe(uglify())
.pipe(gulp.dest(dist.js))
;
});
gulp.task('default', ['vendor', 'js']);

View File

@ -1,13 +0,0 @@
{
"name": "kanboard",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-cli": "^1.2.2",
"gulp-concat": "^2.6.1",
"gulp-uglify": "^2.0.0",
"jshint": "^2.9.4"
},
"dependencies": {
"textarea-caret": "^3.0.2"
}
}