-
Notifications
You must be signed in to change notification settings - Fork 876
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
72 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
lib/generators/ckeditor/templates/active_record/shrine/ckeditor/asset.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class Ckeditor::Asset < ActiveRecord::Base | ||
include Ckeditor::Orm::ActiveRecord::AssetBase | ||
include Ckeditor::Backend::Shrine | ||
|
||
include CkeditorAttachmentUploader::Attachment(:attachment) | ||
end |
7 changes: 7 additions & 0 deletions
7
lib/generators/ckeditor/templates/active_record/shrine/ckeditor/attachment_file.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# frozen_string_literal: true | ||
|
||
class Ckeditor::AttachmentFile < Ckeditor::Asset | ||
def url_thumb | ||
Ckeditor::Utils.filethumb(filename) | ||
end | ||
end |
11 changes: 11 additions & 0 deletions
11
lib/generators/ckeditor/templates/active_record/shrine/ckeditor/picture.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Ckeditor::Picture < Ckeditor::Asset | ||
def url_content | ||
attachment.url | ||
end | ||
|
||
def url_thumb | ||
attachment.url | ||
end | ||
end |
25 changes: 25 additions & 0 deletions
25
lib/generators/ckeditor/templates/active_record/shrine/migration.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class CreateCkeditorAssets < ActiveRecord::Migration[6.1] | ||
def up | ||
create_table :ckeditor_assets do |t| | ||
t.integer :data_size | ||
t.string :type, limit: 30 | ||
|
||
# Shrine column | ||
t.text :attachment_data | ||
|
||
# Uncomment these to save image dimensions, if your need them. | ||
# t.integer :data_width | ||
# t.integer :data_height | ||
|
||
t.timestamps null: false | ||
end | ||
|
||
add_index :ckeditor_assets, :type | ||
end | ||
|
||
def down | ||
drop_table :ckeditor_assets | ||
end | ||
end |
3 changes: 3 additions & 0 deletions
3
lib/generators/ckeditor/templates/base/shrine/attachment_uploader.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class CkeditorAttachmentUploader < Shrine | ||
# plugins and uploading logic | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters