2017 © Pedro Peláez
 

drupal-module shomeya_utility

Shomeya utility tools for Drupal

image

shomeya/shomeya_utility

Shomeya utility tools for Drupal

  • Friday, April 7, 2017
  • by mikeyp
  • Repository
  • 2 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Shomeya Utility module for Drupal

This module provides several useful features, such as an environment indicator, a style guide, some render elements and template functions/helpers., (*1)

Build metadata

This module provide a helper class to access information about the build, such as latest Git commit, date, time, as well as who and where the build was packaged. This information is available in the status report at admin/reports/status. It also includes links to Github for relevant commits as long as the Github URL is set in settings.php:, (*2)

$config['shomeya_utility.settings']['github_url'] = 'https://github.com/shomeya/projectname';

Environment indicator

An environment indicator is available that provides text and an icon indicating which environment you are viewing:, (*3)

environment indicator for production with green checkmark, (*4)

This functionality is based on the enviroment specified in the settings.json file and is mapped in src/Environment.php., (*5)

Style Guide

This module provides a sample style guide at styleguide/web with additional pages for form elements and Drupal elements at styleguide/web/drupal/form and styleguide/web/drupal/elements., (*6)

Elements

A time element is defined in src/Element/Time.php. This element also supports optionally rendering as a dynamic 'time ago' with Javascript if the option is enabled., (*7)

$build = [
  '#type' => 'time',
  '#timestamp' => '1456527560', // Unix timestamp to use for the date, will be used to populate a ISO 8601 in the 'datetime' attribute of the tag
  '#value' => 'Friday, Feb. 26th', // The value to be displayed
  '#options' => [
    'timeago' => TRUE, // Whether or not the element should be rendered as timeago using javascript
  ],
  '#attributes' => [ // additional attributes for the element
    'class' => 'my-time-element', 
  ],
];

Template functions/helpers

There are several helper function that are exposed to Twig templates:, (*8)

URL from URI

This helper turns a Drupal URI (such as internal:/about-us , entity:node/1234, or base:robots.txt) into a fully qualified URL:, (*9)

<a href="{{ url_from_uri(node.field_link.uri) }}">My Link</a>

It supports options that will be based to Url::fromUri() such as query, absolute, https, and more:, (*10)

<a href="{{ url_from_uri(node.field_link.uri, {absolute: true}) }}">My Link</a>

Time

Supports creation of a time element from a timestamp:, (*11)

{# Without value provided a value will be formatted from the timestamp #}
{{ time(item.timestamp) }}

It supports an optional value to be displayed if you wish to customize the date display:, (*12)

{{ time(item.timestamp, item.date) }}

Finally it supports all options that can be passed to the time element, and additional options for generating a value if one is not provided:, (*13)

{# Type and format correspond to options passed to DateFormatter::format() #}
{{ time(item.timestamp, null, {type: custom, format: 'F j Y'}) }}

The last example will output something like:, (*14)

<time datetime="2016-02-26T14:59:20-08:00">February 26 2016</time>

Time ago

Support time element from timestamp with timeago set to true:, (*15)

{{ time_ago(item.timestamp) }}

The output will be:, (*16)

<time datetime="2016-02-26T14:59:20-08:00" data-drupal-time-ago>Fri, 02/26/2016 - 14:59</time>

This also automatically includes jquery.timeago.js which will format the value as a time ago, such as 'less than a minute ago.', (*17)

This support the same options for value and options as the time helper., (*18)

Time From String

This function supports generating a time element from a date string parsed with strtotime():, (*19)

{{ time_from_string('Fri, 02/26/2016 - 14:59') }}

Also allows for value, options., (*20)

Time ago from string

Supports generating a time ago tag from a string:, (*21)

{{ time_ago_from_string('Fri, 02/26/2016 - 14:59') }}

The Versions

07/04 2017

dev-master

9999999-dev https://github.com/shomeya/shomeya_utility

Shomeya utility tools for Drupal

  Sources   Download

GPL 2.0+

development utility drupal drupal module

07/04 2017

1.0.0-rc1

1.0.0.0-RC1 https://github.com/shomeya/shomeya_utility

Shomeya utility tools for Drupal

  Sources   Download

GPL 2.0+

development utility drupal drupal module

27/02 2017

0.1.2

0.1.2.0

Shomeya utility tools

  Sources   Download

GPL 2.0+

27/02 2017

0.1.1

0.1.1.0

Shomeya utility tools

  Sources   Download

GPL 2.0+

27/02 2017

0.1.0

0.1.0.0

Shomeya utility tools

  Sources   Download

GPL 2.0+