refs #3971 Catalog & basket style fixes, version check/set fixes
gitea/hedera-web/pipeline/head This commit looks good Details

This commit is contained in:
Juan Ferrer 2022-11-11 15:20:48 +01:00
parent 5de1601348
commit f82ecaad91
8 changed files with 68 additions and 25 deletions

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (22.44.2) stable; urgency=low
hedera-web (22.44.3) stable; urgency=low
* Initial Release.

View File

@ -20,7 +20,7 @@
.basket .line {
display: flex;
gap: 15px;
gap: 12px;
margin: 24px 0;
height: 65px;
}
@ -29,7 +29,7 @@
}
.basket .line > .delete {
align-self: center;
margin-right: -8px;
margin: 0 -8px;
}
.basket .line > .photo {
flex: none;

View File

@ -213,7 +213,6 @@
flex-direction: column;
width: 260px;
height: 425px;
overflow: hidden;
}
.grid-view .item-box:hover {
@ -221,10 +220,11 @@
}
.grid-view .item-info {
margin: 10px;
height: 142px;
}
.grid-view .item-box > .htk-image {
width: 260px;
height: 260px;
width: 100%;
min-height: 260px;
}
.grid-view .item-box > .item-info {
flex: auto;
@ -371,26 +371,30 @@
}
@media (max-width: 960px) {
.catalog-actions > button.menu
{
.catalog-actions > button.menu {
display: block;
}
.right-panel
{
.right-panel {
top: 0;
right: -18em;
z-index: 20;
transition: transform 200ms ease-out;
-webkit-transition: transform 200ms ease-out;
}
.right-panel.show
{
.right-panel.show {
transform: translateZ(0) translateX(-18em);
-webkit-transform: translateZ(0) translateX(-18em);
}
.catalog
{
.catalog {
margin-right: 0;
}
}
@media (max-width: 515px) {
.grid-view .item-box {
width: 100%;
max-width: 450px;
}
.grid-view .item-box > .htk-image {
min-height: initial;
}
}

View File

@ -1,6 +1,6 @@
{
"name": "hedera-web",
"version": "22.44.2",
"version": "22.44.3",
"description": "Verdnatura web page",
"license": "GPL-3.0",
"repository": {

View File

@ -66,7 +66,11 @@ class HtmlService extends Service {
// Setting the version
setcookie('vnVersion', $this->getVersion(), ['samesite' => 'Lax']);
$domain = explode(':', $_SERVER['HTTP_HOST'])[0];
setcookie('vnVersion', $this->getVersion()->toString(), [
'samesite' => 'Lax',
'domain' => $domain
]);
// Loading the requested page

View File

@ -18,7 +18,7 @@ class JsonService extends RestService {
$this->init();
$this->startSession();
//$this->checkVersion();
$this->checkVersion();
$json = $this->loadMethod(__NAMESPACE__.'\JsonRequest');
$this->replyJson($json);

View File

@ -124,9 +124,11 @@ abstract class Service {
);
if (isset($row['access'])) {
$domain = explode(':', $_SERVER['HTTP_HOST'])[0];
setcookie('vnVisit', $row['visit'], [
'expires' => time() + 31536000, // 1 Year
'samesite' => 'Lax'
'samesite' => 'Lax',
'domain' => $domain
]);
$_SESSION['access'] = $row['access'];
} else
@ -300,9 +302,9 @@ abstract class Service {
if (!$success) {
if (file_exists('package.json')) {
$package = json_decode(file_get_contents('package.json'));
$version = $package->version;
$version = new Version($package->version);
} else
$version = '0.0.0';
$version = new Version();
apcu_store("$appName.version", $version);
}
@ -314,11 +316,12 @@ abstract class Service {
* Checks the client version.
*/
function checkVersion() {
if (!empty($_COOKIE['vnVersion']))
$clientVersion = $_COOKIE['vnVersion'];
if (empty($_COOKIE['vnVersion'])) return;
$client = new Version($_COOKIE['vnVersion']);
$last = $this->getVersion();
if (isset($clientVersion)
&& $clientVersion < $this->getVersion())
if ($client->isLowerThan($last))
throw new OutdatedVersionException();
}

32
web/version.php Normal file
View File

@ -0,0 +1,32 @@
<?php
namespace Vn\Web;
class Version {
function __construct($version = '') {
if (!empty($version) && preg_match('/^\d+\.\d+\.\d+$/', $version)) {
$numbers = explode('.', $version);
$this->major = (int) $numbers[0];
$this->minor = (int) $numbers[1];
$this->fixes = (int) $numbers[2];
} else {
$this->major = 0;
$this->minor = 0;
$this->fixes = 0;
}
}
function isLowerThan($version) {
if ($this->major == $version->major) {
if ($this->minor == $version->minor)
return $this->fixes < $version->fixes;
else
return $this->minor < $version->minor;
} else
return $this->major < $version->major;
}
function toString() {
return "$this->major.$this->minor.$this->fixes";
}
}