-
Notifications
You must be signed in to change notification settings - Fork 6
Website : How does it work?
If you want to contribute to our project, you may need some information about how the system works. We tried to structure and comment our files as much as possible. If you still find some files difficult to understand, please contact us!
This is the first page the user arrives on. He can look for Point Of Interests (POI) around his own position or around a certain spot (address or monument). The user is located thanks to the navigator.geolocation properties (we're still experiencing trouble with Firefox using this method). Datas from the form and GPS coordinates of the user are sent to map.php using POST datas.
The heart of our system! 😉
If the user used geolocation around him, coordinates are in the POST datas. Of course, we check it to make sure the navigator supports geolocation and to be sure we can go further in the code. If not, the user is redirected to index.php. If the user chose to find POI around a special destination, we extract GPS coordinates of this location thanks to OpenStreetMaps nominatim system. Please refer to the source code for further information.
That part is simple: the website contacts WikiJourney API. The input is typically GPS coordinates, range and number maximum of POI. It also sends the current language of the Website, only to have data matching the user's language. Once the JSON is decoded and errors are checked, it's sent to the JS script.
The map is displayed using MapBox. It's an OpenSource project which allows the integration of OSM map in a website in a very easy way. A marker is created for every POI we can find in the list. There's also a marker for the user's position. A click on a marker opens a Pop-up window which propose to add the POI in the cart.
The cart is basically a JS array, and its display is refreshed every time an operation is made on it.
- Adding a POI to the cart
- Reorganizing POI: there are some algorithms to switch elements from the cart array.
- Deleting a POI: basically slicing the Array
- Clearing POI lists
26-07-2015: When the "Export" button is clicked, the array is sent in the JSON format to another page. For the moment, it does absolutely nothing, but it's ready.
If there are WikiVoyage guides in the WikiJourney API return, we display them. It's as simple as that.
All of the website's text is stored in PHP files, which are included upon the page load. For instance, if the user's language is french, then the file loaded is fr.php. All languages files have the same structure, with same constant names, who are linked to text on the HTML pages. So, it's easy to translate the site in an other language: you just make a copy of en.php then replace all English content with your language, change its name, and commit it.
Note: We sometimes add functions. More references are thus needed in the language file. If developers can't speak (for instance) Russian or Italian, they will add those references in English. Please come back often to see if the language file you created contains new references.
Note 2: You can improve and correct the English translation of all documentation and comments if you think it is inadequate. We use English to be understood by the community; however our developer team does not count any native English speaker and we may make spelling mistakes.
The code is in include/haut.php. It is fully secured - that means it can only change to languages mentioned in the code. Once you've created a new language page, please add a link on haut.php page, and also on action.php. Thanks! The user's language is stored in a cookie on his computer. That's the only cookie WikiJourney currently uses.