Browse Source

Add custom imageURL icon for each layer

master
Adrian Short 11 years ago
parent
commit
c29cc0984d
5 changed files with 23 additions and 3 deletions
  1. +8
    -1
      app/helpers/posts_helper.rb
  2. +1
    -1
      app/models/layer.rb
  3. +7
    -0
      app/views/layers/_form.html.haml
  4. +5
    -0
      db/migrate/20130424113732_add_icon_url_to_layers.rb
  5. +2
    -1
      db/schema.rb

+ 8
- 1
app/helpers/posts_helper.rb View File

@@ -1,9 +1,16 @@
module PostsHelper
def post_to_poi(post, subscription)
# http://layar.com/documentation/browser/api/getpois-response/

if subscription.layer.icon_url.blank?
image_url = "%s%s/assets/layar-icons/tal-logo-100.png" % [ request.protocol, request.env['HTTP_HOST'] ]
else
image_url = subscription.layer.icon_url
end

res = {
:id => post.id,
:imageURL => "%s%s/assets/layar-icons/tal-logo-100.png" % [ request.protocol, request.env['HTTP_HOST'] ],
:imageURL => image_url,
:anchor => {
:geolocation => {
:lat => post.lat,


+ 1
- 1
app/models/layer.rb View File

@@ -2,7 +2,7 @@ class Layer < ActiveRecord::Base
has_many :subscriptions
has_many :feeds, :through => :subscriptions, :uniq => true

attr_accessible :name
attr_accessible :name, :icon_url

# Unique name for Layar layer
def layar_name


+ 7
- 0
app/views/layers/_form.html.haml View File

@@ -8,6 +8,13 @@

.field
= f.label :name
%br
= f.text_field :name
%br
.field
= f.label "Icon URL (optional)"
%br
= f.text_field :icon_url, :size => 60
%br
.actions
= f.submit 'Save'

+ 5
- 0
db/migrate/20130424113732_add_icon_url_to_layers.rb View File

@@ -0,0 +1,5 @@
class AddIconUrlToLayers < ActiveRecord::Migration
def change
add_column :layers, :icon_url, :string
end
end

+ 2
- 1
db/schema.rb View File

@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20130417153542) do
ActiveRecord::Schema.define(:version => 20130424113732) do

create_table "delayed_jobs", :force => true do |t|
t.integer "priority", :default => 0
@@ -45,6 +45,7 @@ ActiveRecord::Schema.define(:version => 20130417153542) do
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "icon_url"
end

create_table "posts", :force => true do |t|


Loading…
Cancel
Save