lib/weneedfeed/controllers/show_feed.rb in weneedfeed-0.5.0 vs lib/weneedfeed/controllers/show_feed.rb in weneedfeed-0.6.0
- old
+ new
@@ -1,33 +1,24 @@
# frozen_string_literal: true
module Weneedfeed
module Controllers
- class ShowFeed < ::Hibana::Controller
+ class ShowFeed < ::Weneedfeed::Controllers::Base
def call
- env = request.env
- page_name = env.dig(
- 'router.params',
- :page_name
- )
- properties = env.dig(
- 'weneedfeed.schema',
- 'pages',
- page_name
- )
- unless properties
+ page_schema = schema.find_page_schema(path_parameters[:page_id])
+ unless page_schema
response.status = 404
return
end
scraping = ::Weneedfeed::Scraping.new(
- item_description_selector: properties['item_description_selector'],
- item_link_selector: properties['item_link_selector'],
- item_time_selector: properties['item_time_selector'],
- item_title_selector: properties['item_title_selector'],
- item_selector: properties['item_selector'],
- title: properties['title'],
- url: properties['url']
+ item_description_selector: page_schema.item_description_selector,
+ item_link_selector: page_schema.item_link_selector,
+ item_time_selector: page_schema.item_time_selector,
+ item_title_selector: page_schema.item_title_selector,
+ item_selector: page_schema.item_selector,
+ title: page_schema.title,
+ url: page_schema.url,
)
page = scraping.call
response.content_type = 'application/xml; charset=utf-8'
response.write(