From e47e83cf6bded3d1924b4d500193e7876833ef83 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 2 Jul 2017 13:03:43 -0400 Subject: Created admin panel Currently allows you to create and edit blogs, including associated records. Uses a WYSIWYG editor that allows uploading images. Also included jQuery :( --- app/models/ckeditor/asset.rb | 4 ++++ app/models/ckeditor/attachment_file.rb | 13 +++++++++++++ app/models/ckeditor/picture.rb | 14 ++++++++++++++ 3 files changed, 31 insertions(+) create mode 100644 app/models/ckeditor/asset.rb create mode 100644 app/models/ckeditor/attachment_file.rb create mode 100644 app/models/ckeditor/picture.rb (limited to 'app/models/ckeditor') diff --git a/app/models/ckeditor/asset.rb b/app/models/ckeditor/asset.rb new file mode 100644 index 0000000..cf636ed --- /dev/null +++ b/app/models/ckeditor/asset.rb @@ -0,0 +1,4 @@ +class Ckeditor::Asset < ActiveRecord::Base + include Ckeditor::Orm::ActiveRecord::AssetBase + include Ckeditor::Backend::Paperclip +end diff --git a/app/models/ckeditor/attachment_file.rb b/app/models/ckeditor/attachment_file.rb new file mode 100644 index 0000000..fe09132 --- /dev/null +++ b/app/models/ckeditor/attachment_file.rb @@ -0,0 +1,13 @@ +class Ckeditor::AttachmentFile < Ckeditor::Asset + has_attached_file :data, + url: '/uploads/attachments/:id/:filename', + path: ':rails_root/public/uploads/attachments/:id/:filename' + + validates_attachment_presence :data + validates_attachment_size :data, less_than: 100.megabytes + do_not_validate_attachment_file_type :data + + def url_thumb + @url_thumb ||= Ckeditor::Utils.filethumb(filename) + end +end diff --git a/app/models/ckeditor/picture.rb b/app/models/ckeditor/picture.rb new file mode 100644 index 0000000..02aa9b2 --- /dev/null +++ b/app/models/ckeditor/picture.rb @@ -0,0 +1,14 @@ +class Ckeditor::Picture < Ckeditor::Asset + has_attached_file :data, + url: '/uploads/pictures/:id/:style_:basename.:extension', + path: ':rails_root/public/uploads/pictures/:id/:style_:basename.:extension', + styles: { content: '800>', thumb: '118x100#' } + + validates_attachment_presence :data + validates_attachment_size :data, less_than: 2.megabytes + validates_attachment_content_type :data, content_type: /\Aimage/ + + def url_content + url(:content) + end +end -- cgit 1.4.1