Skip to content

Commit

Permalink
Switch tracking and add Standards category ribbon
Browse files Browse the repository at this point in the history
Addresses: #334, #332
  • Loading branch information
nils-work committed Nov 23, 2023
1 parent 3a6a594 commit 2dc8b90
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 3 deletions.
4 changes: 3 additions & 1 deletion slate/source/includes/additional.md
@@ -1,6 +1,8 @@
# Additional Standards


```diff
Added a red ribbon below the CDS logo on different Standards versions to visually distinguish them from the binding version
```

The Consumer Data Standards also incorporate other non-binding standards that are developed to facilitate consultation and feedback or to facilitate voluntary extension of CDR implementations.

Expand Down
Expand Up @@ -17,7 +17,7 @@ Release notes for version v1.29.0 of the [CDR Standards](../../index.html).

This release addresses the following minor defects raised on [Standards Staging](https://github.com/ConsumerDataStandardsAustralia/standards-staging/issues):

- [Staging Issue xxx - Description](https://github.com/ConsumerDataStandardsAustralia/standards-staging/issues/xxx)
- [Staging Issue 334 - Add visual indicator for different Standards categories](https://github.com/ConsumerDataStandardsAustralia/standards-staging/issues/334)

This release addresses the following change requests raised on [Standards Maintenance](https://github.com/ConsumerDataStandardsAustralia/standards-maintenance/issues):

Expand All @@ -32,6 +32,7 @@ This release addresses the following Decision Proposals published on [Standards]
## General Changes
|Change|Description|Link|
|------|-----------|----|
|Standards category ribbon|Added a red ribbon below the CDS logo on different Standards versions to visually distinguish them from the binding version|[Draft](../../#draft-standards), [Candidate](../../#candidate-standards), [Staging](https://consumerdatastandardsaustralia.github.io/standards-staging/) and [Archived](../../#archives) pages|


## Introduction
Expand Down
1 change: 1 addition & 0 deletions slate/source/javascripts/all_nosearch.js
Expand Up @@ -4,6 +4,7 @@
//= require ./app/_tooltips
//= require ./app/_datepicker
//= require ./app/_scroll
//= require ./cds/standards-category

$(function() {
loadToc($('#toc'), '.toc-link', '.toc-list-h2', 10);
Expand Down
76 changes: 76 additions & 0 deletions slate/source/javascripts/cds/standards-category.js
@@ -0,0 +1,76 @@
// Set Standards category ribbon and update analytics site
// https://github.com/ConsumerDataStandardsAustralia/standards-staging/issues/332
// https://github.com/ConsumerDataStandardsAustralia/standards-staging/issues/334
(function () {
var locHostname = document.location.hostname;
var locPathname = document.location.pathname;
var docScripts = document.scripts;
var settings = {};
var lp;
var fathomScript;
var fathomStagingSiteId = 'KTYHJBYJ';
var fathomNonProdSiteId = 'UEFFSKGJ';

function onDOMContentLoaded(func) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function () {
func();
});
} else {
func();
}
}

// Check category
settings.standardsGitHub = locHostname === 'consumerdatastandardsaustralia.github.io';
settings.experimental = locPathname.indexOf('/standards-experimental/') > -1;
settings.draft = locPathname.indexOf('/includes/additional/drafts/') > -1;
settings.candidate = locPathname.indexOf('/includes/additional/candidates/') > -1;
settings.staging = locPathname.indexOf('/standards-staging/') > -1;
settings.archived = locPathname.indexOf('/standards-archives/') > -1;

// Testing
//console.log(JSON.stringify(settings, null, 4));

// Set Standards category and archive ribbon
function setCssForCategories() {
var cdsLogoElem = document.querySelector('body > div.toc-wrapper > img.logo');
var cdsCategoryElem = document.createElement('p');
cdsCategoryElem.id = 'cdsCategoryMessage';
cdsCategoryElem.style.cssText = 'font-size: 16px; padding: 10px; margin: 2px 0px; background-color: #b60000; color: white;';

if (settings.draft) {
cdsCategoryElem.textContent = 'Draft';
}
if (settings.candidate) {
cdsCategoryElem.textContent = 'Candidate';
}
if (settings.staging) {
cdsCategoryElem.textContent = 'Staging';
}
if (settings.archived) {
cdsCategoryElem.textContent = 'Archived version';
}
if (cdsLogoElem && cdsCategoryElem.textContent && !document.getElementById('cdsCategoryMessage')) {
cdsLogoElem.parentNode.insertBefore(cdsCategoryElem, cdsLogoElem.nextSibling);
}
}
onDOMContentLoaded(setCssForCategories);

// Switch Fathom tracking
for (lp = 0; lp < docScripts.length; lp += 1) {
if (docScripts[lp].src.indexOf('cdn.usefathom.com/script.js') > -1) {
fathomScript = docScripts[lp];
break;
}
}
if (fathomScript) {
if (settings.staging) {
fathomScript.setAttribute('data-site', fathomStagingSiteId);
}
if (!settings.standardsGitHub) {
fathomScript.setAttribute('data-site', fathomNonProdSiteId);
}
}
}
());
2 changes: 1 addition & 1 deletion slate/source/layouts/layout.erb
Expand Up @@ -32,7 +32,7 @@ under the License.
<title><%= current_page.data.title || "API Documentation" %></title>
<%= favicon_tag 'images/favicon.ico' %>

<script src="https://cdn.usefathom.com/script.js" data-spa="auto" data-site="GWAEHCUX" defer></script>
<script src="https://cdn.usefathom.com/script.js" data-spa="hash" data-site="GWAEHCUX" defer></script>

<style>
<%= Rouge::Themes::MonokaiSublime.render(:scope => '.highlight') %>
Expand Down

0 comments on commit 2dc8b90

Please sign in to comment.