summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-06-23 20:47:46 -0400
committerFrederic Guillot <fred@kanboard.net>2015-06-23 20:47:46 -0400
commit948ebb242490092c5a7e187c3b7813134b047d5e (patch)
tree28ed10f76c648ad8c70ffcc74e85c6de1ad8cfde
parentcdd2080fc0041d71b99862a9aa3542fe6150c6c4 (diff)
Improve assets loading: remove http call to load task colors and async load of app.js
-rw-r--r--app/Controller/App.php10
-rw-r--r--app/Helper/Asset.php15
-rw-r--r--app/Model/Acl.php1
-rw-r--r--app/Template/analytic/layout.php8
-rw-r--r--app/Template/budget/index.php6
-rw-r--r--app/Template/layout.php4
-rw-r--r--tests/units/AclTest.php1
7 files changed, 22 insertions, 23 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php
index 8a97e8c7..5c9c45b5 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -94,16 +94,6 @@ class App extends Base
}
/**
- * Colors stylesheet
- *
- * @access public
- */
- public function colors()
- {
- $this->response->css($this->color->getCss());
- }
-
- /**
* Task autocompletion (Ajax)
*
* @access public
diff --git a/app/Helper/Asset.php b/app/Helper/Asset.php
index fe285081..1b1e47c5 100644
--- a/app/Helper/Asset.php
+++ b/app/Helper/Asset.php
@@ -16,9 +16,9 @@ class Asset extends \Core\Base
* @param string $filename Filename
* @return string
*/
- public function js($filename)
+ public function js($filename, $async = false)
{
- return '<script type="text/javascript" src="'.$filename.'?'.filemtime($filename).'"></script>';
+ return '<script '.($async ? 'async' : '').' type="text/javascript" src="'.$filename.'?'.filemtime($filename).'"></script>';
}
/**
@@ -48,4 +48,15 @@ class Asset extends \Core\Base
return '';
}
+
+ /**
+ * Get CSS for task colors
+ *
+ * @access public
+ * @return string
+ */
+ public function colorCss()
+ {
+ return '<style>'.$this->color->getCss().'</style>';
+ }
}
diff --git a/app/Model/Acl.php b/app/Model/Acl.php
index 90944128..c9e155ed 100644
--- a/app/Model/Acl.php
+++ b/app/Model/Acl.php
@@ -21,7 +21,6 @@ class Acl extends Base
'user' => array('google', 'github'),
'task' => array('readonly'),
'board' => array('readonly'),
- 'app' => array('colors'),
'webhook' => '*',
'ical' => '*',
'feed' => '*',
diff --git a/app/Template/analytic/layout.php b/app/Template/analytic/layout.php
index 72aab4d8..41c6a2ab 100644
--- a/app/Template/analytic/layout.php
+++ b/app/Template/analytic/layout.php
@@ -1,6 +1,3 @@
-<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
-<?= $this->asset->js('assets/js/vendor/c3.min.js') ?>
-
<section id="main">
<div class="page-header">
<ul>
@@ -32,4 +29,7 @@
<?= $content_for_sublayout ?>
</div>
</section>
-</section> \ No newline at end of file
+</section>
+
+<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/c3.min.js') ?> \ No newline at end of file
diff --git a/app/Template/budget/index.php b/app/Template/budget/index.php
index 3b594017..80153bbd 100644
--- a/app/Template/budget/index.php
+++ b/app/Template/budget/index.php
@@ -1,6 +1,3 @@
-<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
-<?= $this->asset->js('assets/js/vendor/c3.min.js') ?>
-
<div class="page-header">
<h2><?= t('Budget overview') ?></h2>
</div>
@@ -32,3 +29,6 @@
<?php else: ?>
<p class="alert"><?= t('There is not enough data to show something.') ?></p>
<?php endif ?>
+
+<?= $this->asset->js('assets/js/vendor/d3.v3.min.js') ?>
+<?= $this->asset->js('assets/js/vendor/c3.min.js') ?> \ No newline at end of file
diff --git a/app/Template/layout.php b/app/Template/layout.php
index 0d9326f4..c630132d 100644
--- a/app/Template/layout.php
+++ b/app/Template/layout.php
@@ -12,12 +12,12 @@
<?php endif ?>
<?php if (! isset($not_editable)): ?>
- <?= $this->asset->js('assets/js/app.js') ?>
+ <?= $this->asset->js('assets/js/app.js', true) ?>
<?php endif ?>
- <?= $this->asset->css($this->url->href('app', 'colors'), false, 'all') ?>
<?= $this->asset->css('assets/css/app.css') ?>
<?= $this->asset->css('assets/css/print.css', true, 'print') ?>
+ <?= $this->asset->colorCss() ?>
<?= $this->asset->customCss() ?>
<link rel="icon" type="image/png" href="assets/img/favicon.png">
diff --git a/tests/units/AclTest.php b/tests/units/AclTest.php
index c74a90ca..72c897c0 100644
--- a/tests/units/AclTest.php
+++ b/tests/units/AclTest.php
@@ -37,7 +37,6 @@ class AclTest extends Base
$acl = new Acl($this->container);
$this->assertTrue($acl->isPublicAction('board', 'readonly'));
$this->assertFalse($acl->isPublicAction('board', 'show'));
- $this->assertTrue($acl->isPublicAction('app', 'colors'));
$this->assertTrue($acl->isPublicAction('feed', 'project'));
$this->assertTrue($acl->isPublicAction('feed', 'user'));
}