📜 ⬆️ ⬇️

Background Dating - in search of people with whom it is interesting to talk

So, I have long wanted to write a dating site, but at the same time I didn’t want it to be the same as hundreds of others. As a result, it became clear that this should not be a dating site, but rather a place where you can find interesting people. On the other hand, I did not want to be limited to any particular category of people, therefore the option of creating a thematic site was not considered. The result is that you can see the link . Immediately, you can pay attention to the fact that it is not proposed to fill in any personal data. Not because they need to be filled out after registration, but because there are no profiles on the site.

The questionnaire is not because they have too large restrictions. It is usually proposed to set a standardized set of parameters with the same standardized response options. But as soon as I want to indicate something else or respond in some other way, you are faced with the fact that you have not foreseen such a possibility (or it does not work the way we would like).

Under Habrakat I will talk about what is on this site instead of the questionnaires, and also, of course, I will write about some technical details (wherever without it).
')
By the way, the description is in the “advertising” style:

Have you long wanted to find a girlfriend who knows how to program in Brainfuck? Or is it important for you to be a supporter of adaptive and semantic layout? Or maybe you want to get acquainted with the one who can easily tell about the differences between a microkernel and a monolithic one, but at the same time it is still a dancer?

Now you have such an opportunity - unless, of course, she has already registered for Background Dating. :)

Instead of profiles on the site have key phrases. Each key phrase is a short first-person statement.

Here are some examples:


Each user can have any number of key phrases, and any keyword phrase can be used in the search. Also, users have the opportunity to search for several key phrases of interest at once - in this case, only people who have added all the specified key phrases are displayed in the results (respectively, if the search result is empty, then you can try to remove some of the specified key phrases from request).

When you enter key phrases, auto-substitution works, respectively, if someone similar has already added something similar, then it is suggested to select one of the key phrases in the list.

Since key phrases can be about anything, you can find, respectively, a variety of people. If suddenly a person is interesting, who, for example, clearly knows why a decanter is used, then you can try to find such ones.

Thus, with a sufficient number of people, each user has the opportunity to get acquainted with those who are of the greatest interest to him, and whose background he sympathizes with most.

The site works, by the way, on Django (Python language). Web sockets ( RFC 6455 ) are used to transmit data about private messages. When the tabs are minimized (exception - chat), the connection to the server is temporarily closed so as not to overload the Internet channel - this is implemented through the HTML5 Visibility API , namely using the well-known iskin Visibility.js .

On the server side, web socket support is implemented using the Tornado asynchronous non-blocking server. If someone wants, ready to share the source code and information about how to deploy it - there is, in principle, nothing complicated. To send messages between Django and Tornado (and also to store some data) Redis is used, which has excellent pub / sub support. Django uses the standard redis-py client, and the Tornado asynchronous client brükva .

To validate the file (photo) on the client side, use the File API . Photo resolution, however, is not checked - it can be done , but so far I have decided not to complicate it, especially since everything is rechecked on the server. But the type and size of the file are checked, which is also not bad. However, I was surprised by one interesting fact - the fact is that according to the File API specification, the type attribute of an object representing a file must contain the MIME type of the file, according to RFC 2046 , but browsers do not use the actual file type, but generate it based on the existing extensions.

In other words, take an MP3 file, say, file.mp3. Let's look at MIME with the file command:

$ file --mime-type file.mp3 file.mp3: audio/mpeg 

Now remove the extension, and try again:

 $ file --mime-type file file: audio/mpeg 

Same. Let's try another extension.

 $ file --mime-type file.jpg file.jpg: audio/mpeg 

Similarly.

But web browsers have a different opinion - in the first case, files [0] .type contains the string audio / mpeg (which is expected), in the second case there is an empty string, and in the third case, image / jpeg. Again, this is not critical, because it is rechecked on the server, but still a bit surprising. By the way, if you really want to make the file type checked "for real", then this can be done manually via FileReader. Maybe I'll do it later.

Another great technology I decided to use here is Web Storage . At first, Web Storage technology was part of the HTML5 specification, but was later described in a separate specification. With the help of it, the site saves the registration form data in the local storage of the browser (localStorage) - right when the user completes it. That is, if the user, for example, has already indicated some key phrases, and was about to register, and then suddenly closed the tab (or the browser, or the computer turned off at all), then when he logs back into the site, he will not have to add again These key phrases - they will be automatically downloaded from the local storage and will appear in the form.

Also, the site uses an adaptive layout, and therefore it can be used from mobile phones, tablets and netbooks - the main thing is that there is a modern browser (by the way, the default browser in Android 4.2, unfortunately, does not support everything yet, but on the other hand under Android there is Firefox, Opera Mobile and Chrome, where everything is fine).

If anyone is interested in any other technical details (for example, server validation and crop photos, or I want to discuss authorization by email in Django and changes in version 1.5), I can tell you about them, for example, in personal correspondence.

And, of course, if there are any ideas on how to make using the site better / easier / more convenient, I will be very happy to hear them in the comments. By the way, I have some ideas of what, most likely, it will be quite interesting to add, and if someone wants, I can tell you about them in advance. Again, if someone has a desire to join the development (at the moment only I work on this site) - write.

Have a nice day and interesting dating. :)

Source: https://habr.com/ru/post/159693/


All Articles