From 9bd39e96921a680e903c12e4fa4adb5787f67484 Mon Sep 17 00:00:00 2001 From: Oliver Davies <oliver@oliverdavies.uk> Date: Thu, 1 Sep 2016 08:00:21 +0100 Subject: [PATCH] Update partials --- source/_partials/badges.html.twig | 9 ++++ source/_partials/post/about-author.html.twig | 7 +++ source/_partials/post/feedback.html.twig | 3 ++ source/_partials/post/pager.html.twig | 6 +++ source/_partials/post/related.html.twig | 11 +++++ source/_partials/post/tags.html.twig | 8 ++++ source/_partials/posts/latest.html.twig | 32 +++++++------ .../{projects => project}/company.html.twig | 0 source/_partials/project/image.html.twig | 3 ++ .../{projects => project}/skills.html.twig | 0 source/_partials/project/website.html.twig | 5 ++ source/_partials/sidebar.html.twig | 18 ++------ source/_partials/talk/event.html.twig | 14 ++++++ source/_partials/talk/slides.html.twig | 9 ++++ source/_partials/talk/video.html.twig | 7 +++ source/_views/post.html.twig | 46 +++---------------- source/_views/project.html.twig | 15 ++---- source/_views/talk.html.twig | 35 ++------------ source/blog.html | 25 +++++----- 19 files changed, 129 insertions(+), 124 deletions(-) create mode 100644 source/_partials/badges.html.twig create mode 100644 source/_partials/post/about-author.html.twig create mode 100644 source/_partials/post/feedback.html.twig create mode 100644 source/_partials/post/pager.html.twig create mode 100644 source/_partials/post/related.html.twig create mode 100644 source/_partials/post/tags.html.twig rename source/_partials/{projects => project}/company.html.twig (100%) create mode 100644 source/_partials/project/image.html.twig rename source/_partials/{projects => project}/skills.html.twig (100%) create mode 100644 source/_partials/project/website.html.twig create mode 100644 source/_partials/talk/event.html.twig create mode 100644 source/_partials/talk/slides.html.twig create mode 100644 source/_partials/talk/video.html.twig diff --git a/source/_partials/badges.html.twig b/source/_partials/badges.html.twig new file mode 100644 index 00000000..ea7286f7 --- /dev/null +++ b/source/_partials/badges.html.twig @@ -0,0 +1,9 @@ +<div class="panel badges"> + <a class="badges__badge--da-member" href="https://assoc.drupal.org/membership" title="I’m a Drupal Association member."> + <img src="{{ site.images_url }}/assets/images/da-individual-member.png" alt="Drupal Association Individual Member"> + </a> + + <a href="https://www.drupal.org/8"> + <img alt="I built Drupal 8 with hand holding a wrench on blue background" src="{{ site.images_url }}/assets/images/drupal-8.jpg"/> + </a> +</div> diff --git a/source/_partials/post/about-author.html.twig b/source/_partials/post/about-author.html.twig new file mode 100644 index 00000000..3f9d0f3e --- /dev/null +++ b/source/_partials/post/about-author.html.twig @@ -0,0 +1,7 @@ +<div class="about-author"> + <h2>About the Author</h2> + + <img src="{{ site.gravatar.url }}?s=100" alt="Picture of Oliver" class="img-circle"> + + <p>{{ site.author.bio|raw }}</p> +</div> diff --git a/source/_partials/post/feedback.html.twig b/source/_partials/post/feedback.html.twig new file mode 100644 index 00000000..20867a87 --- /dev/null +++ b/source/_partials/post/feedback.html.twig @@ -0,0 +1,3 @@ +<p class="post-feedback" style="font-style: italic"> + <b>Have feedback on this post?</b> <a href="mailto:{{ site.email }}?subject=Feedback: {{ page.title }}">Email me</a> or <a href="https://twitter.com/intent/tweet?text=@{{ site.twitter.name }}&url={{ site.url }}{{ page.url|url_encode }}">send me a tweet</a>. +</p> diff --git a/source/_partials/post/pager.html.twig b/source/_partials/post/pager.html.twig new file mode 100644 index 00000000..87bfa930 --- /dev/null +++ b/source/_partials/post/pager.html.twig @@ -0,0 +1,6 @@ +{% if page.next_post or page.previous_post %} + <ul> + {% if page.next_post %}<li>Next post: <a href="{{ page.next_post.url }}">{{ page.next_post.title }}</a></li>{% endif %} + {% if page.previous_post %}<li>Previous post: <a href="{{ page.previous_post.url }}">{{ page.previous_post.title }}</a></li>{% endif %} + </ul> +{% endif %} diff --git a/source/_partials/post/related.html.twig b/source/_partials/post/related.html.twig new file mode 100644 index 00000000..f865b49e --- /dev/null +++ b/source/_partials/post/related.html.twig @@ -0,0 +1,11 @@ +{% if page.related -%} + <h2>Related Posts</h2> + + <ul> + {% for relate in page.related -%} + <li> + <a href="{{ relate.source.url }}">{{ relate.title }}</a> + </li> + {% endfor %} + </ul> +{%- endif %} diff --git a/source/_partials/post/tags.html.twig b/source/_partials/post/tags.html.twig new file mode 100644 index 00000000..6f4862de --- /dev/null +++ b/source/_partials/post/tags.html.twig @@ -0,0 +1,8 @@ +{% if page.tags %} + <p class="tags"> + Tags: + {% for tag in page.tags %} + <a href="{{ site.url }}/blog/tags/{{ tag|url_encode(true) }}">{{ tag }}</a>{% if not loop.last %}, {% endif %} + {% endfor %} + </p> +{% endif %} diff --git a/source/_partials/posts/latest.html.twig b/source/_partials/posts/latest.html.twig index ea3cd9bc..14e58db0 100644 --- a/source/_partials/posts/latest.html.twig +++ b/source/_partials/posts/latest.html.twig @@ -1,16 +1,18 @@ -<div class="latest-posts"> - <div class="latest-posts__heading">Latest blog posts</div> +{% if page.url == '/.' %} + <div class="latest-posts"> + <div class="latest-posts__heading">Latest blog posts</div> - <ul> - {% for post in data.posts|slice(0, site.latest_posts) %} - <li class="post"> - <span class="post__title"> - <a href="{{ post.url }}"> - {{ post.title }} - </a> - </span> - - <span class="post__date">{{ post.date|date(site.default_date_format) }}</span> - </li> - {% endfor %} - </ul> -</div> + <ul> + {% for post in data.posts|slice(0, site.latest_posts) %} + <li class="post"> + <span class="post__title"> + <a href="{{ post.url }}"> + {{ post.title }} + </a> + </span> - + <span class="post__date">{{ post.date|date(site.default_date_format) }}</span> + </li> + {% endfor %} + </ul> + </div> +{% endif %} diff --git a/source/_partials/projects/company.html.twig b/source/_partials/project/company.html.twig similarity index 100% rename from source/_partials/projects/company.html.twig rename to source/_partials/project/company.html.twig diff --git a/source/_partials/project/image.html.twig b/source/_partials/project/image.html.twig new file mode 100644 index 00000000..9595fcb0 --- /dev/null +++ b/source/_partials/project/image.html.twig @@ -0,0 +1,3 @@ +{% if page.image -%} + <img src="/assets/images/projects/{{ page.image.name ?: page.image }}" alt="{{ page.image.alt }}"> +{%- endif %} diff --git a/source/_partials/projects/skills.html.twig b/source/_partials/project/skills.html.twig similarity index 100% rename from source/_partials/projects/skills.html.twig rename to source/_partials/project/skills.html.twig diff --git a/source/_partials/project/website.html.twig b/source/_partials/project/website.html.twig new file mode 100644 index 00000000..b53e444a --- /dev/null +++ b/source/_partials/project/website.html.twig @@ -0,0 +1,5 @@ +{% if page.website %} + <a class="project__website" href="{{ page.website }}"> + View the website + </a> +{% endif %} diff --git a/source/_partials/sidebar.html.twig b/source/_partials/sidebar.html.twig index 3e18d9b2..cfde2fca 100644 --- a/source/_partials/sidebar.html.twig +++ b/source/_partials/sidebar.html.twig @@ -1,21 +1,9 @@ {% block sidebar_wrapper %} <div class="col-md-3"> {% block sidebar %} - <div class="panel badges"> - <a class="badges__badge--da-member" href="https://assoc.drupal.org/membership" title="I’m a Drupal Association member."> - <img src="{{ site.images_url }}/assets/images/da-individual-member.png" alt="Drupal Association Individual Member"> - </a> - - <a href="https://www.drupal.org/8"> - <img alt="I built Drupal 8 with hand holding a wrench on blue background" src="{{ site.images_url }}/assets/images/drupal-8.jpg"/> - </a> - </div> - - {% include('availability') %} - - {% if page.url == '/.' %} - {% include ('posts/latest') %} - {% endif %} + {{ include('badges') }} + {{ include('availability') }} + {{ include('posts/latest') }} {% endblock %} </div> {% endblock %} diff --git a/source/_partials/talk/event.html.twig b/source/_partials/talk/event.html.twig new file mode 100644 index 00000000..81440aae --- /dev/null +++ b/source/_partials/talk/event.html.twig @@ -0,0 +1,14 @@ +{% if page.event %} + <h2>Details</h2> + + <ul> + <li> + Event: + {% if page.event.website %}<a href="{{ page.event.website }}">{%- endif -%} + {{ page.event.name }} + {%- if page.event.website -%}</a>{%- endif %} + </li> + <li>Date: {{ page.date|date(site.default_date_format) }}</li> + <li>Location: {{ page.event.location }}</li> + </ul> +{% endif %} diff --git a/source/_partials/talk/slides.html.twig b/source/_partials/talk/slides.html.twig new file mode 100644 index 00000000..9a2271f4 --- /dev/null +++ b/source/_partials/talk/slides.html.twig @@ -0,0 +1,9 @@ +{% if page.slides.embed %} + <div class="slides"> + <h2 class="slides__title">Slides</h2> + + <div class="slides__content"> + {{ page.slides.embed|raw }} + </div> + </div> +{% endif %} diff --git a/source/_partials/talk/video.html.twig b/source/_partials/talk/video.html.twig new file mode 100644 index 00000000..96a9dd87 --- /dev/null +++ b/source/_partials/talk/video.html.twig @@ -0,0 +1,7 @@ +{% if page.video.embed %} + <h2>Video</h2> + + <div class="embed-container"> + {{ page.video.embed|raw }} + </div> +{% endif %} diff --git a/source/_views/post.html.twig b/source/_views/post.html.twig index 9b7b66a3..2385de40 100644 --- a/source/_views/post.html.twig +++ b/source/_views/post.html.twig @@ -1,47 +1,13 @@ {% extends 'default' %} {% block content_wrapper %} - {% include('post/header') %} + {{ include('post/header') }} {% block content %}{% endblock %} - <p class="post-feedback" style="font-style: italic"> - <b>Have feedback on this post?</b> <a href="mailto:{{ site.email }}?subject=Feedback: {{ page.title }}">Email me</a> or <a href="https://twitter.com/intent/tweet?text=@{{ site.twitter.name }}&url={{ site.url }}{{ page.url|url_encode }}">send me a tweet</a>. - </p> - - {% if page.related -%} - <h2>Related Posts</h2> - - <ul> - {% for relate in page.related -%} - <li> - <a href="{{ relate.source.url }}">{{ relate.title }}</a> - </li> - {% endfor %} - </ul> - {%- endif %} - - {% if page.tags %} - <p class="tags"> - Tags: - {% for tag in page.tags %} - <a href="{{ site.url }}/blog/tags/{{ tag|url_encode(true) }}">{{ tag }}</a>{% if not loop.last %}, {% endif %} - {% endfor %} - </p> - {% endif %} - - <div class="about-author"> - <h2>About the Author</h2> - - <img src="{{ site.gravatar.url }}?s=100" alt="Picture of Oliver" class="img-circle"> - - <p>{{ site.author.bio|raw }}</p> - </div> - - {% if page.next_post or page.previous_post %} - <ul> - {% if page.next_post %}<li>Next post: <a href="{{ page.next_post.url }}">{{ page.next_post.title }}</a></li>{% endif %} - {% if page.previous_post %}<li>Previous post: <a href="{{ page.previous_post.url }}">{{ page.previous_post.title }}</a></li>{% endif %} - </ul> - {% endif %} + {{ include('post/feedback') }} + {{ include('post/related') }} + {{ include('post/tags') }} + {{ include('post/about-author') }} + {{ include('post/pager') }} {% endblock %} diff --git a/source/_views/project.html.twig b/source/_views/project.html.twig index b9977cd5..a5228201 100644 --- a/source/_views/project.html.twig +++ b/source/_views/project.html.twig @@ -3,18 +3,11 @@ {% block body_classes 'page--project' %} {% block content_wrapper %} - {% if page.image -%} - <img src="/assets/images/projects/{{ page.image.name ?: page.image }}" alt="{{ page.image.alt }}"> - {%- endif %} + {{ include('project/image') }} {% block content %}{% endblock %} - {% if page.website %} - <a class="project__website" href="{{ page.website }}"> - View the website - </a> - {% endif %} - - {{ include('projects/skills') }} - {{ include('projects/company') }} + {{ include('project/website') }} + {{ include('project/skills') }} + {{ include('project/company') }} {% endblock %} diff --git a/source/_views/talk.html.twig b/source/_views/talk.html.twig index 40296195..06ba181d 100644 --- a/source/_views/talk.html.twig +++ b/source/_views/talk.html.twig @@ -7,36 +7,7 @@ {% block content_wrapper %} {% block content %}{% endblock %} - {% if page.event %} - <h2>Details</h2> - - <ul> - <li> - Event: - {% if page.event.website %}<a href="{{ page.event.website }}">{%- endif -%} - {{ page.event.name }} - {%- if page.event.website -%}</a>{%- endif %} - </li> - <li>Date: {{ page.date|date(site.default_date_format) }}</li> - <li>Location: {{ page.event.location }}</li> - </ul> - {% endif %} - - {% if page.slides.embed %} - <div class="slides"> - <h2 class="slides__title">Slides</h2> - - <div class="slides__content"> - {{ page.slides.embed|raw }} - </div> - </div> - {% endif %} - - {% if page.video.embed %} - <h2>Video</h2> - - <div class="embed-container"> - {{ page.video.embed|raw }} - </div> - {% endif %} + {{ include('talk/event') }} + {{ include('talk/slides') }} + {{ include('talk/video') }} {% endblock %} diff --git a/source/blog.html b/source/blog.html index 47e15dfb..7d999231 100644 --- a/source/blog.html +++ b/source/blog.html @@ -11,19 +11,22 @@ use: <h1>Blog</h1> <ul class="posts"> - {% for post in page.pagination.items %} - <li class="post"> - {% include 'post-header' with { page: post, title_tag: 'h2' } %} + {% for post in page.pagination.items %} + <li class="post"> + {{ include('post/header', { + page: post, + title_tag: 'h2' + }) }} - {% if post.blocks.excerpt %} - {{ post.blocks.excerpt|raw }} - {% else %} - <p>{{ post.blocks.content|raw|striptags|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' }) }} …</p> - {% endif %} + {% if post.blocks.excerpt %} + {{ post.blocks.excerpt|raw }} + {% else %} + <p>{{ post.blocks.content|raw|striptags|split(' ')|slice(0,50)|join(' ')|replace({ 'h2':'h3' }) }} …</p> + {% endif %} - <a href="{{ post.url }}">Read more →</a> - </li> - {% endfor %} + <a href="{{ post.url }}">Read more →</a> + </li> + {% endfor %} </ul> {% if page.pagination.previous_page or page.pagination.next_page %}