Skip to content

Commit

Permalink
Set PWA
Browse files Browse the repository at this point in the history
  • Loading branch information
rantes committed Aug 5, 2021
1 parent 53f1a54 commit bb3bcf7
Show file tree
Hide file tree
Showing 29 changed files with 697 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin_base_trait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private function _init() {
}

public function before_filter() {
// Require_login();
Require_login();
$this->menuLinks = adminMenu();
}

Expand Down
47 changes: 47 additions & 0 deletions app/controllers/index_controller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php
require_once INST_PATH.'app/controllers/admin_base_trait.php';
class IndexController extends Page {
use AdminBaseTrait;

public $exceptsBeforeFilter = [
'actions' => 'login,logout,signin'
];

public function __construct() {
$this->_init();
}

public function before_filter() {
Require_login();
$this->menuLinks = generalMenu();
}

public function indexAction() {
$this->render = ['text'=>'noop'];
}

public function loginAction() {
$this->layout = false;
}
public function signinAction() {
$code = HTTP_401;

if (!empty($_POST['e']) and !empty($_POST['p'])):
$id = $this->User->login($_POST['e'], $_POST['p']);
$id > 0 and ($code = HTTP_202) and ($_SESSION['user'] = $id);
endif;

http_response_code($code);
$this->respondToAJAX('{}');
}
/**
* Destroy all registered information of a session and redirect to the login page.
*/
public function logoutAction() {
$this->layout = false;
php_sapi_name() !== 'cli' && session_destroy();
$_SESSION = null;
unset($_SESSION);
header('Location: /index/login');
}
}
9 changes: 8 additions & 1 deletion app/helpers/Menu_Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ function adminMenu() {
return [
new menuEntry('/admin/index', 'Inicio', null, 'home'),
new menuEntry('/admin/users', 'Usuarios', null, 'user'),
new menuEntry('/admin/logout?logout=1', 'Salir', null, 'exit')
new menuEntry('/index/logout?logout=1', 'Salir', null, 'exit')
];
}

function generalMenu() {
return [
new menuEntry('/index/index', 'Inicio', null, 'home'),
new menuEntry('/index/logout?logout=1', 'Salir', null, 'exit')
];
}
17 changes: 17 additions & 0 deletions app/views/_footer-contents.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

<script type="text/javascript">
<? readfile(INST_PATH.'app/webroot/libs/dumbo.min.js'); ?>
<? readfile(INST_PATH.'app/webroot/libs/dmb-factories.min.js'); ?>
<? file_exists(INST_PATH.'app/webroot/js/factories.min.js') and readfile(INST_PATH.'app/webroot/js/factories.min.js'); ?>
<? readfile(INST_PATH.'app/webroot/libs/dmb-components.min.js'); ?>
<? file_exists(INST_PATH.'app/webroot/js/components.min.js') and readfile(INST_PATH.'app/webroot/js/components.min.js'); ?>
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js')
.then(function(registration) {
/* NOOP */
});
navigator.serviceWorker.ready.then(function(registration) {
/* NOOP */
});
}
</script>
39 changes: 39 additions & 0 deletions app/views/_header-contents.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Basilisk Project Management">
<meta name="keywords" content="project,management">
<meta name="theme-color" content="#ff9901">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
<meta name="msapplication-starturl" content="/">

<base href="<?=INST_URI;?>">
<title>Basilisk</title>

<link rel="apple-touch-icon" sizes="57x57" href="/images/logo-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/images/logo-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/images/logo-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/images/logo-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/logo-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/logo-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/images/logo-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/images/logo-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/images/logo-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/images/logo-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/images/logo-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/images/logo-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/images/logo-16x16.png">
<link rel="manifest" href="/manifest.json">

<script type="text/javascript">
window.innerWidth = window.outerWidth;
</script>

<style type="text/css">
<? readfile(INST_PATH.'app/webroot/libs/dmb-styles.css'); ?>
<? readfile(INST_PATH.'app/webroot/css/styles.css'); ?>
</style>
17 changes: 17 additions & 0 deletions app/views/index/login.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<? require_once(INST_PATH.'app/views/_header-contents.phtml'); ?>
</head>
<body style="background: url(/images/basilisk.svg) no-repeat; background-size: contain;background-position: center;height: 100vh;width: 100vw;overflow: hidden;">
<noscript>
<h1>Your browser does not support JS</h1>
</noscript>
<dmb-dialog open>
<dmb-login target="/index/">
<? readfile(INST_PATH.'app/webroot/images/logo.svg'); ?>
</dmb-login>
</dmb-dialog>
<? require_once(INST_PATH.'app/views/_footer-contents.phtml'); ?>
</body>
</html>
33 changes: 4 additions & 29 deletions app/views/layout.phtml
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<base href="<?=INST_URI;?>">
<title>Basilisk Project Management</title>
<meta name="msapplication-starturl" content="/">
<meta name="theme-color" content="#ff9901">
<meta name="viewport" content="initial-scale=1, width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="description" content="Basilisk Project Management">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script type="text/javascript">
window.innerWidth = window.outerWidth;
</script>

<style type="text/css">
<? readfile(INST_PATH.'app/webroot/libs/dmb-styles.css'); ?>
<? readfile(INST_PATH.'app/webroot/css/styles.css'); ?>
</style>
<? require_once(INST_PATH.'app/views/_header-contents.phtml'); ?>
</head>
<body>
<dmb-view class="dmb-view" id="page">
<dmb-header>
<div class="section-group">
<div class="col col2 col2-md col2-sm">
<? if(_ACTION !== 'login' and !empty($_SESSION['admin'])): ?>
<? if(_ACTION !== 'login'): ?>
<dmb-menu-button menu="#general-menu" legend="Men&uacute; Principal">Menu</dmb-menu-button>
<? endif; ?>
</div>
Expand All @@ -40,7 +21,7 @@
<?=$this->yield;?>
</dmb-content>
<dmb-footer is="footer" id="page-footer"></dmb-footer>
<? if(_ACTION !== 'login' and !empty($_SESSION['admin'])): ?>
<? if(_ACTION !== 'login'): ?>
<dmb-panel id="general-menu" class="dmb-panel dmb-menu left">
<dmb-header>
<h3>Men&uacute;</h3>
Expand All @@ -65,12 +46,6 @@
</dmb-panel>
<? endif; ?>
</dmb-view>
<script type="text/javascript">
<? readfile(INST_PATH.'app/webroot/libs/dumbo.min.js'); ?>
<? readfile(INST_PATH.'app/webroot/libs/dmb-factories.min.js'); ?>
<? file_exists(INST_PATH.'app/webroot/js/factories.min.js') and readfile(INST_PATH.'app/webroot/js/factories.min.js'); ?>
<? readfile(INST_PATH.'app/webroot/libs/dmb-components.min.js'); ?>
<? file_exists(INST_PATH.'app/webroot/js/components.min.js') and readfile(INST_PATH.'app/webroot/js/components.min.js'); ?>
</script>
<? require_once(INST_PATH.'app/views/_footer-contents.phtml'); ?>
</body>
</html>
9 changes: 7 additions & 2 deletions app/webroot/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
**/
:root {
--primary: #16253F;
--primary-contrast: #1a1a1a;
--primary-hover: #CC660099;
--primary-contrast: #ffffff;
--primary-hover: #16253F99;
--secondary: #182517;
--secondary-contrast: #FAFBFC;
--secondary-hover: #E8EBEF;
Expand Down Expand Up @@ -1476,6 +1476,11 @@ dmb-login dmb-button {
width: 90%;
}

dmb-login svg {
height: auto;
width: 100%;
}

dmb-menu-button {
top: 1em;
left: 1.5em;
Expand Down
180 changes: 180 additions & 0 deletions app/webroot/images/basilisk.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-114x114.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-120x120.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-144x144.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-152x152.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-16x16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-32x32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-57x57.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-60x60.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-72x72.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-76x76.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/webroot/images/logo-96x96.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
180 changes: 180 additions & 0 deletions app/webroot/images/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
60 changes: 60 additions & 0 deletions app/webroot/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"name": "Basilisk Project Management",
"short_name": "Basilisk",
"display": "standalone",
"background_color": "white",
"orientation": "landscape",
"theme_color": "#e30a33",
"start_url": "/index/login",
"icons": [
{
"src": "/images/logo-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75",
"purpose": "any maskable"
},
{
"src": "/images/logo-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0",
"purpose": "any maskable"
},
{
"src": "/images/logo-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5",
"purpose": "any maskable"
},
{
"src": "/images/logo-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0",
"purpose": "any maskable"
},
{
"src": "/images/logo-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0",
"purpose": "any maskable"
},
{
"src": "/images/logo-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0",
"purpose": "any maskable"
},
{
"src": "/images/logo-512x512.png",
"sizes": "512x512",
"type": "image/png",
"density": "4.0",
"purpose": "any maskable"
}
]
}
Loading

0 comments on commit bb3bcf7

Please sign in to comment.