Browse Source

Generate unique layer names for Layar

master
Adrian Short 11 years ago
parent
commit
12eb811cd3
3 changed files with 10 additions and 2 deletions
  1. +2
    -1
      app/controllers/posts_controller.rb
  2. +5
    -0
      app/models/layer.rb
  3. +3
    -1
      app/views/layers/show.html.haml

+ 2
- 1
app/controllers/posts_controller.rb View File

@@ -9,9 +9,10 @@ class PostsController < ApplicationController
# :params => params, # :params => params,
# :pois_returned => @posts.size # :pois_returned => @posts.size
# ) # )
@layer = Layer.find(params[:layer_id])


layar_response = { layar_response = {
:layer => 'hyparlocal',
:layer => @layer.layar_name,
:hotspots => @posts.collect { |p| post_to_poi(p) }, :hotspots => @posts.collect { |p| post_to_poi(p) },
:errorCode => 0, # OK :errorCode => 0, # OK
:errorString => "OK", :errorString => "OK",


+ 5
- 0
app/models/layer.rb View File

@@ -1,4 +1,9 @@
class Layer < ActiveRecord::Base class Layer < ActiveRecord::Base
attr_accessible :name attr_accessible :name
has_and_belongs_to_many :feeds has_and_belongs_to_many :feeds

# Unique name for Layar layer
def layar_name
"apollo" + self.name.strip.downcase.gsub(/[^a-z0-9]/, '')
end
end end

+ 3
- 1
app/views/layers/show.html.haml View File

@@ -5,7 +5,9 @@
%p %p
API URL: API URL:
= "#{request.protocol}#{request.host_with_port}/posts/near.layar?layer_id=#{@layer.id}" = "#{request.protocol}#{request.host_with_port}/posts/near.layar?layer_id=#{@layer.id}"
%br
Layar layer name:
= @layer.layar_name


%h2 Feeds %h2 Feeds




Loading…
Cancel
Save