Fix issues and update js/css bundles

This commit is contained in:
Dale Davies
2022-06-03 23:17:44 +01:00
parent ad322ba0c0
commit 52666c18fa
7 changed files with 34 additions and 105 deletions

View File

@@ -25,7 +25,7 @@ if (http_response_code() === false) {
header('Content-Type: application/json; charset=utf-8');
// Initialise a new session using the request object.
$session = new \Nette\Http\Session((new \Nette\Http\RequestFactory)->fromGlobals(), new \Nette\Http\Response);
$session = new Nette\Http\Session((new Nette\Http\RequestFactory)->fromGlobals(), new Nette\Http\Response);
$session->setName($config->get('sessionname'));
$session->setExpiration($config->get('sessiontimeout'));
@@ -56,24 +56,31 @@ function load_cache_unsplash_data() {
'utmSource' => 'jump_startpage',
'applicationId' => $config->get('unsplashapikey'),
]);
// Or apply some optional filters by passing a key value array of filters
$filters = [
'collections' => $config->get('unsplashcollections', false),
];
$photo = Crew\Unsplash\Photo::random($filters);
// Try to get a random image via the API.
try {
$photo = Crew\Unsplash\Photo::random([
'collections' => $config->get('unsplashcollections', false),
]);
} catch (Exception $e) {
http_response_code(500);
die(json_encode(['error' => json_decode($e->getMessage())]));
}
// Download the image data from Unsplash.
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $photo->urls['raw'] . '&auto=compress&w=1920');
curl_setopt($ch, CURLOPT_URL, $photo->urls['raw'].'&auto=compress&w=1920');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_FAILONERROR, true);
$response = curl_exec($ch);
$description = $photo->description?$photo->description:'Photo';
// Create the response and return it.
$description = 'Photo';
if ($photo->description !== null &&
strlen($photo->description) <= 45) {
$description = $photo->description;
}
$unsplashdata = new stdClass();
$unsplashdata->cssimg = $photo->urls['raw'] . '&auto=compress&w=1920';
$unsplashdata->attribution = '<a target="_blank" rel="noopener" href="'.$photo->links['html'].'">'.$description.'</a> by <a target="_blank" rel="noopener" href="'.$photo->user['links']['html'].'">'.$photo->user['name'].'</a>';
$unsplashdata->blurhash = $photo->blur_hash;
$unsplashdata->imagedatauri = 'data: '.(new \finfo(FILEINFO_MIME_TYPE))->buffer($response).';base64,'.base64_encode($response);
$unsplashdata->imagedatauri = 'data: '.(new finfo(FILEINFO_MIME_TYPE))->buffer($response).';base64,'.base64_encode($response);
return $unsplashdata;
});
}

View File

@@ -57,7 +57,6 @@ body {
}
.background {
//filter: brightness(0.85) blur(10px);
background-repeat: no-repeat;
background-size: cover;
background-position: center center;
@@ -83,6 +82,12 @@ body {
}
}
@media (max-width: 850px) {
.unsplash {
display: none;
}
}
.content {
z-index: 100;
display: flex;
@@ -92,89 +97,3 @@ body {
max-width: 650px;
margin:-50px auto 0 auto;
}
.loading {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 100000;
background: #efefef;
transition: opacity .2s;
&.complete {
opacity: 0;
z-index: 0;
}
.lds-grid {
display: inline-block;
position: absolute;
width: 80px;
height: 80px;
top: 50%;
margin-top: -40px;
}
.lds-grid div {
position: absolute;
width: 16px;
height: 16px;
border-radius: 50%;
background: #bbb;
animation: lds-grid 1.2s linear infinite;
}
.lds-grid div:nth-child(1) {
top: 8px;
left: 8px;
animation-delay: 0s;
}
.lds-grid div:nth-child(2) {
top: 8px;
left: 32px;
animation-delay: -0.4s;
}
.lds-grid div:nth-child(3) {
top: 8px;
left: 56px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(4) {
top: 32px;
left: 8px;
animation-delay: -0.4s;
}
.lds-grid div:nth-child(5) {
top: 32px;
left: 32px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(6) {
top: 32px;
left: 56px;
animation-delay: -1.2s;
}
.lds-grid div:nth-child(7) {
top: 56px;
left: 8px;
animation-delay: -0.8s;
}
.lds-grid div:nth-child(8) {
top: 56px;
left: 32px;
animation-delay: -1.2s;
}
.lds-grid div:nth-child(9) {
top: 56px;
left: 56px;
animation-delay: -1.6s;
}
@keyframes lds-grid {
0%, 100% {
opacity: 1;
}
50% {
opacity: 0.5;
}
}
}

View File

@@ -18,11 +18,14 @@ class TagPage extends AbstractPage {
'title' => $title,
'owmapikey' => !!$this->config->get('owmapikey', false),
'metrictemp' => $this->config->parse_bool($this->config->get('metrictemp')),
'ampmclock' => $this->config->parse_bool($this->config->get('ampmclock', false)),
'unsplash' => !!$this->config->get('unsplashapikey', false),
];
if ($this->config->parse_bool($this->config->get('showsearch', false))) {
$templatecontext = array_merge($templatecontext,
['searchengines' => json_encode((new \Jump\SearchEngines($this->config, $this->cache))->get_search_engines()),
'searchjson' => json_encode((new \Jump\Sites($this->config, $this->cache))->get_sites_for_search()),]);
$templatecontext = array_merge($templatecontext, [
'searchengines' => json_encode((new \Jump\SearchEngines($this->config, $this->cache))->get_search_engines()),
'searchjson' => json_encode((new \Jump\Sites($this->config, $this->cache))->get_sites_for_search()),
]);
}
return $template->render($templatecontext);
}

View File

@@ -33,6 +33,6 @@
{{/ hastags}}
<span class="unsplash"></span>
<div class="background fixed"></div>
<script defer src="/assets/js/index.ba136a0b0f7568f72fe2.min.js"></script>
<script defer src="/assets/js/index.dc0f2861d62f085d50c9.min.js"></script>
</body>
</html>

View File

@@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
{{# noindex}}<meta name="robots" content="noindex">{{/ noindex}}
<link rel="stylesheet" href="/assets/css/styles.a2d961744a0ef66e91b4.min.css">
<link rel="stylesheet" href="/assets/css/styles.9077780cf1d7c1a7fc4e.min.css">
<link rel="stylesheet" href="/background-css.php">
<link rel="stylesheet" href="/assets/css/weather-icons.min.css">
<link rel="icon" type="image/png" href="/favicon.png">