Skip to content

Instantly share code, notes, and snippets.

@ArunGupta25
Created June 14, 2012 21:41
Show Gist options
  • Save ArunGupta25/2933121 to your computer and use it in GitHub Desktop.
Save ArunGupta25/2933121 to your computer and use it in GitHub Desktop.
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
<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