Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

Commit

Permalink
DEPT-35 Add field template for consultation published date (#11)
Browse files Browse the repository at this point in the history
* Add field template for consultation published date, that doesn't include a colon suffix

* Update CI config file to PHP 8.1, thecodingmachine images etc
  • Loading branch information
Johan Gant authored Sep 7, 2022
1 parent 221a606 commit 54426c0
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 32 deletions.
57 changes: 25 additions & 32 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
# PHP CircleCI 2.0 configuration file
#
# Check https://circleci.com/docs/2.0/language-php/ for more details
version: 2
version: 2.1

default_docker_image: &docker_image
docker:
- image: thecodingmachine/php:8.1-v4-apache-node14
environment:
PROJECT_ROOT: "/home/docker/project"
PHP_EXTENSION_GD: 1
PHP_INI_MEMORY_LIMIT: 1g

jobs:
install:
docker:
- image: circleci/node:lts
<<: *docker_image
steps:
- checkout
- restore_cache:
Expand All @@ -24,8 +28,7 @@ jobs:
- ./
# Code static analysis.
lint:
docker:
- image: circleci/node:lts
<<: *docker_image
steps:
- attach_workspace:
at: ./
Expand All @@ -35,8 +38,7 @@ jobs:
npm run lint
# Build front-end assets.
build_assets:
docker:
- image: circleci/node:lts
<<: *docker_image
steps:
- attach_workspace:
at: ./
Expand All @@ -46,56 +48,47 @@ jobs:

# Static analysis of any PHP/Drupal code.
coding_standards:
docker:
- image: circleci/php:7.4.15-apache-browsers
<<: *docker_image
steps:
- checkout
- run:
name: Fetch phpcs and dependencies
command: |
composer require drupal/coder --prefer-stable --no-interaction --optimize-autoloader
composer require drupal/coder
# Move vendor directory up a level as we don't want to code-check all of that.
mv vendor ../
- run:
name: Fetch phpcs convenience script
command: |
curl https://raw.githubusercontent.com/dof-dss/nidirect-drupal/main/phpcs.sh -o /home/circleci/project/phpcs.sh
chmod +x /home/circleci/project/phpcs.sh
curl https://raw.githubusercontent.com/dof-dss/nicsdru_dept/main/phpcs.sh -o $PROJECT_ROOT/phpcs.sh
chmod +x $PROJECT_ROOT/phpcs.sh
- run:
name: PHPCS analysis
command: /home/circleci/project/phpcs.sh /home/circleci "/home/circleci/project"
command: $PROJECT_ROOT/phpcs.sh ~/ "${PROJECT_ROOT}"

deprecated_code:
docker:
- image: circleci/php:7.4.15-apache-browsers
<<: *docker_image
steps:
- checkout:
path: /home/circleci/nicsdru_origins_theme
- run:
name: Add OS and PHP extensions/config
command: |
sudo cp /home/circleci/nicsdru_dept_theme/.circleci/docker-php-circleci.ini /usr/local/etc/php/conf.d/
sudo apt --allow-releaseinfo-change update
sudo apt install -y libpng-dev
sudo docker-php-ext-install gd
path: ~/nicsdru_dept_theme
- run:
name: Fetch latest Drupal version
command: |
cd /home/circleci
composer create-project drupal-composer/drupal-project:8.x-dev /home/circleci/project --no-interaction
cd $PROJECT_ROOT
composer create-project drupal-composer/drupal-project:9.x-dev $PROJECT_ROOT --no-interaction
- run:
name: Download dependent contrib modules.
command: |
cd /home/circleci/project
cd $PROJECT_ROOT
composer require mglaman/drupal-check --no-interaction
- run:
name: Move custom code into position
command: mv /home/circleci/nicsdru_origins_theme /home/circleci/project/web/themes/custom
command: mv ~/nicsdru_dept_theme $PROJECT_ROOT/web/themes/custom/
- run:
name: Deprecated code check
command: |
cd /home/circleci/project/web
../vendor/bin/drupal-check themes/custom -e "*/tests/*"
cd $PROJECT_ROOT/web
../vendor/bin/drupal-check themes/custom
workflows:
version: 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{#
/**
* @file
* Theme override for a field.
*
* To override output, copy the "field.html.twig" from the templates directory
* to your theme's directory and customize it, just like customizing other
* Drupal templates such as page.html.twig or node.html.twig.
*
* Instead of overriding the theming for all fields, you can also just override
* theming for a subset of fields using
* @link themeable Theme hook suggestions. @endlink For example,
* here are some theme hook suggestions that can be used for a field_foo field
* on an article node type:
* - field--node--field-foo--article.html.twig
* - field--node--field-foo.html.twig
* - field--node--article.html.twig
* - field--field-foo.html.twig
* - field--text-with-summary.html.twig
* - field.html.twig
*
* Available variables:
* - attributes: HTML attributes for the containing element.
* - label_hidden: Whether to show the field label or not.
* - title_attributes: HTML attributes for the title.
* - label: The label for the field.
* - multiple: TRUE if a field can contain multiple items.
* - items: List of all the field items. Each item contains:
* - attributes: List of HTML attributes for each item.
* - content: The field item's content.
* - entity_type: The entity type to which the field belongs.
* - field_name: The name of the field.
* - field_type: The type of the field.
* - label_display: The display settings for the label.
*
* @see template_preprocess_field()
*/
#}
{% set attributes = attributes.addClass('published-date') %}
{%
set title_classes = [
label_display == 'visually_hidden' ? 'visually-hidden',
]
%}

{% if label_hidden %}
<p{{ attributes }}>
{% for item in items %}
<span{{ item.attributes }}>{{ item.content }}</span>
{% endfor %}
</p>
{% else %}
<p{{ attributes }}>
<span{{ title_attributes.addClass(title_classes) }}>{{ label }} </span>
{% for item in items %}
<span{{ item.attributes }}>{{ item.content }}</span>
{% endfor %}
</p>
{% endif %}

0 comments on commit 54426c0

Please sign in to comment.