From 06d85d868aa5a36bb83575d3cd9df95d3011320d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rapha=C3=ABl=20Gertz?= Date: Tue, 1 Aug 2017 19:32:55 +0200 Subject: [PATCH 1/1] Add blog bundle files --- .gitignore | 2 + Controller/DefaultController.php | 46 +++++++++++++ Controller/PageController.php | 28 ++++++++ RapsysBlogBundle.php | 9 +++ Resources/config/parameters.yml | 12 ++++ Resources/config/routing.yml | 45 +++++++++++++ Resources/config/services.yml | 4 ++ Resources/public/css/base.css | 61 +++++++++++++++++ Resources/public/css/reset.css | 46 +++++++++++++ Resources/public/css/screen.css | 108 ++++++++++++++++++++++++++++++ Resources/views/about.html.twig | 3 + Resources/views/base.html.twig | 20 ++++++ Resources/views/body.html.twig | 42 ++++++++++++ Resources/views/contact.html.twig | 3 + Resources/views/index.html.twig | 3 + 15 files changed, 432 insertions(+) create mode 100644 .gitignore create mode 100644 Controller/DefaultController.php create mode 100644 Controller/PageController.php create mode 100644 RapsysBlogBundle.php create mode 100644 Resources/config/parameters.yml create mode 100644 Resources/config/routing.yml create mode 100644 Resources/config/services.yml create mode 100644 Resources/public/css/base.css create mode 100644 Resources/public/css/reset.css create mode 100644 Resources/public/css/screen.css create mode 100644 Resources/views/about.html.twig create mode 100644 Resources/views/base.html.twig create mode 100644 Resources/views/body.html.twig create mode 100644 Resources/views/contact.html.twig create mode 100644 Resources/views/index.html.twig diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1c17649 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.*.un~ +*~ diff --git a/Controller/DefaultController.php b/Controller/DefaultController.php new file mode 100644 index 0000000..b9316f2 --- /dev/null +++ b/Controller/DefaultController.php @@ -0,0 +1,46 @@ +getParameter('blog.locales')); + + //Language list + if (!empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { + //Init array + $httpAcceptLanguage = []; + + //Extract languages + foreach(explode(',',str_replace('-','_',$_SERVER['HTTP_ACCEPT_LANGUAGE'])) as $candidate) { + //Extract candidate and optional weight + @list($candidate, $weight) = explode(';', $candidate); + if (!empty($candidate)) { + $httpAcceptLanguage[!empty($weight)?$weight:1][] = $candidate; + } + } + + //Find first match + if (!empty($httpAcceptLanguage)) { + foreach($httpAcceptLanguage as $weight => $candidates) { + if (($candidate = array_intersect($candidates, $supportedLanguage)) && ($candidate = reset($candidate))) { + $locale = $candidate; + break; + } + } + } + } + + //Redirect to localised homepage + return $this->redirectToRoute('homepage', array('_locale' => $locale), 302); + } +} diff --git a/Controller/PageController.php b/Controller/PageController.php new file mode 100644 index 0000000..32eddfd --- /dev/null +++ b/Controller/PageController.php @@ -0,0 +1,28 @@ +render('RapsysBlogBundle::index.html.twig'); + } + + /** + * Legal informations + */ + public function aboutAction() { + return $this->render('RapsysBlogBundle::about.html.twig'); + } + + /** + * Contact form + */ + public function contactAction() { + return $this->render('RapsysBlogBundle::contact.html.twig'); + } +} diff --git a/RapsysBlogBundle.php b/RapsysBlogBundle.php new file mode 100644 index 0000000..529e6ea --- /dev/null +++ b/RapsysBlogBundle.php @@ -0,0 +1,9 @@ +Dev log{% endblock %} +{% block content %}TODO: page de about{% endblock %} diff --git a/Resources/views/base.html.twig b/Resources/views/base.html.twig new file mode 100644 index 0000000..0a40530 --- /dev/null +++ b/Resources/views/base.html.twig @@ -0,0 +1,20 @@ + + + + + {% block title %}Welcome!{% endblock %} - Devlog + + {% block stylesheets %} + {% stylesheets '//fonts.googleapis.com/css?family=Irish+Grover' '//fonts.googleapis.com/css?family=La+Belle+Aurore' '@RapsysBlogBundle/Resources/public/css/{reset,screen}.css' filter='toto' %} + + {% endstylesheets %} + {% endblock %} + {% block javascripts %} + {% javascripts '@RapsysBlogBundle/Resources/js/*.js' output='js/compiled/main.js' %} + + {% endjavascripts %} + {% endblock %} + + + {% block body %}{% endblock %} + diff --git a/Resources/views/body.html.twig b/Resources/views/body.html.twig new file mode 100644 index 0000000..0fd4304 --- /dev/null +++ b/Resources/views/body.html.twig @@ -0,0 +1,42 @@ +{% extends 'RapsysBlogBundle::base.html.twig' %} +{% block body %} + +
+ {% block header %} + + {% endblock %} + + {% block sidebar %}{% endblock %} + + {% block content %}
{% endblock %} + + {% block footer %} +
+ Copyright 2016 - Raphaël Gertz all rights reserved. +
+ {% endblock %} +
+ +{% endblock %} diff --git a/Resources/views/contact.html.twig b/Resources/views/contact.html.twig new file mode 100644 index 0000000..f1b3677 --- /dev/null +++ b/Resources/views/contact.html.twig @@ -0,0 +1,3 @@ +{% extends 'RapsysBlogBundle::body.html.twig' %} +{% block title %}

Dev log

{% endblock %} +{% block content %}TODO: page de contact{% endblock %} diff --git a/Resources/views/index.html.twig b/Resources/views/index.html.twig new file mode 100644 index 0000000..a32a0ca --- /dev/null +++ b/Resources/views/index.html.twig @@ -0,0 +1,3 @@ +{% extends 'RapsysBlogBundle::body.html.twig' %} +{% block title %}Welcome!{% endblock %} +{% block content %}Hello world !{% endblock %} -- 2.41.1