You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
550 B

  1. # frozen_string_literal: true
  2. class Api::OEmbedController < Api::BaseController
  3. respond_to :json
  4. def show
  5. @stream_entry = find_stream_entry.stream_entry
  6. render json: @stream_entry, serializer: OEmbedSerializer, width: maxwidth_or_default, height: maxheight_or_default
  7. end
  8. private
  9. def find_stream_entry
  10. StreamEntryFinder.new(params[:url])
  11. end
  12. def maxwidth_or_default
  13. (params[:maxwidth].presence || 400).to_i
  14. end
  15. def maxheight_or_default
  16. params[:maxheight].present? ? params[:maxheight].to_i : nil
  17. end
  18. end