Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
toastercup committed Apr 26, 2017
2 parents 5e36487 + 8e0fde3 commit dfc1c99
Show file tree
Hide file tree
Showing 27 changed files with 267 additions and 124 deletions.
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
7 changes: 6 additions & 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.2'
gem 'cortex-plugins-core', '= 0.12.1'

# API
gem 'grape', '~> 0.17'
Expand Down Expand Up @@ -103,6 +103,11 @@ gem 'ng-rails-csrf', '~> 0.1.0'
gem 'bootstrap-tagsinput-rails', '~> 0.4.2'
gem 'dialog-polyfill-rails', '~> 0.4.5'

# Feature Flagging
gem 'flipper', '~> 0.10'
gem 'flipper-ui', '~> 0.10'
gem 'flipper-active_record', '~> 0.10'

group :tasks do
# Parsing
gem 'nokogiri'
Expand Down
32 changes: 27 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.2)
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,9 +210,19 @@ 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)
flipper (0.10.2)
flipper-active_record (0.10.2)
activerecord (>= 3.2, < 6)
flipper (~> 0.10.2)
flipper-ui (0.10.2)
erubis (~> 2.7.0)
flipper (~> 0.10.2)
rack (>= 1.4, < 3)
rack-protection (>= 1.5.3, < 2.1.0)
fog (1.38.0)
fog-aliyun (>= 0.1.0)
fog-atmos
Expand Down Expand Up @@ -402,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 @@ -462,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 @@ -645,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 @@ -725,7 +744,7 @@ DEPENDENCIES
cells-rails (~> 0.0.7)
codeclimate-test-reporter (~> 0.6)
cortex-exceptions (= 0.0.4)
cortex-plugins-core (= 0.11.2)
cortex-plugins-core (= 0.12.1)
database_cleaner (~> 1.5)
deep_cloneable (~> 2.2.2)
devise (~> 4.2.0)
Expand All @@ -739,6 +758,9 @@ DEPENDENCIES
excon (~> 0.55.0)
factory_girl_rails (~> 4.8)
faker (~> 1.7)
flipper (~> 0.10)
flipper-active_record (~> 0.10)
flipper-ui (~> 0.10)
fog (~> 1.38.0)
font-awesome-sass (~> 4.7.0)
foreman
Expand Down
1 change: 1 addition & 0 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

//= require base
//= require datepicker_init
//= require form
//= require flash
//= require media_dialogs
//= require sidebar-toggle
Expand Down
6 changes: 6 additions & 0 deletions app/assets/javascripts/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
var requiredFormField = function() {
$('input[data-required=true]').attr('required', true);
}

$(document).ready(requiredFormField);
$(document).on('page:load', requiredFormField);
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
1 change: 1 addition & 0 deletions app/assets/stylesheets/components/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ form {
border-right: none;
border-left: none;
border-bottom: 1px solid $color-grey-light;
box-shadow: none;
}
.cortex-bootstrap .label {
border-radius: 0.75em;
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: 4 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ def extra_config
def qualtrics_domain
extra_config.qualtrics_id.delete('_').downcase
end

def flag_enabled?(flag_name)
Cortex.flipper[flag_name].enabled?(current_user, request)
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
21 changes: 13 additions & 8 deletions app/helpers/rss_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,20 @@ def media_data(media_hash, rss_content_item)

field_name = linked_field_item.field.metadata["field_name"]
asset_content_item_id = linked_field_item.data["content_item_id"]
field_item = Field.find_by_name(field_name).field_items.find { |field_item| field_item.content_item_id == asset_content_item_id }

asset_data = Field.find_by_name(field_name).field_items.find { |field_item| field_item.content_item_id == asset_content_item_id }.data["asset"]
if field_item.nil?
{}
else
asset_data = field_item.data['asset']['versions']['original']

{
"url": asset_data["url"],
"type": asset_data["content_type"],
"medium": media_hash["medium"],
"width": media_hash["width"] || asset_data["dimensions"]["width"],
"height": media_hash["height"] || asset_data["dimensions"]["height"]
}
{
"url": asset_data["url"],
"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"]
}
end
end
end
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
23 changes: 21 additions & 2 deletions app/models/concerns/searchable_webpage.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,31 @@ module SearchableWebpage
include Searchable

mapping do
indexes :id, :type => :integer, :index => :not_analyzed
indexes :tenant_id, :type => :integer, :index => :not_analyzed
indexes :name, :analyzer => :snowball
indexes :url, :analyzer => :keyword
indexes :dynamic_yield_sku, :analyzer => :keyword
indexes :dynamic_yield_category, :analyzer => :keyword
indexes :created_by, :analyzer => :keyword
indexes :created_at, :type => :date, :include_in_all => false
indexes :deleted_at, :type => :date, :include_in_all => false
indexes :updated_at, :type => :date, :include_in_all => false

indexes :id, :type => :integer, :index => :not_analyzed
indexes :tenant_id, :type => :integer, :index => :not_analyzed
indexes :user_id, :type => :integer, :index => :not_analyzed
indexes :thumbnail_file_name, :type => :string, :index => :not_analyzed
indexes :thumbnail_content_type, :type => :string, :index => :not_analyzed
indexes :thumbnail_file_size, :type => :long, :index => :not_analyzed
indexes :thumbnail_updated_at, :type => :date, :index => :not_analyzed
indexes :seo_title, :type => :string, :index => :not_analyzed
indexes :seo_description, :type => :string, :index => :not_analyzed
indexes :noindex, :type => :boolean, :index => :not_analyzed
indexes :nofollow, :type => :boolean, :index => :not_analyzed
indexes :nosnippet, :type => :boolean, :index => :not_analyzed
indexes :noodp, :type => :boolean, :index => :not_analyzed
indexes :noarchive, :type => :boolean, :index => :not_analyzed
indexes :noimageindex, :type => :boolean, :index => :not_analyzed
indexes :tables_widget, :type => :nested, :enabled => false
end

def as_indexed_json(options = {})
Expand Down
Loading

0 comments on commit dfc1c99

Please sign in to comment.