embed images / vids from local TL

This commit is contained in:
fenwick67 2017-05-01 23:08:23 -05:00
parent 54dc7a5be0
commit 09a09eb65d
1 changed files with 28 additions and 18 deletions

View File

@ -75,7 +75,6 @@ function buildUp(jsonObj,opts){
// assign opts to the obj
jsonObj.opts = opts||{};
console.log(opts);
// iterate through the items
jsonObj.items = jsonObj.items.filter(function(item){
@ -94,29 +93,40 @@ function buildUp(jsonObj,opts){
// get enclosures
item.enclosures = [];
if (item["activity:object"] && item["activity:object"].link){
var links = item["activity:object"].link;
function findEnclosure(link){
if (!link['@']){return;} // avoid keyerror
var rel = link['@'].rel;
var href = link['@'].href;
if (rel == 'enclosure'){
item.enclosures.push({
url:href,
type:link['@'].type||''
});
}
}
// find them in the item's links
if (item['atom:link']){
var links = item['atom:link'];
if (!isArray(links) && typeof links == 'object'){
links = [links];
}else if (!isArray(links)){
links = [];// not an object or array.
links = [];
}
links.forEach(findEnclosure);
}
links.forEach(function (link){
if (!link['@']){return;} // avoid keyerror
var rel = link['@'].rel;
var href = link['@'].href;
if (rel == 'enclosure'){
item.enclosures.push({
url:href,
type:link['@'].type||''
});
}
});
// find them in activity:object
if (item["activity:object"] && item["activity:object"].link){
var enclosureLinks = item["activity:object"].link;
if (!isArray(enclosureLinks) && typeof enclosureLinks == 'object'){
enclosureLinks = [enclosureLinks];
}else if (!isArray(enclosureLinks)){
enclosureLinks = [];// not an object or array.
}
enclosureLinks.forEach(findEnclosure);
}
}
// get author info
@ -136,7 +146,7 @@ function buildUp(jsonObj,opts){
if (!isArray(authorLinks) && typeof authorLinks == 'object'){
authorLinks = [authorLinks];
}else if ( !isArray(authorLinks) ){
authorLinks = [];// not an object or string. WTF?
authorLinks = [];// not an object or string.
}
authorLinks.forEach(function(link){// todo: guard against authorLinks not being an array