Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Sitemaps break with images #93

Closed
aeldaly opened this Issue · 3 comments

3 participants

Ahmed El-Daly Karl Varga Waylon Peele
Ahmed El-Daly

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:in
each'
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:in
initialize'
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:in
add'
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:in
add'
/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:in
block (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:in
block 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:in
find_each'
gems/activerecord-3.2.6/lib/active_record/querying.rb:8:in find_each'
/Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:40:in
block (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:in
eval'
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:in
group'
/Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:39:in block 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:in eval'
gems/sitemap_generator-3.4/lib/sitemap_generator/link_set.rb:39:in
create'
gems/sitemap_generator-3.4/lib/sitemap_generator.rb:33:in method_missing'
/Users/aeldaly/Code/winealign/winealign4/config/sitemap.rb:15:in
run'
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:in
run'
gems/sitemap_generator-3.4/lib/sitemap_generator/tasks.rb:51:in `block (2 levels) in '
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.

Karl Varga
Owner

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

Waylon Peele

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.

Karl Varga
Owner

It seems to be working for me. Closing.

Karl Varga kjvarga closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.