Class: Weneedfeed::Controllers::ShowFeed

Inherits:
Base
  • Object
show all
Defined in:
lib/weneedfeed/controllers/show_feed.rb

Instance Method Summary collapse

Instance Method Details

#callObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/weneedfeed/controllers/show_feed.rb', line 6

def call
  page_schema = schema.find_page_schema(path_parameters[:page_id])
  unless page_schema
    response.status = 404
    return
  end

  scraping = ::Weneedfeed::Scraping.new(
    description: page_schema.description,
    item_description_selector: page_schema.item_description_selector,
    item_image_selector: page_schema.item_image_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(
    ::Weneedfeed::Views::ShowFeed.new(
      page: page,
      partial_template_path: ::File.expand_path(
        'templates/show_feed.xml.erb',
        "#{__dir__}/../../.."
      ),
      request: request
    ).to_s
  )
end