mirror of
https://github.com/Neetpone/foalfetch.git
synced 2025-02-08 18:06:43 +01:00
17 lines
492 B
Ruby
17 lines
492 B
Ruby
# frozen_string_literal: true
|
|
class Stories::DownloadsController < ApplicationController
|
|
MIME_TYPES = {
|
|
text: 'text/plain',
|
|
html: 'text/html',
|
|
epub: 'application/x-epub'
|
|
}.freeze
|
|
|
|
def show
|
|
@story = Story.find(params[:story_id])
|
|
|
|
format = MIME_TYPES.keys.detect { |fmt| fmt.to_s == params[:fmt] } || :text
|
|
renderer = StoryRenderer.new @story
|
|
|
|
render inline: renderer.send(format), content_type: MIME_TYPES[format], content_disposition: 'attachment'
|
|
end
|
|
end
|