Skip to content

Instantly share code, notes, and snippets.

@cjcolvar
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjcolvar/1d821fe502016aceea1b to your computer and use it in GitHub Desktop.
Save cjcolvar/1d821fe502016aceea1b to your computer and use it in GitHub Desktop.
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