From 29fc03937a18da971fa900c640fad1affa9c11e2 Mon Sep 17 00:00:00 2001 From: Aldarien Date: Thu, 30 Apr 2020 08:26:51 -0400 Subject: [PATCH] Estructura central --- .gitignore | 3 +- bootstrap/app.php | 57 +++++++++++++++++++++++++++++++++ bootstrap/base/config.php | 8 +++++ bootstrap/composer.php | 6 ++++ bootstrap/web/config.php | 24 ++++++++++++++ bootstrap/web/middleware.php | 2 ++ bootstrap/web/setup.php | 59 +++++++++++++++++++++++++++++++++++ composer.json | 31 ++++++++++++++++++ public/.htaccess | 4 +++ public/assets/styles/main.css | 47 ++++++++++++++++++++++++++++ public/index.php | 10 ++++++ 11 files changed, 250 insertions(+), 1 deletion(-) create mode 100644 bootstrap/app.php create mode 100644 bootstrap/base/config.php create mode 100644 bootstrap/composer.php create mode 100644 bootstrap/web/config.php create mode 100644 bootstrap/web/middleware.php create mode 100644 bootstrap/web/setup.php create mode 100644 composer.json create mode 100644 public/.htaccess create mode 100644 public/assets/styles/main.css create mode 100644 public/index.php diff --git a/.gitignore b/.gitignore index 7a1868c..9b2d73f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,10 +4,11 @@ composer.lock # Environment .env -/config/env/ +/bootstrap/env/ # Blade /cache/ # Uploads /public/uploads/ +/resources/data/ diff --git a/bootstrap/app.php b/bootstrap/app.php new file mode 100644 index 0000000..cfbac81 --- /dev/null +++ b/bootstrap/app.php @@ -0,0 +1,57 @@ +addDefinitions($filename); + } +} + +$container = $builder->build(); +$container->set('env', $__environment); +$app = Bridge::create($container); +$app->setBasePath($container->get('base_url')); + +foreach ($folders as $folder) { + $filename = implode(DIRECTORY_SEPARATOR, [ + __DIR__, + $folder, + 'middleware.php' + ]); + if (!file_exists($filename)) { + continue; + } + include_once $filename; +} + +include_once implode(DIRECTORY_SEPARATOR, [ + $container->get('folders.routes'), + 'router.php' +]); diff --git a/bootstrap/base/config.php b/bootstrap/base/config.php new file mode 100644 index 0000000..680b4a1 --- /dev/null +++ b/bootstrap/base/config.php @@ -0,0 +1,8 @@ + 'es', + 'folders.base' => dirname(__DIR__, 2), + 'folders.resources' => DI\string(implode(DIRECTORY_SEPARATOR, ['{folders.base}', 'resources'])), + 'folders.routes' => DI\string(implode(DIRECTORY_SEPARATOR, ['{folders.resources}', 'routes'])), + 'folders.data' => DI\string(implode(DIRECTORY_SEPARATOR, ['{folders.resources}', 'data'])) +]; diff --git a/bootstrap/composer.php b/bootstrap/composer.php new file mode 100644 index 0000000..c8fb135 --- /dev/null +++ b/bootstrap/composer.php @@ -0,0 +1,6 @@ + DI\string(implode(DIRECTORY_SEPARATOR, [ + '{folders.resources}', + 'views' + ])), + 'folders.cache' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{folders.base}', + 'cache' + ])), + 'urls.assets' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{urls.base}', + 'assets' + ])), + 'urls.styles' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{urls.assets}', + 'styles' + ])), + 'file.visits' => DI\string(implode(DIRECTORY_SEPARATOR, [ + '{folders.data}', + 'visitas.json' + ])), + 'visits.time' => 12 * 60 * 60 +]; diff --git a/bootstrap/web/middleware.php b/bootstrap/web/middleware.php new file mode 100644 index 0000000..92731c3 --- /dev/null +++ b/bootstrap/web/middleware.php @@ -0,0 +1,2 @@ +add(new ProVM\KI\Common\Middleware\Visits($app->getContainer()->get('file.visits'), $app->getContainer()->get('visits.time'))); diff --git a/bootstrap/web/setup.php b/bootstrap/web/setup.php new file mode 100644 index 0000000..8ea8711 --- /dev/null +++ b/bootstrap/web/setup.php @@ -0,0 +1,59 @@ + function(Container $c) { + return (object) [ + 'base' => $c->get('base_url'), + 'facebook' => '', + 'linkedin' => '', + 'twitter' => '', + 'youtube' => '' + ]; + }, + 'assets' => function(Container $c) { + return (object) [ + 'styles' => [ + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/semantic.min.css', + implode(DIRECTORY_SEPARATOR, [ + $c->get('urls.styles'), + 'main.css' + ]) + ], + 'fonts' => [ + 'text/css' => [ + 'https://fonts.googleapis.com/css2?family=Roboto:wght@300;900&display=swap', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/brand-icons.woff', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/brand-icons.woff2', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/icons.woff', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/icons.woff2', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/outline-icons.woff', + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/themes/default/assets/fonts/outline-icons.woff2' + ] + ], + 'scripts' => [ + 'https://cdnjs.cloudflare.com/ajax/libs/fomantic-ui/2.8.4/semantic.min.js' + ] + ]; + }, + 'visitas' => function(Container $c) { + $filename = implode(DIRECTORY_SEPARATOR, [ + $c->get('folders.data'), + 'visitas.json' + ]); + $file = json_decode(trim(file_get_contents($filename))); + return $file->visits; + }, + Slim\Views\Blade::class => function(Container $c) { + return new Slim\Views\Blade( + $c->get('folders.templates'), + $c->get('folders.cache'), + null, + [ + 'page_language' => $c->get('language'), + 'urls' => $c->get('urls'), + 'assets' => $c->get('assets') + ] + ); + } +]; diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..721e483 --- /dev/null +++ b/composer.json @@ -0,0 +1,31 @@ +{ + "name": "provm/capitalinvestments", + "description": "Web para Capital Investments", + "type": "project", + "require": { + "slim/slim": "^4.5", + "php-di/slim-bridge": "^3.0", + "rubellum/slim-blade-view": "^0.1.1", + "nyholm/psr7": "^1.2", + "nyholm/psr7-server": "^0.4.1", + "nesbot/carbon": "^2.32" + }, + "require-dev": { + "phpunit/phpunit": "^8.5", + "kint-php/kint": "^3.3", + "zeuxisoo/slim-whoops": "^0.7.2" + }, + "license": "UNLICENSED", + "authors": [ + { + "name": "Aldarien", + "email": "aldarien85@gmail.com" + } + ], + "autoload": { + "psr-4": { + "ProVM\\KI\\Common\\": "common", + "ProVM\\KI\\": "src" + } + } +} diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..66ef8f6 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,4 @@ +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteCond %{REQUEST_FILENAME} !-d +RewriteRule ^ index.php [QSA,L] diff --git a/public/assets/styles/main.css b/public/assets/styles/main.css new file mode 100644 index 0000000..3b88cb9 --- /dev/null +++ b/public/assets/styles/main.css @@ -0,0 +1,47 @@ +/*body { + font-family: Roboto, sans-serif !important; +}*/ + +.brand { + color: #000070 !important; +} +.inverted.brand { + background-color: #000070 !important; + color: white !important; +} +.button.brand { + box-shadow: none !important; +} + +header #franja { + background-color: #707070; + color: white !important; +} +header #franja .menu { + color: inherit !important; +} +header #franja .menu .spacer { + width: 3rem; +} +header #franja .menu .input { + height: 1.3rem !important; +} +header #franja a { + color: inherit; +} +header .menu { + margin-top: 0 !important; + margin-bottom: 0 !important; +} +header .menu .logo { + font-size: 2rem; + font-weight: 900; +} + +.menu { + font-family: inherit !important; +} +.item { + font-family: inherit !important; + color: inherit !important; +} diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000..2acb831 --- /dev/null +++ b/public/index.php @@ -0,0 +1,10 @@ +run();