From fe6e7d93ec0cccbead6592f2501e6c28121045b2 Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Mon, 6 Jun 2016 23:59:13 +0200 Subject: [PATCH 1/9] Create a unit test subsite --- ansible/roles/wordpress/tasks/main.yml | 10 +++++++++- ansible/roles/wordpress/tasks/unit.yml | 26 +++++++++++++++++++++++++ theme/components/register_component.php | 10 ++++++++++ 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 ansible/roles/wordpress/tasks/unit.yml diff --git a/ansible/roles/wordpress/tasks/main.yml b/ansible/roles/wordpress/tasks/main.yml index 64e958b..4376fdc 100644 --- a/ansible/roles/wordpress/tasks/main.yml +++ b/ansible/roles/wordpress/tasks/main.yml @@ -8,4 +8,12 @@ vars: dir: /var/www/nuitdebout theme: nuitdebout - theme_dir: /vagrant/theme \ No newline at end of file + theme_dir: /vagrant/theme + +- include: unit.yml + vars: + dir: /var/www/nuitdebout + site_name: unit + site: nuitdebout.dev/unit + site_title: A very log name for the unit test site to test if all is ok + theme: nuitdebout diff --git a/ansible/roles/wordpress/tasks/unit.yml b/ansible/roles/wordpress/tasks/unit.yml new file mode 100644 index 0000000..c0917c4 --- /dev/null +++ b/ansible/roles/wordpress/tasks/unit.yml @@ -0,0 +1,26 @@ +--- +- name: Test Unit site is installed + shell: wp site list --path={{dir}} | grep {{site_name}} + register: unit + changed_when: false + ignore_errors: True + +- name: Create unit site + when: unit|failed + shell: wp site create --path={{dir}} --slug={{site_name}} --title="{{site_title}}" + +- name: Empty the site + when: unit|failed + shell: wp site empty --path={{dir}} --yes --url={{site}} + +- name: Active the theme + when: unit|failed + shell: wp theme activate {{theme}} --path={{dir}} --url={{site}} + +- name: Download testing datas + when: unit|failed + get_url: url=https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml dest=~/testing-data.xml + +- name: Import testing datas + when: unit|failed + shell: wp import --path={{dir}} --url={{site}} --authors=create ~/testing-data.xml diff --git a/theme/components/register_component.php b/theme/components/register_component.php index fff2b94..7b8932f 100644 --- a/theme/components/register_component.php +++ b/theme/components/register_component.php @@ -10,6 +10,12 @@ function instanciate_components() { global $componentClasses; global $components; + + // on wp-cli + if ($componentClasses === null) { + return; + } + foreach ($componentClasses as $componentClass) { $reflected = new \ReflectionClass($componentClass); $component = $reflected->newInstance(); @@ -21,6 +27,10 @@ function instanciate_components() { function register_modules_as_widget () { global $components; + // on wp-cli + if ($components === null) { + return; + } foreach ($components as $component) { $component->register_as_widget(); } From 1c5c6cfd439c20102869441bbd293a2c339ba504 Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 00:34:27 +0200 Subject: [PATCH 2/9] reformat and set sidebar as default --- theme/base.php | 39 +++++++++++--------- theme/lib/setup.php | 90 +++++++++++++++++++++------------------------ 2 files changed, 63 insertions(+), 66 deletions(-) diff --git a/theme/base.php b/theme/base.php index cfea366..94de240 100644 --- a/theme/base.php +++ b/theme/base.php @@ -32,13 +32,16 @@ > > + + - - + + +
@@ -51,11 +54,13 @@
+ +
- - - - + + + + diff --git a/theme/lib/setup.php b/theme/lib/setup.php index dd8e023..8252a85 100644 --- a/theme/lib/setup.php +++ b/theme/lib/setup.php @@ -57,55 +57,47 @@ function setup() { * Register sidebars */ function widgets_init() { - register_sidebar([ - 'name' => 'Bannière homepage', // TODO translate - 'id' => 'homepage-banner', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); - register_sidebar([ - 'name' => 'Haut de page', // TODO translate - 'id' => 'homepage-top', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); - // register_sidebar([ - // 'name' => 'homepage-flex-top', - // 'id' => 'homepage-flex-top', - // 'before_widget' => '
', - // 'after_widget' => '
', - // 'before_title' => '

', - // 'after_title' => '

' - // ]); - register_sidebar([ - 'name' => 'Bas de page', // TODO translate - 'id' => 'homepage-bottom', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); - - register_sidebar([ - 'name' => 'Panneau latéral', // TODO translate - 'id' => 'sidebar-primary', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

' - ]); - register_sidebar([ - 'name' => __('Footer', 'sage'), // TODO translate - 'id' => 'sidebar-footer', - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '
', - 'after_title' => '
' - ]); + register_sidebar([ + 'name' => 'Panneau latéral', // TODO translate + 'id' => 'sidebar-primary', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); + register_sidebar([ + 'name' => 'Bannière homepage', // TODO translate + 'id' => 'homepage-banner', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); + register_sidebar([ + 'name' => 'Haut de page', // TODO translate + 'id' => 'homepage-top', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); + register_sidebar([ + 'name' => 'Bas de page', // TODO translate + 'id' => 'homepage-bottom', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); + + register_sidebar([ + 'name' => __('Footer', 'sage'), // TODO translate + 'id' => 'sidebar-footer', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '
', + 'after_title' => '
' + ]); } add_action('widgets_init', __NAMESPACE__ . '\\widgets_init'); From 92099fea0d036da2f6a13b7978416a002b07f4d6 Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 23:01:54 +0200 Subject: [PATCH 3/9] open the nav on over if the parent item have a link --- theme/components/Navbar/navbar.js | 35 +++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/theme/components/Navbar/navbar.js b/theme/components/Navbar/navbar.js index 7b84419..983e61e 100644 --- a/theme/components/Navbar/navbar.js +++ b/theme/components/Navbar/navbar.js @@ -16,11 +16,28 @@ ); } + function hasUrl(element) { + var link = element.is('a') ? element : element.find('a'); + if (! link.length) { + link = element.closest('a'); + } + + if (! link.length) { + return false; + } + + return link.attr('href').length > 2; + } + $navbar.find('.menu-item-has-children').click(function(event) { if(isIn(event.target, '.navbar-subnav')) { return; } + if (hasUrl($(this))) { + return; + } + event.preventDefault(); var isOpen = $(this).is('.open'); @@ -33,6 +50,24 @@ event.stopPropagation(); }); + $navbar.find('.menu-item-has-children').hover(function(event) { + if(isIn(event.target, '.navbar-subnav')) { + return; + } + + if (! hasUrl($(this))) { + return; + } + + var isOpen = $(this).is('.open'); + + $('.menu-item.open').removeClass('open'); + if (! isOpen) { + $(this).addClass('open'); + } + }); + + $(document).click(function(event) { if(isIn(event.target, '.navbar-subnav')) { return; From 09a7ff10c8a74af5aadd9a6c3049610552c3f44c Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 23:11:09 +0200 Subject: [PATCH 4/9] push the footer at the bottom --- theme/assets/styles/common/_global.scss | 11 ++++++++++- theme/assets/styles/layouts/_footer.scss | 3 ++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/theme/assets/styles/common/_global.scss b/theme/assets/styles/common/_global.scss index 32a14e2..a9ee379 100644 --- a/theme/assets/styles/common/_global.scss +++ b/theme/assets/styles/common/_global.scss @@ -4,9 +4,18 @@ a:active { text-decoration: none; } -.content { +// to always move the footer at the bottom of the page +body { + display: flex; + flex-direction: column; + min-height: 100vh; } +.wrap { + flex: 1; +} + + body.sidebar-primary, body.page:not(.home) { .main, diff --git a/theme/assets/styles/layouts/_footer.scss b/theme/assets/styles/layouts/_footer.scss index 1505b70..565f461 100644 --- a/theme/assets/styles/layouts/_footer.scss +++ b/theme/assets/styles/layouts/_footer.scss @@ -3,6 +3,7 @@ $footer-font-color: #e4f7f7 !default; .footer { background-color: $footer-bg; color: $footer-font-color; + clear: both; .footer__main { @include make-row(); @@ -80,5 +81,5 @@ $footer-font-color: #e4f7f7 !default; } } - + } From 348aecbe238fdfbc9b5190a02d1ff1669a3b521f Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 23:20:25 +0200 Subject: [PATCH 5/9] fix search result style --- theme/assets/styles/layouts/_posts.scss | 1 + theme/search.php | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/theme/assets/styles/layouts/_posts.scss b/theme/assets/styles/layouts/_posts.scss index a1519e4..2ecd5dc 100644 --- a/theme/assets/styles/layouts/_posts.scss +++ b/theme/assets/styles/layouts/_posts.scss @@ -138,6 +138,7 @@ body.single-post{ } +article.page.type-page, article.post.format-standard { margin-bottom: 40px; header { diff --git a/theme/search.php b/theme/search.php index 8eca4a5..63d867c 100644 --- a/theme/search.php +++ b/theme/search.php @@ -1,5 +1,3 @@ -
- @@ -14,4 +12,3 @@ -
\ No newline at end of file From 523d32ac90fb125a6f9f6fa45f0edab0498e129f Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 23:39:07 +0200 Subject: [PATCH 6/9] style table and h1 in post and pages --- theme/assets/styles/common/_overload.scss | 21 ------------------- theme/assets/styles/common/_user_content.scss | 18 ++++++++++++++++ theme/assets/styles/main.scss | 1 + theme/page.php | 2 +- theme/single.php | 2 +- 5 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 theme/assets/styles/common/_user_content.scss diff --git a/theme/assets/styles/common/_overload.scss b/theme/assets/styles/common/_overload.scss index 93012e0..8b13789 100644 --- a/theme/assets/styles/common/_overload.scss +++ b/theme/assets/styles/common/_overload.scss @@ -1,22 +1 @@ -.navbar { - margin-bottom: 0; - border: none; -} -.navbar-fixed-top { - /* wait for new navbar with smaller height */ - /* top: 32px !important; */ - position: relative; -} - -.opaque-navbar { - background-color: rgba(255,255,255,0.9); - /* Transparent = rgba(0,0,0,0) / Translucent = (0,0,0,0.5) */ - height: 60px; - border-bottom: 0px; - transition: background-color .5s ease 0s; -} - -h1, h2, h3, h4, h5, h6 { - color: $heading-color; -} diff --git a/theme/assets/styles/common/_user_content.scss b/theme/assets/styles/common/_user_content.scss new file mode 100644 index 0000000..404128d --- /dev/null +++ b/theme/assets/styles/common/_user_content.scss @@ -0,0 +1,18 @@ +/** + * This file contains the style of all content enter by the user in the admin interface + * This is the html where we have no control on the class applied + * + * Indeally, this is the only place where you can set style directly on tag name + */ + +.user-content { + + table { + @extend .table; + } + + + h1 { + @include title-font; + } +} diff --git a/theme/assets/styles/main.scss b/theme/assets/styles/main.scss index 6da7c4e..c4124d4 100644 --- a/theme/assets/styles/main.scss +++ b/theme/assets/styles/main.scss @@ -11,6 +11,7 @@ @import "common/global"; @import "common/fonts"; @import "common/overload"; +@import "common/user_content"; @import "components/agenda"; @import "components/buttons"; @import "components/comments"; diff --git a/theme/page.php b/theme/page.php index e1992c6..84d9bcc 100644 --- a/theme/page.php +++ b/theme/page.php @@ -8,7 +8,7 @@
-
+
diff --git a/theme/single.php b/theme/single.php index fc08281..3e020e6 100644 --- a/theme/single.php +++ b/theme/single.php @@ -11,7 +11,7 @@ -
+
From ea636c1c1ca233e2746940f994a771fd5cf914d7 Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Tue, 7 Jun 2016 23:59:18 +0200 Subject: [PATCH 7/9] fix responsive post image --- theme/assets/styles/common/_global.scss | 1 + theme/assets/styles/common/_user_content.scss | 6 +++++- theme/components/Navbar/navbar.scss | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/theme/assets/styles/common/_global.scss b/theme/assets/styles/common/_global.scss index a9ee379..0771d3b 100644 --- a/theme/assets/styles/common/_global.scss +++ b/theme/assets/styles/common/_global.scss @@ -13,6 +13,7 @@ body { .wrap { flex: 1; + max-width: 100vw; } diff --git a/theme/assets/styles/common/_user_content.scss b/theme/assets/styles/common/_user_content.scss index 404128d..f941a27 100644 --- a/theme/assets/styles/common/_user_content.scss +++ b/theme/assets/styles/common/_user_content.scss @@ -11,8 +11,12 @@ @extend .table; } - h1 { @include title-font; } + + figure, + img { + max-width: 100%; + } } diff --git a/theme/components/Navbar/navbar.scss b/theme/components/Navbar/navbar.scss index f036224..81b7efc 100644 --- a/theme/components/Navbar/navbar.scss +++ b/theme/components/Navbar/navbar.scss @@ -195,7 +195,6 @@ .navbar-nuitdebout-bloginfo { position: relative; display: inline-block; - white-space: nowrap; font-family: 'CommuneB1San31'; text-transform: uppercase; @@ -210,6 +209,10 @@ &:before { content: '//'; } + + @media (min-width: $screen-sm-min) { + white-space: nowrap; + } } .navbar-subnav-list { From 0e0942e51aad5134e3946ebf328b15721b3ca863 Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Wed, 8 Jun 2016 00:52:43 +0200 Subject: [PATCH 8/9] styling the gallery post and add unstyled post pagination --- theme/assets/styles/common/_user_content.scss | 44 +++++++++++++++++++ theme/assets/styles/layouts/_posts.scss | 2 +- theme/single.php | 4 +- theme/templates/comments.php | 2 +- 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/theme/assets/styles/common/_user_content.scss b/theme/assets/styles/common/_user_content.scss index f941a27..edde0cf 100644 --- a/theme/assets/styles/common/_user_content.scss +++ b/theme/assets/styles/common/_user_content.scss @@ -19,4 +19,48 @@ img { max-width: 100%; } + + + .gallery { + display: flex; + flex-wrap: wrap; + align-items: stretch; + justify-content: space-between; + + margin-bottom: 10px; + + .gallery-item { + position: relative; + border: 1px solid white; + overflow: hidden; + + img { + width: 100%; + height: auto; + } + + &:hover .gallery-caption { + transform: translateY(0); + } + } + + .gallery-caption { + position: absolute; + bottom: 0; + + white-space: nowrap; + background: rgba(255, 255, 255, .8); + width: 100%; + + transition: transform .3s; + transform: translateY(100px); + } + } + + @for $i from 1 through 10 { + .gallery-columns-#{$i} .gallery-item { + flex: 1 0 100%/$i; + + } + } } diff --git a/theme/assets/styles/layouts/_posts.scss b/theme/assets/styles/layouts/_posts.scss index 2ecd5dc..7e6866e 100644 --- a/theme/assets/styles/layouts/_posts.scss +++ b/theme/assets/styles/layouts/_posts.scss @@ -139,7 +139,7 @@ body.single-post{ } article.page.type-page, -article.post.format-standard { +article.post { margin-bottom: 40px; header { display: table; diff --git a/theme/single.php b/theme/single.php index 3e020e6..7c82723 100644 --- a/theme/single.php +++ b/theme/single.php @@ -25,7 +25,9 @@
- + + + diff --git a/theme/templates/comments.php b/theme/templates/comments.php index 167a4d1..dae5d9d 100644 --- a/theme/templates/comments.php +++ b/theme/templates/comments.php @@ -8,7 +8,7 @@

' . get_the_title() . ''); ?>

-
    +
      'ol', 'short_ping' => true]); ?>
    From ca83812c707bca9e12a757657b33093425a83b9e Mon Sep 17 00:00:00 2001 From: Nicolas Djambazian Date: Wed, 8 Jun 2016 01:07:33 +0200 Subject: [PATCH 9/9] style the post pagination --- theme/assets/styles/layouts/_posts.scss | 4 +++ theme/lib/nuitdebout/utils.php | 42 +++++++++++++++++++++++++ theme/single.php | 15 +++++++-- 3 files changed, 59 insertions(+), 2 deletions(-) diff --git a/theme/assets/styles/layouts/_posts.scss b/theme/assets/styles/layouts/_posts.scss index 7e6866e..8c6d2c8 100644 --- a/theme/assets/styles/layouts/_posts.scss +++ b/theme/assets/styles/layouts/_posts.scss @@ -175,3 +175,7 @@ article.post { padding: 30px 0 15px; } } + +.post-pagination { + text-align: center; +} diff --git a/theme/lib/nuitdebout/utils.php b/theme/lib/nuitdebout/utils.php index daeb0f4..8ab61e9 100644 --- a/theme/lib/nuitdebout/utils.php +++ b/theme/lib/nuitdebout/utils.php @@ -21,3 +21,45 @@ function getAttachmentThumb($id) { $url = wp_get_attachment_image_src($thumb , [330, 180])[0]; return $url; } + +/** + * Link Pages + * @author toscha + * @link http://wordpress.stackexchange.com/questions/14406/how-to-style-current-page-number-wp-link-pages + * @param array $args + * @return void + * Modification of wp_link_pages() with an extra element to highlight the current page. + */ +function bootstrap_link_pages( $args = array () ) { + $defaults = array( + 'before' => '

    ' . __('Pages:'), + 'after' => '

    ', + 'before_link' => '', + 'after_link' => '', + 'current_before' => '', + 'current_after' => '', + 'link_before' => '', + 'link_after' => '', + 'pagelink' => '%', + 'echo' => 1 + ); + $r = wp_parse_args( $args, $defaults ); + $r = apply_filters( 'wp_link_pages_args', $r ); + extract( $r, EXTR_SKIP ); + global $page, $numpages, $multipage, $more, $pagenow; + if ( ! $multipage ) { + return; + } + $output = $before; + for ( $i = 1; $i < ( $numpages + 1 ); $i++ ) { + $j = str_replace( '%', $i, $pagelink ); + $output .= ' '; + if ( $i != $page || ( ! $more && 1 == $page ) ) { + $output .= "{$before_link}" . _wp_link_page( $i ) . "{$link_before}{$j}{$link_after}{$after_link}"; + } else { + $output .= "{$current_before}{$link_before}{$j}{$link_after}{$current_after}"; + } + } + print $output . $after; +} +add_action( 'bootstrap_link_pages', 'bootstrap_link_pages', 10, 1 ); \ No newline at end of file diff --git a/theme/single.php b/theme/single.php index 7c82723..b787c86 100644 --- a/theme/single.php +++ b/theme/single.php @@ -15,6 +15,19 @@ +
    + '
      ', + 'after' => '
    ', + 'before_link' => '
  1. ', + 'after_link' => '
  2. ', + 'current_before' => '
  3. ', + 'current_after' => '
  4. ', + 'previouspagelink' => '«', + 'nextpagelink' => '»' + ]); ?> +
    +