Compare commits

..

2 Commits

  1. 2
      .project
  2. 2
      README.md
  3. 7
      composer.json
  4. 13
      extend.php
  5. 14
      js/dist/admin.js
  6. 2
      js/dist/admin.js.map
  7. 40
      js/dist/forum.js
  8. 2
      js/dist/forum.js.map
  9. 4
      js/package-lock.json
  10. 2
      js/package.json
  11. 14
      js/src/admin/index.js
  12. 20
      js/src/forum/components/AddLocationComponent.js
  13. 10
      js/src/forum/components/GlobalMapPage.tsx
  14. 12
      js/src/forum/index.js
  15. 3580
      js/yarn.lock
  16. 2
      locale/en.yml
  17. 2
      locale/fr.yml
  18. 4
      src/Api/Controller/ListUserLocationsController.php
  19. 2
      src/Api/Serializer/UserLocationSerializer.php
  20. 2
      src/Listeners/AddLocationAttribute.php
  21. 2
      src/Listeners/SaveLocationToDatabase.php

2
.project

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>flarum-users-map-location</name> <name>flarum-users-map</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>

2
README.md

@ -2,7 +2,7 @@
A [Flarum](http://flarum.org) extension. Adds an optional Location Attribute and a map to users settings, as well as a global map that displays all users that have opted in. A [Flarum](http://flarum.org) extension. Adds an optional Location Attribute and a map to users settings, as well as a global map that displays all users that have opted in.
This fork is based on [the plugin from justoverclockl](https://github.com/justoverclockl/users-map-location), with some improvements, and notably a global map where it is possible to see the location of all forum users that have filled this information. This fork is based on [the plugin from justoverclock](https://github.com/justoverclockl/users-map-location), with some improvements, and notably a global map where it is possible to see the location of all forum users that have filled this information.
No precise location is disclosed, only city or municipality, and only for users who want to indicate this information. No precise location is disclosed, only city or municipality, and only for users who want to indicate this information.

7
composer.json

@ -24,13 +24,18 @@
"role": "Developer" "role": "Developer"
} }
], ],
"autoload": {
"psr-4": {
"Youen\\UsersMap\\": "src/"
}
},
"extra": { "extra": {
"flarum-extension": { "flarum-extension": {
"title": "Users Map", "title": "Users Map",
"category": "feature", "category": "feature",
"icon": { "icon": {
"name": "fas fa-map-marked-alt", "name": "fas fa-map-marked-alt",
"backgroundColor": "purple", "backgroundColor": "darkgreen",
"color": "white" "color": "white"
} }
} }

13
extend.php

@ -1,19 +1,20 @@
<?php <?php
/* /*
* This file is part of justoverclock/users-map-location. * This file is part of youen/users-map.
* *
* Copyright (c) 2022 Marco Colia. * Copyright (c) 2022 Marco Colia.
* Copyright (c) 2024 Youen Toupin.
* *
* For the full copyright and license information, please view the LICENSE.md * For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
namespace Justoverclock\UsersMapLocation; namespace Youen\UsersMap;
use Justoverclock\UsersMapLocation\Listeners\SaveLocationToDatabase; use Youen\UsersMap\Listeners\SaveLocationToDatabase;
use Justoverclock\UsersMapLocation\Listeners\AddLocationAttribute; use Youen\UsersMap\Listeners\AddLocationAttribute;
use Flarum\Api\Serializer\UserSerializer; use Flarum\Api\Serializer\UserSerializer;
use Flarum\Extend; use Flarum\Extend;
use Flarum\User\Event\Saving; use Flarum\User\Event\Saving;
@ -50,10 +51,10 @@ return [
(new Extend\ApiSerializer(UserSerializer::class)) (new Extend\ApiSerializer(UserSerializer::class))
->attributes(AddLocationAttribute::class), ->attributes(AddLocationAttribute::class),
(new Extend\Settings)->serializeToForum('justoverclock-users-map-location.mapBox-api-key', 'justoverclock-users-map-location.mapBox-api-key'), (new Extend\Settings)->serializeToForum('youen-users-map.mapbox-api-key', 'youen-users-map.mapbox-api-key'),
(new Extend\Frontend('forum')) (new Extend\Frontend('forum'))
->route('/global-map', 'justoverclock.global-map'), ->route('/global-map', 'youen-users-map.global-map'),
(new Extend\Filter(UserFilterer::class)) (new Extend\Filter(UserFilterer::class))
->addFilterMutator(UserLocationFilterMutator::class), ->addFilterMutator(UserLocationFilterMutator::class),

14
js/dist/admin.js vendored

@ -19,17 +19,17 @@ __webpack_require__.r(__webpack_exports__);
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justoverclock/users-map-location', function () { flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('youen/users-map', function () {
flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().extensionData["for"]('justoverclock-users-map-location').registerSetting({ flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().extensionData["for"]('youen-users-map').registerSetting({
setting: 'justoverclock-users-map-location.mapBox-api-key', setting: 'youen-users-map.mapbox-api-key',
name: 'justoverclock-users-map-location.mapBox-api-key', name: 'youen-users-map.mapbox-api-key',
type: 'text', type: 'text',
label: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('justoverclock-users-map-location.admin.mapBox-api-key'), label: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('youen-users-map.admin.mapbox-api-key'),
help: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('justoverclock-users-map-location.admin.mapBox-api-key-help') help: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('youen-users-map.admin.mapbox-api-key-help')
}); });
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_1__.extend)((flarum_admin_components_UserListPage__WEBPACK_IMPORTED_MODULE_2___default().prototype), 'columns', function (items) { (0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_1__.extend)((flarum_admin_components_UserListPage__WEBPACK_IMPORTED_MODULE_2___default().prototype), 'columns', function (items) {
items.add('location', { items.add('location', {
name: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('justoverclock-users-map-location.admin.adminLocationField'), name: flarum_admin_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('youen-users-map.admin.adminLocationField'),
content: function content(user) { content: function content(user) {
return m("div", null, user.data.attributes.location); return m("div", null, user.data.attributes.location);
} }

2
js/dist/admin.js.map vendored

File diff suppressed because one or more lines are too long

40
js/dist/forum.js vendored

@ -16160,16 +16160,16 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
return m("fieldset", { return m("fieldset", {
className: "Settings-theme" className: "Settings-theme"
}, m("legend", null, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.location')), m((flarum_common_components_Switch__WEBPACK_IMPORTED_MODULE_3___default()), { }, m("legend", null, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.location')), m((flarum_common_components_Switch__WEBPACK_IMPORTED_MODULE_3___default()), {
state: this.enableLocation, state: this.enableLocation,
onchange: function onchange(val) { onchange: function onchange(val) {
return _this.setEnableLocation(val); return _this.setEnableLocation(val);
} }
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.enableLocation')), m("div", { }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.enableLocation')), m("div", {
className: "fieldset-separator" className: "fieldset-separator"
}), this.enableLocation ? m("div", null, m("label", { }), this.enableLocation ? m("div", null, m("label", {
"for": "search-country" "for": "search-country"
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationCountry')), m("input", { }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationCountry')), m("input", {
type: "text", type: "text",
className: "FormControl search-country", className: "FormControl search-country",
id: "search-country", id: "search-country",
@ -16180,9 +16180,9 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
className: "fieldset-separator" className: "fieldset-separator"
}), m("label", { }), m("label", {
"for": "search-city" "for": "search-city"
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationCity')), m("p", { }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationCity')), m("p", {
className: "helpText" className: "helpText"
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationCityDescription')), m("input", { }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationCityDescription')), m("input", {
type: "text", type: "text",
className: "FormControl search-city", className: "FormControl search-city",
id: "search-city", id: "search-city",
@ -16217,8 +16217,8 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
if (mapElements.length > 0) { if (mapElements.length > 0) {
if (!this.map) { if (!this.map) {
var mapElement = mapElements[0]; var mapElement = mapElements[0];
var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('justoverclock-users-map-location.mapBox-api-key'); var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('youen-users-map.mapbox-api-key');
var markerIconPath = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; var markerIconPath = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
var markerIcon = L.icon({ var markerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
iconSize: [25, 41], iconSize: [25, 41],
@ -16283,7 +16283,7 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
_this2.location = null; _this2.location = null;
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({ flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({
type: 'success' type: 'success'
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationCleared')); }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationCleared'));
_this2.updateMap(); _this2.updateMap();
}); });
@ -16366,7 +16366,7 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
}; };
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({ flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({
type: 'success' type: 'success'
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationSaved')); }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationSaved'));
_this2.updateMap(); _this2.updateMap();
}); });
@ -16380,7 +16380,7 @@ var AddLocationComponent = /*#__PURE__*/function (_Component) {
if (!foundResult) { if (!foundResult) {
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({ flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().alerts.show({
type: 'error' type: 'error'
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('justoverclock-users-map-location.forum.locationNotFound')); }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().translator.trans('youen-users-map.forum.locationNotFound'));
} }
}); });
}; };
@ -16439,7 +16439,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
_proto.oninit = function oninit(vnode) { _proto.oninit = function oninit(vnode) {
_Page.prototype.oninit.call(this, vnode); _Page.prototype.oninit.call(this, vnode);
flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().setTitle(translate('justoverclock-users-map-location.forum.global-map.title')); flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().setTitle(translate('youen-users-map.forum.global-map.title'));
this.map = null; this.map = null;
}; };
@ -16448,7 +16448,7 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
"class": "GlobalMapPage" "class": "GlobalMapPage"
}, m("div", { }, m("div", {
className: "container" className: "container"
}, m("h2", null, translate('justoverclock-users-map-location.forum.global-map.title2')), m("p", null, translate('justoverclock-users-map-location.forum.global-map.description')), m("div", { }, m("h2", null, translate('youen-users-map.forum.global-map.title2')), m("p", null, translate('youen-users-map.forum.global-map.description')), m("div", {
className: "global-map" className: "global-map"
}))); })));
}; };
@ -16464,8 +16464,8 @@ var GlobalMapPage = /*#__PURE__*/function (_Page) {
if (mapElements.length > 0) { if (mapElements.length > 0) {
if (!this.map) { if (!this.map) {
var mapElement = mapElements[0]; var mapElement = mapElements[0];
var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('justoverclock-users-map-location.mapBox-api-key'); var publicToken = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('youen-users-map.mapbox-api-key');
var markerIconPath = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; var markerIconPath = flarum_forum_app__WEBPACK_IMPORTED_MODULE_1___default().forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
this.userMarkerIcon = L.icon({ this.userMarkerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
iconSize: [25, 41], iconSize: [25, 41],
@ -16601,7 +16601,7 @@ __webpack_require__.r(__webpack_exports__);
flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justoverclock/users-map-location', function (app) { flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('youen/users-map', function (app) {
(flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_country = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_country'); (flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_country = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_country');
(flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_countrycode = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_countrycode'); (flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_countrycode = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_countrycode');
(flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_postcode = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_postcode'); (flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_postcode = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_postcode');
@ -16609,7 +16609,7 @@ flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justov
(flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_latitude = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_latitude'); (flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_latitude = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_latitude');
(flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_longitude = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_longitude'); (flarum_common_models_User__WEBPACK_IMPORTED_MODULE_3___default().prototype).location_longitude = flarum_common_Model__WEBPACK_IMPORTED_MODULE_4___default().attribute('location_longitude');
app.store.models.userlocations = _models_UserLocation__WEBPACK_IMPORTED_MODULE_6__["default"]; app.store.models.userlocations = _models_UserLocation__WEBPACK_IMPORTED_MODULE_6__["default"];
app.routes['justoverclock.global-map'] = { app.routes['youen.global-map'] = {
path: '/global-map', path: '/global-map',
component: _components_GlobalMapPage__WEBPACK_IMPORTED_MODULE_12__["default"] component: _components_GlobalMapPage__WEBPACK_IMPORTED_MODULE_12__["default"]
}; };
@ -16625,7 +16625,7 @@ flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justov
(0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_1__.extend)((flarum_forum_components_UserCard__WEBPACK_IMPORTED_MODULE_7___default().prototype), 'oncreate', function (originalResult, vnode) { (0,flarum_common_extend__WEBPACK_IMPORTED_MODULE_1__.extend)((flarum_forum_components_UserCard__WEBPACK_IMPORTED_MODULE_7___default().prototype), 'oncreate', function (originalResult, vnode) {
var script = document.createElement('script'); var script = document.createElement('script');
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/leaflet.edgebuffer.js'; script.src = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/leaflet.edgebuffer.js';
document.head.appendChild(script); document.head.appendChild(script);
var user = this.attrs.user; var user = this.attrs.user;
var location = user.location_latitude() ? { var location = user.location_latitude() ? {
@ -16634,8 +16634,8 @@ flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justov
} : null; } : null;
if (!location) return; if (!location) return;
var mapElement = vnode.dom.getElementsByClassName('location-map')[0]; var mapElement = vnode.dom.getElementsByClassName('location-map')[0];
var publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); var publicToken = app.forum.attribute('youen-users-map.mapbox-api-key');
var markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; var markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
var markerIcon = L.icon({ var markerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
iconSize: [25, 41], iconSize: [25, 41],
@ -16686,7 +16686,7 @@ flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().initializers.add('justov
href: "/global-map", href: "/global-map",
id: "map-link", id: "map-link",
"class": "Button Button--primary" "class": "Button Button--primary"
}, flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('justoverclock-users-map-location.forum.global-map.linkToMap'))); }, flarum_forum_app__WEBPACK_IMPORTED_MODULE_0___default().translator.trans('youen-users-map.forum.global-map.linkToMap')));
} }
} }
}); });

2
js/dist/forum.js.map vendored

File diff suppressed because one or more lines are too long

4
js/package-lock.json generated

@ -1,11 +1,11 @@
{ {
"name": "@justoverclock/users-map-location", "name": "@youen/users-map",
"version": "0.0.0", "version": "0.0.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "@justoverclock/users-map-location", "name": "@youen/users-map",
"version": "0.0.0", "version": "0.0.0",
"dependencies": { "dependencies": {
"@flarum/prettier-config": "^1.0.0", "@flarum/prettier-config": "^1.0.0",

2
js/package.json

@ -1,5 +1,5 @@
{ {
"name": "@justoverclock/users-map-location", "name": "@youen/users-map",
"version": "0.0.0", "version": "0.0.0",
"private": true, "private": true,
"prettier": "@flarum/prettier-config", "prettier": "@flarum/prettier-config",

14
js/src/admin/index.js

@ -2,19 +2,19 @@ import app from 'flarum/admin/app';
import { extend } from 'flarum/common/extend'; import { extend } from 'flarum/common/extend';
import UserListPage from 'flarum/admin/components/UserListPage'; import UserListPage from 'flarum/admin/components/UserListPage';
app.initializers.add('justoverclock/users-map-location', () => { app.initializers.add('youen/users-map', () => {
app.extensionData.for('justoverclock-users-map-location').registerSetting({ app.extensionData.for('youen-users-map').registerSetting({
setting: 'justoverclock-users-map-location.mapBox-api-key', setting: 'youen-users-map.mapbox-api-key',
name: 'justoverclock-users-map-location.mapBox-api-key', name: 'youen-users-map.mapbox-api-key',
type: 'text', type: 'text',
label: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key'), label: app.translator.trans('youen-users-map.admin.mapbox-api-key'),
help: app.translator.trans('justoverclock-users-map-location.admin.mapBox-api-key-help'), help: app.translator.trans('youen-users-map.admin.mapbox-api-key-help'),
}); });
extend(UserListPage.prototype, 'columns', function (items) { extend(UserListPage.prototype, 'columns', function (items) {
items.add( items.add(
'location', 'location',
{ {
name: app.translator.trans('justoverclock-users-map-location.admin.adminLocationField'), name: app.translator.trans('youen-users-map.admin.adminLocationField'),
content: (user) => { content: (user) => {
return <div>{user.data.attributes.location}</div>; return <div>{user.data.attributes.location}</div>;

20
js/src/forum/components/AddLocationComponent.js

@ -26,20 +26,20 @@ export default class AddLocationComponent extends Component {
view(vnode) { view(vnode) {
return ( return (
<fieldset className="Settings-theme"> <fieldset className="Settings-theme">
<legend>{app.translator.trans('justoverclock-users-map-location.forum.location')}</legend> <legend>{app.translator.trans('youen-users-map.forum.location')}</legend>
<Switch state={this.enableLocation} onchange={val => this.setEnableLocation(val)}>{app.translator.trans('justoverclock-users-map-location.forum.enableLocation')}</Switch> <Switch state={this.enableLocation} onchange={val => this.setEnableLocation(val)}>{app.translator.trans('youen-users-map.forum.enableLocation')}</Switch>
<div className="fieldset-separator"></div> <div className="fieldset-separator"></div>
{ this.enableLocation ? <div> { this.enableLocation ? <div>
<label for="search-country">{app.translator.trans('justoverclock-users-map-location.forum.locationCountry')}</label> <label for="search-country">{app.translator.trans('youen-users-map.forum.locationCountry')}</label>
<input type="text" className="FormControl search-country" id="search-country" name="search-country" value={this.search_country} onblur={this.countryChanged.bind(this)} /> <input type="text" className="FormControl search-country" id="search-country" name="search-country" value={this.search_country} onblur={this.countryChanged.bind(this)} />
<div className="fieldset-separator"></div> <div className="fieldset-separator"></div>
<label for="search-city">{app.translator.trans('justoverclock-users-map-location.forum.locationCity')}</label> <label for="search-city">{app.translator.trans('youen-users-map.forum.locationCity')}</label>
<p className="helpText">{app.translator.trans('justoverclock-users-map-location.forum.locationCityDescription')}</p> <p className="helpText">{app.translator.trans('youen-users-map.forum.locationCityDescription')}</p>
<input type="text" className="FormControl search-city" id="search-city" name="search-city" value={this.search_city} onblur={this.cityChanged.bind(this)} /> <input type="text" className="FormControl search-city" id="search-city" name="search-city" value={this.search_city} onblur={this.cityChanged.bind(this)} />
<div className="fieldset-separator"></div> <div className="fieldset-separator"></div>
@ -71,8 +71,8 @@ export default class AddLocationComponent extends Component {
if(!this.map) { if(!this.map) {
let mapElement = mapElements[0]; let mapElement = mapElements[0];
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('youen-users-map.mapbox-api-key');
const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
let markerIcon = L.icon({ let markerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
@ -135,7 +135,7 @@ export default class AddLocationComponent extends Component {
this.search_country = 'France'; this.search_country = 'France';
this.search_city = ''; this.search_city = '';
this.location = null; this.location = null;
app.alerts.show({ type: 'success' }, app.translator.trans('justoverclock-users-map-location.forum.locationCleared')) app.alerts.show({ type: 'success' }, app.translator.trans('youen-users-map.forum.locationCleared'))
this.updateMap(); this.updateMap();
}); });
@ -216,7 +216,7 @@ export default class AddLocationComponent extends Component {
lat: attributes.location_latitude, lat: attributes.location_latitude,
lon: attributes.location_longitude lon: attributes.location_longitude
}; };
app.alerts.show({ type: 'success' }, app.translator.trans('justoverclock-users-map-location.forum.locationSaved')) app.alerts.show({ type: 'success' }, app.translator.trans('youen-users-map.forum.locationSaved'))
this.updateMap(); this.updateMap();
}); });
@ -226,7 +226,7 @@ export default class AddLocationComponent extends Component {
} }
if(!foundResult) { if(!foundResult) {
app.alerts.show({ type: 'error' }, app.translator.trans('justoverclock-users-map-location.forum.locationNotFound')) app.alerts.show({ type: 'error' }, app.translator.trans('youen-users-map.forum.locationNotFound'))
} }
}); });
} }

10
js/src/forum/components/GlobalMapPage.tsx

@ -14,7 +14,7 @@ export default class GlobalMapPage extends Page {
oninit(vnode: Mithril.Vnode) { oninit(vnode: Mithril.Vnode) {
super.oninit(vnode); super.oninit(vnode);
app.setTitle(translate('justoverclock-users-map-location.forum.global-map.title')); app.setTitle(translate('youen-users-map.forum.global-map.title'));
this.map = null; this.map = null;
} }
@ -22,8 +22,8 @@ export default class GlobalMapPage extends Page {
view() { view() {
return <div class="GlobalMapPage"> return <div class="GlobalMapPage">
<div className="container"> <div className="container">
<h2>{translate('justoverclock-users-map-location.forum.global-map.title2')}</h2> <h2>{translate('youen-users-map.forum.global-map.title2')}</h2>
<p>{translate('justoverclock-users-map-location.forum.global-map.description')}</p> <p>{translate('youen-users-map.forum.global-map.description')}</p>
<div className="global-map"></div> <div className="global-map"></div>
</div> </div>
</div>; </div>;
@ -41,8 +41,8 @@ export default class GlobalMapPage extends Page {
if(!this.map) { if(!this.map) {
let mapElement = mapElements[0]; let mapElement = mapElements[0];
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('youen-users-map.mapbox-api-key');
const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
this.userMarkerIcon = L.icon({ this.userMarkerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,

12
js/src/forum/index.js

@ -17,7 +17,7 @@ import "./../../node_modules/leaflet/dist/leaflet.css";
import "./../../node_modules/leaflet.markercluster/dist/MarkerCluster.css"; import "./../../node_modules/leaflet.markercluster/dist/MarkerCluster.css";
import "./../../node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css"; import "./../../node_modules/leaflet.markercluster/dist/MarkerCluster.Default.css";
app.initializers.add('justoverclock/users-map-location', (app) => { app.initializers.add('youen/users-map', (app) => {
User.prototype.location_country = Model.attribute('location_country'); User.prototype.location_country = Model.attribute('location_country');
User.prototype.location_countrycode = Model.attribute('location_countrycode'); User.prototype.location_countrycode = Model.attribute('location_countrycode');
User.prototype.location_postcode = Model.attribute('location_postcode'); User.prototype.location_postcode = Model.attribute('location_postcode');
@ -27,7 +27,7 @@ app.initializers.add('justoverclock/users-map-location', (app) => {
app.store.models.userlocations = UserLocation; app.store.models.userlocations = UserLocation;
app.routes['justoverclock.global-map'] = { path: '/global-map', component: GlobalMapPage }; app.routes['youen.global-map'] = { path: '/global-map', component: GlobalMapPage };
extend(UserCard.prototype, 'infoItems', function (items) { extend(UserCard.prototype, 'infoItems', function (items) {
const user = this.attrs.user; const user = this.attrs.user;
@ -41,7 +41,7 @@ app.initializers.add('justoverclock/users-map-location', (app) => {
let script = document.createElement('script'); let script = document.createElement('script');
script.type = 'text/javascript'; script.type = 'text/javascript';
script.src = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/leaflet.edgebuffer.js' script.src = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/leaflet.edgebuffer.js'
document.head.appendChild(script); document.head.appendChild(script);
@ -58,8 +58,8 @@ app.initializers.add('justoverclock/users-map-location', (app) => {
let mapElement = vnode.dom.getElementsByClassName('location-map')[0]; let mapElement = vnode.dom.getElementsByClassName('location-map')[0];
const publicToken = app.forum.attribute('justoverclock-users-map-location.mapBox-api-key'); const publicToken = app.forum.attribute('youen-users-map.mapbox-api-key');
const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/justoverclock-users-map-location/marker-icon.png'; const markerIconPath = app.forum.attribute('baseUrl') + '/assets/extensions/youen-users-map/marker-icon.png';
let markerIcon = L.icon({ let markerIcon = L.icon({
iconUrl: markerIconPath, iconUrl: markerIconPath,
@ -105,7 +105,7 @@ extend(HeaderPrimary.prototype, 'onupdate', function() {
homeLink.parentElement?.append(globalMapLink); homeLink.parentElement?.append(globalMapLink);
m.render(globalMapLink, <Link href="/global-map" id="map-link" class="Button Button--primary"> m.render(globalMapLink, <Link href="/global-map" id="map-link" class="Button Button--primary">
{app.translator.trans('justoverclock-users-map-location.forum.global-map.linkToMap')} {app.translator.trans('youen-users-map.forum.global-map.linkToMap')}
</Link>); </Link>);
} }
} }

3580
js/yarn.lock

File diff suppressed because it is too large Load Diff

2
locale/en.yml

@ -1,4 +1,4 @@
justoverclock-users-map-location: youen-users-map:
admin: admin:
adminLocationField: Location adminLocationField: Location
mapBox-api-key: MapBox Public Token mapBox-api-key: MapBox Public Token

2
locale/fr.yml

@ -1,4 +1,4 @@
justoverclock-users-map-location: youen-users-map:
admin: admin:
adminLocationField: Localisation adminLocationField: Localisation
mapBox-api-key: Jeton public MapBox mapBox-api-key: Jeton public MapBox

4
src/Api/Controller/ListUserLocationsController.php

@ -1,13 +1,13 @@
<?php <?php
namespace Justoverclock\UsersMapLocation\Api\Controller; namespace Youen\UsersMap\Api\Controller;
use Flarum\Api\Controller\AbstractListController; use Flarum\Api\Controller\AbstractListController;
use Flarum\Http\RequestUtil; use Flarum\Http\RequestUtil;
use Flarum\Http\UrlGenerator; use Flarum\Http\UrlGenerator;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Tobscure\JsonApi\Document; use Tobscure\JsonApi\Document;
use Justoverclock\UsersMapLocation\Api\Serializer\UserLocationSerializer; use Youen\UsersMap\Api\Serializer\UserLocationSerializer;
use Flarum\User\User; use Flarum\User\User;
use Flarum\Query\QueryCriteria; use Flarum\Query\QueryCriteria;
use Flarum\User\Filter\UserFilterer; use Flarum\User\Filter\UserFilterer;

2
src/Api/Serializer/UserLocationSerializer.php

@ -1,6 +1,6 @@
<?php <?php
namespace Justoverclock\UsersMapLocation\Api\Serializer; namespace Youen\UsersMap\Api\Serializer;
use Flarum\Api\Serializer\AbstractSerializer; use Flarum\Api\Serializer\AbstractSerializer;
use Flarum\User\User; use Flarum\User\User;

2
src/Listeners/AddLocationAttribute.php

@ -1,6 +1,6 @@
<?php <?php
namespace Justoverclock\UsersMapLocation\Listeners; namespace Youen\UsersMap\Listeners;
use Flarum\Api\Serializer\UserSerializer; use Flarum\Api\Serializer\UserSerializer;
use Flarum\User\User; use Flarum\User\User;

2
src/Listeners/SaveLocationToDatabase.php

@ -1,6 +1,6 @@
<?php <?php
namespace Justoverclock\UsersMapLocation\Listeners; namespace Youen\UsersMap\Listeners;
use Flarum\User\Event\Saving; use Flarum\User\Event\Saving;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;

Loading…
Cancel
Save