Version 5.1 - All the GraphQL #32
@ -35,5 +35,5 @@
|
|||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=anime_collection') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/anime_collection') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -65,5 +65,5 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</main>
|
</main>
|
||||||
<?php if ($auth->is_authenticated()): ?>
|
<?php if ($auth->is_authenticated()): ?>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/edit') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -85,5 +85,5 @@
|
|||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/edit') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -74,4 +74,4 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</main>
|
</main>
|
||||||
<?php $group = ($auth->is_authenticated()) ? 'table_edit' : 'table' ?>
|
<?php $group = ($auth->is_authenticated()) ? 'table_edit' : 'table' ?>
|
||||||
<script src="<?= $urlGenerator->asset_url("js.php?g={$group}") ?>"></script>
|
<script src="<?= $urlGenerator->asset_url("js.php/g/{$group}") ?>"></script>
|
||||||
|
@ -40,5 +40,5 @@
|
|||||||
<img src="{{:cover_image}}" alt="{{:title}}" />
|
<img src="{{:cover_image}}" alt="{{:title}}" />
|
||||||
</article>
|
</article>
|
||||||
</template>
|
</template>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=anime_collection') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/anime_collection') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -52,5 +52,5 @@
|
|||||||
<img src="{{:cover_image}}" alt="{{:title}}" />
|
<img src="{{:cover_image}}" alt="{{:title}}" />
|
||||||
</article>
|
</article>
|
||||||
</template>
|
</template>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=anime_collection') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/anime_collection') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -49,4 +49,4 @@
|
|||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=table') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/table') ?>"></script>
|
@ -1,3 +1,3 @@
|
|||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=event') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/event') ?>"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -6,8 +6,8 @@
|
|||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<meta http-equiv="cache-control" content="no-store" />
|
<meta http-equiv="cache-control" content="no-store" />
|
||||||
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
|
<meta http-equiv="Content-Security-Policy" content="script-src 'self'" />
|
||||||
<link rel="stylesheet" href="<?= $urlGenerator->asset_url('css.php?g=base') ?>" />
|
<link rel="stylesheet" href="<?= $urlGenerator->asset_url('css.php/g/base') ?>" />
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=base') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/base') ?>"></script>
|
||||||
</head>
|
</head>
|
||||||
<body class="<?= $escape->attr($url_type) ?> list">
|
<body class="<?= $escape->attr($url_type) ?> list">
|
||||||
<header>
|
<header>
|
||||||
|
@ -35,5 +35,5 @@
|
|||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=manga_collection') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/manga_collection') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -56,5 +56,5 @@
|
|||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</main>
|
</main>
|
||||||
<?php if ($auth->is_authenticated()): ?>
|
<?php if ($auth->is_authenticated()): ?>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/edit') ?>"></script>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
|
@ -85,5 +85,4 @@
|
|||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=edit') ?>"></script>
|
|
||||||
<?php endif ?>
|
<?php endif ?>
|
@ -45,4 +45,4 @@
|
|||||||
<?php endforeach ?>
|
<?php endforeach ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</main>
|
</main>
|
||||||
<script src="<?= $urlGenerator->asset_url('js.php?g=table') ?>"></script>
|
<script src="<?= $urlGenerator->asset_url('js.php/g/table') ?>"></script>
|
@ -13,16 +13,19 @@
|
|||||||
|
|
||||||
namespace Aviat\EasyMin;
|
namespace Aviat\EasyMin;
|
||||||
|
|
||||||
|
require_once('./min.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple CSS Minifier
|
* Simple CSS Minifier
|
||||||
*/
|
*/
|
||||||
class CSSMin {
|
class CSSMin extends BaseMin {
|
||||||
|
|
||||||
protected $css_root;
|
protected $css_root;
|
||||||
protected $path_from;
|
protected $path_from;
|
||||||
protected $path_to;
|
protected $path_to;
|
||||||
protected $group;
|
protected $group;
|
||||||
protected $last_modified;
|
protected $last_modified;
|
||||||
|
protected $requested_time;
|
||||||
|
|
||||||
public function __construct(array $config, array $groups)
|
public function __construct(array $config, array $groups)
|
||||||
{
|
{
|
||||||
@ -33,6 +36,11 @@ class CSSMin {
|
|||||||
$this->group = $groups[$group];
|
$this->group = $groups[$group];
|
||||||
$this->last_modified = $this->get_last_modified();
|
$this->last_modified = $this->get_last_modified();
|
||||||
|
|
||||||
|
$this->requested_time = $this->get_if_modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
$this->send();
|
$this->send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,16 +51,11 @@ class CSSMin {
|
|||||||
*/
|
*/
|
||||||
protected function send()
|
protected function send()
|
||||||
{
|
{
|
||||||
$requested_time=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
|
/*if($this->last_modified >= $this->requested_time)
|
||||||
? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])
|
|
||||||
: 0;
|
|
||||||
|
|
||||||
// Send 304 when not modified for faster response
|
|
||||||
if($this->last_modified === $requested_time)
|
|
||||||
{
|
{
|
||||||
header("HTTP/1.1 304 Not Modified");
|
header('304 Not Modified');
|
||||||
exit();
|
die();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$css = ( ! array_key_exists('debug', $_GET))
|
$css = ( ! array_key_exists('debug', $_GET))
|
||||||
? $this->compress($this->get_css())
|
? $this->compress($this->get_css())
|
||||||
@ -69,7 +72,6 @@ class CSSMin {
|
|||||||
*/
|
*/
|
||||||
public function compress($buffer)
|
public function compress($buffer)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Remove CSS comments
|
//Remove CSS comments
|
||||||
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
|
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
|
||||||
|
|
||||||
@ -119,9 +121,8 @@ class CSSMin {
|
|||||||
|
|
||||||
//Get the latest modified date
|
//Get the latest modified date
|
||||||
rsort($modified);
|
rsort($modified);
|
||||||
$last_modified = $modified[0];
|
|
||||||
|
|
||||||
return $last_modified;
|
return array_shift($modified);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -133,18 +134,15 @@ class CSSMin {
|
|||||||
{
|
{
|
||||||
$css = '';
|
$css = '';
|
||||||
|
|
||||||
if(isset($this->group))
|
foreach($this->group as $file)
|
||||||
{
|
{
|
||||||
foreach($this->group as $file)
|
$new_file = realpath("{$this->css_root}{$file}");
|
||||||
{
|
$css .= file_get_contents($new_file);
|
||||||
$new_file = realpath("{$this->css_root}{$file}");
|
|
||||||
$css .= file_get_contents($new_file);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Correct paths that have changed due to concatenation
|
// Correct paths that have changed due to concatenation
|
||||||
// based on rules in the config file
|
// based on rules in the config file
|
||||||
$css = str_replace($this->path_from, $this->path_to, $css);
|
// $css = str_replace($this->path_from, $this->path_to, $css);
|
||||||
|
|
||||||
return $css;
|
return $css;
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,12 @@ use GuzzleHttp\Psr7\Request;
|
|||||||
|
|
||||||
// Include guzzle
|
// Include guzzle
|
||||||
require_once('../vendor/autoload.php');
|
require_once('../vendor/autoload.php');
|
||||||
|
require_once('./min.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simple Javascript minfier, using google closure compiler
|
* Simple Javascript minfier, using google closure compiler
|
||||||
*/
|
*/
|
||||||
class JSMin {
|
class JSMin extends BaseMin {
|
||||||
|
|
||||||
protected $js_root;
|
protected $js_root;
|
||||||
protected $js_group;
|
protected $js_group;
|
||||||
@ -43,14 +44,15 @@ class JSMin {
|
|||||||
$this->cache_file = "{$this->js_root}cache/{$group}";
|
$this->cache_file = "{$this->js_root}cache/{$group}";
|
||||||
$this->last_modified = $this->get_last_modified();
|
$this->last_modified = $this->get_last_modified();
|
||||||
|
|
||||||
$this->requested_time = (isset($_SERVER['HTTP_IF_MODIFIED_SINCE']))
|
$this->requested_time = $this->get_if_modified();
|
||||||
? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])
|
|
||||||
: time();
|
|
||||||
|
|
||||||
$this->cache_modified = (is_file($this->cache_file))
|
$this->cache_modified = (is_file($this->cache_file))
|
||||||
? filemtime($this->cache_file)
|
? filemtime($this->cache_file)
|
||||||
: 0;
|
: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __destruct()
|
||||||
|
{
|
||||||
// Output some JS!
|
// Output some JS!
|
||||||
$this->send();
|
$this->send();
|
||||||
}
|
}
|
||||||
@ -59,11 +61,11 @@ class JSMin {
|
|||||||
{
|
{
|
||||||
// If the browser's cached version is up to date,
|
// If the browser's cached version is up to date,
|
||||||
// don't resend the file
|
// don't resend the file
|
||||||
if($this->last_modified === $this->requested_time)
|
/*if($this->last_modified === $this->requested_time)
|
||||||
{
|
{
|
||||||
header('HTTP/1.1 304 Not Modified');
|
header($_SERVER['SERVER_PROTOCOL'].' 304 Not Modified');
|
||||||
exit();
|
exit();
|
||||||
}
|
}*/
|
||||||
|
|
||||||
//Determine what to do: rebuild cache, send files as is, or send cache.
|
//Determine what to do: rebuild cache, send files as is, or send cache.
|
||||||
// If debug is set, just concatenate
|
// If debug is set, just concatenate
|
||||||
@ -86,7 +88,7 @@ class JSMin {
|
|||||||
// Otherwise, send the cached file
|
// Otherwise, send the cached file
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return $this->output(file_get_contents($cache_file));
|
return $this->output(file_get_contents($this->cache_file));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
47
public/min.php
Normal file
47
public/min.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Hummingbird Anime Client
|
||||||
|
*
|
||||||
|
* An API client for Hummingbird to manage anime and manga watch lists
|
||||||
|
*
|
||||||
|
* @package HummingbirdAnimeClient
|
||||||
|
* @author Timothy J. Warren
|
||||||
|
* @copyright Copyright (c) 2015 - 2016
|
||||||
|
* @link https://github.com/timw4mail/HummingBirdAnimeClient
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace Aviat\EasyMin;
|
||||||
|
|
||||||
|
//Creative rewriting of /g/groupname to ?g=groupname
|
||||||
|
$pi = $_SERVER['PATH_INFO'];
|
||||||
|
$pia = explode('/', $pi);
|
||||||
|
|
||||||
|
$pia_len = count($pia);
|
||||||
|
$i = 1;
|
||||||
|
|
||||||
|
while($i < $pia_len)
|
||||||
|
{
|
||||||
|
$j = $i+1;
|
||||||
|
$j = (isset($pia[$j])) ? $j : $i;
|
||||||
|
|
||||||
|
$_GET[$pia[$i]] = $pia[$j];
|
||||||
|
|
||||||
|
$i = $j + 1;
|
||||||
|
};
|
||||||
|
|
||||||
|
class BaseMin {
|
||||||
|
public function get_if_modified()
|
||||||
|
{
|
||||||
|
return (array_key_exists('HTTP_IF_MODIFIED_SINCE', $_SERVER))
|
||||||
|
? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])
|
||||||
|
: time();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_if_none_match()
|
||||||
|
{
|
||||||
|
return (array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER))
|
||||||
|
? $_SERVER['HTTP_IF_NONE_MATCH']
|
||||||
|
: '';
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user