From 00f9a10cbf658194cf27432b2a866b03292219e3 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Sun, 22 Mar 2020 17:25:11 -0300 Subject: [PATCH] v0.7.0 --- .ENV | 1 + bootstrap/common/setup.php | 8 ++ bootstrap/web/config.php | 16 +++- bootstrap/web/middleware.php | 9 ++ bootstrap/web/setup.php | 9 +- common/Controller/Web/Admin/Admin.php | 12 +++ common/Controller/Web/Admin/Login.php | 12 +++ common/Controller/Web/Admin/Notificacion.php | 45 ++++++++++ common/Controller/Web/Home.php | 7 -- common/Controller/Web/Notaria.php | 7 +- composer.json | 5 +- provm/common/Service/Filemanager.php | 80 +++++++++++++++++ public/assets/scripts/main.js | 5 +- public/assets/styles/notaria.css | 10 +++ resources/data/documentos.yml | 7 ++ resources/data/equipos.yml | 40 +++++++++ resources/routes/web/admin.php | 20 +++++ resources/routes/web/admin/notificacion.php | 7 ++ resources/views/admin/admin.blade.php | 5 ++ resources/views/admin/layout/base.blade.php | 12 +++ resources/views/admin/layout/menu.blade.php | 8 ++ resources/views/admin/login.blade.php | 11 +++ .../views/admin/notificacion/show.blade.php | 36 ++++++++ resources/views/home/banner.blade.php | 6 +- resources/views/home/indice.blade.php | 30 ++++--- resources/views/home/links.blade.php | 28 +++--- resources/views/home/suplente.blade.php | 10 ++- .../views/home/suplente/horario.blade.php | 9 +- resources/views/layout/footer.blade.php | 22 ++--- .../views/layout/footer/horario.blade.php | 9 +- resources/views/layout/footer/menu.blade.php | 2 +- resources/views/layout/header.blade.php | 4 +- resources/views/layout/styles.blade.php | 5 ++ resources/views/notaria.blade.php | 10 +++ resources/views/notaria/equipos.blade.php | 33 +++++++ .../views/notaria/transparencia.blade.php | 87 +++++++++++++++++++ 36 files changed, 559 insertions(+), 68 deletions(-) create mode 100644 .ENV create mode 100644 bootstrap/common/setup.php create mode 100644 common/Controller/Web/Admin/Admin.php create mode 100644 common/Controller/Web/Admin/Login.php create mode 100644 common/Controller/Web/Admin/Notificacion.php create mode 100644 provm/common/Service/Filemanager.php create mode 100644 public/assets/styles/notaria.css create mode 100644 resources/data/documentos.yml create mode 100644 resources/data/equipos.yml create mode 100644 resources/routes/web/admin.php create mode 100644 resources/routes/web/admin/notificacion.php create mode 100644 resources/views/admin/admin.blade.php create mode 100644 resources/views/admin/layout/base.blade.php create mode 100644 resources/views/admin/layout/menu.blade.php create mode 100644 resources/views/admin/login.blade.php create mode 100644 resources/views/admin/notificacion/show.blade.php create mode 100644 resources/views/notaria/equipos.blade.php create mode 100644 resources/views/notaria/transparencia.blade.php diff --git a/.ENV b/.ENV new file mode 100644 index 0000000..8aa3037 --- /dev/null +++ b/.ENV @@ -0,0 +1 @@ +ADMIN_PASSWORD admin diff --git a/bootstrap/common/setup.php b/bootstrap/common/setup.php new file mode 100644 index 0000000..0842ddf --- /dev/null +++ b/bootstrap/common/setup.php @@ -0,0 +1,8 @@ + function(Container $c) { + return new Symfony\Component\Filesystem\Filesystem(); + } +]; diff --git a/bootstrap/web/config.php b/bootstrap/web/config.php index f31cbc8..2f81773 100644 --- a/bootstrap/web/config.php +++ b/bootstrap/web/config.php @@ -8,6 +8,14 @@ return [ '{folders.resources}', 'cache' ])), + 'folders.upload' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{folders.base}', + 'uploads' + ])), + 'folders.data' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{folders.resources}', + 'data' + ])), 'blade_template_path' => DI\get('folders.templates'), 'blade_cache_path' => DI\get('folders.cache'), 'urls.assets' => DI\string(implode('/', [ @@ -32,8 +40,8 @@ return [ ])), 'urls.metro.logo' => 'https://img.freepik.com/free-icon/santiago-metro-logo_318-66588.jpg?size=338&ext=jpg', 'urls.notaria.turno' => 'http://www.notariasdeturno.cl', - 'urls.play.store' => 'https://play.google.com/store/apps/details?id=cl.totalpack.suturno.movil', - 'urls.play.store.logo' => 'https://www.gstatic.com/android/market_images/web/favicon_v2.ico', + 'urls.play.store' => 'https://zeroq.cl/#/local/notaria-patricio-raby', + 'urls.play.store.logo' => 'https://zeroq.cl/img/logo-small.png', 'assets' => (object) [ (object) [ 'script' => 'https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js' @@ -56,7 +64,9 @@ return [ (object) [ 'style' => implode('/', ['assets', 'styles', 'metro.css']), 'fonts' => [ - 'https://fonts.googleapis.com/css?family=Roboto&subset=latin&display=swap', + 'https://fonts.googleapis.com/css?family=Roboto&subset=latin&display=swap' + ], + 'xfont' => [ implode('/', ['assets', 'fonts', 'metro.ttf']) ] ] diff --git a/bootstrap/web/middleware.php b/bootstrap/web/middleware.php index 637b9fa..aab4835 100644 --- a/bootstrap/web/middleware.php +++ b/bootstrap/web/middleware.php @@ -1,2 +1,11 @@ add(new ProVM\NotariaRaby\Common\Middleware\Blade($app->getContainer())); +$app->add(new Tuupola\Middleware\HttpBasicAuthentication([ + 'path' => $app->getContainer()->get('urls.base') . '/admin', + 'ignore' => [ + '/admin/login' + ], + 'users' => [ + 'admin' => 'admin' + ] +])); diff --git a/bootstrap/web/setup.php b/bootstrap/web/setup.php index ce29ea0..47e0359 100644 --- a/bootstrap/web/setup.php +++ b/bootstrap/web/setup.php @@ -1,8 +1,8 @@ function(ContainerInterface $container) { + Slim\Views\Blade::class => function(Container $container) { return new Slim\Views\Blade( $container->get('blade_template_path'), $container->get('blade_cache_path'), @@ -23,5 +23,10 @@ return [ 'assets' => $container->get('assets') ] ); + }, + ProVM\Common\Service\Filemanager::class => function(Container $c) { + $manager = new ProVM\Common\Service\Filemanager($c->get(Symfony\Component\Filesystem\Filesystem::class), $c->get('folders.upload')); + $manager->addFolder('data', $c->get('folders.data')); + return $manager; } ]; diff --git a/common/Controller/Web/Admin/Admin.php b/common/Controller/Web/Admin/Admin.php new file mode 100644 index 0000000..d10cbc6 --- /dev/null +++ b/common/Controller/Web/Admin/Admin.php @@ -0,0 +1,12 @@ +render($response, 'admin.admin'); + } +} diff --git a/common/Controller/Web/Admin/Login.php b/common/Controller/Web/Admin/Login.php new file mode 100644 index 0000000..2f7217a --- /dev/null +++ b/common/Controller/Web/Admin/Login.php @@ -0,0 +1,12 @@ +render($response, 'admin.login'); + } +} diff --git a/common/Controller/Web/Admin/Notificacion.php b/common/Controller/Web/Admin/Notificacion.php new file mode 100644 index 0000000..1e2bd6c --- /dev/null +++ b/common/Controller/Web/Admin/Notificacion.php @@ -0,0 +1,45 @@ +load($filename); + if (!$notificacion) { + $notificacion = (object) [ + 'title' => '', + 'text' => '', + 'active' => false + ]; + } + return $view->render($response, 'admin.notificacion.show', compact('notificacion')); + } + public function do_edit(Request $request, Response $response, View $view, Filemanager $filemanager): Response { + $post = $request->getParsedBody(); + $filename = 'notificacion.yml'; + $notificacion = $filemanager->load($filename); + if (!$notificacion) { + $notificacion = (object) [ + 'title' => '', + 'text' => '', + 'active' => false + ]; + } + $notificacion->title = $post['title']; + $notificacion->text = $post['text']; + $notificacion->active = (isset($post['active']) and $post['active'] == 'on') ? true : false; + $filemanager->save($filename, $notificacion); + return $response + ->withHeader('Location', implode('/', [ + $container->get('urls.base'), + 'admin', + 'notificacion' + ])) + ->withStatus(302); + } +} diff --git a/common/Controller/Web/Home.php b/common/Controller/Web/Home.php index ac6fc94..da140ee 100644 --- a/common/Controller/Web/Home.php +++ b/common/Controller/Web/Home.php @@ -13,13 +13,6 @@ class Home { 'contenido' => "Gertrudis Echenique 30, of. 32, El Golf\n Metro Alcantara" ]; $suplente = (object) [ - 'horario' => (object) [ - 'titulo' => "Horario lunes a viernes\n9:30 - 13:30 | 15:30 - 18:00", - 'contenido' => "La atención dentro del horario, puede verse - afectada circunstancialmente y sin previo - aviso, por encontrarse el notario cumpliendo - funciones fuera de la Notaría." - ], 'datos' => (object) [ 'fechas' => "DEL 1 DE ABRIL AL 15 DE MAYO", 'nombre' => "MARIA VIRGINIA\nWIELANDT COVARRUBIAS" diff --git a/common/Controller/Web/Notaria.php b/common/Controller/Web/Notaria.php index 10be8df..d519452 100644 --- a/common/Controller/Web/Notaria.php +++ b/common/Controller/Web/Notaria.php @@ -4,9 +4,12 @@ namespace ProVM\NotariaRaby\Common\Controller\Web; use Psr\Http\Message\ServerRequestInterface as Request; use Psr\Http\Message\ResponseInterface as Response; use Slim\Views\Blade as View; +use ProVM\Common\Service\Filemanager; class Notaria { - public function __invoke(Request $request, Response $response, View $view): Response { - return $view->render($response, 'notaria'); + public function __invoke(Request $request, Response $response, View $view, Filemanager $filemanager): Response { + $filename = 'equipos.yml'; + $equipos = $filemanager->folder('data')->load($filename); + return $view->render($response, 'notaria', compact('equipos')); } } diff --git a/composer.json b/composer.json index b83f54e..333afe9 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,10 @@ "php-di/slim-bridge": "^3.0", "zeuxisoo/slim-whoops": "^0.7.2", "whoops/soap": "^1.0", - "symfony/var-dumper": "^5.0" + "symfony/var-dumper": "^5.0", + "symfony/filesystem": "^5.0", + "tuupola/slim-basic-auth": "^3.2", + "mustangostang/spyc": "^0.6.3" }, "require-dev": { "phpunit/phpunit": "^8.5", diff --git a/provm/common/Service/Filemanager.php b/provm/common/Service/Filemanager.php new file mode 100644 index 0000000..27c9234 --- /dev/null +++ b/provm/common/Service/Filemanager.php @@ -0,0 +1,80 @@ +filesystem = $filesystem; + $this->base_folder = $base_folder; + } + protected function fullPath(string $filename): string { + if ($this->filesystem->exists($filename)) { + return $filename; + } + return implode(DIRECTORY_SEPARATOR, [ + $this->base_folder, + $filename + ]); + } + protected $folders; + public function addFolder(string $name, string $folder) { + if ($this->folders === null) { + $this->folders = []; + } + $this->folders[$name] = $folder; + } + public function folder(string $name) { + return new Filemanager($this->filesystem, $this->folders[$name]); + } + public function load(string $filename) { + $filename = $this->fullPath($filename); + if (!$this->filesystem->exists($filename)) { + return false; + } + $file = new \SplFileInfo($filename); + $method = 'load' . ucfirst($file->getExtension()); + return $this->parseData($this->{$method}($filename)); + } + protected function loadYml(string $filename) { + return Yaml::YAMLLoad($filename); + } + protected function loadYaml(string $filename) { + return $this->loadYml($filename); + } + protected function loadJson(string $filename) { + return json_decode(trim(file_get_contents($filename))); + } + protected function loadPhp(string $filename) { + return include $filename; + } + protected function parseData($data) { + $temp = $data; + if (is_array($temp)) { + $is_object = false; + foreach ($data as $i => $sub) { + if (!is_numeric($i)) { + $is_object = true; + } + $temp[$i] = $this->parseData($sub); + } + if ($is_object) { + $temp = (object) $temp; + } + } + return $temp; + } + public function save(string $filename, $data) { + if (is_object($data)) { + $data = (array) $data; + } + if (is_array($data)) { + $data = implode(PHP_EOL, $data); + } + $filename = $this->fullPath($filename); + file_put_contents($filename, $data); + } +} diff --git a/public/assets/scripts/main.js b/public/assets/scripts/main.js index 7ab9d63..c492ab7 100644 --- a/public/assets/scripts/main.js +++ b/public/assets/scripts/main.js @@ -1,6 +1,3 @@ $(document).ready(function() { - var base_width = 1110 - var width = $(window).width() - var padding = (width - base_width) / 2 - $('#page_container').find('.padded').css('padding-left', padding + 'px').css('padding-right', padding + 'px') + }) diff --git a/public/assets/styles/notaria.css b/public/assets/styles/notaria.css new file mode 100644 index 0000000..7afd2ba --- /dev/null +++ b/public/assets/styles/notaria.css @@ -0,0 +1,10 @@ +#equipos { + padding-top: 50px; + padding-bottom: 50px; +} +#transparencia { + background-color: rgba(0, 0, 0, .05); + padding-top: 50px; + padding-bottom: 50px; + font-family: Roboto; +} diff --git a/resources/data/documentos.yml b/resources/data/documentos.yml new file mode 100644 index 0000000..bc98406 --- /dev/null +++ b/resources/data/documentos.yml @@ -0,0 +1,7 @@ +documentos: + - titulo: Autorizaciones + - titulo: Declaraciones + - titulo: Certificados + - titulo: Poderes + - titulo: Contratos + - titulo: Otros diff --git a/resources/data/equipos.yml b/resources/data/equipos.yml new file mode 100644 index 0000000..9f2a69b --- /dev/null +++ b/resources/data/equipos.yml @@ -0,0 +1,40 @@ +- titulo: ABOGADOS + miembros: + - nombre: María Virginia Wielandt Covarrubias + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl +- titulo: ESCRITURAS PÚBLICAS + miembros: + - nombre: Paola Díaz de Lartundo + cargo: Jefe de Registro + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl + - nombre: Carmen Gloria Alvarez Carrasco + cargo: Jefe de Registro + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl + - nombre: Roxana Muñoz Donoso + cargo: Jefe de Registro + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl +- titulo: INSTRUMENTOS PRIVADOS + miembros: + - nombre: Massiel Guzmán Villalobos + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl +- titulo: FACTORING + miembros: + - nombre: Karen Ramirez Gortaris + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl +- titulo: PROTESTOS + miembros: + - nombre: Alejandro González Villalobos + cargo: Asistente + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl +- titulo: ADMINISTRACIÓN CUENTAS + miembros: + - nombre: Juan Corrales Carrasco + telefono: +56 2 2222 2222 + email: vwielandt@notariaraby.cl diff --git a/resources/routes/web/admin.php b/resources/routes/web/admin.php new file mode 100644 index 0000000..b482433 --- /dev/null +++ b/resources/routes/web/admin.php @@ -0,0 +1,20 @@ +group('/admin', function($app) { + $folder = implode(DIRECTORY_SEPARATOR, [ + __DIR__, + 'admin' + ]); + if (file_exists($folder)) { + $files = new DirectoryIterator($folder); + foreach ($files as $file) { + if ($file->isDir()) { + continue; + } + include_once $file->getRealPath(); + } + } + + $app->get('[/]', Admin::class); +}); diff --git a/resources/routes/web/admin/notificacion.php b/resources/routes/web/admin/notificacion.php new file mode 100644 index 0000000..e4a96e8 --- /dev/null +++ b/resources/routes/web/admin/notificacion.php @@ -0,0 +1,7 @@ +group('/notificacion', function($app) { + $app->get('[/]', Notificacion::class); + $app->post('[/]', [Notificacion::class, 'do_edit']); +}); diff --git a/resources/views/admin/admin.blade.php b/resources/views/admin/admin.blade.php new file mode 100644 index 0000000..74d0f0b --- /dev/null +++ b/resources/views/admin/admin.blade.php @@ -0,0 +1,5 @@ +@extends('admin.layout.base') + +@section('content') + +@endsection diff --git a/resources/views/admin/layout/base.blade.php b/resources/views/admin/layout/base.blade.php new file mode 100644 index 0000000..ce54817 --- /dev/null +++ b/resources/views/admin/layout/base.blade.php @@ -0,0 +1,12 @@ +@extends('layout.base') + +@section('page_title') + - Admin +@endsection + +@section('page_content') +
+ @include('admin.layout.menu') + @yield('content') +
+@endsection diff --git a/resources/views/admin/layout/menu.blade.php b/resources/views/admin/layout/menu.blade.php new file mode 100644 index 0000000..d03decf --- /dev/null +++ b/resources/views/admin/layout/menu.blade.php @@ -0,0 +1,8 @@ +
+ +
+
diff --git a/resources/views/admin/login.blade.php b/resources/views/admin/login.blade.php new file mode 100644 index 0000000..8db5721 --- /dev/null +++ b/resources/views/admin/login.blade.php @@ -0,0 +1,11 @@ +@extends('admin.base') + +@section('content') +
+
+ + +
+ +
+@endsection diff --git a/resources/views/admin/notificacion/show.blade.php b/resources/views/admin/notificacion/show.blade.php new file mode 100644 index 0000000..aa5c969 --- /dev/null +++ b/resources/views/admin/notificacion/show.blade.php @@ -0,0 +1,36 @@ +@extends('admin.layout.base') + +@section('content') +
+
+ + +
+
+ + +
+
+
+ + active) + checked="checked" + @endif + /> +
+
+ +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/home/banner.blade.php b/resources/views/home/banner.blade.php index d99a245..e59917d 100644 --- a/resources/views/home/banner.blade.php +++ b/resources/views/home/banner.blade.php @@ -1,5 +1,7 @@ -