Created
June 14, 2012 21:41
-
-
Save ArunGupta25/2933121 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def aviarycreate | |
@photo = Photo.new | |
@photo.user_id = current_user.id if current_user | |
@photo.remote_image_url = params[:url] | |
@photo.save | |
respond_to do |format| | |
format.json { render json: @photo } | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://feather.aviary.com/js/feather.js"></script> | |
<script type="text/javascript"> | |
var featherEditor = new Aviary.Feather({ | |
apiKey: '59b170820', | |
apiVersion: 2, | |
tools: 'all', | |
appendTo: '', | |
minimumStyling: true, | |
//postUrl: 'http://localhost:3000/photos', | |
onSave: function(imageID, newURL) { | |
//var img = document.getElementById(imageID); | |
//img.src = newURL; | |
postImage(imageID, newURL); | |
featherEditor.close(); | |
return false; | |
} | |
}); | |
function launchEditor(id, src) { | |
featherEditor.launch({ | |
image: id, | |
url: src | |
}); | |
return false; | |
} | |
function postImage(imageID, newURL) { | |
$.ajax({ | |
type: 'POST', | |
url: '/aviarycreate', | |
data: { url : newURL}, | |
headers: { | |
'X-Transaction': 'POST Example', | |
'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content') | |
}, | |
success: function(msg) { | |
var id = msg.id; | |
var url = '/share?id=' + id; | |
$.ajax({ | |
type: "get", | |
url: url, | |
data: $(this).serializeArray(), | |
success: function(data) { | |
$.fancybox(data); | |
} | |
}) | |
} | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment