📜 ⬆️ ⬇️

Cards for all, for nothing

Programmers are rare people. We can do absolutely everything, but the Internet responds with a gaping void, where you have to do absolutely everything. Especially if you live in non-core communities. Requests from all sides, here you need to patch, there is a plugin to finish, and no one but you. This story is about one of these spaces, which I had hoped to close in a week, and that week everything goes on. In the program: road construction and cyclists, a site for exchanging maps is better than Yandex, osmery without osma, plugin architecture in forum engines and interactive maps right in Habré.


Fifty fourth kilometer

I am interested in many. Once I drove Friday night bike rides, now I am helping people understand that OpenStreetMap is the best map in the world, and I also follow the “Projects of St. Petersburg” forum for road construction in the city and region. The federal budget means news every day: they blocked and unearthed there, an inconvenient transition was erected there, VAD again built an ideal outcome again. The forum participants quickly mastered OSM, so on the map of the Leningrad Region roads open exactly on the day of ribbon cutting, and all plans are so accurate that OpenStreetMap prints hang in the offices of construction companies.

One uncomfortable: no cards at hand. In the city, you can still attach yourself to the streets in words (everyone knows where Solunskaya Street intersects with Tbilisi), and outside the city either “they will restrict traffic on the highway from 54 to 81 km” or “the base of builders stands behind the junction in Skotny, six kilometers to the north and one to the west ”: everything is incomprehensible. Therefore, participants take pictures of Yandex.Maps and attach a picture. This is at best, otherwise just give a link. Placing photographing points on the map is generally a special street magic. I made a photo report from the construction of the railway from Losev to Kamennogorsk on a separate website so that the map was at hand, but the openness and simplicity of the tool will help anyone: many do not even have their own page. We need a real map, full-featured and simple.
')
In the spring, I realized that 1) the Leaflet library makes embedding a card elementary, 2) no one except me will write a normal map plugin. Because the main principle of open source: who needs it - he writes. Immediately came up with the code format . Basic prerequisite: maps are inseparable from the text, like pictures and links, so they must be expressed in the usual bb-code, of course, [map] . Inside the tag, the objects expressed by a sequence of coordinates are listed in a semicolon. One pair of "latitude, longitude" - will be a marker, two or more separated by a gap - a line, the first point is equal to the last - a polygon. After the coordinates in brackets can go signature. Like this:

[map]59.939,30.316(); 59.937,30.3127 59.9312,30.36[/map]

The target forum works on the engine of 2006 (that was the time of IE 7 and Opera 9), so it’s unwise to be tied to it. I decided to bring all the functionality, including the parser, to the library in JavaScript, in order to later connect it to different engines. Thanks to Leaflet.draw, my job has come down to developing an API and a plugin. The case was arguing: a comment to the commit from October 1 reports “almost final”. But the technological demo is one thing, and the pro-exploitation requires refinement: combing and breaking the source into modules, checking in a heap of browsers, adding important functions, polishing formats and parameters. A week after the start of development, the source code moved from a personal svn to a githab , and an unusually long gitkhabovsky streak began: as many as 23 days (before that there were 5). The game of maintaining the chain of days is fascinating: after a couple of weeks, sometimes you just want to add a ticket so that participation is registered.

On October 28, the plugin was installed on the forum, on October 31, release 1.0.0 was released.



After graduation, I realized that storing documentation on a githaba is not the case: how to translate it? Mapbbcode.org appeared with a library demonstration, a link to plug-ins and, for today, 80 kilobytes of documentation in English and 50 in Russian. The library, meanwhile, learned how to connect the proprietary layers of the Google Index, because it was the second question for all administrators (the first one - “why is the layer not stored in bb code?”). Immediately comment from the OpenStreetMap forum: “it started as an OSM tool, and you’ll get another gugloplagin”. FURY. Added to the relevant classes to check whether the library does not use a google plugin. Another osmer: "in my opinion, it is somehow petty." Everything is wrong for them.

The format of the bb-code provides for expansion through the parameters, and it is answered in the library. Processing signatures and color parameters, counting the length of lines and thinning broken points - everything can be done through handlers . With the advent of tasks, their APIs quickly outgrew the API for library users: there is both the modification of objects, the management of the map, and the fine tuning of the editor. Through them, it’s quite possible to embed another editor into the editor, or to cut holes from bagels.

When, a month and a half after the release, no one translated a word into new languages, I suspected that translation by pull-requests was hopeless. After removing the script from the repository of the iD editor, I sent all the lines to Transifex , and download them before building the release. “Well, let's go fucking live now” - rubbing his hands, satisfied someone's request to add German to the project. Then another added French. I can add a lot more - only to sense, when even that German escaped somewhere. Apparently, the problem was not in pull requests.

Make a wanted iron - an elephant turned out suddenly

Custom maps are regular strings. And what if they are stored in a database? MapBBCode + DB = a simple service for exchanging maps, MapBBCode Share . The source code of the map is available - it can be copied to a forum or blog. Inspired by openstreetmap.ru, I made the issuance of two links after saving: to view and to change. And here on the forum the organizer of the Moscow kartovstrechi posted a link to edit the plan, breaking the template for me. Suddenly it turned out that I had written a wonderful tool for joint planning of routes and meetings.



The site is anonymous and does not require anything: I went in, drew lines with markers, clicked "Save", got a link. In order not to clutter up browser bookmarks with links to editing, I made an entry through OAuth: the resulting identifier is hashed so that even the administrator does not know who draws the cards, and the API does not allow linking hashes and maps, so even indirect recognition is excluded. This is not Google, which writes every sneeze into the database: in some way I wanted to make an absolutely safe service.

Then - import and export buttons. I love to process data, so the site supports about 11 main formats, including CSV, GPX, GeoJSON (where can I go without it), OziExplorer formats and HTML. Unlike all other sites, MapBBCode Share produces absolutely self-sufficient HTML (apart from Leaflet dependencies): no links to MapBBCode, no conditions. And considering the other formats, the service can be used for conversions: CSV → HTML for table visualization, or PLT → GPX.

Well, the API. Having made the key ?format=raw , it dawned on me once again, which epic website I wrote. The MapBBCode class has a new method: by the banal showExternal('divid', '') call showExternal('divid', '') you can load and display an external map. For example, having seen how great the Olympic infrastructure is drawn in OSM, I made a postcard about Sochi in this way. In all forum plugins, the code [mapid] , the same map can be inserted wherever the code is supported, you can edit it together, and you can download the track directly with a button from the forum. Without any <iframe>. Of course, the source code of the server is open, and plugins allow the administrator to send requests to himself.

Your plugin is very important to us, stay on line.

It quickly became clear that, despite the simplicity of the API (in reality, an object with two methods, show and editor) and a detailed integration guide , no one will write plugins for forums. The first principle is open source, you remember. And Napoleon’s plans: to seize a bicycle rider (FUDForum), a bicycle route (local marathon runners, phpBB 3), an OSM forum (FluxBB), a superman (vBulletin), the Pskov off-road club (SMF). Later, the forums included the Citygide (IP.Board) and Krasnodar jeepers (PunBB) forums. Christmas trees, sticks, why so many different engines? This is some kind of hell.

The programming process is not interesting: well, I sat down, well, about ... 4-5 days, got the plugin and experience. I'll tell you about the system modifications.

The forums are divided into two types: which need to be changed line by line (plug-ins are called modifications and are ennobled diffs) and which are hooked (plug-ins are divided into small functions called from different points). The first are terrible. Just dark. This is phpBB3, SMF and FluxBB - a unique engine, lauding for its speed, and reviewers tactfully skip the system of modifications. No wonder: it is not. Totally. The engine is conceptually minimalist, even without bb-code buttons in the editor (and for the MapBBCode editor open button is important: the user will not write coordinates with his hands), while there is absolutely no way to install extensions except to climb into the wilds of the code and manually edit the lines. Madness.

At the same time, writing plug-ins under its other branch, PunBB, is a continuous pleasure. Hundreds of hooks, everything is clean and clear, simplicity follows from minimalism, from simplicity - an understanding of how everything works, and where to embed. Installing plug-ins is elementary: unpack the archive, click the “install” button in the admin panel. And, of course, there is a delete button with which the forums of the first type have a problem. But life is cruel: PunBB had the last release two years ago, and it slowly dies, and on the FluxBB forum, life boils over. FUDForum, also fast and with hooks, barely breathes, supported by one person.

Today I have released plugins for phpBB 2, phpBB 3 (they are very different), FUDForum, PunBB and FluxBB. Waiting: “Thank you for the plugin, we installed it and use everything!” Reality: “Thank you, but I don’t want to touch anything,” “I will install, only a little later”, “the inscriptions in Georgia are not translated and the time stamps are not saved in the tracks, better in the old manner. At one of the forums on phpBB 3, the administrator enthusiastically started to install, but AutoMOD suddenly crashed, unable to copy files in a banal manner, and there is no more news from there. Forum administrator OpenStreetMap does not respond. Nobody needs maps: on the construction forum they were useful, and bicyclists and jeepers are easier to use GPSies and Osik.



Everyone is paying


Somewhere on the horizon looms the grail, a forum that will give meaning to all this endless work. SkyscraperCity is also dedicated to the construction, but on the scale of the entire planet. It is included in all the dozens of the largest forums of the network. The administrator is interested in the plugin. One “but”: the forum, like the first hundred of the other largest, works on vBulletin. And this engine is closed all around: no source, no documentation, no code on the user forum (!), Until you buy a license (from $ 250). Even if you are not going to install it, but you only want to expand the plugin catalog. The support service answers in monosyllables:

- You would need a license to get access to the vBulletin code.
- We do not offer any sort of development license, sorry.

On the other hand, requests to roll up IP.Board are multiplying. Which is all so beautiful, friendly and with documentation, that's just also paid and "sorry, goodbye." I suppose the sellers of these engines believe that administrators let plugins write and third-party developers are so few that they can be neglected. Although ... It must be true.

Violent penetration

Finally, the engine of my news blog "SHTOSM" tightly closed. Enough of this: to hell with the integration guide, I have 100 kilobytes of code behind me, I can bypass this problem too. And smog. MapBBCode Loader is a small script that quietly views the page and barely envies the bb-code of the map, connects all the necessary libraries and turns the codes (preferably wrapped in <div class="mapbbcode"> ) into interactive maps, and into buttons with class="mapbbcode_edit" hangs up the editor. In fact, it is a plugin for anything on one line.

Why explain when you can show? Copy the following line in the browser's address field. In IE and Chrome, you need to restore the “javascript:” prefix, in Firefox, you need to press Shift + F4, copy to the window and press Ctrl + R. Thank you jsDelivr for the responsive CDN.

javascript:(function(){document.body.appendChild(document.createElement('script')).src = '//cdn.jsdelivr.net/mapbbcode-loader/1.2.0/MapBBCodeLoader.plain.js';})();

[map] 56.4077,40.44374 (B); 56.12384, 40.38076 (R); 57.61273.39.83042 (R); 57.75955.40.9372 (A); 56.31796.38.12943 (H); 57.18758.39.41592 (B); 56.73446.38.85856 (A); 57.51117,41.23761 (H); 55.7574,37.6623 58.0721,40.5286 57.439,41.3635 56.0414,40.188 55.9247.39.4626 (black |); 56.9995,40.9675 (A) [/ map]

And a victory: maps appeared in the patrol, and the modification for FluxBB was reduced to four edits: one per bootloader, two per bb code and one per editor button. Anyone can add a map to the site, and some engines allow you to do this without touching the files at all (for example, phpBB 3 and, theoretically, vBulletin).

So close and so far


(drawing by Tanya Zadorozhnaya )

The project is exhausting. For three months, every day, several hours in the evenings, I close library tickets, I suddenly write important functions, I fight with forum engines and IE, I write documentation in English and translate into Russian. The project eats away the time from the rest: movies, mapping, friends, sex. I finished one function - I invented two others, wrote a plugin for the forum - nobody needs it, but three people asked for another engine. Versioning and milestones help: when 90% of tickets for the next version are closed, there is no incentive to add work to yourself. Always need a goal, the achievement of which is tangible and does not cause a feeling of incompleteness.

This night there was another release, MapBBCode 1.2 . All important tasks are finally done, the documentation is almost complete: there is a step-by-step developer guide left (no task). Transifex is waiting for translators, plug-ins are waiting for administrators. I unsuccessfully struggle with the desire to drown in programming, to close absolutely all tickets, to cover all the engines, including Joomla and Drupal (bitrix? ..). Development can not be completed, you can only stop, and it's time to take up other ideas, waiting for the pages of a notebook. MapBBCode is not going anywhere: I am responsible for what I wrote, and minor versions with corrected errors are inevitable, and vBulletin will sooner or later submit.

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


All Articles