From 609d58b0b62ae31db74965480fcecd8fbbd96b3a Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Sat, 21 Jan 2017 11:44:10 -0500 Subject: [PATCH] implement base url thing whoo --- app/controllers/maps_controller.rb | 3 ++- app/models/user.rb | 5 +++-- app/services/map_export_service.rb | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/app/controllers/maps_controller.rb b/app/controllers/maps_controller.rb index d91e465e..f97e6c69 100644 --- a/app/controllers/maps_controller.rb +++ b/app/controllers/maps_controller.rb @@ -91,7 +91,8 @@ class MapsController < ApplicationController # GET maps/:id/export def export - exporter = MapExportService.new(current_user, @map) + + exporter = MapExportService.new(current_user, @map, base_url: request.base_url) respond_to do |format| format.json { render json: exporter.json } format.csv { send_data exporter.csv } diff --git a/app/models/user.rb b/app/models/user.rb index 7ec2a032..abb03553 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -67,11 +67,12 @@ class User < ApplicationRecord json end - def as_rdf + def as_rdf(opts = {}) + base_url = opts[:base_url] || 'https://metamaps.cc' output = '' output += %(d:mapper_#{id} a foaf:OnlineAccount ;\n) output += %( foaf:accountName "#{name}";\n) - output += %( foaf:accountServiceHomepage "https://metamaps.cc/mapper/#{id}";\n) + output += %( foaf:accountServiceHomepage "#{base_url}/mapper/#{id}";\n) output[-2] = '.' # change last ; to a . output += %(\n) output diff --git a/app/services/map_export_service.rb b/app/services/map_export_service.rb index 80c0c4fe..e500575e 100644 --- a/app/services/map_export_service.rb +++ b/app/services/map_export_service.rb @@ -32,7 +32,7 @@ class MapExportService output += "PREFIX foaf: \n" output += "\n" map.contributors.each do |mapper| - output += mapper.as_rdf + output += mapper.as_rdf(base_url: base_url) end map.topics.each do |topic| output += topic.as_rdf