1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

move RSS code into separate folders

This commit is contained in:
Sylvain 2016-09-29 10:53:20 +02:00
parent 376cb6dbe9
commit 34ad1c9056
8 changed files with 72 additions and 44 deletions

View File

@ -0,0 +1,9 @@
class Rss::EventsController < Rss::RssController
def index
@events = Event.includes(:event_image, :event_files, :availability, :category)
.where('availabilities.start_at >= ?', Time.now)
.order('availabilities.start_at ASC').references(:availabilities).limit(10)
@fab_name = Setting.find_by(name: 'fablab_name').value
end
end

View File

@ -0,0 +1,7 @@
class Rss::ProjectsController < Rss::RssController
def index
@projects = Project.includes(:project_image, :users).published.order('created_at desc').limit(10)
@fab_name = Setting.find_by(name: 'fablab_name').value
end
end

View File

@ -0,0 +1,4 @@
class Rss::RssController < ApplicationController
end

View File

@ -1,21 +0,0 @@
#encoding: UTF-8
xml.instruct! :xml, version: "1.0"
xml.rss version: "2.0" do
xml.channel do
xml.title "#{t('app.public.events_list.the_fablab_s_courses_and_workshops')} - #{Setting.find_by(name: 'fablab_name').value}"
xml.author Setting.find_by(name: 'fablab_name').value
xml.link request.base_url + "/#!/events"
xml.language I18n.locale.to_s
@events.each do |event|
xml.item do
xml.guid event.id
xml.pubDate event.created_at.strftime("%F %T")
xml.title event.name
xml.link request.base_url + "/#!/events/" + event.id.to_s
xml.description event.description
end
end
end
end

View File

@ -1,23 +0,0 @@
#encoding: UTF-8
xml.instruct! :xml, version: "1.0"
xml.rss version: "2.0" do
xml.channel do
xml.title "#{t('app.public.projects_list.the_fablab_projects')} - #{Setting.find_by(name: 'fablab_name').value}"
xml.description t('app.public.projects_list.all_projects')
xml.author Setting.find_by(name: 'fablab_name').value
xml.link request.base_url + "/#!/projects"
xml.language I18n.locale.to_s
@projects.each do |project|
xml.item do
xml.guid project.id
xml.pubDate project.created_at.strftime("%F %T")
xml.title project.name
xml.link request.base_url + "/#!/projects/" + project.slug
xml.author project.author.first_name
xml.description project.description
end
end
end
end

View File

@ -0,0 +1,22 @@
#encoding: UTF-8
xml.instruct! :xml, version: '1.0'
xml.rss version: '2.0' do
xml.channel do
xml.title "#{t('app.public.events_list.the_fablab_s_events')} - #{@fab_name}"
xml.description t('app.public.home.fablab_s_next_events')
xml.author @fab_name
xml.link root_url + '#!/events'
xml.language I18n.locale.to_s
@events.each do |event|
xml.item do
xml.guid event.id
xml.pubDate event.created_at.strftime('%F %T')
xml.title event.name
xml.link root_url + '#!/events/' + event.id.to_s
xml.description event.description
end
end
end
end

View File

@ -0,0 +1,23 @@
#encoding: UTF-8
xml.instruct! :xml, version: '1.0'
xml.rss version: '2.0' do
xml.channel do
xml.title "#{t('app.public.projects_list.the_fablab_projects')} - #{@fab_name}"
xml.description t('app.public.home.latest_documented_projects')
xml.author @fab_name
xml.link root_url + '#!/projects'
xml.language I18n.locale.to_s
@projects.each do |project|
xml.item do
xml.guid project.id
xml.pubDate project.created_at.strftime('%F %T')
xml.title project.name
xml.link root_url + '#!/projects/' + project.slug
xml.author project.author.first_name
xml.description project.description
end
end
end
end

View File

@ -132,6 +132,13 @@ Rails.application.routes.draw do
get 'version' => 'version#show'
end
# rss
namespace :rss, as: nil, defaults: { format: :xml } do
resources :projects, only: [:index]
resources :events, only: [:index]
end
# open_api
namespace :open_api do