From 4cac60ff37c852c8118671e7e067d904767f9b97 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Mon, 26 Feb 2018 17:01:11 +0000 Subject: [PATCH] Auto-hyperlink URLs If someone issues a command like #upgrades now Upgrades SIG https://etherpad.openstack.org/p/ffu-ptg-rocky then make the URL a hyperlink so that viewers of the webpage can easily jump to the etherpad to learn about the topic being discussed and make a quick but informed decision whether it's worth them going to that room. To avoid duplicating the word iteration logic, we do this by extending the existing "hashtag" helper; however this widens its scope beyond merely formatting hashtags, so also rename the helper to reflect this. Change-Id: I8e21ab9a1966a09a7b4ec1742eeb578cfd0a3f49 --- html/ptg.html | 4 ++-- html/ptg.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/html/ptg.html b/html/ptg.html index b9fc88a..f88dbc8 100644 --- a/html/ptg.html +++ b/html/ptg.html @@ -31,7 +31,7 @@ {{#if (lookup @root.now track) }} {{track}} - {{#hashtag}}{{lookup @root.now track}}{{/hashtag}} + {{#trackContentLine}}{{lookup @root.now track}}{{/trackContentLine}} {{lookup @root.location track}} {{/if}} @@ -49,7 +49,7 @@ {{track}} {{#each (lookup @root.next track) as |item|}} - {{#hashtag}}{{item}}{{/hashtag}}
+ {{#trackContentLine}}{{item}}{{/trackContentLine}}
{{/each}} diff --git a/html/ptg.js b/html/ptg.js index fdb4ec3..7270c4d 100644 --- a/html/ptg.js +++ b/html/ptg.js @@ -4,13 +4,16 @@ var source = document.getElementById("PTGtemplate").innerHTML; // Handlebars compiles the above source into a template var template = Handlebars.compile(source); -Handlebars.registerHelper('hashtag', function(options) { +Handlebars.registerHelper('trackContentLine', function(options) { var words = options.fn(this).split(" "); var sentence = ""; for (var i = 0; i < words.length; i++) { if (words[i].startsWith("#")) { sentence += '' + words[i].substring(1) + ' '; + } else if (words[i].match(/^https?:\/\//)) { + sentence += '' + + words[i] + ''; } else { sentence += words[i] + " "; }