alexandria-core
Advanced tools
Comparing version 1.0.3 to 1.0.4
128
index.js
@@ -23,2 +23,3 @@ import axios from 'axios'; | ||
Core.IPFSGatewayURL = "http://gateway.ipfs.io/ipfs/"; | ||
Core.issoURL = "https://isso.alexandria.io/"; | ||
@@ -76,3 +77,7 @@ // Define URLS for things we don't control, these likely will change often | ||
try { | ||
files = oip['oip-041'].artifact.storage.files | ||
let tmpFiles = oip['oip-041'].artifact.storage.files; | ||
for (let i = 0; i < tmpFiles.length; i++) { | ||
files.push(tmpFiles[i]) | ||
} | ||
} catch(e) {} | ||
@@ -90,4 +95,18 @@ return files; | ||
Core.Artifact.getTimestamp = function(oip){ | ||
let timestamp = 0; | ||
try { | ||
timestamp = oip['oip-041'].artifact.timestamp | ||
} catch(e) {} | ||
return timestamp; | ||
} | ||
Core.Artifact.getPublisherName = function(oip){ | ||
return oip.publisherName ? oip.publisherName : "Flotoshi"; | ||
let pubName = "Flotoshi"; | ||
try { | ||
pubName = oip.publisherName | ||
} catch(e) {} | ||
return pubName; | ||
} | ||
@@ -184,2 +203,28 @@ | ||
Core.Artifact.getMainFileDisPlay = function(oip, type){ | ||
let disPlay = false; | ||
try { | ||
disPlay = Core.Artifact.getMainPaidFile(oip, type).disPlay; | ||
} catch (e) {} | ||
if (!disPlay) | ||
disPlay = false; | ||
return disPlay | ||
} | ||
Core.Artifact.getMainFileDisBuy = function(oip, type){ | ||
let disBuy = 0; | ||
try { | ||
disBuy = Core.Artifact.getMainPaidFile(oip, type).disBuy; | ||
} catch (e) {} | ||
if (!disBuy) | ||
disBuy = false; | ||
return disBuy | ||
} | ||
Core.Artifact.getThumbnail = function(oip){ | ||
@@ -192,3 +237,3 @@ let thumbnail; | ||
for (let i = 0; i < files.length; i++){ | ||
if (files[i].type === "Image" && files[i].sugPlay === 0 && files[i].fsize < Core.Artifact.maxThumbnailSize && !thumbnail){ | ||
if (files[i].type === "Image" && files[i].subtype === "cover" && !files[i].sugPlay && files[i].fsize < Core.Artifact.maxThumbnailSize && !thumbnail){ | ||
thumbnail = files[i]; | ||
@@ -331,2 +376,32 @@ } | ||
Core.Comments = {}; | ||
Core.Comments.get = function(hash, callback){ | ||
Core.Network.getCommentsFromISSO("/browser/" + hash, function(results){ | ||
console.log(results); | ||
callback(results); | ||
}) | ||
} | ||
Core.Comments.add = function(hash, comment, callback){ | ||
Core.Network.postCommentToISSO("/browser/" + hash, {text: comment}, function(results){ | ||
console.log(results) | ||
callback(results); | ||
}) | ||
} | ||
Core.Comments.like = function(id, callback){ | ||
Core.Network.likeISSOComment(id, function(results){ | ||
console.log(results) | ||
callback(results); | ||
}) | ||
} | ||
Core.Comments.dislike = function(id, callback){ | ||
Core.Network.dislikeISSOComment(id, function(results){ | ||
console.log(results) | ||
callback(results); | ||
}) | ||
} | ||
Core.Data = {}; | ||
@@ -412,3 +487,3 @@ | ||
onData(Core.util.buildIPFSURL(hash)); | ||
//onData(Core.util.buildIPFSURL(hash)); | ||
@@ -440,3 +515,5 @@ try { | ||
}) | ||
} catch (e){ } | ||
} catch (e){ | ||
onData(Core.util.buildIPFSURL(hash)); | ||
} | ||
} | ||
@@ -470,2 +547,43 @@ | ||
Core.Network.getCommentsFromISSO = function(uri, callback){ | ||
axios.get(Core.issoURL + "?uri=" + encodeURIComponent(uri)).then(function(results){ | ||
callback(results); | ||
}).catch(function (error) { | ||
// If there is an error, it is likely because the artifact has no comments, just return an empty array. | ||
callback([]); | ||
}); | ||
} | ||
Core.Network.postCommentToISSO = function(uri, comment, callback){ | ||
var instance = axios.create(); | ||
instance.post(Core.issoURL + "new?uri=" + encodeURIComponent(uri), comment, {headers: {"Content-Type": "application/json"}, transformRequest: [(data, headers) => { | ||
delete headers.common.Authorization | ||
return data }] | ||
}).then(function(results){ | ||
callback(results); | ||
}).catch(function (error) { | ||
// If there is an error, it is likely because the artifact has no comments, just return an empty array. | ||
callback({error: true}); | ||
}); | ||
} | ||
Core.Network.likeISSOComment = function(id, callback){ | ||
axios.post(Core.issoURL + "id/" + id + "/like", {}).then(function(results){ | ||
callback(results); | ||
}).catch(function (error) { | ||
// If there is an error, it is likely because the artifact has no comments, just return an empty array. | ||
callback({error: true}); | ||
}); | ||
} | ||
Core.Network.dislikeISSOComment = function(id, callback){ | ||
axios.post(Core.issoURL + "id/" + id + "/dislike", {}).then(function(results){ | ||
callback(results); | ||
}).catch(function (error) { | ||
// If there is an error, it is likely because the artifact has no comments, just return an empty array. | ||
callback({error: true}); | ||
}); | ||
} | ||
Core.util = {}; | ||
@@ -472,0 +590,0 @@ |
{ | ||
"name": "alexandria-core", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "The core module of Alexandria!", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22435
505