mirror of
https://github.com/thelounge/thelounge
synced 2025-02-18 06:08:26 +00:00
Linkify urls in chat
This commit is contained in:
parent
8049e93703
commit
98331decd6
4 changed files with 2012 additions and 5 deletions
|
@ -100,7 +100,7 @@
|
||||||
<div class="message {{type}}">
|
<div class="message {{type}}">
|
||||||
<span class="time">{{time}}</span>
|
<span class="time">{{time}}</span>
|
||||||
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
||||||
<span class="text">{{type}} {{text}}</span>
|
<span class="text">{{type}} {{{autoLink text}}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
@ -125,7 +125,7 @@
|
||||||
<div class="message {{type}}">
|
<div class="message {{type}}">
|
||||||
<span class="time">{{time}}</span>
|
<span class="time">{{time}}</span>
|
||||||
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
<a href="{{user}}" class="user">{{mode}}{{user}}</a>
|
||||||
<span class="text">{{type}} {{text}}</span>
|
<span class="text">{{type}} {{{autoLink text}}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/messages}}
|
{{/messages}}
|
||||||
</script>
|
</script>
|
||||||
|
@ -136,6 +136,7 @@
|
||||||
<script src="/js/lib/jquery.cookie.js"></script>
|
<script src="/js/lib/jquery.cookie.js"></script>
|
||||||
<script src="/js/lib/jquery.scrollGlue.js"></script>
|
<script src="/js/lib/jquery.scrollGlue.js"></script>
|
||||||
<script src="/js/lib/bootstrap.js"></script>
|
<script src="/js/lib/bootstrap.js"></script>
|
||||||
|
<script src="/js/lib/URI.js"></script>
|
||||||
<script src="/js/chat.js"></script>
|
<script src="/js/chat.js"></script>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -14,7 +14,7 @@ $(function() {
|
||||||
tpl[id] = tpl[id] || Handlebars.compile($(id).html());
|
tpl[id] = tpl[id] || Handlebars.compile($(id).html());
|
||||||
return tpl[id](json);
|
return tpl[id](json);
|
||||||
}
|
}
|
||||||
|
|
||||||
function event(type, json) {
|
function event(type, json) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
|
||||||
|
@ -213,4 +213,11 @@ $(function() {
|
||||||
.removeClass("active")
|
.removeClass("active")
|
||||||
.end();
|
.end();
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Handlebars.registerHelper("autoLink", function(text) {
|
||||||
|
var text = Handlebars.Utils.escapeExpression(text);
|
||||||
|
return URI.withinString(text, function(url) {
|
||||||
|
return "<a href='" + url + "' target='_blank'>" + url + "</a>";
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
2000
client/js/lib/URI.js
Normal file
2000
client/js/lib/URI.js
Normal file
File diff suppressed because it is too large
Load diff
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue