implement base url thing whoo

This commit is contained in:
Devin Howard 2017-01-21 11:44:10 -05:00
parent b9c5b59269
commit 609d58b0b6
3 changed files with 6 additions and 4 deletions

View file

@ -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 }

View file

@ -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

View file

@ -32,7 +32,7 @@ class MapExportService
output += "PREFIX foaf: <http://xmlns.com/foaf/0.1/>\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