From 381b24e118e2d42aef18e00da3dd98e3833838df Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 28 May 2019 15:41:50 +0100 Subject: [PATCH 1/3] Lint Twig --- .travis.yml | 1 + composer.json | 1 + composer.lock | 148 +++++++++++++++++++++++++++++++++++++++++- docker-compose.ci.yml | 4 ++ 4 files changed, 153 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 4a966c5c..4e60976c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ script: - docker-compose --file docker-compose.yml --file docker-compose.ci.yml build - .travis/smoke-test.sh - docker-compose --file docker-compose.yml --file docker-compose.ci.yml run gulp npx mocha ./test/libero-config + - docker-compose --file docker-compose.yml --file docker-compose.ci.yml run php vendor/bin/twigcs lint ./build/source/ after_success: - docker run --name pattern-library-patterns patternlibrary_gulp npx gulp exportPatterns diff --git a/composer.json b/composer.json index 8a23fab6..de487ea0 100644 --- a/composer.json +++ b/composer.json @@ -8,6 +8,7 @@ }, "require": { "php": "^7.2", + "allocine/twigcs": "^3.1", "henrikbjorn/lurker": "^1.2", "pattern-lab/core": "^2.0", "pattern-lab/patternengine-twig": "^2.0", diff --git a/composer.lock b/composer.lock index eadb0758..628666ef 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c8ee8c1eeba471e97aa30c4541cf866c", + "content-hash": "2594c18cc08ca5d718cfb0a9f2ab296e", "packages": [ { "name": "alchemy/zippy", @@ -68,6 +68,53 @@ ], "time": "2016-02-15T22:46:40+00:00" }, + { + "name": "allocine/twigcs", + "version": "v3.1.3", + "source": { + "type": "git", + "url": "https://github.com/allocine/twigcs.git", + "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/allocine/twigcs/zipball/9894a01a34b22d49e8898f8584c72961c9ca0592", + "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592", + "shasum": "" + }, + "require": { + "php": "^7.0", + "pimple/pimple": "^3.0", + "symfony/console": "^2.7 || ^3.0 || ^4.0", + "symfony/finder": "^2.7 || ^3.0 || ^4.0", + "twig/twig": "^1.0 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.2 || ^6.5" + }, + "bin": [ + "bin/twigcs" + ], + "type": "library", + "autoload": { + "psr-4": { + "Allocine\\Twigcs\\": "src/", + "Allocine\\Twigcs\\Tests\\": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "OwlyCode", + "email": "tmaindron@gmail.com" + } + ], + "description": "Checkstyle automation for Twig", + "time": "2018-09-10T07:42:53+00:00" + }, { "name": "doctrine/collections", "version": "v1.4.0", @@ -529,6 +576,105 @@ ], "time": "2016-07-04T01:24:27+00:00" }, + { + "name": "pimple/pimple", + "version": "v3.2.3", + "source": { + "type": "git", + "url": "https://github.com/silexphp/Pimple.git", + "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/silexphp/Pimple/zipball/9e403941ef9d65d20cba7d54e29fe906db42cf32", + "reference": "9e403941ef9d65d20cba7d54e29fe906db42cf32", + "shasum": "" + }, + "require": { + "php": ">=5.3.0", + "psr/container": "^1.0" + }, + "require-dev": { + "symfony/phpunit-bridge": "^3.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.2.x-dev" + } + }, + "autoload": { + "psr-0": { + "Pimple": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + } + ], + "description": "Pimple, a simple Dependency Injection Container", + "homepage": "http://pimple.sensiolabs.org", + "keywords": [ + "container", + "dependency injection" + ], + "time": "2018-01-21T07:42:36+00:00" + }, + { + "name": "psr/container", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "time": "2017-02-14T16:28:37+00:00" + }, { "name": "psr/log", "version": "1.1.0", diff --git a/docker-compose.ci.yml b/docker-compose.ci.yml index 68f5dc19..cf1fbf5c 100644 --- a/docker-compose.ci.yml +++ b/docker-compose.ci.yml @@ -5,3 +5,7 @@ services: build: context: . target: gulp + php: + build: + context: . + target: build From 7ba3f2de8f72328975982ed44df45c45313fae26 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 30 Jul 2019 12:51:00 +0100 Subject: [PATCH 2/3] Update dependency --- composer.json | 2 +- composer.lock | 96 +++++++++++++++++++++++++-------------------------- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/composer.json b/composer.json index de487ea0..3feb2bf1 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ }, "require": { "php": "^7.2", - "allocine/twigcs": "^3.1", + "friendsoftwig/twigcs": "^3.1", "henrikbjorn/lurker": "^1.2", "pattern-lab/core": "^2.0", "pattern-lab/patternengine-twig": "^2.0", diff --git a/composer.lock b/composer.lock index 628666ef..76337e97 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "2594c18cc08ca5d718cfb0a9f2ab296e", + "content-hash": "a70e79383dcd9544682bce3442098f1a", "packages": [ { "name": "alchemy/zippy", @@ -68,53 +68,6 @@ ], "time": "2016-02-15T22:46:40+00:00" }, - { - "name": "allocine/twigcs", - "version": "v3.1.3", - "source": { - "type": "git", - "url": "https://github.com/allocine/twigcs.git", - "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/allocine/twigcs/zipball/9894a01a34b22d49e8898f8584c72961c9ca0592", - "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592", - "shasum": "" - }, - "require": { - "php": "^7.0", - "pimple/pimple": "^3.0", - "symfony/console": "^2.7 || ^3.0 || ^4.0", - "symfony/finder": "^2.7 || ^3.0 || ^4.0", - "twig/twig": "^1.0 || ^2.0" - }, - "require-dev": { - "phpunit/phpunit": "^7.2 || ^6.5" - }, - "bin": [ - "bin/twigcs" - ], - "type": "library", - "autoload": { - "psr-4": { - "Allocine\\Twigcs\\": "src/", - "Allocine\\Twigcs\\Tests\\": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "OwlyCode", - "email": "tmaindron@gmail.com" - } - ], - "description": "Checkstyle automation for Twig", - "time": "2018-09-10T07:42:53+00:00" - }, { "name": "doctrine/collections", "version": "v1.4.0", @@ -182,6 +135,53 @@ ], "time": "2017-01-03T10:49:41+00:00" }, + { + "name": "friendsoftwig/twigcs", + "version": "v3.1.3", + "source": { + "type": "git", + "url": "https://github.com/friendsoftwig/twigcs.git", + "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/friendsoftwig/twigcs/zipball/9894a01a34b22d49e8898f8584c72961c9ca0592", + "reference": "9894a01a34b22d49e8898f8584c72961c9ca0592", + "shasum": "" + }, + "require": { + "php": "^7.0", + "pimple/pimple": "^3.0", + "symfony/console": "^2.7 || ^3.0 || ^4.0", + "symfony/finder": "^2.7 || ^3.0 || ^4.0", + "twig/twig": "^1.0 || ^2.0" + }, + "require-dev": { + "phpunit/phpunit": "^7.2 || ^6.5" + }, + "bin": [ + "bin/twigcs" + ], + "type": "library", + "autoload": { + "psr-4": { + "Allocine\\Twigcs\\": "src/", + "Allocine\\Twigcs\\Tests\\": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "OwlyCode", + "email": "tmaindron@gmail.com" + } + ], + "description": "Checkstyle automation for Twig", + "time": "2018-09-10T07:42:53+00:00" + }, { "name": "henrikbjorn/lurker", "version": "1.2.0", From 614bb6930355aa04c9867f067f6219d8f6611263 Mon Sep 17 00:00:00 2001 From: Chris Wilkinson Date: Tue, 30 Jul 2019 13:24:21 +0100 Subject: [PATCH 3/3] =?UTF-8?q?Obey=20the=20=F0=9F=A4=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../01-molecules/reference/reference.twig | 8 ++++++-- .../content-header/content-header.twig | 19 +++++++++---------- .../content-grid/content-grid.twig | 5 ++--- .../listing-grid/listing-grid.twig | 5 ++--- .../03-templates/page-grid/page-grid.twig | 3 +-- .../page-content/page-content.twig | 3 ++- 6 files changed, 22 insertions(+), 21 deletions(-) diff --git a/source/patterns/01-molecules/reference/reference.twig b/source/patterns/01-molecules/reference/reference.twig index b76540f9..a5fe37fc 100644 --- a/source/patterns/01-molecules/reference/reference.twig +++ b/source/patterns/01-molecules/reference/reference.twig @@ -2,8 +2,12 @@ {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['reference']) }) -%} +{%- if doi is defined -%} + {%- set doi = 'https://doi.org/' ~ doi -%} +{%- endif -%} + {%- if href is not defined and doi is defined -%} - {%- set href = 'https://doi.org/'~doi -%} + {%- set href = doi -%} {%- endif -%}
@@ -50,7 +54,7 @@ {%- block doi -%} {%- if doi -%} - {%- include 'atoms-link' with {attributes: {class: 'reference__doi', href: 'https://doi.org/'~doi}, text: 'https://doi.org/'~doi} only -%} + {%- include 'atoms-link' with {attributes: {class: 'reference__doi', href: doi}, text: doi} only -%} {%- endif -%} {%- endblock doi -%} diff --git a/source/patterns/02-organisms/content-header/content-header.twig b/source/patterns/02-organisms/content-header/content-header.twig index 7da7c818..8ee9d8c2 100644 --- a/source/patterns/02-organisms/content-header/content-header.twig +++ b/source/patterns/02-organisms/content-header/content-header.twig @@ -93,25 +93,24 @@ {% set length = include('atoms-heading')|striptags|trim|length %} {% if length < 20 %} - {% set lengthClass = 'xx-short' %} + {% set length_class = 'xx-short' %} {% elseif length < 36 %} - {% set lengthClass = 'x-short' %} + {% set length_class = 'x-short' %} {% elseif length < 46 %} - {% set lengthClass = 'short' %} + {% set length_class = 'short' %} {% elseif length < 57 %} - {% set lengthClass = 'medium' %} + {% set length_class = 'medium' %} {% elseif length < 80 %} - {% set lengthClass = 'long' %} + {% set length_class = 'long' %} {% elseif length < 120 %} - {% set lengthClass = 'x-long' %} + {% set length_class = 'x-long' %} {% else %} - {% set lengthClass = 'xx-long' %} + {% set length_class = 'xx-long' %} {% endif %} - {% set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['content-header__title', 'content-header__title--' ~ lengthClass]) }) %} - {% set level = 1 %} + {% set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['content-header__title', 'content-header__title--' ~ length_class]) }) %} - {% include 'atoms-heading' %} + {% include 'atoms-heading' with {level: 1} %} {%- endblock -%} diff --git a/source/patterns/03-templates/content-grid/content-grid.twig b/source/patterns/03-templates/content-grid/content-grid.twig index f1d0dae3..192737dd 100644 --- a/source/patterns/03-templates/content-grid/content-grid.twig +++ b/source/patterns/03-templates/content-grid/content-grid.twig @@ -2,12 +2,11 @@ {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['content-grid']) }) -%} -{%- set hasSecondary = false -%} {%- for area in content if area.area|default('full') == 'secondary' and area.content|default([])|length -%} - {%- set hasSecondary = true -%} + {%- set has_secondary = true -%} {# twigcs use-var has_secondary #} {%- endfor -%} -{%- if hasSecondary -%} +{%- if has_secondary|default(false) -%} {%- set attributes = attributes|merge({class: attributes.class|merge(['content-grid--has-secondary']) }) -%} {%- endif -%} diff --git a/source/patterns/03-templates/listing-grid/listing-grid.twig b/source/patterns/03-templates/listing-grid/listing-grid.twig index 5b112878..cb0d57a8 100644 --- a/source/patterns/03-templates/listing-grid/listing-grid.twig +++ b/source/patterns/03-templates/listing-grid/listing-grid.twig @@ -2,12 +2,11 @@ {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['listing-grid']) }) -%} -{%- set hasSecondary = false -%} {%- for area in content if area.area|default('full') == 'secondary' and area.content|default([])|length -%} - {%- set hasSecondary = true -%} + {%- set has_secondary = true -%} {# twigcs use-var has_secondary #} {%- endfor -%} -{%- if hasSecondary -%} +{%- if has_secondary|default(false) -%} {%- set attributes = attributes|merge({class: attributes.class|merge(['listing-grid--has-secondary']) }) -%} {%- endif -%} diff --git a/source/patterns/03-templates/page-grid/page-grid.twig b/source/patterns/03-templates/page-grid/page-grid.twig index 32c24513..a4ae5473 100644 --- a/source/patterns/03-templates/page-grid/page-grid.twig +++ b/source/patterns/03-templates/page-grid/page-grid.twig @@ -28,9 +28,8 @@ {%- with arguments|merge({_template: template}) only -%} {%- set attributes = attributes|default({})|merge({class: attributes.class|default([])|merge(['page-grid__item', 'page-grid__main']), role: 'main'}) -%} - {%- set element = "main" -%} - {%- include _template -%} + {%- include _template with {element: 'main'} -%} {%- endwith -%} diff --git a/source/patterns/04-pages/grid-examples/page-content/page-content.twig b/source/patterns/04-pages/grid-examples/page-content/page-content.twig index c122e73a..4b99332c 100644 --- a/source/patterns/04-pages/grid-examples/page-content/page-content.twig +++ b/source/patterns/04-pages/grid-examples/page-content/page-content.twig @@ -14,7 +14,8 @@ }, ], }, - }, main: { + }, + main: { template: 'templates-content-grid', arguments: { content: [