Skip to content

Commit

Permalink
move combined refworks/endnote exports to SolrResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
jrochkind committed Apr 2, 2014
1 parent 3afd78e commit d2530d9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
10 changes: 2 additions & 8 deletions app/controllers/bookmarks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ def index
additional_response_formats(format)

format.endnote do
# Just concatenate individual endnote exports with blank lines. Not
# every record can be exported as endnote -- only include those that
# can.
render :text => @document_list.collect {|d| d.export_as(:endnote) if d.export_formats.keys.include? :endnote}.join("\n"), :layout => false
render :text => @response.to_endnote, :layout => false
end

format.refworks_marc_txt do
# Just concatenate individual refworks_marc_txt exports with blank lines. Not
# every record can be exported as refworks_marc_txt -- only include those that
# can.
render :text => @document_list.collect {|d| d.export_as(:refworks_marc_txt) if d.export_formats.keys.include? :refworks_marc_txt}.join("\n"), :layout => false
render :text => @response.to_refworks_marc_txt, :layout => false
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions lib/blacklight/solr_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,22 @@ def grouped?
self.has_key? "grouped"
end

# Exports the entire list of #documents as an EndNote document;
# that is, the individual endnote documents separated by newlines.
#
# Only documents that can be exported to endnote format are included.
def to_endnote

This comment has been minimized.

Copy link
@cbeer

cbeer Apr 2, 2014

Member

I wonder if we can do this in a generic way that is reusable for other types of document export formats. I guess the trick is knowing if the export format is text and can just be concatenated together or not. Too bad the MIME type for endnote is application/x-endnote-refer or we could just key off that somehow.

This comment has been minimized.

Copy link
@jrochkind

jrochkind Apr 2, 2014

Author Member

yeah, I thought about that too, but didn't come up with a good solution. If someone else can though, that'd be awesome. Otherwise, maybe it's okay to do it the simple way for now, and add a more clever way later if it seems needed and someone comes up with one? I think avoiding unneccesary complexity that may not be needed is probably also good.

This comment has been minimized.

Copy link
@cbeer

cbeer Apr 2, 2014

Member

It would go a long way to appeasing my squeamish belief that this is a MARC-only feature, if we were able to build this out in a generic way. I'm also eyeing the RSS and Atom export formats, and wonder if we could deal with them in a similar way. I'll try to find some time to poke at it.

documents.select {|d| d.export_formats.keys.include?(:endnote)}.collect {|d| d.export_as(:endnote)}.join("\n")
end

# Exports the entire list of #documents as "Refworks tagged MARC" format,
# that is individual documents separated by newlines.
#
# Only documents that can be exported in this format are included.
def to_refworks_marc_txt
documents.select {|d| d.export_formats.keys.include?(:refworks_marc_txt)}.collect {|d| d.export_as(:refworks_marc_txt)}.join("\n")
end

private

def force_to_utf8(value)
Expand Down

0 comments on commit d2530d9

Please sign in to comment.