Skip to content

Commit

Permalink
Merge branch 'main' into depfu/update/importmap/maplibre-gl-5.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
digitaltom authored Jan 30, 2025
2 parents 93cd3f1 + 86ac0dd commit ea357b4
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def destroy
private

def require_admin_user
not_found! unless @user&.admin?
redirect_to login_path unless @user&.admin?
end
end
6 changes: 1 addition & 5 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ class ApplicationController < ActionController::Base
before_action :set_user
before_action :disable_session_cookies

def not_found!
render file: "#{Rails.root}/public/404.html", layout: false, status: :not_found
end

private

def set_user
@user = User.find_by(id: session[:user_id]) if session[:user_id]
end

def require_login
not_found! unless @user
redirect_to login_path unless @user
end

def disable_session_cookies
Expand Down
1 change: 1 addition & 0 deletions app/controllers/images_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def upload
file = params[:image]
ext = file.content_type.split("/").last
filename = "#{SecureRandom.hex(4)}.#{ext}"
raise "Image size exceeds 4MB" if file.size / (1024 * 1024) > 4
uid = Dragonfly.app.store(file.tempfile, "name" => filename)
img = Image.create!(img_uid: uid)
render json: { icon: "/icon/#{img.public_id}", image: "/image/#{img.public_id}" }
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/sessions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def create
# Make first user admin
user.update!(admin: true) if User.count == 1
session[:user_id] = user.id
redirect_to root_path
redirect_to my_path
end
end
6 changes: 6 additions & 0 deletions app/javascript/controllers/feature_edit_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ export default class extends Controller {
const feature = this.getFeature()
const image = document.querySelector('#marker-image').files[0]
const formData = new FormData() // send using multipart/form-data

if (image && image.size > (4 * 1024 * 1024)) {
alert('Image is too large. Maximum size is 4MB.')
}

formData.append('image', image)
fetch('/images', {
method: 'POST',
Expand All @@ -141,6 +146,7 @@ export default class extends Controller {
console.log('Setting icon: ' + data.icon)
feature.properties['marker-image-url'] = data.icon
draw.setFeatureProperty(this.featureIdValue, 'marker-image-url', data.icon)
draw.setFeatureProperty(this.featureIdValue, 'marker-size', 15)
setFeatureTitleImage(feature)
redrawGeojson(false)
this.saveFeature()
Expand Down
6 changes: 3 additions & 3 deletions app/javascript/maplibre/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,17 +374,17 @@ export function sortLayers () {
const currentStyle = map.getStyle()
let layers = currentStyle.layers

// const userExtrusions = layers.filter(l => l.properties &&
// (l.properties['fill-extrusion-height'] || l.properties['user_fill-extrusion-height']))
const mapExtrusions = functions.reduceArray(layers, (e) => e.paint && e.paint['fill-extrusion-height'])
// increase opacity of 3D houses
mapExtrusions.filter(l => l.id === 'Building 3D').forEach((layer) => {
layer.paint['fill-extrusion-opacity'] = 0.8
})
const symbols = functions.reduceArray(layers, (e) => (e.type === 'symbol' || e.id === 'symbols-border-layer'))
const mapLabels = functions.reduceArray(layers, (e) => e.layout && e.layout['text-field'])
const lineLayerHits = functions.reduceArray(layers, (e) => e.id === 'line-layer-hit')
const pointsLayerHits = functions.reduceArray(layers, (e) => e.id === 'points-hit-layer')

layers = layers.concat(mapExtrusions).concat(mapLabels).concat(symbols)
layers = layers.concat(mapExtrusions).concat(mapLabels).concat(symbols).concat(lineLayerHits).concat(pointsLayerHits)
const newStyle = { ...currentStyle, layers }
map.setStyle(newStyle, { diff: true })
// console.log(map.getStyle().layers)
Expand Down
16 changes: 13 additions & 3 deletions docs/privacy.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
## Mapforge Privacy Policy

TL;DR: For not logged in visitors, we do not use cookies and we do not collect any personal data. If you decide to log in, we store the bare minimum and do not share it with other companies or services.
TL;DR: For not logged in visitors, we do not use cookies and we do not collect any personal data. If you decide to log in, we store the bare minimum and do not share it with third party companies or services.

In this policy, we lay out what data we collect and why, how your data is handled and your rights to your data.

All of the data that we collect is kept fully secured and hosted in Germany. The server is owned by Hetzner, a European company. This ensures that all of the site data is being covered by the European Union’s strict laws on data privacy. Your site data never leaves the EU. See Hetzner privacy policy for full details.

### As a visitor to the mapforge.org website

No personal information is collected
Expand All @@ -15,7 +17,7 @@ In this policy, we lay out what data we collect and why, how your data is handle

When you are browsing maps, the background maps can get configured to get loaded from external providers, such as opentopomap.org, stadiamaps.com, arcgisonline.com, openstreetmap.org, openfreemap.org, versatiles.org and maptiler.com. Those providers have their own policies which can get accessed via the info link in the lower right corner of the map.

### As a logged in user and map creator of Mapforge
### As a logged in user

We only collect what we need and that we will solely process this information to provide you with the Mapforge service.

Expand All @@ -28,7 +30,15 @@ Here’s what that means in practice. When you log in via one of the supported l

A persistent first-party cookie is stored to remember you’re logged in.

All of the data that we collect is kept fully secured and hosted on 100% renewable energy powered server in Falkenstein, Germany. The server is owned by Hetzner, a European company. This ensures that all of the site data is being covered by the European Union’s strict laws on data privacy. Your site data never leaves the EU. See Hetzner privacy policy for full details.
### As a map creator of Mapforge

The geojson and image data you upload or create on Mapforge is available to other users
by default. You can decide to configure your map as private, then it is only
available to others that know the private or public link to it.

Users are responsible for any data they share through Mapforge and confirm that they have the permission to share it.

You can export all your map data in GeoJSON format.


### Retention of data
Expand Down
4 changes: 2 additions & 2 deletions spec/features/admin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
visit admin_path
end

it 'shows 404' do
expect(page).to have_text 'The page you were looking for doesn’t exist'
it 'shows login page' do
expect(page).to have_text 'Log in here'
end
end
end
4 changes: 2 additions & 2 deletions spec/features/login_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
fill_in 'name', with: 'Test User'
fill_in 'email', with: '[email protected]'
click_button('Sign In')
expect(page).to have_current_path(root_path)
expect(page).to have_current_path(my_path)
expect(User.count).to eq 1
end

Expand All @@ -24,7 +24,7 @@
fill_in 'name', with: 'Test User'
fill_in 'email', with: '[email protected]'
click_button('Sign In')
expect(page).to have_current_path(root_path)
expect(page).to have_current_path(my_path)
expect(User.count).to eq 1
visit maps_path
find('.profile-image').click
Expand Down

0 comments on commit ea357b4

Please sign in to comment.