mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
commit
e4c9100ea6
8 changed files with 92 additions and 3 deletions
2
Gemfile
2
Gemfile
|
|
@ -219,6 +219,8 @@ gem 'nokogiri', '>= 1.8.1'
|
|||
# memcached binary connector
|
||||
gem 'dalli'
|
||||
|
||||
gem 'icalendar'
|
||||
|
||||
# Use guard and spring for testing in development
|
||||
group :development do
|
||||
# to launch specs when files are modified
|
||||
|
|
|
|||
|
|
@ -241,6 +241,9 @@ GEM
|
|||
image_processing (1.12.1)
|
||||
mini_magick (>= 4.9.5, < 5)
|
||||
ruby-vips (>= 2.0.17, < 3)
|
||||
icalendar (2.7.0)
|
||||
ice_cube (~> 0.16)
|
||||
ice_cube (0.16.3)
|
||||
io-like (0.3.0)
|
||||
iso-639 (0.2.8)
|
||||
jaro_winkler (1.5.3)
|
||||
|
|
@ -652,6 +655,7 @@ DEPENDENCIES
|
|||
guard-rspec
|
||||
haml-rails
|
||||
haml_lint
|
||||
icalendar
|
||||
iso-639
|
||||
jquery-datatables-rails
|
||||
jquery-rails
|
||||
|
|
|
|||
|
|
@ -67,6 +67,45 @@ class ConferencesController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def calendar
|
||||
respond_to do |format|
|
||||
format.ics do
|
||||
calendar = Icalendar::Calendar.new
|
||||
Conference.all.each do |conf|
|
||||
if params[:full]
|
||||
event_schedules = conf.program.selected_event_schedules(
|
||||
includes: [{ event: %i[event_type speakers submitter] }]
|
||||
)
|
||||
calendar = icalendar_proposals(calendar, event_schedules.map(&:event), conf)
|
||||
else
|
||||
calendar.event do |e|
|
||||
e.dtstart = conf.start_date
|
||||
e.dtstart.ical_params = { 'VALUE'=>'DATE' }
|
||||
e.dtend = conf.end_date
|
||||
e.dtend.ical_params = { 'VALUE'=>'DATE' }
|
||||
e.duration = "P#{(conf.end_date - conf.start_date + 1).floor}D"
|
||||
e.created = conf.created_at
|
||||
e.last_modified = conf.updated_at
|
||||
e.summary = conf.title
|
||||
e.description = conf.description
|
||||
e.uid = conf.guid
|
||||
e.url = conference_url(conf.short_title)
|
||||
v = conf.venue
|
||||
e.geo = v.latitude, v.longitude if v.latitude && v.longitude
|
||||
location = ''
|
||||
location += "#{v.street}, " if v.street
|
||||
location += "#{v.postalcode} #{v.city}, " if v.postalcode && v.city
|
||||
location += v.country_name if v.country_name
|
||||
e.location = location if location
|
||||
end
|
||||
end
|
||||
end
|
||||
calendar.publish
|
||||
render inline: calendar.to_ical
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def conference_finder_conditions
|
||||
|
|
|
|||
|
|
@ -21,6 +21,12 @@ class SchedulesController < ApplicationController
|
|||
format.xml do
|
||||
@events_xml = event_schedules.map(&:event).group_by{ |event| event.time.to_date } if event_schedules
|
||||
end
|
||||
format.ics do
|
||||
cal = Icalendar::Calendar.new
|
||||
cal = icalendar_proposals(cal, event_schedules.map(&:event), @conference)
|
||||
cal.publish
|
||||
render inline: cal.to_ical
|
||||
end
|
||||
|
||||
format.html do
|
||||
@rooms = @conference.venue.rooms if @conference.venue
|
||||
|
|
|
|||
|
|
@ -21,4 +21,31 @@ module ConferenceHelper
|
|||
'%20Sponsorship'
|
||||
].join
|
||||
end
|
||||
|
||||
# adds events to icalendar for proposals in a conference
|
||||
def icalendar_proposals(calendar, proposals, conference)
|
||||
proposals.each do |proposal|
|
||||
calendar.event do |e|
|
||||
e.dtstart = proposal.time
|
||||
e.dtend = proposal.time + proposal.event_type.length * 60
|
||||
e.duration = "PT#{proposal.event_type.length}M"
|
||||
e.created = proposal.created_at
|
||||
e.last_modified = proposal.updated_at
|
||||
e.summary = proposal.title
|
||||
e.description = proposal.abstract
|
||||
e.uid = proposal.guid
|
||||
e.url = conference_program_proposal_url(conference.short_title, proposal.id)
|
||||
v = conference.venue
|
||||
e.geo = v.latitude, v.longitude if v.latitude && v.longitude
|
||||
location = ''
|
||||
location += "#{proposal.room.name} - " if proposal.room.name
|
||||
location += " - #{v.street}, " if v.street
|
||||
location += "#{v.postalcode} #{v.city}, " if v.postalcode && v.city
|
||||
location += "#{v.country_name}, " if v.country_name
|
||||
e.location = location
|
||||
e.categories = conference.title, "Difficulty: #{proposal.difficulty_level.title}", "Track: #{proposal.track.name}"
|
||||
end
|
||||
end
|
||||
calendar
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -18,6 +18,11 @@
|
|||
#antiquated.collapse
|
||||
- @antiquated.each do |conference|
|
||||
= render '/conferences/conference_details', conference: conference
|
||||
%p
|
||||
Add the events to your calendar:
|
||||
%span.btn-group
|
||||
= link_to("Days only", calendar_url(protocol: 'webcal', format: 'ics'), class: 'btn btn-default')
|
||||
= link_to("Detailed", calendar_url(protocol: 'webcal', format: 'ics', full: true), class: 'btn btn-default')
|
||||
|
||||
-content_for :script_body do
|
||||
:javascript
|
||||
|
|
|
|||
|
|
@ -26,7 +26,11 @@
|
|||
|
||||
.visible-md-inline.visible-lg-inline
|
||||
= render partial: 'carousel', locals: { date: date, hrs_per_slide: 3 }
|
||||
%p.pull-right
|
||||
%p
|
||||
%span
|
||||
= link_to conference_schedule_url(protocol: 'webcal', format: 'ics') do
|
||||
Add the schedule to your calendar
|
||||
%span.pull-right
|
||||
= link_to app_conference_schedule_path do
|
||||
Get the mobile app!
|
||||
|
||||
|
|
|
|||
|
|
@ -219,6 +219,8 @@ Osem::Application.routes.draw do
|
|||
|
||||
get '/admin' => redirect('/admin/conferences')
|
||||
|
||||
get '/calendar' => 'conferences#calendar'
|
||||
|
||||
unless ENV['OSEM_ROOT_CONFERENCE'].blank?
|
||||
root to: redirect("/conferences/#{ENV['OSEM_ROOT_CONFERENCE']}")
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue