Created
September 20, 2011 18:00
-
-
Save jkeck/1229804 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Blacklight.configure(:shared) do |config| | |
#... | |
SolrDocument.use_extension(YourModule) | |
#... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class YourController < ApplicationController | |
def my_json | |
response, @document = get_solr_response_for_doc_id | |
render :text => @document.my_json, :layout => false | |
end | |
def our_json | |
response, @document = get_solr_response_for_doc_id | |
render :text => @document.export_as(:our_json), :layout => false | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module YourModule | |
# This is the simplest implementation | |
def my_json | |
return {:this_is_my_json => ["Thing1","Thing2"]}.to_json | |
end | |
# This uses the export_as functionality. This will make the JSON a true export format which will be auto-discoverable. | |
def self.extended(document) | |
document.export_as(:our_json,"application/json") | |
end | |
private | |
def export_as_our_json | |
return {:this_is_our_json => ["Thing1","Thing2"]}.to_json | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment