/activeadmin-qiniu_input

ActiveAdmin Inputs for using qiniu to upload image or video.

Primary LanguageRubyMIT LicenseMIT

ActiveAdmin::QiniuInput

ActiveAdmin::QiniuInput provides two inputs for activeadmin when we using qiniu. They have been used in our company Beansmile for several times. And now we open-source them, hoping they can help you.

  • qiniu_image

qiniu_image

  • qiniu_video

qiniu_video

Installation

Add this line to your application's Gemfile:

gem 'activeadmin-qiniu_input'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activeadmin-qiniu_input

Usage

  • Run the generator:
$ rails g active_admin:qiniu_input:install

Check here to see more information about this generator.

  • To use this gem, we need you to implement your API with which we can fetch the Qiniu meta. With the use of Qiniu gem, it should be easy. Please refer to our test controller code.

  • Use your api to change qiniu_meta_url in config/initializers/active_admin/qiniu_input.rb. You also have to set ActiveAdmin::QiniuInput.domain.

ActiveAdmin::QiniuInput.qiniu_meta_url = "/your_qiniu_meta_url"
ActiveAdmin::QiniuInput.domain = "example.com"
  • use our inputs in your ActiveAdmin form. Use them like this:
form do |f|
  f.inputs do
    f.input :image_url, as: :qiniu_image
    f.input :video_url, as: :qiniu_video
    f.input :audio_url, as: :qiniu_audio
  end
  f.actions
end
  • we also add qiniu_image_column, qiniu_video_column, qiniu_audio_column, qiniu_image_row, qiniu_video_row and qiniu_audio_row dsl to show images, videos and audio.
index do
  column :title
  qiniu_image_column :image_url
  qiniu_video_column :video_url
  qiniu_audio_column :audio_url
  actions
end

show do
  attributes_table do
    row :id
    row :title
    qiniu_image_row :image_url
    qiniu_video_row :video_url
    qiniu_audio_row :audio_url
    row :created_at
    row :updated_at
  end
end

Contributing

Please open an issue or a pull request to Contribute.

License

The gem is available as open source under the terms of the MIT License.