GCDigital Tools views documentation
- Overview
- Defining the view structure
- Tagging content that is relevant to the view
- Creating a page that retrieves and displays tagged content
- Including content from the view in the Playbook dataset
- Testing the view
Overview
The GCDigital Tools views are generated from the GCDigital Tools dataset and can make the GCDigital Tools more relevant and easier to use for certain tasks by providing only the information that is relevant to the task and ordering it in a way that makes sense for the user.
There are four steps to creating a GCDigital Tools view:
- Defining the view structure
- Tagging content that is relevant to the view
- Creating a page that retrieves and displays tagged content
- Testing the view
Defining the view structure
The view structure consists of two levels of content groupings, view pages and view page sections. View pages can be used to divide up content according the logical steps for a task or scenario, helping users to focus on what is relevant for a given step. View page sections can be used to group and order content on a page to make it easier to consume for users.
View pages
To determine which view pages are needed, consider the logical steps for the task or scenario for which the view is addressing. For instance, a task with four discrete phases could have a view page for each phase, allowing users to proceed from phase to phase, only being presented with the content that is relevant to the current phase.
For each view page, determine which content should be included. Varying sizes of blocks of content can be included, from large content sections to much smaller blocks of content such as individual list items and paragraphs. The content that will be included on a view page can be controlled by applying one or more tags to that content.
For more details about the dataset structure, see the GCDigital Tools dataset schema.
For simple views, the default page sections and ordering of content can be used to present the content that is included in the page. For more advanced views, the content could be reordered or combined in different ways to produce different page structures and designs.
It is recommended that any custom page sections and ordering of content be designed and tested with users to ensure that the resulting view page is easy for them to use and meets their needs. Custom page sections can be produced by using tags to create new content groupings, which don't exist in the Playbook by default, which can then be retrieved from the dataset and output to sections in the view page.
Tagging content that is relevant to the view
Each piece of content can be tagged through the use of CSS classes, where each piece of content can have multiple tags. There is no specific naming convention for tags, but they do need to be unique. There should be a unique tags for view-level content grouping and each page-level content grouping. The tag can be either an existing supported tag or a new tag. The suggested format for new tags is: dpgn-<group>-<item>
(e.g., dpgn-stage-alpha
).
Tags can be applied directly to content in the source .md files, using either the HTML class attribute (for blocks of HTML content) or through the Kramdown approach for applying CSS classes (for blocks of Markdown content). Tags applied to a parent container (e.g., list) will also apply to the child items.
Content type | HTML example | Markdown (Kramdown) example |
---|---|---|
Section / container | <section class="dpgn-stage-alpha dpgn-stage-live">...</section> |
n/a |
List | <ul class="dpgn-stage-alpha dpgn-stage-live">...</ul> |
<!-- markdownlint-disable MD032 --> - List item 1 - List item 2 - List item 3 {: .dpgn-stage-alpha .dpgn-stage-live} <!-- markdownlint-enable MD032 --> |
List item | <li class="dpgn-stage-alpha dpgn-stage-live">List item</li> |
- {: .dpgn-stage-alpha .dpgn-stage-live} List item |
Table | <table class="dpgn-stage-alpha dpgn-stage-live"> |
| Header 1 | Header 2 | |----------|----------| | Data 1 | Data 2 | {: .dpgn-stage-alpha .dpgn-stage-live} |
Table row | <tr class="dpgn-stage-alpha dpgn-stage-live"> |
n/a |
Table cell | <td class="dpgn-stage-alpha dpgn-stage-live">Table cell</td> |
n/a |
Paragraph | <p class="dpgn-stage-alpha dpgn-stage-live">Paragraph content</p> |
Paragraph content {: .dpgn-stage-alpha .dpgn-stage-live} |
Supported tags
The following tags are supported by default by the Digital Playbook:
View tags:
dpgn-standards-hide
: Content should be hidden from the standards-normes and single-page-seule viewsdpgn-stage-alpha
: Content is related to the alpha development stagedpgn-stage-beta
: Content is related to the beta development stagedpgn-stage-live
: Content is related to the live development stage
Section tags:
Section tags are mainly used for dataset generation and filtering. Each of these tags should only be used to identify sections or containers of the specified type.
dpgn-section-overview
: Contains the Playbook overviewdpgn-section-standard
: Contains a standarddpgn-section-intro-standard
: Contains the introduction for the current standarddpgn-section-guidelines
: Contains a list of links to the guidelines within the current standarddpgn-section-guidelines-related
: Contains a list of links to the guidelines that are within other standards but related to the current standarddpgn-section-guideline
: Contains a guideline for the current standarddpgn-section-intro-guideline
: Contains the introduction for the current guidelinedpgn-section-checklist
: Contains the checklist(s) for the current guidelinedpgn-section-guides
: Contains links to the implementation guides for the current guidelinedpgn-section-solutions
: Contains links to the reusable solutions for the current guidelinedpgn-section-similar
: Contains links to similar ressources for the current guideline
Special tags:
dpgn-data-ignore
: Content should be ignored when generating the dataset
Creating a page that retrieves and displays tagged content
The GCDigital Tools provides several helper functions to make it easier to produce the desired output. This section will cover the basics of building a view page and the available helper functions.
Building a view page
- Create English and French .md files for each view page using the template files in views-vues/view-template-modele-vue/. These new .md files should placed in "en" and "fr" folders in the directory for the new view (
views/<view-name>
).</li> - For each .md file, update the following properties in the data at the start of the file delimited by "—":
title
: Title of the view pagealtLangPage
: Filename (without extension) for the .md file in the other languagecollectionDirectory
: Folder for the view (in the formviews/<view-name>
)
- Build the content for each .md file:
- Simple views: Update the
relevantTags
parameter in the include statement with the tags for the view page. Multiple tags should be separated with commas (e.g.,"dpgn-stage-alpha,dpgn-stage-live"
).</li> - Advanced views: Use the GCDigital Tools helper functions and/or build custom output using Jekyll and Liquid on the Playbook data from
site.data.playbook
(English) orsite.data.guide
(French).
- Simple views: Update the
Helper functions
The following are three of the more commonly used helper functions. For the rest of the functions, see _includes/functions (each function has usage instructions in the comments at the beginning of the file).
filtered-standard-guideline-content.html
- Overview: Outputs filtered and ordered content from the dataset according to the specified tags.
- Example usage:
{% include /functions/filtered-standard-guideline-content.html relevantTags="dpgn-group-group1,dpgn-group-group2" relevantSections="dpgn-section-guidelines,dpgn-section-guideline,dpgn-section-checklist" %}
- Parameters:
standardIndexes
{String/Array} Optional (default to all) Comma-separated indexes or array of indexes of standards to display.relevantTags
{String/Array} Optional (defaults to all). Comma-separated tag requirements or an array of tag requirements for which content to display. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.irrelevantTags
{String/Array} Optional (defaults to none). Comma-separated tag requirements or an array of tag requirements for which content to filter out. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.groupByTagsTags
{String/Array} Optional (defaults to none). Comma-separated tags or array of tags that will be used to create filtered sub-sections for each tag, with a final section for anything that doesn't match any of the tags (to filter out content completely, use relevantTags instead). If a title is provided for the final section, that final section will be put at the end, otherwise the content will be put at the start.groupByTagsTitles
{String/Array} Optional (defaults to none). Semi-colon-separated subsection titles or array of subsection titles. Used to provide titles for the subsections for each tag ingroupByTagsTags
. Provide an extra title (at the end) to group everything else in a final section at the end (otherwise anything that doesn't match will be put at the start). Must have at minimum the same number of entries in the same order asgroupByTagsTags
.relevantSections
{String/Array} Optional (defaults to all sections). Comma-separated section tags or array of section tags that sections must have at least one of to be displayed.guidelineSectionsOrder
{String/Array} Optional (defaults tosite.guidelineSectionsOrder
). Comma-separated section keys or array of section keys determining the order to display the sections (omitting a section will prevent it from being displayed).standardsListClasses
{String} Optional. Classes (separated by a space) to add to the standards list.standardsListItemClasses
{String} Optional. Classes (separated by a space) to add to the standards list items.standardsLinkClasses
{String} Optional. Classes (separated by a space) to add to the standards list item links.standardsSubLinkClasses
{String} Optional. Classes (separated by a space) to add to the standards list item link content.guidelinesListClasses
{String} Optional. Classes (separated by a space) to add to the guidelines list.guidelinesListItemClasses
{String} Optional. Classes (separated by a space) to add to the guidelines list items.guidelinesLinkClasses
{String} Optional. Classes (separated by a space) to add to the guidelines list item links.guidelinesSubLinkClasses
{String} Optional. Classes (separated by a space) to add to the guidelines list item link content.
- Returns: {String} Outputs filtered and ordered content from the dataset according to the specified tags.
output-guideline.html
- Overview: Outputs the content for a guideline.
- Example usage:
{% include /functions/output-standard.html guidelineHeadingLevel="2" standardIndex="1" guidelineIndex="4" relevantGuidelines="1.2,1.4,1.6" relevantRelatedGuidelines="3.4,5.2,6.2" relevantTags="dpgn-group-group1,dpgn-group-group2" relevantSections="dpgn-section-guidelines,dpgn-section-guideline,dpgn-section-checklist" %}
- Parameters:
guidelineHeadingLevel
{Number} Heading level of the guideline section header.standardIndex
{Number} Index of the standard that is the parent of the guideline to process.guidelineIndex
{Number} Index of the guideline to process.relevantTags
{String/Array} Optional (defaults to all). Comma-separated tag requirements or an array of tag requirements for which content to display. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.irrelevantTags
{String/Array} Optional (defaults to none). Comma-separated tag requirements or an array of tag requirements for which content to filter out. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.groupByTagsTags
{String/Array} Optional (defaults to none). Comma-separated tags or array of tags that will be used to create filtered sub-sections for each tag, with a final section for anything that doesn't match any of the tags (to filter out content completely, use relevantTags instead). If a title is provided for the final section, that final section will be put at the end, otherwise the content will be put at the start.groupByTagsTitles
{String/Array} Optional (defaults to none). Semi-colon-separated subsection titles or array of subsection titles. Used to provide titles for the subsections for each tag ingroupByTagsTags
. Provide an extra title (at the end) to group everything else in a final section at the end (otherwise anything that doesn't match will be put at the start). Must have at minimum the same number of entries in the same order asgroupByTagsTags
.relevantSections
{String/Array} Optional (defaults to all). Comma-separated section tags or array of section tags that content must have at least one of to be displayed.guidelineSectionsOrder
{String/Array} Optional (defaults tosite.guidelineSectionsOrder
). Comma-separated section keys or array of section keys determining the order to display the sections (omitting a section will prevent it from being displayed)
- Returns: {String} Outputs the content for a guideline.
output-sections.html
- Overview: Outputs the guideline sections.
- Example usage:
{% include /functions/output-sections.html parentHeadingLevel="2" relevantTags="dpgn-digital-architectural" groupListsSeparately=true guidelineSectionsOrder="checklist,guides,solutions" %}
- Parameters:
parentHeadingLevel
{Number} Heading level for the current section.standardIndex
{Number} Optional (required if guideline is provided, defaults to all standards). Index of the standard that is the parent of the guideline to process.guidelineIndex
{Number} Optional (defaults to all guidelines) Index of the guideline to process.relevantTags
{String/Array} Optional (defaults to all). Comma-separated tag requirements or an array of tag requirements for which content to display. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.irrelevantTags
{String/Array} Optional (defaults to none). Comma-separated tag requirements or an array of tag requirements for which content to filter out. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.groupListsSeparately
{Boolean} Optional (defaults to false). When enabled, top-level lists will be grouped and merged together, followed by the rest of the content.groupByTagsTags
{String/Array} Optional (defaults to none). Comma-separated tags or array of tags that will be used to create filtered sub-sections for each tag, with a final section for anything that doesn't match any of the tags (to filter out content completely, use relevantTags instead). If a title is provided for the final section, that final section will be put at the end, otherwise the content will be put at the start.groupByTagsTitles
{String/Array} Optional (defaults to none). Semi-colon-separated subsection titles or array of subsection titles. Used to provide titles for the subsections for each tag ingroupByTagsTags
. Provide an extra title (at the end) to group everything else in a final section at the end (otherwise anything that doesn't match will be put at the start). Must have at minimum the same number of entries in the same order asgroupByTagsTags
.relevantSections
{String/Array} Optional (defaults to all). Comma-separated section tags or array of section tags that content must have at least one of to be displayed.guidelineSectionsOrder
{String/Array} Optional (defaults tosite.guidelineSectionsOrder
). Comma-separated section keys or array of section keys determining the order to display the sections (omitting a section will prevent it from being displayed).collapseSubsections
{Boolean} Optional (defaults to true). Collapses subsections, preventing the output of the section element and heading without affecting content of the subsections.
- Returns: {String} Outputs the guideline sections.
output-section-content.html
- Overview: Outputs the content for the guideline section.
- Example usage:
{% include /functions/output-sections.html parentHeadingLevel="2" relevantTags="dpgn-digital-architectural" groupListsSeparately=true guidelineSectionsOrder="checklist,guides,solutions" %}
- Parameters:
parentHeadingLevel
{Number} Heading level for the current section.sectionKey
{String} Dataset property name of the guideline section to process.standardIndex
{Number} Optional (required if guideline is provided, defaults to all standards). Index of the standard that is the parent of the guideline to process.guidelineIndex
{Number} Optional (defaults to all guidelines) Index of the guideline to process.relevantTags
{String/Array} Optional (defaults to all). Comma-separated tag requirements or an array of tag requirements for which content to display. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.irrelevantTags
{String/Array} Optional (defaults to none). Comma-separated tag requirements or an array of tag requirements for which content to filter out. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.relevantSourceElements
{String/Array} Optional (defaults to all). Comma-separated source elements or an array of source elements for which content to display (e.g.,"ul,ol"
). Can be overridden byirrelevantSourceElements
. Only affects content at the current level (i.e., doesn't affect nested content for parent content that isn't filtered out).irrelevantSourceElements
{String/Array} Optional (defaults to none). Comma-separated source elements or an array of source elements for which content not to display (e.g.,"ul,ol"
). OverridesrelevantSourceElements
. Only affects content at the current level (i.e., doesn't affect nested content for parent content that isn't filtered out).suppressParentListElement
{Boolean} Optional (defaults to false). Prevents the output of the parent list element (useful when used withrelevantSourceElements
to merge lists together). Only affects lists at the current level (i.e., doesn't affect descendant lists).collapseSubsections
{Boolean} Optional (defaults to true). Collapses subsections, preventing the output of the section element and heading without affecting content of the subsections.
- Returns: {String} Outputs the guideline sections.
output-content-array.html
- Overview: Iterates over an array of content blocks, including nested content arrays, outputting the relevant content.
- Example usage:
{% include /functions/output-content-array.html contentArray=site.data.playbook.standards.content[0].guidelines.content[2].checklist.content relevantTags="dpgn-group-group1,dpgn-group-group2" %}
- Parameters:
contentArray
{Array} Array of content blocks to process.parentHeadingLevel
(Integer} Preceding heading level (i.e., heading level for the section that contentArray is contained within).relevantTags
{String/Array} Optional (defaults to all). Comma-separated tag requirements or an array of tag requirements for which content to display. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.irrelevantTags
{String/Array} Optional (defaults to none). Comma-separated tag requirements or an array of tag requirements for which content to filter out. Each requirement can include multiple criteria, separated by "+
" (e.g.,"string1,string2+string3"
). This means that the target array must have an entry that either matchesstring1
or entries that matchstring2
andstring3
. Partial match criteria (contains) start with "~
" (e.g.,"string1+~string2"
). Can be overridden byirrelevantTags
.relevantSourceElements
{String/Array} Optional (defaults to all). Comma-separated source elements or an array of source elements for which content to display (e.g.,"ul,ol"
). Can be overridden byirrelevantSourceElements
. Only affects content at the current level (i.e., doesn't affect nested content for parent content that isn't filtered out).irrelevantSourceElements
{String/Array} Optional (defaults to none). Comma-separated source elements or an array of source elements for which content not to display (e.g.,"ul,ol"
). OverridesrelevantSourceElements
. Only affects content at the current level (i.e., doesn't affect nested content for parent content that isn't filtered out).suppressParentListElement
{Boolean} Optional (defaults to false). Prevents the output of the parent list element (useful when used withrelevantSourceElements
to merge lists together). Only affects lists at the current level (i.e., doesn't affect descendant lists).collapseSubsections
{Boolean} Optional (defaults to true). Collapses subsections, preventing the output of the section element and heading without affecting content of the subsections.contentStandardIndex
{Number} Optional (required if guideline is provided, defaults to none). Index of the standard that is an ancestor of the content being processed.contentGuidelineIndex
{Number} Optional (defaults to none) Index of the guideline that is an ancestor of the content being processed.
- Returns: {String} Returns the processed output from the content array.
Including content from the view in the Playbook dataset
Normally the source of content for the Playbook dataset are the .md files in the /en and /fr directories. It is also possible to include content from the /views-vues directory. To do that, add the data-dpgn-data-include
attribute to the content in question.
data-dpgn-data-include='{ "guideline": "8.2", "section": "checklist" }'
- Adds the content to the checklist section of guideline 8.2
data-dpgn-data-include='{ "standard": "8", "section": "introduction" }'
- Adds the content to the introduction of standard 8
The content can only be added to a sub-section of a guideline or standard within the dataset. The supported sections are the named sections with the standard or guideline (introduction
in the case of a standard and introduction
, checklist
, guides
or solutions
in the case of a guideline).
Note: When applying the attribute in Markdown files, the curly brackets need to be escaped:
- {: data-dpgn-data-include='{ "guideline": "8.2", "section": "checklist" }'} List item content
Testing the view
- If not already done, set up GitHub pages for your repository:
- Go to the repository settings
- In the GitHub pages section, set "Source" to "gh-pages branch"
- Create a new "gh-pages" branch from the branch used to create the view
- Go to your branches page. Refresh the page periodically until the gh-pages build for the gh-pages branch either passes (green checkmark) or fails (red x).
- If the build passes, the view can be found at https://<github-handle>.github.io/digital-playbook-guide-numerique/views-vues/<view-directory>/en/<filename>.html
- If the build fails, review your code and correct the error. To get the build error messages, you can use Travis-CI by:
- Going to the Travis-CI website
- Sign in using your GitHub account
- Go to your profile (upper-right corner)
- Click the "Sync account"
- Enable integration for the <username>/digital-playbook-guide-numerique repository
- Do a new push to the branch used to create the view (e.g., make a change and commit it).
- Go to the branches page and wait for the Travis-CI build to complete. If the build fails then review the Travis-CI log (can either be reached through the Travis-CI website or by clicking the red "x" and then clicking Travis-CI).