Initial commit
This commit is contained in:
commit
65e0da7e11
1397 changed files with 596542 additions and 0 deletions
58
site/OFF_plugins/autobuster/lib/css.php
Normal file
58
site/OFF_plugins/autobuster/lib/css.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Autobuster;
|
||||
|
||||
use F;
|
||||
|
||||
/**
|
||||
* Kirby Autobuster CSS Component
|
||||
*
|
||||
* @package Kirby CMS
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
* @link http://getkirby.com
|
||||
* @copyright Bastian Allgeier
|
||||
* @license http://getkirby.com/license
|
||||
*/
|
||||
class CSS extends \Kirby\Component\CSS {
|
||||
|
||||
/**
|
||||
* Builds the html link tag for the given css file
|
||||
*
|
||||
* @param string $url
|
||||
* @param null|string $media
|
||||
* @return string
|
||||
*/
|
||||
public function tag($url, $media = null) {
|
||||
|
||||
if(is_array($url)) {
|
||||
$css = array();
|
||||
foreach($url as $u) $css[] = $this->tag($u, $media);
|
||||
return implode(PHP_EOL, $css) . PHP_EOL;
|
||||
}
|
||||
|
||||
// auto template css files
|
||||
if ($url == '@auto') {
|
||||
$template = $this->kirby->site()->page()->template();
|
||||
$file = $template . '.css';
|
||||
$root = $this->kirby->roots()->autocss() . DS . $file;
|
||||
if (file_exists($root)) {
|
||||
$mod = f::modified($root);
|
||||
$url = $this->kirby->urls()->autocss() . '/' . $template . '.css' . '?v=' . $mod;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$file = kirby()->roots()->index() . DS . $url;
|
||||
|
||||
if (file_exists($file)) {
|
||||
$mod = f::modified($file);
|
||||
$url = dirname($url) . '/' . f::filename($url) . '?v=' . $mod;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return parent::tag($url, $media);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
66
site/OFF_plugins/autobuster/lib/js.php
Normal file
66
site/OFF_plugins/autobuster/lib/js.php
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace Kirby\Autobuster;
|
||||
|
||||
use HTML;
|
||||
use STR;
|
||||
use F;
|
||||
|
||||
/**
|
||||
* Kirby Autobuster JS Component
|
||||
*
|
||||
* @package Kirby CMS
|
||||
* @author Bastian Allgeier <bastian@getkirby.com>
|
||||
* @link http://getkirby.com
|
||||
* @copyright Bastian Allgeier
|
||||
* @license http://getkirby.com/license
|
||||
*/
|
||||
class JS extends \Kirby\Component\JS
|
||||
{
|
||||
/**
|
||||
* Builds the html script tag for the given javascript file
|
||||
*
|
||||
* @param string $src
|
||||
* @param boolean async
|
||||
* @return string
|
||||
*/
|
||||
public function tag($src, $async = false)
|
||||
{
|
||||
if (is_array($src)) {
|
||||
$js = array();
|
||||
foreach ($src as $s) {
|
||||
$js[] = $this->tag($s, $async);
|
||||
}
|
||||
return implode(PHP_EOL, $js) . PHP_EOL;
|
||||
}
|
||||
|
||||
// auto template js files
|
||||
if ($src == '@auto') {
|
||||
$template = $this->kirby->site()->page()->template();
|
||||
$file = $template . '.js';
|
||||
$root = $this->kirby->roots()->autojs() . DS . $file;
|
||||
if (file_exists($root)) {
|
||||
$mod = f::modified($root);
|
||||
$src = $this->kirby->urls()->autojs() . '/' . $template . '.js' . '?v=' . $mod;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$file = kirby()->roots()->index() . DS . $src;
|
||||
|
||||
if (file_exists($file)) {
|
||||
$mod = f::modified($file);
|
||||
$src = dirname($src) . '/' . f::filename($src) . '?v=' . $mod;
|
||||
}
|
||||
}
|
||||
|
||||
// build the array of HTML attributes
|
||||
$attr = array('src' => url($src));
|
||||
if (is_array($async)) {
|
||||
$attr = array_merge($attr, $async);
|
||||
} elseif ($async === true) {
|
||||
$attr['async'] = true;
|
||||
}
|
||||
return html::tag('script', '', $attr);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue