Last active
August 29, 2015 14:07
-
-
Save cjcolvar/1d821fe502016aceea1b to your computer and use it in GitHub Desktop.
Blacklight actions
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
#Adding a new document action: | |
#Override the catalog controller or subclass and add your action: | |
#needs user feedback from a form | |
self.add_action(:translate, :translate_action, validator: :validate_translate_params) | |
def translate_action | |
Translator.translate(documents, params[:language]) | |
end | |
#doesn't require form feedback | |
self.add_action(:reverse) | |
#Create partials | |
#app/views/bookmarks/translate.html.erb | |
#app/views/bookmarks/translate_success.html.erb | |
#app/views/bookmarks/reverse.html.erb | |
#Add Routes | |
#make sure to place these before the blacklight routes | |
get 'bookmarks/reverse', as: :reverse_bookmarks | |
get 'bookmarks/translate', as: :translate_bookmarks | |
post 'bookmarks/translate' | |
#Add translations | |
en: | |
blacklight: | |
tools: | |
reverse: Reverse titles | |
translate: Translate this! | |
translate: | |
success: Successfully translated. | |
#Can also remove inherited actions | |
self.document_actions -= [:sms] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment