Aupajo / almanack

Aggregate iCal and Google Calendar events. Pluggable or standalone app. UI optional and 100% customisable.
MIT License
54 stars 25 forks source link

Encoding problem #18

Open wprzyb opened 7 years ago

wprzyb commented 7 years ago

Here is my ics i want to use - and the problem is with the encoding. I know only a bit of ruby, but all my attempts to inject some UTF-8 forcing into config.ru was unsuccessful:

2017-11-02T23:18:58.801533+00:00 heroku[router]: at=info method=GET path="/" host=address-censored.herokuapp.com request_id=xxxxxxx-65a7-4f2f-xxxx-c9800e50537f fwd="xx.xx.xx.xx" dyno=web.1 connect=1ms service=449ms status=500 bytes=1054 protocol=https
2017-11-02T23:18:58.801307+00:00 app[web.1]: 2017-11-02 23:18:58 - Encoding::CompatibilityError - incompatible character encodings: UTF-8 and ASCII-8BIT:
2017-11-02T23:18:58.801322+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:15:in `concat'
2017-11-02T23:18:58.801323+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:15:in `block (2 levels) in singleton class'
2017-11-02T23:18:58.801324+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:4:in `each'
2017-11-02T23:18:58.801325+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:4:in `block in singleton class'
2017-11-02T23:18:58.801326+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:-6:in `instance_eval'
2017-11-02T23:18:58.801327+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:-6:in `singleton class'
2017-11-02T23:18:58.801327+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/themes/legacy/views/events.erb:-9:in `__tilt_19721980'
2017-11-02T23:18:58.801328+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/tilt-2.0.8/lib/tilt/template.rb:170:in `call'
2017-11-02T23:18:58.801329+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/tilt-2.0.8/lib/tilt/template.rb:170:in `evaluate'
2017-11-02T23:18:58.801330+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/tilt-2.0.8/lib/tilt/template.rb:109:in `render'
2017-11-02T23:18:58.801330+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:839:in `render'
2017-11-02T23:18:58.801331+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:682:in `erb'
2017-11-02T23:18:58.801332+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/server.rb:62:in `block in <class:Server>'
2017-11-02T23:18:58.801332+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `call'
2017-11-02T23:18:58.801333+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `block in compile!'
2017-11-02T23:18:58.801334+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (3 levels) in route!'
2017-11-02T23:18:58.801334+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1010:in `route_eval'
2017-11-02T23:18:58.801335+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (2 levels) in route!'
2017-11-02T23:18:58.801336+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1037:in `block in process_route'
2017-11-02T23:18:58.801336+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `catch'
2017-11-02T23:18:58.801337+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `process_route'
2017-11-02T23:18:58.801338+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:989:in `block in route!'
2017-11-02T23:18:58.801338+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `each'
2017-11-02T23:18:58.801339+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `route!'
2017-11-02T23:18:58.801340+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1094:in `block in dispatch!'
2017-11-02T23:18:58.801340+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-02T23:18:58.801343+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-02T23:18:58.801344+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-02T23:18:58.801345+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1091:in `dispatch!'
2017-11-02T23:18:58.801346+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `block in call!'
2017-11-02T23:18:58.801346+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-02T23:18:58.801347+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-02T23:18:58.801348+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-02T23:18:58.801348+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `call!'
2017-11-02T23:18:58.801349+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:913:in `call'
2017-11-02T23:18:58.801350+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/xss_header.rb:18:in `call'
2017-11-02T23:18:58.801350+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/path_traversal.rb:16:in `call'
2017-11-02T23:18:58.801351+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/json_csrf.rb:26:in `call'
2017-11-02T23:18:58.801352+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-02T23:18:58.801352+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-02T23:18:58.801358+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/null_logger.rb:9:in `call'
2017-11-02T23:18:58.801359+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/head.rb:12:in `call'
2017-11-02T23:18:58.801360+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:194:in `call'
2017-11-02T23:18:58.801360+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1955:in `call'
2017-11-02T23:18:58.801361+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `block in call'
2017-11-02T23:18:58.801362+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1726:in `synchronize'
2017-11-02T23:18:58.801363+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `call'
2017-11-02T23:18:58.801363+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service'
2017-11-02T23:18:58.801364+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
2017-11-02T23:18:58.801365+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
2017-11-02T23:18:58.801366+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
2017-11-02T23:18:59.161179+00:00 heroku[router]: at=info method=GET path="/stylesheets/calendar.css" host=address-censored.herokuapp.com request_id=xxxxxxxx-7e7a-4b61-xxxxx-dad3274852db fwd="xx.xx.xx.xx" dyno=web.1 connect=1ms service=11ms status=200 bytes=2847 protocol=https
Aupajo commented 7 years ago

@wprzyb Hmm. I'm probably doing the wrong thing here, which is forcing the encoding at the attribute level rather than converting the whole response as Unicode.

If you add this to your config.ru (before Almanack.config), does it fix the issue?

module Almanack::EventSource::IcalFeed
  def entities
    RiCal.parse_string(response.body.force_encoding('utf-8'))
  end
end

If it does I'll prepare a fix for a new point version release.

wprzyb commented 7 years ago
2017-11-06T23:07:39.091432+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 11905`
2017-11-06T23:07:41.543806+00:00 heroku[web.1]: Process exited with status 1
2017-11-06T23:07:41.550590+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-06T23:07:41.552305+00:00 heroku[web.1]: State changed from crashed to starting
2017-11-06T23:07:41.412599+00:00 app[web.1]: TypeError: IcalFeed is not a module
2017-11-06T23:07:41.412599+00:00 app[web.1]:   /app/config.ru:3:in `block in <main>'
2017-11-06T23:07:41.412600+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
2017-11-06T23:07:41.412560+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.3.0/bin/rackup)
2017-11-06T23:07:41.412600+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
2017-11-06T23:07:41.412601+00:00 app[web.1]:   /app/config.ru:in `<main>'
2017-11-06T23:07:41.412602+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
2017-11-06T23:07:41.412602+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
2017-11-06T23:07:41.412603+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-11-06T23:07:41.412604+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-11-06T23:07:41.412601+00:00 app[web.1]:   /app/config.ru:in `new'
2017-11-06T23:07:41.412602+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
2017-11-06T23:07:41.412606+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `load'
2017-11-06T23:07:41.412605+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:148:in `start'
2017-11-06T23:07:41.412605+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-11-06T23:07:41.412605+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/bin/rackup:4:in `<top (required)>'
2017-11-06T23:07:41.412606+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `<top (required)>'
2017-11-06T23:07:41.412604+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-11-06T23:07:43.542061+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 28504`
2017-11-06T23:07:46.569117+00:00 heroku[web.1]: Process exited with status 1
2017-11-06T23:07:46.583370+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-06T23:07:46.381665+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.3.0/bin/rackup)
2017-11-06T23:07:46.381728+00:00 app[web.1]: TypeError: IcalFeed is not a module
2017-11-06T23:07:46.381730+00:00 app[web.1]:   /app/config.ru:3:in `block in <main>'
2017-11-06T23:07:46.381730+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
2017-11-06T23:07:46.381731+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
2017-11-06T23:07:46.381731+00:00 app[web.1]:   /app/config.ru:in `new'
2017-11-06T23:07:46.381732+00:00 app[web.1]:   /app/config.ru:in `<main>'
2017-11-06T23:07:46.381733+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
2017-11-06T23:07:46.381734+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
2017-11-06T23:07:46.381733+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
2017-11-06T23:07:46.381735+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-11-06T23:07:46.381736+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-11-06T23:07:46.381736+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-11-06T23:07:46.381737+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-11-06T23:07:46.381739+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/bin/rackup:4:in `<top (required)>'
2017-11-06T23:07:46.381738+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:148:in `start'
2017-11-06T23:07:46.381739+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `load'
2017-11-06T23:07:46.381740+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `<top (required)>'
Aupajo commented 7 years ago

@wprzyb Ah, sorry. You may need to require 'almanack' beforehand.

Aupajo commented 7 years ago

@wprzyb And I noticed a mistake I wrote in the original. First line should be module Almanack::EventSource::IcalFeed (no space between Almanack:: and EventSource.

wprzyb commented 7 years ago

I figured the missing space out, my config looks like this:

require 'almanack/server'
require 'almanack'

module Almanack::EventSource::IcalFeed
  def entities
    RiCal.parse_string(response.body.force_encoding('utf-8'))
  end
end

Almanack.config do |c|
  c.title = "XXXXXX"
  c.theme = 'legacy' # available: legacy
  c.days_lookahead = 30

  # Your group's URL name is what you'd find at www.meetup.com/Your-Group-URL-Name/
  # You can get a Meetup API key from https://secure.meetup.com/meetup_api/key
  c.add_meetup_group group_urlname: 'XXXXXX', key: '<censored api key>'

  # For a Google Calendar, find the "iCal" link under your Calendar's settings
  c.add_ical_feed 'http://alufel.ga/basic.ics' # sidenote - normally there is google calendar ics, backup file for the need of sending that paste

end

run Almanack::Server

and still

2017-11-07T00:48:06.524081+00:00 heroku[web.1]: State changed from crashed to starting
2017-11-07T00:48:08.407699+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 16630`
2017-11-07T00:48:11.847348+00:00 heroku[web.1]: Process exited with status 1
2017-11-07T00:48:11.863681+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-07T00:48:11.865995+00:00 heroku[web.1]: State changed from crashed to starting
2017-11-07T00:48:11.697400+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.3.0/bin/rackup)
2017-11-07T00:48:11.697447+00:00 app[web.1]: TypeError: IcalFeed is not a module
2017-11-07T00:48:11.697449+00:00 app[web.1]:   /app/config.ru:4:in `block in <main>'
2017-11-07T00:48:11.697450+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
2017-11-07T00:48:11.697452+00:00 app[web.1]:   /app/config.ru:in `<main>'
2017-11-07T00:48:11.697450+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
2017-11-07T00:48:11.697451+00:00 app[web.1]:   /app/config.ru:in `new'
2017-11-07T00:48:11.697454+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
2017-11-07T00:48:11.697454+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-11-07T00:48:11.697453+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
2017-11-07T00:48:11.697455+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-11-07T00:48:11.697452+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
2017-11-07T00:48:11.697456+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-11-07T00:48:11.697456+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-11-07T00:48:11.697457+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:148:in `start'
2017-11-07T00:48:11.697458+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/bin/rackup:4:in `<top (required)>'
2017-11-07T00:48:11.697458+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `load'
2017-11-07T00:48:11.697459+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `<top (required)>'
2017-11-07T00:48:13.489917+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 21943`
2017-11-07T00:48:15.627885+00:00 heroku[web.1]: State changed from starting to crashed
2017-11-07T00:48:15.616805+00:00 heroku[web.1]: Process exited with status 1
2017-11-07T00:48:15.509503+00:00 app[web.1]: bundler: failed to load command: rackup (/app/vendor/bundle/ruby/2.3.0/bin/rackup)
2017-11-07T00:48:15.509527+00:00 app[web.1]: TypeError: IcalFeed is not a module
2017-11-07T00:48:15.509528+00:00 app[web.1]:   /app/config.ru:4:in `block in <main>'
2017-11-07T00:48:15.509528+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `instance_eval'
2017-11-07T00:48:15.509529+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:55:in `initialize'
2017-11-07T00:48:15.509530+00:00 app[web.1]:   /app/config.ru:in `new'
2017-11-07T00:48:15.509530+00:00 app[web.1]:   /app/config.ru:in `<main>'
2017-11-07T00:48:15.509531+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `eval'
2017-11-07T00:48:15.509532+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:49:in `new_from_string'
2017-11-07T00:48:15.509532+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/builder.rb:40:in `parse_file'
2017-11-07T00:48:15.509533+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:319:in `build_app_and_options_from_config'
2017-11-07T00:48:15.509551+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:219:in `app'
2017-11-07T00:48:15.509551+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:354:in `wrapped_app'
2017-11-07T00:48:15.509552+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:283:in `start'
2017-11-07T00:48:15.509552+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/server.rb:148:in `start'
2017-11-07T00:48:15.509553+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/bin/rackup:4:in `<top (required)>'
2017-11-07T00:48:15.509553+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `load'
2017-11-07T00:48:15.509554+00:00 app[web.1]:   /app/vendor/bundle/ruby/2.3.0/bin/rackup:22:in `<top (required)>'
Phitherek commented 7 years ago

It seems that IcalFeed is a class not a module. So:

module Almanack
  module EventSource
    class IcalFeed
      def entities
        RiCal.parse_string(response.body.force_encoding('utf-8'))
      end
    end
  end
end

Not the prettiest code, but the monkey-patch should work.

wprzyb commented 7 years ago

@Phitherek sweet! now it works for web ui, but still not for ics file:

2017-11-07T22:38:14.288848+00:00 app[web.1]: 2017-11-07 22:38:14 - NoMethodError - undefined method `utc' for #<DateTime:0x00000001fed340>:
2017-11-07T22:38:14.288863+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:46:in `block in ical_feed'
2017-11-07T22:38:14.288864+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:43:in `each'
2017-11-07T22:38:14.288865+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:43:in `ical_feed'
2017-11-07T22:38:14.288865+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/server.rb:67:in `block in <class:Server>'
2017-11-07T22:38:14.288866+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `call'
2017-11-07T22:38:14.288867+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `block in compile!'
2017-11-07T22:38:14.288867+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (3 levels) in route!'
2017-11-07T22:38:14.288868+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1010:in `route_eval'
2017-11-07T22:38:14.288869+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (2 levels) in route!'
2017-11-07T22:38:14.288871+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `process_route'
2017-11-07T22:38:14.288869+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1037:in `block in process_route'
2017-11-07T22:38:14.288870+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `catch'
2017-11-07T22:38:14.288872+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:989:in `block in route!'
2017-11-07T22:38:14.288872+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `each'
2017-11-07T22:38:14.288873+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `route!'
2017-11-07T22:38:14.288873+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1094:in `block in dispatch!'
2017-11-07T22:38:14.288874+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-07T22:38:14.288875+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-07T22:38:14.288875+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-07T22:38:14.288876+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1091:in `dispatch!'
2017-11-07T22:38:14.288876+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `block in call!'
2017-11-07T22:38:14.288877+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-07T22:38:14.288878+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-07T22:38:14.288881+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/path_traversal.rb:16:in `call'
2017-11-07T22:38:14.288878+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-07T22:38:14.288879+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `call!'
2017-11-07T22:38:14.288880+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:913:in `call'
2017-11-07T22:38:14.288881+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/xss_header.rb:18:in `call'
2017-11-07T22:38:14.288882+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/json_csrf.rb:26:in `call'
2017-11-07T22:38:14.288884+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/null_logger.rb:9:in `call'
2017-11-07T22:38:14.288883+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-07T22:38:14.288885+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/head.rb:12:in `call'
2017-11-07T22:38:14.288883+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-07T22:38:14.288886+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:194:in `call'
2017-11-07T22:38:14.288886+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1955:in `call'
2017-11-07T22:38:14.288887+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `block in call'
2017-11-07T22:38:14.288888+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1726:in `synchronize'
2017-11-07T22:38:14.288888+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `call'
2017-11-07T22:38:14.288890+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
2017-11-07T22:38:14.288889+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service'
2017-11-07T22:38:14.288891+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
2017-11-07T22:38:14.288891+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
Phitherek commented 7 years ago

Try this one:

module Almanack
  module EventSource
    class IcalFeed
      private def ical_event_for(event)
        ical_event = RiCal.Event
        ical_event.summary = event.title
        ical_event.dtstart = event.start_time.new_offset(0)
        ical_event.dtend = (event.end_time || event.start_time + default_event_duration ).new_offset(0)
        ical_event.description = event.description if event.description
        ical_event.location = event.location if event.location
        ical_event
      end
    end
  end
end

Let me know if it works, I didn't test it. Of course you can add this to previous monkey-patch.

wprzyb commented 7 years ago

@Phitherek - Same

2017-11-07T23:51:15.069688+00:00 app[web.1]: 2017-11-07 23:51:15 - NoMethodError - undefined method `utc' for #<DateTime:0x000000012614b0>:
2017-11-07T23:51:15.069700+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:46:in `block in ical_feed'
2017-11-07T23:51:15.069708+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:43:in `each'
2017-11-07T23:51:15.069709+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/calendar.rb:43:in `ical_feed'
2017-11-07T23:51:15.069710+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/almanack-1.0.5/lib/almanack/server.rb:67:in `block in <class:Server>'
2017-11-07T23:51:15.069711+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `call'
2017-11-07T23:51:15.069711+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1632:in `block in compile!'
2017-11-07T23:51:15.069712+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (3 levels) in route!'
2017-11-07T23:51:15.069712+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1010:in `route_eval'
2017-11-07T23:51:15.069713+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:991:in `block (2 levels) in route!'
2017-11-07T23:51:15.069714+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1037:in `block in process_route'
2017-11-07T23:51:15.069714+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `catch'
2017-11-07T23:51:15.069715+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1035:in `process_route'
2017-11-07T23:51:15.069715+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:989:in `block in route!'
2017-11-07T23:51:15.069716+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `each'
2017-11-07T23:51:15.069717+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:988:in `route!'
2017-11-07T23:51:15.069717+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1094:in `block in dispatch!'
2017-11-07T23:51:15.069718+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-07T23:51:15.069718+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-07T23:51:15.069719+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-07T23:51:15.069719+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1091:in `dispatch!'
2017-11-07T23:51:15.069719+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `block in call!'
2017-11-07T23:51:15.069720+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `block in invoke'
2017-11-07T23:51:15.069720+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `catch'
2017-11-07T23:51:15.069721+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1073:in `invoke'
2017-11-07T23:51:15.069721+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:923:in `call!'
2017-11-07T23:51:15.069722+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:913:in `call'
2017-11-07T23:51:15.069722+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/xss_header.rb:18:in `call'
2017-11-07T23:51:15.069723+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/path_traversal.rb:16:in `call'
2017-11-07T23:51:15.069723+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/json_csrf.rb:26:in `call'
2017-11-07T23:51:15.069724+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-07T23:51:15.069724+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-protection-2.0.0/lib/rack/protection/base.rb:50:in `call'
2017-11-07T23:51:15.069725+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/null_logger.rb:9:in `call'
2017-11-07T23:51:15.069725+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/head.rb:12:in `call'
2017-11-07T23:51:15.069726+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:194:in `call'
2017-11-07T23:51:15.069726+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1955:in `call'
2017-11-07T23:51:15.069727+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `block in call'
2017-11-07T23:51:15.069727+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1726:in `synchronize'
2017-11-07T23:51:15.069728+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/sinatra-2.0.0/lib/sinatra/base.rb:1499:in `call'
2017-11-07T23:51:15.069728+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.3.0/gems/rack-2.0.3/lib/rack/handler/webrick.rb:86:in `service'
2017-11-07T23:51:15.069729+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
2017-11-07T23:51:15.069730+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
2017-11-07T23:51:15.069730+00:00 app[web.1]:    /app/vendor/ruby-2.3.4/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'