Skip to content
This repository has been archived by the owner on Aug 1, 2018. It is now read-only.

add cleanUp option and bump wysihtml5 version #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/javascripts/active_admin/editor/config.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
config.spinner = '<%= asset_path 'active_admin/editor/loader.gif' %>'
config.uploads_enabled = <%= ActiveAdmin::Editor.configuration.s3_configured? %>
config.parserRules = <%= ActiveAdmin::Editor.configuration.parser_rules.to_json %>
config.cleanUp = <%= ActiveAdmin::Editor.configuration.clean_up.to_json %>
})(window)
3 changes: 2 additions & 1 deletion app/assets/javascripts/active_admin/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
this._editor = new wysihtml5.Editor(this.$textarea.attr('id'), {
toolbar: this.$toolbar.attr('id'),
stylesheets: config.stylesheets,
parserRules: config.parserRules
parserRules: config.parserRules,
cleanUp: config.cleanUp
})
}

Expand Down
13 changes: 8 additions & 5 deletions lib/active_admin/editor/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ class Configuration
# The s3 bucket to store uploads.
attr_accessor :s3_bucket

# Base directory to store the uploaded files in the bucket. Defaults to
# 'uploads'.
attr_accessor :storage_dir

# wysiwyg stylesheets that get included in the backend and the frontend.
attr_accessor :stylesheets
attr_writer :stylesheets

# wysihtml5 cleanUp options
attr_writer :clean_up

def storage_dir
@storage_dir ||= 'uploads'
Expand All @@ -40,6 +39,10 @@ def storage_dir=(dir)
def stylesheets
@stylesheets ||= [ 'active_admin/editor/wysiwyg.css' ]
end

def clean_up
@clean_up.nil? ? true : !!@clean_up
end

def s3_configured?
aws_access_key_id.present? &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
# config.aws_access_key_id = ''
# config.aws_access_secret = ''
# config.storage_dir = 'uploads'
# config.clean_up = false
end
1 change: 1 addition & 0 deletions spec/lib/config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
its(:aws_access_secret) { should be_nil }
its(:s3_bucket) { should be_nil }
its(:storage_dir) { should eq 'uploads' }
its(:clean_up) { should be_true }
end

describe '.s3_configured?' do
Expand Down
Loading