fixed #113
This commit is contained in:
parent
9f6c9f9131
commit
f4c72da843
2 changed files with 83 additions and 12 deletions
|
@ -147,12 +147,6 @@ p {
|
||||||
}
|
}
|
||||||
|
|
||||||
.images img {
|
.images img {
|
||||||
border-radius: 5px;
|
|
||||||
max-height: 75px;
|
|
||||||
margin-right: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.images img.photo {
|
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
max-height: inherit;
|
max-height: inherit;
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
|
@ -160,6 +154,10 @@ p {
|
||||||
box-shadow: 0 0 1px black;
|
box-shadow: 0 0 1px black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.images img.photo {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.data {
|
.data {
|
||||||
margin-left: 62px;
|
margin-left: 62px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -256,6 +256,8 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.parseForMedia(text, template.images);
|
||||||
|
|
||||||
text = text.escapeHTML().replace(/\n/g, "<br>");
|
text = text.escapeHTML().replace(/\n/g, "<br>");
|
||||||
|
|
||||||
var entities = [status.entity];
|
var entities = [status.entity];
|
||||||
|
@ -263,9 +265,8 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
entities.push(mention.entity)
|
entities.push(mention.entity)
|
||||||
});
|
});
|
||||||
|
|
||||||
template.message.innerHTML = this.replaceUsernamesWithLinks(
|
var hash = /(^|\s)(#)(\w+)/ig;
|
||||||
this.replaceURLWithHTMLLinks(text, entities, template.message)
|
template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message).replace(hash, "$1$2<a href='https://skate.io/search?q=%23$3'>$3</a>");
|
||||||
);
|
|
||||||
|
|
||||||
if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
if (status.type == "https://tent.io/types/post/photo/v0.1.0") {
|
||||||
|
|
||||||
|
@ -799,9 +800,81 @@ function(jQuery, Paths, URI, HostApp, Cache) {
|
||||||
return URI.withinString(text, callback);
|
return URI.withinString(text, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.prototype.replaceUsernamesWithLinks = function(text, mentions) {
|
Core.prototype.parseForMedia = function(text, images) {
|
||||||
var hash = /(^|\s)(#)(\w+)/ig;
|
|
||||||
return text.replace(hash, "$1$2<a href='https://skate.io/search?q=%23$3'>$3</a>");
|
var words = text.split(" ");
|
||||||
|
|
||||||
|
for (var i = 0; i < words.length; i++) {
|
||||||
|
|
||||||
|
var word = words[i];
|
||||||
|
|
||||||
|
if (word.startsWith("http")) {
|
||||||
|
|
||||||
|
var src = null;
|
||||||
|
|
||||||
|
if (word.startsWith("http") && (word.endsWith(".jpg") || word.endsWith(".jpeg") || word.endsWith(".gif") || word.endsWith(".png"))) {
|
||||||
|
|
||||||
|
src = word;
|
||||||
|
|
||||||
|
} else if(word.startsWith("http://youtube.com/") || word.startsWith("http://www.youtube.com/") || word.startsWith("https://youtube.com/") || word.startsWith("https://www.youtube.com/")) {
|
||||||
|
|
||||||
|
var v = Paths.getUrlVars(word)["v"];
|
||||||
|
if (v) src = "http://img.youtube.com/vi/" + v + "/0.jpg";
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://youtu.be/") || word.startsWith("https://youtu.be/")) {
|
||||||
|
|
||||||
|
var v = word.replace(/https?:\/\/youtu\.be\//, "");
|
||||||
|
src = "http://img.youtube.com/vi/" + v + "/0.jpg";
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://twitpic.com/") || word.startsWith("https://twitpic.com/")) {
|
||||||
|
|
||||||
|
src = "http://twitpic.com/show/thumb/" + word.substring("http://twitpic.com/".length);
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://yfrog") || word.startsWith("https://yfrog")) {
|
||||||
|
|
||||||
|
src = word + ":medium"
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://instagr.am/p/") || word.startsWith("http://instagram.com/p/") || word.startsWith("https://instagr.am/p/") || word.startsWith("https://instagram.com/p/")) {
|
||||||
|
|
||||||
|
src = word + "media?size=l";
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://cl.ly/") || word.startsWith("https://cl.ly/")) {
|
||||||
|
|
||||||
|
var v = word.replace(/https?:\/\/cl\.ly\//, "");
|
||||||
|
src = "http://thumbs.cl.ly/" + v;
|
||||||
|
|
||||||
|
} else if (word.startsWith("http://vimeo.com/") || word.startsWith("http://vimeo.com/")) {
|
||||||
|
|
||||||
|
var video_id = word.replace(/https?:\/\/vimeo\.com\//, "");
|
||||||
|
|
||||||
|
var a = document.createElement("a");
|
||||||
|
a.href = word;
|
||||||
|
var img = document.createElement("img");
|
||||||
|
a.appendChild(img);
|
||||||
|
images.appendChild(a);
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type:'GET',
|
||||||
|
url: 'http://vimeo.com/api/v2/video/' + video_id + '.json',
|
||||||
|
dataType: 'json',
|
||||||
|
success: function(data) {
|
||||||
|
img.src = data[0].thumbnail_large;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (src) {
|
||||||
|
var a = document.createElement("a");
|
||||||
|
a.href = word;
|
||||||
|
var img = document.createElement("img");
|
||||||
|
img.src = src;
|
||||||
|
a.appendChild(img);
|
||||||
|
images.appendChild(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.prototype.replyTo = function(entity, status_id, mentions, is_private) {
|
Core.prototype.replyTo = function(entity, status_id, mentions, is_private) {
|
||||||
|
|
Reference in a new issue