简体   繁体   English

Rails站点地图生成器通过雾和载波上传到亚马逊S3

[英]Rails sitemap generator uploading to amazon s3 with fog and carrierwave

I simply cannot get it to work. 我根本无法正常工作。 I am following the tutorial here: https://github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku 我在这里关注该教程: https : //github.com/kjvarga/sitemap_generator/wiki/Generate-Sitemaps-on-read-only-filesystems-like-Heroku

I already have the sitemap working locally, however, now I have followed this tutorial I can neither load up the server nor use sitemap commands without errors. 我已经使站点地图在本地工作,但是,现在我已经按照本教程进行操作,既不能加载服务器,也不能使用站点地图命令而不会出现错误。

Error: 错误:

=> Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)                                 
=> Ctrl-C to shutdown server                                                                                                            
Exiting                                                                                                                                 
C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:203:in `parse': (C:/Users/Callum/Documents/directory/config/environment_variables.ym
l): found a tab character that violate intendation while scanning a plain scalar at line 5 column 22 (Psych::SyntaxError)               
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'                                                  
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:151:in `parse'                                                         
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:127:in `load'                                                          
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `block in load_file'                                            
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `open'                                                          
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:297:in `load_file'                                                     
        from C:/Users/Callum/Documents/directory/config/initializers/environment_variables.rb:7:in `block in <class:Application>'       
        from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/lazy_load_hooks.rb:36:in `call'

Sitemap.rb Sitemap.rb

require 'rubygems'
require 'sitemap_generator'

SitemapGenerator::Sitemap.default_host = "http://www.uk-franchise.co.uk"
SitemapGenerator::Sitemap.sitemaps_host = "http://#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com/"
SitemapGenerator::Sitemap.public_path = 'tmp/'
SitemapGenerator::Sitemap.sitemaps_path = 'sitemaps/'
SitemapGenerator::Sitemap.adapter = SitemapGenerator::WaveAdapter.new
SitemapGenerator::Sitemap.create do
  add root_path, :lastmod => Time.now, :changefreq => 'weekly', :priority => 1
  add posts_path, :lastmod => Time.now, :changefreq => 'weekly', :priority => 1
  add events_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1 
    add industry_accounting_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_agriculture_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_automotive_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_beverage_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_B2B_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_cafeandcoffee_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_care_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_chemical_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_childrenandbabies_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_cleaning_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_communications_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_computers_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_construction_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_consultancy_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_logistics_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_educationandtraining_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_electrical_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_entertainment_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_enviromental_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_estateagents_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_fashion_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_financial_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_food_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_health_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_hirerental_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_hospitality_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_indoorpropertyservices_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_outdoorpropertyservices_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_internet_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_legal_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_manafacture_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_pets_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_promotional_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_print_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
    add industry_repairandmaintenance_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
  add industry_investment1_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
  add industry_investment2_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
  add industry_investment3_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
  add industry_investment4_path, :lastmod => Time.now, :changefreq => 'monthly', :priority => 1
  Post.all.each do |post|
        add post_path(post), :lastmod => post.updated_at, :changefreq => 'monthly', :priority => 1
    end
    Listing.all.each do |listing|
        add listing_path(listing), :lastmod => listing.updated_at, :changefreq => 'yearly', :priority => 1
    end
end

SitemapGenerator::Sitemap.ping_search_engines # Not needed if you use the rake tasks

Gems 宝石

gem 'sitemap_generator'
gem 'carrierwave'
gem 'fog'

Carrierwave.rb 载波波

CarrierWave.configure do |config|
  config.cache_dir = "#{Rails.root}/tmp/"
  config.storage = :fog
  config.permissions = 0666
  config.fog_credentials = {
    :provider               => ENV["FOG_PROVIDER"],
    :aws_access_key_id      => ENV["AWS_ACCESS_KEY_ID"],
    :aws_secret_access_key  => ENV["AWS_SECRET_ACCESS_KEY"],
  }
  config.fog_directory = "ukfranchise"
end

environmental_variables file environmental_variables文件

development:
  AWS_ACCESS_KEY_ID: mykey
    AWS_SECRET_ACCESS_KEY: mykey
    FOG_PROVIDER: AWS
    FOG_DIRECTORY: ukfranchise

Any suggestions would be greatly appreciated, banging my head on the desk atm. 任何建议都将不胜感激,将我的头撞在桌子上的atm上。

Indentation is significant in yaml. 缩进在yaml中很重要。 In your environment variable file you need to remove the extra level of indentation before the last 3 variables (so that all four variables are at the same level of indentation under the development key). 在您的环境变量文件中,您需要删除最后三个变量之前的额外缩进级别(以便在开发密钥下所有四个变量都处于相同的缩进级别)。 I think that should at least get you past the issue you are seeing above. 我认为这至少应该使您摆脱上面遇到的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM