This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2016-11-30 14:01:03 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-22 14:08:51 -08:00
|
|
|
class Api::OEmbedController < ApiController
|
2016-11-30 14:01:03 -08:00
|
|
|
respond_to :json
|
|
|
|
|
|
|
|
def show
|
2017-05-30 13:30:06 -07:00
|
|
|
@stream_entry = find_stream_entry.stream_entry
|
|
|
|
@width = maxwidth_or_default
|
|
|
|
@height = maxheight_or_default
|
2016-11-30 14:01:03 -08:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-05-30 13:30:06 -07:00
|
|
|
def find_stream_entry
|
|
|
|
StreamEntryFinder.new(params[:url])
|
2017-04-27 05:42:22 -07:00
|
|
|
end
|
|
|
|
|
2017-05-30 13:30:06 -07:00
|
|
|
def maxwidth_or_default
|
|
|
|
(params[:maxwidth].presence || 400).to_i
|
2017-04-27 05:42:22 -07:00
|
|
|
end
|
|
|
|
|
2017-05-30 13:30:06 -07:00
|
|
|
def maxheight_or_default
|
|
|
|
params[:maxheight].present? ? params[:maxheight].to_i : nil
|
2016-11-30 14:01:03 -08:00
|
|
|
end
|
|
|
|
end
|