Skip to content
Merged
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
11 changes: 9 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,15 @@ DEVISE_SECRET=
#
# Asset Host Configuration
#
HOST=http://localhost:3000
S3_HOST_ALIAS=
FOG_HOST=http://localhost:3000
HOST_ALIAS=

# S3
S3_ACCESS_KEY_ID=
S3_SECRET_ACCESS_KEY=
S3_BUCKET_NAME=
S3_PROTOCOL=
S3_REGION=

#
# Email Configuration
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
/public/youtubes/
/public/bulk_jobs/
/public/content-snippets-edit
/public/uploads/

# Ignore the default SQLite database.
/db/*.sqlite3
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ gem 'rails', '~> 5.0.1'

# Cortex-specific
gem 'cortex-exceptions', '= 0.0.4'
gem 'cortex-plugins-core', '= 0.11.3'
gem 'cortex-plugins-core', '= 0.12.1'

# API
gem 'grape', '~> 0.17'
Expand Down
20 changes: 15 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,18 @@ GEM
concurrent-ruby (1.0.4)
connection_pool (2.2.1)
cortex-exceptions (0.0.4)
cortex-plugins-core (0.11.3)
cortex-plugins-core (0.12.1)
cells (~> 4.1)
cells-haml (~> 0.0.10)
cells-rails (~> 0.0.6)
cells-haml (~> 0.0)
cells-rails (~> 0.0)
fastimage (~> 2.1)
image_processing (~> 0.4)
jsonb_accessor (~> 1.0.0.beta)
mimemagic (~> 0.3.2)
mimemagic (~> 0.3)
mini_magick (~> 4.7)
rails (>= 4)
react_on_rails (~> 6)
shrine (~> 2.6)
database_cleaner (1.5.3)
debug_inspector (0.0.2)
declarative-builder (0.1.0)
Expand All @@ -169,6 +173,7 @@ GEM
dotenv-rails (2.2.0)
dotenv (= 2.2.0)
railties (>= 3.2, < 5.1)
down (2.4.3)
elasticsearch (5.0.3)
elasticsearch-api (= 5.0.3)
elasticsearch-transport (= 5.0.3)
Expand Down Expand Up @@ -205,6 +210,7 @@ GEM
i18n (~> 0.5)
faraday (0.11.0)
multipart-post (>= 1.2, < 3)
fastimage (2.1.0)
ffi (1.9.17)
fission (0.5.0)
CFPropertyList (~> 2.2)
Expand Down Expand Up @@ -411,6 +417,7 @@ GEM
image_optim_pack (0.3.1.20170121)
fspath (>= 2.1, < 4)
image_optim (~> 0.19)
image_processing (0.4.1)
image_size (1.5.0)
in_threads (1.3.1)
inflecto (0.0.2)
Expand Down Expand Up @@ -471,6 +478,7 @@ GEM
mime-types-data (~> 3.2015)
mime-types-data (3.2016.0521)
mimemagic (0.3.2)
mini_magick (4.7.0)
mini_portile2 (2.1.0)
mini_racer (0.1.8)
libv8 (~> 5.3)
Expand Down Expand Up @@ -654,6 +662,8 @@ GEM
shellany (0.0.1)
shoulda-matchers (3.1.1)
activesupport (>= 4.0.0)
shrine (2.6.1)
down (>= 2.3.6)
sidekiq (4.2.9)
concurrent-ruby (~> 1.0)
connection_pool (~> 2.2, >= 2.2.0)
Expand Down Expand Up @@ -734,7 +744,7 @@ DEPENDENCIES
cells-rails (~> 0.0.7)
codeclimate-test-reporter (~> 0.6)
cortex-exceptions (= 0.0.4)
cortex-plugins-core (= 0.11.3)
cortex-plugins-core (= 0.12.1)
database_cleaner (~> 1.5)
deep_cloneable (~> 2.2.2)
devise (~> 4.2.0)
Expand Down
4 changes: 3 additions & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

@import 'components/card';
@import 'components/confetti';
@import 'components/content';
@import 'components/dialog';
@import 'components/flash';
@import 'components/form';
Expand All @@ -28,6 +27,9 @@
@import 'components/jumbo-button';
@import 'components/notes';
@import 'components/sidebar';
@import 'components/table';
@import 'components/ui';

@import 'demo';

@import 'cortex-plugins-core/application';
3 changes: 2 additions & 1 deletion app/assets/stylesheets/components/card.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// Overrides

.mdl-card {
border: $data-table-dividers;
border-radius: 0;
width: auto;
border-radius: 3px;
overflow: visible;
z-index: auto;
}
2 changes: 1 addition & 1 deletion app/assets/stylesheets/components/dialog.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
justify-content: center;
align-items: center;

border: 1px solid $color-grey;
border: $data-table-dividers;
margin-top: 10px;
margin-bottom: 10px;
width: 100%;
Expand Down
5 changes: 5 additions & 0 deletions app/assets/stylesheets/components/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.index {
width: 100%;
}

.content_item-link {
cursor: pointer;

Expand All @@ -21,3 +25,4 @@
}
}
}

8 changes: 5 additions & 3 deletions app/cells/index/index.haml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
%table{ class: 'mdl-data-table mdl-js-data-table', style: 'width: 100%;' }
= cell('index', @index, data: data).(:table_headers)
= cell('index', @index, data: data).(:table_body)
.mdl-grid
.mdl-cell.mdl-cell--12-col
%table.mdl-data-table.mdl-js-data-table.index
= cell('index', @index, data: data).(:table_headers)
= cell('index', @index, data: data).(:table_body)
12 changes: 9 additions & 3 deletions app/cells/index_cell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,32 @@ def render_table_header(column_data)
end

def asset_field_item(content_item)
# TODO: This needs to be generic functionality
content_item.field_items.find { |field_item| field_item.field.name == 'Asset' }
end

def content_item_title(content_item)
# TODO: This needs to be generic functionality
content_item.field_items.find { |field_item| field_item.field.name == 'Title' }.data['text']
end

def content_item_thumb_url(content_item)
asset_field_item(content_item).data['asset']['style_urls']['mini']
# TODO: The thumb version needs to be configurable, and this needs to be in a plugin
asset_field_item(content_item).data['asset']&.[]('versions')&.[]('mini')&.[]('url')
end

def content_item_asset_url(content_item)
asset_field_item(content_item).data['asset']['url']
# TODO: This needs to be in a plugin
asset_field_item(content_item).data['asset']['versions']['original']['url']
end

def content_item_asset_type(content_item)
MimeMagic.new(asset_field_item(content_item).data['asset']['content_type']).mediatype
# TODO: This needs to be in a plugin
MimeMagic.new(asset_field_item(content_item).data['asset']['versions']['original']['mime_type']).mediatype
end

def content_item_asset_alt_text(content_item)
# TODO: This needs to be in a plugin
content_item.field_items.find { |field_item| field_item.field.name == 'Alt Tag' }.data['text']
end
end
2 changes: 1 addition & 1 deletion app/controllers/content_items_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,6 @@ def create
else
flash[:success] = "Hooray! #{content_type.name} Created!"
redirect_to content_type_content_items_path
end
end
end
end
4 changes: 3 additions & 1 deletion app/helpers/popup_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module PopupHelper
# TODO: This needs to be in a plugin

def media_content_type
@media_content_type ||= ContentType.find_by_name('Media')
end
Expand All @@ -13,7 +15,7 @@ def media_asset_field

def media_image_content_items
@media_image_content_items ||= media_content_items.select do |content_item|
MimeMagic.new(content_item.field_items.find_by_field_id(media_asset_field).data['asset']['content_type']).mediatype == 'image'
MimeMagic.new(content_item.field_items.find_by_field_id(media_asset_field).data['asset']['versions']['original']['mime_type']).mediatype == 'image'
end
end

Expand Down
4 changes: 2 additions & 2 deletions app/helpers/rss_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ def media_data(media_hash, rss_content_item)
if field_item.nil?
{}
else
asset_data = field_item.data["asset"]
asset_data = field_item.data['asset']['versions']['original']

{
"url": asset_data["url"],
"type": asset_data["content_type"],
"type": asset_data["mime_type"],
"medium": media_hash["medium"],
"width": media_hash["width"] || asset_data["dimensions"]["width"],
"height": media_hash["height"] || asset_data["dimensions"]["height"]
Expand Down
14 changes: 10 additions & 4 deletions app/helpers/widget_parsers/media_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
module WidgetParsers
module MediaHelper
# This needs to be abstracted to a plugin

def self.parse(body)
body_document = document_for(body)
body_document = document_for body

widget_nodes_for(body_document).each do |widget_node|
widget_node.inner_html = render_widget_inner widget_node
Expand All @@ -28,10 +30,10 @@ def self.render_widget_inner(widget)
end

def self.content_item_element(id)
asset_field_item = ContentItem.find(id).field_items.find { |field_item| field_item.field.field_type == "asset_field_type" }
url = asset_field_item.data["asset"]["url"]
asset_field_item = ContentItem.find(id).field_items.find { |field_item| field_item.field.field_type_instance.is_a?(AssetFieldType) }
url = asset_field_item.data['asset']['versions']['original']['url']

if asset_field_item.data["asset"]["content_type"].include?("image")
if image? asset_field_item.data['asset']['versions']['original']['mime_type']
element = { src: url }
tag_type = 'img'
else
Expand All @@ -41,5 +43,9 @@ def self.content_item_element(id)

[element, tag_type]
end

def self.image?(mime_type)
MimeMagic.new(mime_type).mediatype == 'image'
end
end
end
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
Paperclip.options[:command_path] = '/usr/local/bin/'
config.paperclip_defaults = {
storage: :fog,
fog_host: ENV['HOST'],
fog_host: ENV['FOG_HOST'],
fog_directory: '',
fog_credentials: {
provider: 'Local',
Expand Down
1 change: 0 additions & 1 deletion config/initializers/field_types.rb

This file was deleted.