Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Blacklight actions
#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
You can’t perform that action at this time.