mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-10 07:11:53 +00:00
Messages containing links will be rendered as such fixes #24
This commit is contained in:
parent
b56a9a4aad
commit
bdbaeab771
3 changed files with 14 additions and 1 deletions
|
@ -70,6 +70,10 @@ var Chatroom = React.createClass({
|
|||
});
|
||||
|
||||
var ChatMessage = React.createClass({
|
||||
mixins: [
|
||||
ReactAutolink
|
||||
],
|
||||
|
||||
componentDidMount() {
|
||||
this.interval = setInterval(this.forceUpdate.bind(this), 1000);
|
||||
},
|
||||
|
@ -78,6 +82,13 @@ var ChatMessage = React.createClass({
|
|||
clearInterval(this.interval);
|
||||
},
|
||||
|
||||
messageContent: function () {
|
||||
return this.autolink(this.props.message.content, {
|
||||
target: "_blank",
|
||||
rel: "nofollow"
|
||||
});
|
||||
},
|
||||
|
||||
render() {
|
||||
let deleteButton;
|
||||
let currentUser = this.props.currentUser;
|
||||
|
@ -105,7 +116,7 @@ var ChatMessage = React.createClass({
|
|||
{$.timeago(this.props.message.createdAt)}
|
||||
</small>
|
||||
</div>
|
||||
<p>{this.props.message.content}</p>
|
||||
<p>{this.messageContent()}</p>
|
||||
</div>
|
||||
</li>
|
||||
);
|
||||
|
|
1
public/js/autolinker.min.js
vendored
Normal file
1
public/js/autolinker.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("react")):"function"==typeof define&&define.amd?define(["react"],e):"object"==typeof exports?exports.ReactAutolink=e(require("react")):t.ReactAutolink=e(t.React)}(this,function(t){return function(t){function e(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return t[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var r={};return e.m=t,e.c=r,e.p="",e(0)}([function(t,e,r){"use strict";var n=function(t){return t&&t.__esModule?t["default"]:t},o=n(r(2)),u=n(r(1)),a=function(){var t=/((?:https?:\/\/)?(?:(?:[a-z0-9]?(?:[a-z0-9\-]{1,61}[a-z0-9])?\.[^\.|\s])+[a-z\.]*[a-z]+|(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3})(?::\d{1,5})*[a-z0-9.,_\/~#&=;%+?\-\\(\\)]*)/gi,e=function(t,e){return t.slice(0,e.length)===e};return{autolink:function(r){var n=void 0===arguments[1]?{}:arguments[1];return r?r.split(t).map(function(r){var a=r.match(t);if(a){var i=a[0],c=i.split("/");return""!==c[1]&&c[0].length<5?r:o.createElement("a",u({href:e(i,"http")?i:"http://"+i},n),i)}return r}):[]}}};t.exports=a()},function(t,e,r){"use strict";function n(t){if(null==t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}t.exports=Object.assign||function(t,e){for(var r,o,u=n(t),a=1;a<arguments.length;a++){r=arguments[a],o=Object.keys(Object(r));for(var i=0;i<o.length;i++)u[o[i]]=r[o[i]]}return u}},function(e,r,n){e.exports=t}])});
|
|
@ -20,5 +20,6 @@
|
|||
<script src="/js/react-0.13.3.js"></script>
|
||||
<script src="/js/howler.min.js"></script>
|
||||
<script src="/js/lodash.min.js"></script>
|
||||
<script src="/js/autolinker.min.js"></script>
|
||||
<script src="/js/helper.js"></script>
|
||||
</head>
|
Loading…
Reference in a new issue