mirror of
https://github.com/vale981/Vulcan
synced 2025-03-07 02:21:43 -05:00
add util for adding "http" to URL; add isVideo posts helper
This commit is contained in:
parent
1f14bcc08b
commit
3b4ee38f99
4 changed files with 21 additions and 12 deletions
|
@ -21,11 +21,7 @@ serveAPI = function(limitSegment){
|
||||||
properties.domain = Telescope.utils.getDomain(url);
|
properties.domain = Telescope.utils.getDomain(url);
|
||||||
|
|
||||||
if (post.thumbnailUrl) {
|
if (post.thumbnailUrl) {
|
||||||
// add http: if missing
|
properties.thumbnailUrl = Telescope.utils.addHttp(post.thumbnailUrl);
|
||||||
if (post.thumbnailUrl.substring(0, 5) !== "http:" && post.thumbnailUrl.substring(0, 6) !== "https:") {
|
|
||||||
post.thumbnailUrl = "http:"+post.thumbnailUrl;
|
|
||||||
}
|
|
||||||
properties.thumbnailUrl = post.thumbnailUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var twitterName = Users.getTwitterNameById(post.userId);
|
var twitterName = Users.getTwitterNameById(post.userId);
|
||||||
|
|
|
@ -169,6 +169,14 @@ Telescope.utils.invitesEnabled = function() {
|
||||||
return Settings.get("requireViewInvite") || Settings.get("requirePostInvite");
|
return Settings.get("requireViewInvite") || Settings.get("requirePostInvite");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// add http: if missing
|
||||||
|
Telescope.utils.addHttp = function (url) {
|
||||||
|
if (url.substring(0, 5) !== "http:" && url.substring(0, 6) !== "https:") {
|
||||||
|
url = "http:"+url;
|
||||||
|
}
|
||||||
|
return url;
|
||||||
|
};
|
||||||
|
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
// String Helper Functions //
|
// String Helper Functions //
|
||||||
/////////////////////////////
|
/////////////////////////////
|
||||||
|
@ -228,5 +236,4 @@ Telescope.getNestedProperty = function (obj, desc) {
|
||||||
var arr = desc.split(".");
|
var arr = desc.split(".");
|
||||||
while(arr.length && (obj = obj[arr.shift()]));
|
while(arr.length && (obj = obj[arr.shift()]));
|
||||||
return obj;
|
return obj;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
|
@ -92,3 +92,12 @@ Posts.checkForSameUrl = function (url, currentUser) {
|
||||||
Posts.current = function () {
|
Posts.current = function () {
|
||||||
return Posts.findOne(Router.current().data().post._id);
|
return Posts.findOne(Router.current().data().post._id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check to see if a post is a link to a video
|
||||||
|
* @param {Object} post
|
||||||
|
*/
|
||||||
|
Posts.isVideo = function (post) {
|
||||||
|
return post.media && post.media.type === "video";
|
||||||
|
};
|
||||||
|
Posts.helpers({isVideo: function () {return Posts.isVideo(this);}});
|
||||||
|
|
|
@ -30,11 +30,8 @@ servePostRSS = function(view, url) {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (post.thumbnailUrl) {
|
if (post.thumbnailUrl) {
|
||||||
// add http: if missing
|
var url = Telescope.utils.addHttp(post.thumbnailUrl);
|
||||||
if (post.thumbnailUrl.substring(0, 5) !== "http:" && post.thumbnailUrl.substring(0, 6) !== "https:") {
|
feedItem.custom_elements = [{"imageUrl":url}, {"content": url}];
|
||||||
post.thumbnailUrl = "http:"+post.thumbnailUrl;
|
|
||||||
}
|
|
||||||
feedItem.custom_elements = [{"imageUrl": post.thumbnailUrl}, {"content": post.thumbnailUrl}];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
feed.item(feedItem);
|
feed.item(feedItem);
|
||||||
|
|
Loading…
Add table
Reference in a new issue