p-v-o-s / infragram-js

A web application for producing NDVI and other composites from DIY multispectral cameras
http://infragram.org
GNU General Public License v2.0
25 stars 11 forks source link

Share on PublicLab.org button #63

Open jywarren opened 10 years ago

jywarren commented 10 years ago

I tried using:

window.location = "http://publiclab.org/post?i="+getCurrentImage()

however the request is too long. We need to do it via POST, perhaps

 $('body').append("<form method='post' id='share-publiclab' action='http://publiclab.org/post'><input name='i' value='"+getCurrentImage()+"'/></form>");$('#share-publiclab').submit()

But this seems to be choking on the "filename":

Completed 500 Internal Server Error in 216ms

ActionView::Template::Error (undefined method `length' for nil:NilClass):
2:
3:   <h3 style="margin-top:0;" class="hidden-phone">Main image</h3>
4:
5:   <img class="img-rounded" id="leadImage" <% unless (@node && @node.main_image) || params[:main_image] || params[:i] %>style="display:none;" <% end %>src="<% if @node && @node.main_image %><%= @node.main_image.path(:default) %><% elsif params[:main_image] && Image.find_by_id(params[:main_image]) %><%= Image.find_by_id(params[:main_image]).path %><% elsif @image %><%= @image.path(:default) %><% end %>" />
6:   <div class="side-dropzone" id="side-dropzone">
7:     <p class="prompt"><span class="hidden-phone">Drag &amp; drop to add an image, or </span><span class="fileinput-button"><a><i class="icon icon-upload visible-phone pull-left" style="padding-right:6px;"></i> choose an image</a><input tabindex="3" id="side-fileinput" type="file" name="image[photo]" style="height:4em;"></span></p>
8:     <br class="hidden-phone" />
app/models/image.rb:31:in `filetype'
app/models/image.rb:27:in `is_image?'
app/models/image.rb:35:in `path'
app/views/editor/_main_image.html.erb:5:in `_app_views_editor__main_image_html_erb__439734243163691178_53754740'

I'm guessing this is because the data_url does not have a filename in its url string. With some tweaking i think we could work around this...

jywarren commented 9 years ago

Been chipping away at this on the publiclab.org codebase here: https://github.com/publiclab/plots2/pull/201