Skip to content
This repository has been archived by the owner on Feb 17, 2021. It is now read-only.

Commit

Permalink
Added page variable so random word code only runs on main page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sumeet Adur committed Dec 14, 2015
1 parent 19d57ea commit 207c289
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
2 changes: 2 additions & 0 deletions client/definition-page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<a href="form/" class="o-buttons o-buttons--standout">Suggest your own entry</a>
</div>

{{#with word}}
<div class="detailed-guff">
<div class="word">{{word}}</div>
<div class="details">
Expand Down Expand Up @@ -58,5 +59,6 @@
<a href="{{nextWord.slug}}/" class="next-guff">Next&raquo;<br><span class="preview">{{nextWord.word}}</span></a>
{{/if}}
</div>
{{/with}}
</main>
{{> bottom }}
2 changes: 1 addition & 1 deletion client/main-page.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

{{#each homewords}}
<div class="{{#if @first}}latest{{else}}random{{/if}}-guff">
<div class="paraHeads">{{#if @first}}<span class="label">Latest guff</span><span class="timestamp">added on {{formatteddate}}</span>{{else}}<span class="label">Random guff</span><span class="refresh"></span>{{/if}}</div>
<div class="paraHeads">{{#if @first}}<span class="label">Latest guff</span><span class="timestamp">added on {{formatteddate}}</span>{{else}}<span class="label">Random guff</span>{{/if}}</div>
<a class="word" href="{{@key}}/">{{word}}&raquo;</a>
<div class="details">
{{#if definition}}
Expand Down
2 changes: 1 addition & 1 deletion client/scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ document.addEventListener('DOMContentLoaded', () => {
// remove the 300ms tap delay on mobile browsers
attachFastClick(document.body);

if (document.documentElement.className === 'enhanced') {
if (page === 'main' && document.documentElement.className === 'enhanced') {
let xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
Expand Down
9 changes: 5 additions & 4 deletions client/top.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
<link rel="shortcut icon" href="https://ig.ft.com/favicon.ico" type="image/x-icon">
<link rel="apple-touch-icon" href="//im.ft-static.com/m/icons/apple-touch-icon.png">

{{#if word}}<base href="../" />{{/if}}

<title>{{#if word}}{{word}} - {{/if}}Lucy Kellaway's Dictionary of Business Jargon and Guff</title>
<!-- <meta name="description" content="ENTER A DESCRIPTION HERE"> -->
{{#with word}}
{{#if word}}<base href="../" />{{/if}}
<title>{{#if word}}{{word}} - {{/if}}Lucy Kellaway's Dictionary of Business Jargon and Guff</title>
{{/with}}

<!-- smoosh -->
<script src="scripts/top.js"></script>
Expand Down Expand Up @@ -43,6 +43,7 @@
<img alt="" border="0" width="1" height="1" src="http://track.ft.com/track/track.js?javascript=disabled"/>
<img alt="" border="0" width="1" height="1" src="http://stats.ft.com/si/track.gif?WT.js=No"/>
</noscript>
<script>const page = '{{page}}';</script>
<header class="site-header">
<a href="http://www.ft.com/">
<img class="masthead" src="https://image.webservices.ft.com/v1/images/raw/fticon:brand-ft-masthead?source=ft-interactive">
Expand Down
13 changes: 11 additions & 2 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,11 @@ gulp.task('templates', () => {

for (const slug of Object.keys(words)) {
const word = words[slug];
const definitionPageHtml = definitionPageTemplate(word);
const definitionPageHtml = definitionPageTemplate({
trackingEnv: (env === 'production' ? 'p' : 't'),
page: "definition",
word
});

mkdirp.sync(`.tmp/${slug}`);
fs.writeFileSync(`.tmp/${slug}/index.html`, definitionPageHtml);
Expand All @@ -365,11 +369,16 @@ gulp.task('templates', () => {
const mainPageTemplate = Handlebars.compile(fs.readFileSync('client/main-page.hbs', 'utf8'));
const mainPageHtml = mainPageTemplate({
trackingEnv: (env === 'production' ? 'p' : 't'),
page: "main",
homewords,
words,
});
fs.writeFileSync(`.tmp/index.html`, mainPageHtml);

const thanksPageTemplate = Handlebars.compile(fs.readFileSync('client/thanks-page.hbs', 'utf8'));
fs.writeFileSync(`.tmp/thanks.html`, thanksPageTemplate());
const thanksPageHtml = thanksPageTemplate({
trackingEnv: (env === 'production' ? 'p' : 't'),
page: "thanks"
})
fs.writeFileSync(`.tmp/thanks.html`, thanksPageHtml);
});

1 comment on commit 207c289

@sumeetadur
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added trackingEnv variable to all pages

Please sign in to comment.