From: Raphaël Gertz <git@rapsys.eu> Date: Tue, 1 Aug 2017 17:32:55 +0000 (+0200) Subject: Add blog bundle files X-Git-Tag: 0.1~69 X-Git-Url: https://git.rapsys.eu/blogbundle/commitdiff_plain/06d85d868aa5a36bb83575d3cd9df95d3011320d Add blog bundle files --- 06d85d868aa5a36bb83575d3cd9df95d3011320d 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 @@ +<?php + +namespace Rapsys\BlogBundle\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; + +class DefaultController extends Controller { + /** + * Redirect on first supported language version + */ + public function rootAction() { + //Set default locale + $locale = 'en'; + + //Supported application languages + $supportedLanguage = explode('|', $this->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 @@ +<?php + +namespace Rapsys\BlogBundle\Controller; + +use Symfony\Bundle\FrameworkBundle\Controller\Controller; + +class PageController extends Controller { + /** + * Localized homepage + */ + public function indexAction() { + return $this->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 @@ +<?php + +namespace Rapsys\BlogBundle; + +use Symfony\Component\HttpKernel\Bundle\Bundle; + +class RapsysBlogBundle extends Bundle +{ +} diff --git a/Resources/config/parameters.yml b/Resources/config/parameters.yml new file mode 100644 index 0000000..c10fdb7 --- /dev/null +++ b/Resources/config/parameters.yml @@ -0,0 +1,12 @@ +parameters: + blog.locales: en|fr + database_host: 127.0.0.1 + database_port: null + database_name: blog + database_user: blog + database_password: MacfingOcGu9Pon9 + mailer_transport: smtp + mailer_host: 127.0.0.1 + mailer_user: null + mailer_password: null + secret: 60a2f0298adc4afb51cfb11c3828c08b40547bf9 diff --git a/Resources/config/routing.yml b/Resources/config/routing.yml new file mode 100644 index 0000000..86a99c9 --- /dev/null +++ b/Resources/config/routing.yml @@ -0,0 +1,45 @@ +root: + path: / + defaults: { _controller: RapsysBlogBundle:Default:root } + +homepage: + path: /{_locale} + defaults: { _controller: RapsysBlogBundle:Page:index } + requirements: + _locale: '%blog.locales%' + +about: + path: /{_locale}/about + defaults: { _controller: RapsysBlogBundle:Page:about } + requirements: + _locale: '%blog.locales%' + +contact: + path: /{_locale}/contact + defaults: { _controller: RapsysBlogBundle:Page:contact } + requirements: + _locale: '%blog.locales%' + +articles: + path: /{_locale}/articles + defaults: { _controller: RapsysBlogBundle:Default:articles } + requirements: + _locale: '%blog.locales%' + +articles_article: + path: /{_locale}/articles/{_article} + defaults: { _controller: RapsysBlogBundle:Default:article } + requirements: + _locale: '%blog.locales%' + +tags: + path: /{_locale}/tags + defaults: { _controller: RapsysBlogBundle:Default:tags } + requirements: + _locale: '%blog.locales%' + +tags_tag: + path: /{_locale}/tags/{_tag} + defaults: { _controller: RapsysBlogBundle:Default:tag } + requirements: + _locale: '%blog.locales%' diff --git a/Resources/config/services.yml b/Resources/config/services.yml new file mode 100644 index 0000000..992dbfe --- /dev/null +++ b/Resources/config/services.yml @@ -0,0 +1,4 @@ +services: +# blog.example: +# class: BlogBundle\Example +# arguments: ["@service_id", "plain_value", "%parameter%"] diff --git a/Resources/public/css/base.css b/Resources/public/css/base.css new file mode 100644 index 0000000..3a9a0e6 --- /dev/null +++ b/Resources/public/css/base.css @@ -0,0 +1,61 @@ + + +/* Smartphones (portrait and landscape) ----------- */ +@media only screen +and (min-device-width : 320px) +and (max-device-width : 480px) { + /* Styles */ +} + +/* Smartphones (landscape) ----------- */ +@media only screen +and (min-width : 321px) { + /* Styles */ +} + +/* Smartphones (portrait) ----------- */ +@media only screen +and (max-width : 320px) { + /* Styles */ +} + +/* iPads (portrait and landscape) ----------- */ +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) { + /* Styles */ +} + +/* iPads (landscape) ----------- */ +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) +and (orientation : landscape) { + /* Styles */ +} + +/* iPads (portrait) ----------- */ +@media only screen +and (min-device-width : 768px) +and (max-device-width : 1024px) +and (orientation : portrait) { + /* Styles */ +} + +/* Desktops and laptops ----------- */ +@media only screen and (min-width : 1224px) { + /* Styles */ +} + +/* Large screens ----------- */ +@media only screen +and (min-width : 1824px) { + /* Styles */ +} + +/* iPhone 4 ----------- */ +@media +only screen and (-webkit-min-device-pixel-ratio : 1.5), +only screen and (min-device-pixel-ratio : 1.5) { + /* Styles */ +} diff --git a/Resources/public/css/reset.css b/Resources/public/css/reset.css new file mode 100644 index 0000000..839e973 --- /dev/null +++ b/Resources/public/css/reset.css @@ -0,0 +1,46 @@ +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + +article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section { + display: block; +} + +body { + line-height: 1; +} + +ol, ul { + list-style: none; +} + +blockquote, q { + quotes: none; +} + +blockquote:before, blockquote:after, q:before, q:after { + content: ''; + content: none; +} + +table { + border-collapse: collapse; + border-spacing: 0; +} + diff --git a/Resources/public/css/screen.css b/Resources/public/css/screen.css new file mode 100644 index 0000000..74e1a23 --- /dev/null +++ b/Resources/public/css/screen.css @@ -0,0 +1,108 @@ +/* Reset link */ +a { + text-decoration: none; +} + +a:hover { + text-decoration: underline; +} + +/* Default styling */ +h1 { + font-size: 2rem; + margin: 1.34rem 0; +} + +h2 { + font-size: 1.5rem; + margin: 1.245rem 0; +} + +h3 { + font-size: 1.17rem; + margin: 1.17rem 0; +} + +h4 { + font-size: 1rem; + margin: 1.33rem 0; +} + +h5 { + font-size: .83rem; + margin: 1.386rem 0; +} + +h6 { + font-size: .67rem; + margin: 1.561rem 0; +} + +#wrapper { + display: flex; + flex-flow: column wrap; +} + +#header { + width: 100%; + border-top: .1rem solid #0074d9; + padding: .5rem; + background-color: #7fdbff; + color: #0074d9; + border-radius: 0 0 .5rem .5rem; +} + +#header a { +} + +#header h1 { +} + +#header nav { + float: right; + display: flex; + flex-direction: row; + flex-wrap: wrap; + align-items: stretch; +} + +#header nav a { + flex: 1; + text-align: center; + border-radius: .25rem; + padding: .25rem .5rem; + margin: 0 0 .5rem .5rem; + /*color: #399696;*/ + color: #0093f9; + background-color: #001f3f; + font-weight: bold; +} + +#footer { + font-size: .8rem; + width: 100%; + padding: .5rem; + background-color: #7fdbff; + color: #0074d9; + border-radius: .5rem; + bottom: 0; + position: absolute; +} + +#footer summary { + display: inline; +} + +#footer summary:after { + content: "\00a0"; +} + +/* +#footer summary:after, +#footer p:after { + content: ' - '; +} + +#footer p:last-child:after { + content: ''; +}*/ diff --git a/Resources/views/about.html.twig b/Resources/views/about.html.twig new file mode 100644 index 0000000..cf26dfb --- /dev/null +++ b/Resources/views/about.html.twig @@ -0,0 +1,3 @@ +{% extends 'RapsysBlogBundle::body.html.twig' %} +{% block title %}<h1><a href="{{ url('homepage') }}">Dev log</a></h1>{% 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 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="UTF-8" /> + <title>{% block title %}Welcome!{% endblock %} - Devlog</title> + <meta name="viewport" content="width=device-width, initial-scale=1" /> + {% 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' %} + <link href="{{ asset_url }}" type="text/css" rel="stylesheet" /> + {% endstylesheets %} + {% endblock %} + {% block javascripts %} + {% javascripts '@RapsysBlogBundle/Resources/js/*.js' output='js/compiled/main.js' %} + <script src="{{ asset_url }}"></script> + {% endjavascripts %} + {% endblock %} + <link rel="icon" type="image/x-icon" href="{{ asset('favicon.ico') }}" /> + </head> + {% block body %}<body></body>{% endblock %} +</html> 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 %} + <body> + <section id="wrapper"> + {% block header %} + <header id="header"> + {% block nav %} + <nav> + <a href="{{ url('about') }}">About</a> + <a href="{{ url('contact') }}">Contact</a> + </nav> + {% endblock %} + + {% block hgroup %} + <hgroup> + {% block blog_title %}<h1><a href="{{ url('homepage') }}">Dev log</a></h1>{% endblock %} + {% block blog_tagline %} + {% if tags is defined and tags %} + <ul> + {% for id, tag in tags %} + <li><h2><a href="#">Tag</a></h2></li> + {% endfor %} + </ul> + {% endif %} + {% endblock %} + </hgroup> + {% endblock %} + </header> + {% endblock %} + + {% block sidebar %}<aside id="sidebar"></aside>{% endblock %} + + {% block content %}<section id="content"></section>{% endblock %} + + {% block footer %} + <footer id="footer"> + <summary>Copyright 2016</summary> - Raphaël Gertz all rights reserved. + </footer> + {% endblock %} + </section> + </body> +{% 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 %}<h1><a href="{{ url('homepage') }}">Dev log</a></h1>{% 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 %}