Django - Preview uploaded picture prior to deciding to save - django

Like the title suggested, I want to implement a two-steps picture uploading mechanism.
User selects a picture to upload and
click on "Upload". Once the server
receives the request that contains
the picture, it would save the
picture in a temporary location, on
disk or memory, and the resize it to
a standard size, if needed. The
server then renders a new response
for the user to preview the uploaded
picture.
After previewing the picture, the user needs to click on "Save" to confirm for the server. The server then moves the picture from the temporary location to a permanent one and updates the corresponding entry in the DB.
What's a good way to implement this? What are some of the apps out there that might be able to help me? Thanks.

I would suggest either rolling your own (you might find it surprisingly easy, start with reading the docs on forms) or customizing django-photologue or django-filebrowser.

Related

Getting the specific data from a web page with boost/asio

I am learning boost/asio. I can do an endpoint, active and passive sockets. Now I want to write something like a simple client application, which will get specific data from web pages.
So I have few questions about that:
If I have a done an socket, which is related with a web page, how can specify some content on the page. For example, I want to get an image. There are many images on the page. Not only images. I want to identify specific image. How can i do that?(may be and "id" from html or some how else).
After that I want to get that specific image on my PC. How can I download it and save it?
If it is not image, if I want to work with audio file, video file, text, hyperlink and e.t.c. How to generalize it for any type of content?
How can I follow links on web page?
You also may use boost/beast in answer for this question.
offtop
(cpp is not good idea for dealing with that stuff, I know that)

Django handling automatic data creation through URL's

hello guys hopefully you guys are willing to work with a newbie I'm working in django and handling a google map (in jscript) which upon displaying a marker I have set a link that is clickable that opens a django url passing data regarding the location of that marker. If that data does not exist in the database I have created a definition in my view that does a check and populates the database with that data if it does not exist. Now the issue here is that what ever you type in for the url parameters ends up becoming populated in the database since there is nothing to validate it against regardless of whether you click in the google map or not. Now what I was looking to do was limit this database addition strictly to when a user clicks on a google map link, what would you guys recommend?
ajax, sessions etc... ? and how to go about it an example per se?
It would be good to have more info.
As a general rule, the http GET method shouldn't be used to change data. In this case, use a POST request, probably through AJAX.

How to develop a button for followers of a web site

I apologize for my English it is not very good.
I am developing a website that will have own followers.
I need to create a button by followers such as facebook, twitter or google plus buttons.
Thank you for any information that will allow me to begin to develop the button next to the platform.
Thank you
First, your English is fair enough. For creating your own follow button you will have to have an image that will be displayed on your website. When someone clicks on that button, your webapp should be able to know who clicked it and your should be able to remember that user in future as well. So first you will have users to register on your website (like facebook and twitter) for unique identification of each user.
Next, for remembering that a particular user is following your website you need to persist some information about that user. The obvious approach is having a database table to store the information. For instance you can have IS_FOLLOWING column in your USER table
But there are some considerations. First, the user must remain on the same page or be able to continue his activity even after cicking the follow button. For example, if the user is filling some form then his data should remain intact even after clicking the follow button. If the user is directed to some other page, he might lose information.
Second, database operations are costly. So you need to use them wisely.
One approach that I could think of is having AJAX do the work. If you want to learn AJAX you can visit this website and for AJAX database operations this one will be helpful.
Ajax will do all the work in background and both the problems mentioned above will be addressed. I hope this was helpful.

HTML5 Canvas to Facebook

I've made a basic HTML5/JS comic creation tool that uses the canvas element.
I want users to be able to upload their comics via the Facebook API.
I don't believe Facebook allows posting images in the form of base64 strings from the canvas.toDataURI() method, and don't want to use my own server to convert these images & temporarily store them.
What's the best way to go about this? Possibilities I've wondered about: Convert canvas to blob? Store blob via web service (if so, suggestions?) Upload blob directly to Facebook? (Is that possible?)
I don’t see why this should not be possible doing a „normal” upload. You can create a new photo for a user by posting to PROFILE_ID/photos, with a source parameter of type multipart/form-data.
So first thing I’d try is getting the picture info from the canvas object into a „normal” form (writing it into a input element in the right format(?)), and sending that to Facebook. If this step succeeds, I’d see if jQuery or some other lib’s form.serialize method can build requests of type multipart/form-data. If that’s also possible, then there should be no further problem in taking the data in that format and posting it using FB.api (although you might want to tell your users to be patient, because that might take a while).
Can’t tell for sure if this’ll work, but I’d give it a try.
Facebook partners with Heroku for free app hosting, you can use it as the temporary server.

Facebook like button - how to prevent activity stream from getting into the user's wall?

Can someone please help me out as to how I can completely prevent the user's activity stream from posting back into their wall after they liked a linked? Because, I really find that to be annoying. Afterall, mine is an application that needs to be integrated into an image gallery viewer serving more than 7.5K photos each with its own like button.
If this seems impossible, is there a way to specifically set an image as thumbnail, description, etc as is with the cases of feed and send buttons?
Because, my application is purely dynamic in nature built out of 100% Javascript where more than 80% of its contents are generated by using Ajax calls under a static single URL.
As a result, the like button activity stream always end up pulling the wrong image and descriptions than desired(but this is not so for feed and send buttons),
Thank you
No, you won't have control over not sending items to peoples activity feeds when they click like, unless your domain gets blocked for spam. You would need to create a dynamic url or hashbang url for each independent image and when those images are requested the page hosting it would need to have the proper open graph meta tags sets for thumbnail image, description, etc. Then for each like button in the gallery, you would need to set the href property to this url.