Merge 3b1f7e5a00 into e267adf8b7
This commit is contained in:
commit
2843b1ecc5
6 changed files with 48 additions and 1 deletions
|
|
@ -3,7 +3,8 @@
|
||||||
class ConferencesController < ApplicationController
|
class ConferencesController < ApplicationController
|
||||||
protect_from_forgery with: :null_session
|
protect_from_forgery with: :null_session
|
||||||
before_action :respond_to_options
|
before_action :respond_to_options
|
||||||
load_and_authorize_resource find_by: :short_title, except: :show
|
load_and_authorize_resource find_by: :short_title, except: [:show, :feed]
|
||||||
|
skip_authorization_check only: :feed
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@current = Conference.upcoming.reorder(start_date: :asc)
|
@current = Conference.upcoming.reorder(start_date: :asc)
|
||||||
|
|
@ -108,6 +109,13 @@ class ConferencesController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def feed
|
||||||
|
@conferences = Conference.order(created_at: :desc)
|
||||||
|
respond_to do |format|
|
||||||
|
format.rss { render layout: false }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def code_of_conduct; end
|
def code_of_conduct; end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
||||||
18
app/views/conferences/feed.rss.builder
Normal file
18
app/views/conferences/feed.rss.builder
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
xml.instruct! :xml, version: "1.0"
|
||||||
|
xml.rss version: "2.0" do
|
||||||
|
xml.channel do
|
||||||
|
xml.title "#{ENV.fetch('OSEM_NAME', 'OSEM')} - Conferences"
|
||||||
|
xml.description "Conferences from #{ENV.fetch('OSEM_NAME', 'OSEM')}"
|
||||||
|
xml.link conferences_url
|
||||||
|
|
||||||
|
@conferences.each do |conference|
|
||||||
|
xml.item do
|
||||||
|
xml.title conference.title
|
||||||
|
xml.description conference.description
|
||||||
|
xml.pubDate conference.created_at.to_fs(:rfc822)
|
||||||
|
xml.link conference_url(conference.short_title)
|
||||||
|
xml.guid conference_url(conference.short_title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -23,6 +23,9 @@
|
||||||
%span.btn-group
|
%span.btn-group
|
||||||
= link_to("Days only", calendar_url(protocol: 'webcal', format: 'ics'), class: 'btn btn-default')
|
= 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')
|
= link_to("Detailed", calendar_url(protocol: 'webcal', format: 'ics', full: true), class: 'btn btn-default')
|
||||||
|
%p
|
||||||
|
Subscribe to the RSS feed:
|
||||||
|
= link_to("RSS Feed", feed_url(format: :rss), class: 'btn btn-default')
|
||||||
|
|
||||||
-content_for :script_body do
|
-content_for :script_body do
|
||||||
:javascript
|
:javascript
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
%meta{content: '', name: 'author'}
|
%meta{content: '', name: 'author'}
|
||||||
= stylesheet_link_tag "application", media: 'all'
|
= stylesheet_link_tag "application", media: 'all'
|
||||||
= javascript_include_tag "application"
|
= javascript_include_tag "application"
|
||||||
|
= auto_discovery_link_tag(:rss, feed_url(format: :rss), title: "#{ENV.fetch('OSEM_NAME', 'OSEM')} Conferences RSS Feed")
|
||||||
|
|
||||||
= csrf_meta_tags
|
= csrf_meta_tags
|
||||||
= content_for(:script_head)
|
= content_for(:script_head)
|
||||||
|
|
|
||||||
|
|
@ -216,6 +216,7 @@ Osem::Application.routes.draw do
|
||||||
get '/admin' => redirect('/admin/conferences')
|
get '/admin' => redirect('/admin/conferences')
|
||||||
|
|
||||||
get '/calendar' => 'conferences#calendar'
|
get '/calendar' => 'conferences#calendar'
|
||||||
|
get '/feed' => 'conferences#feed'
|
||||||
|
|
||||||
if ENV.fetch('OSEM_ROOT_CONFERENCE', nil)
|
if ENV.fetch('OSEM_ROOT_CONFERENCE', nil)
|
||||||
root to: redirect("/conferences/#{ENV.fetch('OSEM_ROOT_CONFERENCE')}")
|
root to: redirect("/conferences/#{ENV.fetch('OSEM_ROOT_CONFERENCE')}")
|
||||||
|
|
|
||||||
|
|
@ -49,4 +49,20 @@ describe ConferencesController do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'GET #feed' do
|
||||||
|
render_views
|
||||||
|
|
||||||
|
it 'returns RSS feed successfully' do
|
||||||
|
get :feed, format: :rss
|
||||||
|
expect(response.response_code).to eq(200)
|
||||||
|
expect(response.content_type).to include('application/rss+xml')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'includes conference data in the feed' do
|
||||||
|
conference # trigger let
|
||||||
|
get :feed, format: :rss
|
||||||
|
expect(response.body).to include(conference.title)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue