about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-07-02 13:03:43 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-07-02 13:03:43 -0400
commite47e83cf6bded3d1924b4d500193e7876833ef83 (patch)
tree058f011637e67455dcd8451fbfa784b5883c6f69 /app/models
parent528ccde8915cd1ed7a39e137dd4d98869797956a (diff)
downloadthoughts-e47e83cf6bded3d1924b4d500193e7876833ef83.tar.gz
thoughts-e47e83cf6bded3d1924b4d500193e7876833ef83.tar.bz2
thoughts-e47e83cf6bded3d1924b4d500193e7876833ef83.zip
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 :(
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ckeditor/asset.rb4
-rw-r--r--app/models/ckeditor/attachment_file.rb13
-rw-r--r--app/models/ckeditor/picture.rb14
-rw-r--r--app/models/entry.rb4
4 files changed, 34 insertions, 1 deletions
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 @@
1class Ckeditor::Asset < ActiveRecord::Base
2 include Ckeditor::Orm::ActiveRecord::AssetBase
3 include Ckeditor::Backend::Paperclip
4end
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 @@
1class Ckeditor::AttachmentFile < Ckeditor::Asset
2 has_attached_file :data,
3 url: '/uploads/attachments/:id/:filename',
4 path: ':rails_root/public/uploads/attachments/:id/:filename'
5
6 validates_attachment_presence :data
7 validates_attachment_size :data, less_than: 100.megabytes
8 do_not_validate_attachment_file_type :data
9
10 def url_thumb
11 @url_thumb ||= Ckeditor::Utils.filethumb(filename)
12 end
13end
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 @@
1class Ckeditor::Picture < Ckeditor::Asset
2 has_attached_file :data,
3 url: '/uploads/pictures/:id/:style_:basename.:extension',
4 path: ':rails_root/public/uploads/pictures/:id/:style_:basename.:extension',
5 styles: { content: '800>', thumb: '118x100#' }
6
7 validates_attachment_presence :data
8 validates_attachment_size :data, less_than: 2.megabytes
9 validates_attachment_content_type :data, content_type: /\Aimage/
10
11 def url_content
12 url(:content)
13 end
14end
diff --git a/app/models/entry.rb b/app/models/entry.rb index 22b330a..87fd46d 100644 --- a/app/models/entry.rb +++ b/app/models/entry.rb
@@ -1,8 +1,10 @@
1class Entry < ApplicationRecord 1class Entry < ApplicationRecord
2 has_many :records, as: :recordable 2 has_many :records, as: :recordable, inverse_of: :recordable
3 3
4 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ 4 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/
5 5
6 accepts_nested_attributes_for :records, allow_destroy: true
7
6 def path 8 def path
7 "/says/#{slug}" 9 "/says/#{slug}"
8 end 10 end