diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 08:40:49 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-07-01 08:53:56 +0200 |
| commit | 34e16b7d7a88013578014be0402ab686b03f235b (patch) | |
| tree | 5ef848d3c44f72ff95a24b123e5da88bc5aef1a2 /app | |
| parent | 24714068efc5866999311ad482d54f5c7a90c449 (diff) | |
| download | operum-34e16b7d7a88013578014be0402ab686b03f235b.tar.gz operum-34e16b7d7a88013578014be0402ab686b03f235b.zip | |
lib: Introduce the PlainExporter
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à <mikisabate@gmail.com>
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/exports_controller.rb | 6 | ||||
| -rw-r--r-- | app/views/exports/new.html.erb | 1 |
2 files changed, 7 insertions, 0 deletions
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 @@ <select id="export-select-format" data-action="export#change"> <option selected="selected" value="csv">CSV</option> <option value="uoc">UOC</option> + <option value="txt">Plain text</option> </select> <a id="export-format-button" class="button" href="#"><%= I18n.t('searches.export.action').capitalize %></a> |
