Sitemaps break with images #93

Closed
aeldaly opened this Issue Dec 20, 2012 · 3 comments

Projects

None yet

3 participants

@aeldaly
aeldaly commented Dec 20, 2012

I have this in my sitemaps.rb file

Wine.find_each do |wine|
add wine_path(id:wine.to_param),
priority:0.7,
changefreq:'daily',
lastmod:wine.updated_at.to_date.to_s,
images:[
{loc:wine.image_label_url, title:wine.image_label_alt},
{loc:wine.main_photo, title:wine.image_bottle_alt}
]
end
end

This breaks with the following stack trace:
rake aborted!
bad URI(is not URI?): https://domain-development.s3.amazonaws.com/wine_bottles/0016/0770/image.jpg
gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_url.rb:162:in block in prepare_images' gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_url.rb:160:ineach'
gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_url.rb:160:in prepare_images' gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_url.rb:56:ininitialize'
gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_file.rb:90:in new' gems/sitemap_generator-3.4/lib/sitemap_generator/builder/sitemap_file.rb:90:inadd'
gems/sitemap_generator-3.4/lib/sitemap_generator/link_set.rb:140:in add' gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:31:inadd'
/Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:41:in block (3 levels) in run' gems/activerecord-3.2.6/lib/active_record/relation/batches.rb:21:inblock (2 levels) in find_each'
gems/activerecord-3.2.6/lib/active_record/relation/batches.rb:21:in each' gems/activerecord-3.2.6/lib/active_record/relation/batches.rb:21:inblock in find_each'
gems/activerecord-3.2.6/lib/active_record/relation/batches.rb:72:in find_in_batches' gems/activerecord-3.2.6/lib/active_record/relation/batches.rb:20:infind_each'
gems/activerecord-3.2.6/lib/active_record/querying.rb:8:in find_each' /Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:40:inblock (2 levels) in run'
gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:59:in instance_eval' gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:59:ineval'
gems/sitemap_generator-3.4/lib/sitemap_generator/link_set.rb:206:in group' gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:43:ingroup'
/Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:39:in block in run' gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:59:ininstance_eval'
gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:59:in eval' gems/sitemap_generator-3.4/lib/sitemap_generator/link_set.rb:39:increate'
gems/sitemap_generator-3.4/lib/sitemap_generator.rb:33:in method_missing' /Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:15:inrun'
gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:76:in instance_eval' gems/sitemap_generator-3.4/lib/sitemap_generator/interpreter.rb:76:inrun'
gems/sitemap_generator-3.4/lib/sitemap_generator/tasks.rb:51:in `block (2 levels) in <top (required)>'
Tasks: TOP => sitemap:refresh:no_ping => sitemap:create
(See full trace by running task with --trace)

It's failing on this line:
r[:loc] = URI.join(host, r[:loc]).to_s

since r[:loc] = 'https://domain-development.s3.amazonaws.com/wine_bottles/0016/0770/image.jpg'

the URI.join method fails.

@kjvarga
Owner
kjvarga commented Jan 3, 2013

I'm not sure if the images are allowed to be on a different host. Can you take a look at the spec? If so we will have to detect whether the loc already contains a host

@Waylon87

I'm using S3, Images in the sitemap works for me. This is what I did.

Art.find_each do |art| add art_path(art), :lastmod => art.updated_at, :changefreq => 'daily', :priority => 0.7, :images => [{:loc => art.pic_one.url, :title => art.artist }] end

Hope this helps.

@kjvarga
Owner
kjvarga commented May 2, 2013

It seems to be working for me. Closing.

@kjvarga kjvarga closed this May 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment