Location in wall posts

This component/theme doesn't work with the latest OSSN version.
5.0
Breton Rafael Amorim 2 months ago

This component change the current location services (Algolia) to MapBox. The old service was shutting down in May-2022, but still working until September. See more details in Algolia web site

Screenshots

Screenshot of OssnLocation
Screenshot of OssnLocation component

Screenshot of OssnLocation admin
Screenshot of OssnChat component

Installation

Installation procedures as the same for any component in OSSN. Also, it's required to admin put the MapBox API Access Token into OssnLocation admin page.

Limitations

  • The component was tested in OSSN 6.1 and 6.4, free and premium version. Maybe some adjustments are required in other versions. Use by your own risk.
  • As a freemium service, MapBox allows 100k requests/month free. More details in https://www.mapbox.com/pricing.

How to get an MapBox API Key

Just go to this page.

Changes

  • 1.3
    -Fix loading current language, found by Michael Zülsdorff
    -Fix GDPR issue, found by Michael Zülsdorff
    -Added contributors file
    -Added link to MapBox Access token into readme file
  • 1.2
    -Removed a lost div tag in admin form
  • 1.1
    -Add verification to load map only when necessary
    -Set OSSN site language in MapBox script
    -Fix error when user cancel location search by click on X button
  • 1.0
    -Initial version. Tested in wall, user posts and groups.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

OSSN

Comments
Indonesian Arsalan Shah Replied 1 week ago

Making this a obsolete as added in core , to avoid people downloading different version

pk Jodie Evans Replied 2 months ago

Ossn is a revolutionary new way to store your personal items. With its patented design, Ossn takes up no space, is portable, and can be folded into itself. Ossn is a small yet powerful item storage solution that can hold items ranging from clothing to shoes.

Breton Rafael Amorim Replied 2 months ago

Thank you for the tips, @Michael

German Michael Zülsdorff Replied 2 months ago

localization to the global site language doesn't work this way
because it will be replaced by the member's individual language
see function at line #320 in ossn.lib.users and line #498 where it's called by hook
see #343 in ossn.lib.system where the global setting gets finally changed
so the only way to retrieve the orignal value I see would be

language: '<?php $ossnsite = new OssnSite(); echo $ossnsite->getSettings("language"); ?>',

Next I would vote to load external libs not on the frontpage (if the user is still logged off) because this might lead to GDPR compliance issues
At least in Germany the visitor has to explicitely agree that his browser data will be sent to 3rd-parties.

Breton Rafael Amorim Replied 2 months ago

Solution founded using https://gomakethings.com/detecting-click-events-on-svgs-with-vanilla-js-event-delegation/ tip. I disable SVG click in CSS. Tomorrow I make more tests here and send a new version. I'm tired, and it's late here (00:26).

Indonesian Arsalan Shah Replied 2 months ago

I will take it from here no worries, I will push manually to the OSSN after some modifications.

Breton Rafael Amorim Replied 2 months ago

I'm almost finishing version 1.1. The new code is on the github repository for review.

I put a check to prevent errors on pages without the div of the old location code. Also, I added site language as default on Mapbox search/results. And on the last item reported, I can't fix it yet. But the source of error is on the OssnNotification component (https://github.com/opensource-socialnetwork/opensource-socialnetwork/blob/fef86e5bd44606fa4a238d18b845e01c61340943/components/OssnNotifications/plugins/default/js/notifications-settings.php#L9).

At this moment, I accept any thoughts to fix this :-)

German Michael Zülsdorff Replied 2 months ago

A big thank you for making this feature back available, Rafael!

small glitch still: Javascript error on all pages without location input field, and script error when clicking the 'X' in order to remove a chosen city

nice to have: localization. As German users for instance have no chance to get 'München' since the default English localization is expecting 'Munich' to be entered.

I'd suggest to derive it from the site's default language - not the individual member setting - to have a meaningful translation for the majority of members. See https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-geocoder-with-language/

Component

Developer: Rafael
License ossnv4
Type: Uncategorized
Requires Ossn Version : 6.1
Latest Version:
Last Updated
Repository Url View Repository

Versions