Skip to content

Commit

Permalink
Added signed example.html
Browse files Browse the repository at this point in the history
  • Loading branch information
blitline-dev committed Mar 3, 2014
1 parent 78f78b3 commit 51daa50
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 2 deletions.
6 changes: 5 additions & 1 deletion blitline_cors.js
Expand Up @@ -38,6 +38,7 @@ Blitline = function() {

if (!errors) {
inProgress = true;
console.dir(JSON.stringify(normalizedJobs));
postCORS(serverUrl + "/job", { json : JSON.stringify(normalizedJobs) }, function(response) {
try {
if (typeof response === "string") {
Expand Down Expand Up @@ -137,7 +138,7 @@ Blitline = function() {
function validateJobs(jobs) {
var errors = [];
_.each(jobs , function(job) {
if (!job.application_id || !job.src) { errors.push("You must have both an application_id and src for each job.");}
if ((!job.application_id && !job.signature) || !job.src) { errors.push("You must have both an application_id and src for each job.");}
if (!job.functions || job.functions.length === 0) { errors.push("You dont have any functions defined for this job."); }
_.each(job.functions , function(blitlineFunction) {
if (!blitlineFunction.name) { errors.push("You are missing a function name"); }
Expand All @@ -150,6 +151,7 @@ Blitline = function() {
}
});
});
console.log("passed validation");
return errors.length > 0 ? errors.join(", ") : null;
}

Expand All @@ -165,8 +167,10 @@ Blitline = function() {
{
try {
// Try using jQuery to POST
console.log("trying jquery", data);
jQuery.post(url, data, callback, type);
} catch(e) {
console.log("Failed jquery");
// jQuery POST failed
var params = '';
var key;
Expand Down
47 changes: 47 additions & 0 deletions example_signed.html
@@ -0,0 +1,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Style-Type" content="text/css">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<title></title>
<script src='http://code.jquery.com/jquery-1.11.0.min.js'></script>
<script src='https://s3.amazonaws.com/web.blitline/underscore-min.js'></script>
<script src='blitline_cors.js'></script>
<script type="text/javascript">
$(document).ready(function() {
// Reminders:
// Public Token can be found on your blitline home page
// Secret can be found on your blitline home page
// Expires is determined by YOU and represents when this signature will NO LONGER work
// Signature is the SHA256 hexdigest of <SECRET> + expires (in the RFC822 ISO string format)
var myAppId = {
"expires" : "Wed, 1 Jan 2014 00:00:00 +0000",
"signature" : "853c511a9ee225d3182bde4151857552a7f3f95d",
"public_token" : "ZlxIi7oLQqnpJhGhPSgIbA"
};

var blitline = new Blitline();
var events = {
completed : function(results, error) {
alert("Job completed:" + JSON.stringify(results));
}
}
var json = { "src" : "http://www.google.com/logos/2011/yokoyama11-hp.jpg", "functions" : [ {"name": "blur", "params" : {"radius" : 0.0, "sigma" : 2.0}, "save" : { "s3" : { "bucket" : "bltemp.shortline", "key" : "myexample.jpg" }, "image_identifier" : "MY_CLIENT_ID" }} ]};

if (typeof myAppId == 'string' || myAppId instanceof String) {
json["application_id"] = myAppId;
}else {
json["expires"] = myAppId["expires"];
json["signature"] = myAppId["signature"];
json["public_token"] = myAppId["public_token"];
}

json = JSON.stringify(json);
console.dir(json);
blitline.submit(json, events);
});
</script>
</head>
<body>
</body>
2 changes: 1 addition & 1 deletion simple.html
Expand Up @@ -10,7 +10,7 @@
<script src='blitline_cors.js'></script>
<script type="text/javascript">
$(document).ready(function() {
var myAppId = "YOUR_APP_ID"
var myAppId = "Jqeu4sS4vDTXDi3EXHjzBw"
if (myAppId == "YOUR_APP_ID") {
alert("You must change YOUR_APP_ID to your Blitline Application ID");
return;
Expand Down

0 comments on commit 51daa50

Please sign in to comment.