Terrastories / terrastories

Terrastories is a geostorytelling application for mapping, managing and sharing place-based stories.
https://terrastories.app
MIT License
316 stars 157 forks source link

[Bug][Rails] For offline field kit, change local style.json path to relative #655

Closed rudokemper closed 2 years ago

rudokemper commented 3 years ago

Describe the bug For offline "field kit" Terrastories usage, we use a parameter in the env file USE_LOCAL_MAP_SERVER="true". This triggers Terrastories to look for local tiles and a local style.json file instead of a Mapbox.com map. This is in lines 33-43 in home_controller.rb:

  helper_method def local_mapbox?
    ENV["USE_LOCAL_MAP_SERVER"].present?
  end

  helper_method def mapbox_style
    if local_mapbox?
      "http://localhost:8080/styles/basic/style.json"
    else
      @theme.mapbox_style_url.presence || ENV["MAPBOX_STYLE"]
    end
  end

This current localhost path as defined for style.json becomes an issue when Terrastories is set up to be accessed by external devices per our offline field kit documentation, since the path is pointing to localhost instead of the ip address of the device serving Terrastories.

Solution Let's make this a relative path so that the style.json file will be found regardless of whether Terrastories is accessed on a local machine using localhost, or by an external device using the hosting device's ip address.

sundus-y commented 2 years ago

This is my first time working on this project, I'm going to give this a shot.

rudokemper commented 2 years ago

Awesome, @sundus-y! Welcome and please let us know if you have any questions.

rudokemper commented 2 years ago

Hi @sundus-y ! Did you still want to work on this? Just checking in :)