From 34e16b7d7a88013578014be0402ab686b03f235b Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 1 Jul 2025 08:40:49 +0200 Subject: lib: Introduce the PlainExporter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This class exports things into plain text. It follows a close format to that of the one for UOC, but without any formatting. Signed-off-by: Miquel Sabaté Solà --- app/controllers/exports_controller.rb | 6 ++++++ app/views/exports/new.html.erb | 1 + 2 files changed, 7 insertions(+) (limited to 'app') diff --git a/app/controllers/exports_controller.rb b/app/controllers/exports_controller.rb index 4303ea6..812cf39 100644 --- a/app/controllers/exports_controller.rb +++ b/app/controllers/exports_controller.rb @@ -8,6 +8,12 @@ class ExportsController < ApplicationController respond_to do |format| format.csv { set_file_name!(ext: 'csv') } format.uoc { set_file_name!(ext: 'tex') } + format.text do + send_data PlainExporter.new(things: @results).export, + type: 'text/plain', + disposition: 'attachment', + filename: "#{@search.name}.txt" + end end end diff --git a/app/views/exports/new.html.erb b/app/views/exports/new.html.erb index 631da20..fa52360 100644 --- a/app/views/exports/new.html.erb +++ b/app/views/exports/new.html.erb @@ -11,6 +11,7 @@ <%= I18n.t('searches.export.action').capitalize %> -- cgit v1.2.3