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
This commit is contained in:
parent
b6ea7e45a2
commit
4cac60ff37
|
@ -31,7 +31,7 @@
|
|||
{{#if (lookup @root.now track) }}
|
||||
<tr>
|
||||
<td class="col-sm-1"><span class="label label-primary {{track}}">{{track}}</span></td>
|
||||
<td>{{#hashtag}}{{lookup @root.now track}}{{/hashtag}}</td>
|
||||
<td>{{#trackContentLine}}{{lookup @root.now track}}{{/trackContentLine}}</td>
|
||||
<td>{{lookup @root.location track}}</td>
|
||||
</tr>
|
||||
{{/if}}
|
||||
|
@ -49,7 +49,7 @@
|
|||
<td class="col-sm-1"><span class="label label-primary {{track}}">{{track}}</span></td>
|
||||
<td>
|
||||
{{#each (lookup @root.next track) as |item|}}
|
||||
{{#hashtag}}{{item}}{{/hashtag}} <br/>
|
||||
{{#trackContentLine}}{{item}}{{/trackContentLine}} <br/>
|
||||
{{/each}}
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -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 += '<span class="label label-info">'
|
||||
+ words[i].substring(1) + '</span> ';
|
||||
} else if (words[i].match(/^https?:\/\//)) {
|
||||
sentence += '<a href="' + words[i] + '">'
|
||||
+ words[i] + '</a>';
|
||||
} else {
|
||||
sentence += words[i] + " ";
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue