Skip to content

Commit dfc1c99

Browse files
committed
Merge branch 'develop'
2 parents 5e36487 + 8e0fde3 commit dfc1c99

File tree

27 files changed

+267
-124
lines changed

27 files changed

+267
-124
lines changed

.env.example

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,15 @@ DEVISE_SECRET=
55
#
66
# Asset Host Configuration
77
#
8-
HOST=http://localhost:3000
9-
S3_HOST_ALIAS=
8+
FOG_HOST=http://localhost:3000
9+
HOST_ALIAS=
10+
11+
# S3
12+
S3_ACCESS_KEY_ID=
13+
S3_SECRET_ACCESS_KEY=
14+
S3_BUCKET_NAME=
15+
S3_PROTOCOL=
16+
S3_REGION=
1017

1118
#
1219
# Email Configuration

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
/public/youtubes/
1616
/public/bulk_jobs/
1717
/public/content-snippets-edit
18+
/public/uploads/
1819

1920
# Ignore the default SQLite database.
2021
/db/*.sqlite3

Gemfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ gem 'rails', '~> 5.0.1'
1212

1313
# Cortex-specific
1414
gem 'cortex-exceptions', '= 0.0.4'
15-
gem 'cortex-plugins-core', '= 0.11.2'
15+
gem 'cortex-plugins-core', '= 0.12.1'
1616

1717
# API
1818
gem 'grape', '~> 0.17'
@@ -103,6 +103,11 @@ gem 'ng-rails-csrf', '~> 0.1.0'
103103
gem 'bootstrap-tagsinput-rails', '~> 0.4.2'
104104
gem 'dialog-polyfill-rails', '~> 0.4.5'
105105

106+
# Feature Flagging
107+
gem 'flipper', '~> 0.10'
108+
gem 'flipper-ui', '~> 0.10'
109+
gem 'flipper-active_record', '~> 0.10'
110+
106111
group :tasks do
107112
# Parsing
108113
gem 'nokogiri'

Gemfile.lock

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,14 +137,18 @@ GEM
137137
concurrent-ruby (1.0.4)
138138
connection_pool (2.2.1)
139139
cortex-exceptions (0.0.4)
140-
cortex-plugins-core (0.11.2)
140+
cortex-plugins-core (0.12.1)
141141
cells (~> 4.1)
142-
cells-haml (~> 0.0.10)
143-
cells-rails (~> 0.0.6)
142+
cells-haml (~> 0.0)
143+
cells-rails (~> 0.0)
144+
fastimage (~> 2.1)
145+
image_processing (~> 0.4)
144146
jsonb_accessor (~> 1.0.0.beta)
145-
mimemagic (~> 0.3.2)
147+
mimemagic (~> 0.3)
148+
mini_magick (~> 4.7)
146149
rails (>= 4)
147150
react_on_rails (~> 6)
151+
shrine (~> 2.6)
148152
database_cleaner (1.5.3)
149153
debug_inspector (0.0.2)
150154
declarative-builder (0.1.0)
@@ -169,6 +173,7 @@ GEM
169173
dotenv-rails (2.2.0)
170174
dotenv (= 2.2.0)
171175
railties (>= 3.2, < 5.1)
176+
down (2.4.3)
172177
elasticsearch (5.0.3)
173178
elasticsearch-api (= 5.0.3)
174179
elasticsearch-transport (= 5.0.3)
@@ -205,9 +210,19 @@ GEM
205210
i18n (~> 0.5)
206211
faraday (0.11.0)
207212
multipart-post (>= 1.2, < 3)
213+
fastimage (2.1.0)
208214
ffi (1.9.17)
209215
fission (0.5.0)
210216
CFPropertyList (~> 2.2)
217+
flipper (0.10.2)
218+
flipper-active_record (0.10.2)
219+
activerecord (>= 3.2, < 6)
220+
flipper (~> 0.10.2)
221+
flipper-ui (0.10.2)
222+
erubis (~> 2.7.0)
223+
flipper (~> 0.10.2)
224+
rack (>= 1.4, < 3)
225+
rack-protection (>= 1.5.3, < 2.1.0)
211226
fog (1.38.0)
212227
fog-aliyun (>= 0.1.0)
213228
fog-atmos
@@ -402,6 +417,7 @@ GEM
402417
image_optim_pack (0.3.1.20170121)
403418
fspath (>= 2.1, < 4)
404419
image_optim (~> 0.19)
420+
image_processing (0.4.1)
405421
image_size (1.5.0)
406422
in_threads (1.3.1)
407423
inflecto (0.0.2)
@@ -462,6 +478,7 @@ GEM
462478
mime-types-data (~> 3.2015)
463479
mime-types-data (3.2016.0521)
464480
mimemagic (0.3.2)
481+
mini_magick (4.7.0)
465482
mini_portile2 (2.1.0)
466483
mini_racer (0.1.8)
467484
libv8 (~> 5.3)
@@ -645,6 +662,8 @@ GEM
645662
shellany (0.0.1)
646663
shoulda-matchers (3.1.1)
647664
activesupport (>= 4.0.0)
665+
shrine (2.6.1)
666+
down (>= 2.3.6)
648667
sidekiq (4.2.9)
649668
concurrent-ruby (~> 1.0)
650669
connection_pool (~> 2.2, >= 2.2.0)
@@ -725,7 +744,7 @@ DEPENDENCIES
725744
cells-rails (~> 0.0.7)
726745
codeclimate-test-reporter (~> 0.6)
727746
cortex-exceptions (= 0.0.4)
728-
cortex-plugins-core (= 0.11.2)
747+
cortex-plugins-core (= 0.12.1)
729748
database_cleaner (~> 1.5)
730749
deep_cloneable (~> 2.2.2)
731750
devise (~> 4.2.0)
@@ -739,6 +758,9 @@ DEPENDENCIES
739758
excon (~> 0.55.0)
740759
factory_girl_rails (~> 4.8)
741760
faker (~> 1.7)
761+
flipper (~> 0.10)
762+
flipper-active_record (~> 0.10)
763+
flipper-ui (~> 0.10)
742764
fog (~> 1.38.0)
743765
font-awesome-sass (~> 4.7.0)
744766
foreman

app/assets/javascripts/application.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
//= require base
1717
//= require datepicker_init
18+
//= require form
1819
//= require flash
1920
//= require media_dialogs
2021
//= require sidebar-toggle

app/assets/javascripts/form.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
var requiredFormField = function() {
2+
$('input[data-required=true]').attr('required', true);
3+
}
4+
5+
$(document).ready(requiredFormField);
6+
$(document).on('page:load', requiredFormField);

app/assets/stylesheets/application.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
@import 'components/card';
2121
@import 'components/confetti';
22-
@import 'components/content';
2322
@import 'components/dialog';
2423
@import 'components/flash';
2524
@import 'components/form';
@@ -28,6 +27,9 @@
2827
@import 'components/jumbo-button';
2928
@import 'components/notes';
3029
@import 'components/sidebar';
30+
@import 'components/table';
3131
@import 'components/ui';
3232

3333
@import 'demo';
34+
35+
@import 'cortex-plugins-core/application';
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
// Overrides
22

33
.mdl-card {
4+
border: $data-table-dividers;
5+
border-radius: 0;
46
width: auto;
5-
border-radius: 3px;
67
overflow: visible;
78
z-index: auto;
89
}

app/assets/stylesheets/components/dialog.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
justify-content: center;
2424
align-items: center;
2525

26-
border: 1px solid $color-grey;
26+
border: $data-table-dividers;
2727
margin-top: 10px;
2828
margin-bottom: 10px;
2929
width: 100%;

app/assets/stylesheets/components/form.scss

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ form {
4646
border-right: none;
4747
border-left: none;
4848
border-bottom: 1px solid $color-grey-light;
49+
box-shadow: none;
4950
}
5051
.cortex-bootstrap .label {
5152
border-radius: 0.75em;

app/assets/stylesheets/components/index.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
.index {
2+
width: 100%;
3+
}
4+
15
.content_item-link {
26
cursor: pointer;
37

@@ -21,3 +25,4 @@
2125
}
2226
}
2327
}
28+

app/cells/index/index.haml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
%table{ class: 'mdl-data-table mdl-js-data-table', style: 'width: 100%;' }
2-
= cell('index', @index, data: data).(:table_headers)
3-
= cell('index', @index, data: data).(:table_body)
1+
.mdl-grid
2+
.mdl-cell.mdl-cell--12-col
3+
%table.mdl-data-table.mdl-js-data-table.index
4+
= cell('index', @index, data: data).(:table_headers)
5+
= cell('index', @index, data: data).(:table_body)

app/cells/index_cell.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,32 @@ def render_table_header(column_data)
2020
end
2121

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

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

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

3437
def content_item_asset_url(content_item)
35-
asset_field_item(content_item).data['asset']['url']
38+
# TODO: This needs to be in a plugin
39+
asset_field_item(content_item).data['asset']['versions']['original']['url']
3640
end
3741

3842
def content_item_asset_type(content_item)
39-
MimeMagic.new(asset_field_item(content_item).data['asset']['content_type']).mediatype
43+
# TODO: This needs to be in a plugin
44+
MimeMagic.new(asset_field_item(content_item).data['asset']['versions']['original']['mime_type']).mediatype
4045
end
4146

4247
def content_item_asset_alt_text(content_item)
48+
# TODO: This needs to be in a plugin
4349
content_item.field_items.find { |field_item| field_item.field.name == 'Alt Tag' }.data['text']
4450
end
4551
end

app/controllers/content_items_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,6 @@ def create
6464
else
6565
flash[:success] = "Hooray! #{content_type.name} Created!"
6666
redirect_to content_type_content_items_path
67-
end
67+
end
6868
end
6969
end

app/helpers/application_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ def extra_config
1212
def qualtrics_domain
1313
extra_config.qualtrics_id.delete('_').downcase
1414
end
15+
16+
def flag_enabled?(flag_name)
17+
Cortex.flipper[flag_name].enabled?(current_user, request)
18+
end
1519
end

app/helpers/popup_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
module PopupHelper
2+
# TODO: This needs to be in a plugin
3+
24
def media_content_type
35
@media_content_type ||= ContentType.find_by_name('Media')
46
end
@@ -13,7 +15,7 @@ def media_asset_field
1315

1416
def media_image_content_items
1517
@media_image_content_items ||= media_content_items.select do |content_item|
16-
MimeMagic.new(content_item.field_items.find_by_field_id(media_asset_field).data['asset']['content_type']).mediatype == 'image'
18+
MimeMagic.new(content_item.field_items.find_by_field_id(media_asset_field).data['asset']['versions']['original']['mime_type']).mediatype == 'image'
1719
end
1820
end
1921

app/helpers/rss_helper.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,20 @@ def media_data(media_hash, rss_content_item)
4949

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

53-
asset_data = Field.find_by_name(field_name).field_items.find { |field_item| field_item.content_item_id == asset_content_item_id }.data["asset"]
54+
if field_item.nil?
55+
{}
56+
else
57+
asset_data = field_item.data['asset']['versions']['original']
5458

55-
{
56-
"url": asset_data["url"],
57-
"type": asset_data["content_type"],
58-
"medium": media_hash["medium"],
59-
"width": media_hash["width"] || asset_data["dimensions"]["width"],
60-
"height": media_hash["height"] || asset_data["dimensions"]["height"]
61-
}
59+
{
60+
"url": asset_data["url"],
61+
"type": asset_data["mime_type"],
62+
"medium": media_hash["medium"],
63+
"width": media_hash["width"] || asset_data["dimensions"]["width"],
64+
"height": media_hash["height"] || asset_data["dimensions"]["height"]
65+
}
66+
end
6267
end
6368
end

app/helpers/widget_parsers/media_helper.rb

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
module WidgetParsers
22
module MediaHelper
3+
# This needs to be abstracted to a plugin
4+
35
def self.parse(body)
4-
body_document = document_for(body)
6+
body_document = document_for body
57

68
widget_nodes_for(body_document).each do |widget_node|
79
widget_node.inner_html = render_widget_inner widget_node
@@ -28,10 +30,10 @@ def self.render_widget_inner(widget)
2830
end
2931

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

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

4244
[element, tag_type]
4345
end
46+
47+
def self.image?(mime_type)
48+
MimeMagic.new(mime_type).mediatype == 'image'
49+
end
4450
end
4551
end

app/models/concerns/searchable_webpage.rb

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,31 @@ module SearchableWebpage
55
include Searchable
66

77
mapping do
8-
indexes :id, :type => :integer, :index => :not_analyzed
9-
indexes :tenant_id, :type => :integer, :index => :not_analyzed
108
indexes :name, :analyzer => :snowball
119
indexes :url, :analyzer => :keyword
10+
indexes :dynamic_yield_sku, :analyzer => :keyword
11+
indexes :dynamic_yield_category, :analyzer => :keyword
1212
indexes :created_by, :analyzer => :keyword
1313
indexes :created_at, :type => :date, :include_in_all => false
14+
indexes :deleted_at, :type => :date, :include_in_all => false
15+
indexes :updated_at, :type => :date, :include_in_all => false
16+
17+
indexes :id, :type => :integer, :index => :not_analyzed
18+
indexes :tenant_id, :type => :integer, :index => :not_analyzed
19+
indexes :user_id, :type => :integer, :index => :not_analyzed
20+
indexes :thumbnail_file_name, :type => :string, :index => :not_analyzed
21+
indexes :thumbnail_content_type, :type => :string, :index => :not_analyzed
22+
indexes :thumbnail_file_size, :type => :long, :index => :not_analyzed
23+
indexes :thumbnail_updated_at, :type => :date, :index => :not_analyzed
24+
indexes :seo_title, :type => :string, :index => :not_analyzed
25+
indexes :seo_description, :type => :string, :index => :not_analyzed
26+
indexes :noindex, :type => :boolean, :index => :not_analyzed
27+
indexes :nofollow, :type => :boolean, :index => :not_analyzed
28+
indexes :nosnippet, :type => :boolean, :index => :not_analyzed
29+
indexes :noodp, :type => :boolean, :index => :not_analyzed
30+
indexes :noarchive, :type => :boolean, :index => :not_analyzed
31+
indexes :noimageindex, :type => :boolean, :index => :not_analyzed
32+
indexes :tables_widget, :type => :nested, :enabled => false
1433
end
1534

1635
def as_indexed_json(options = {})

0 commit comments

Comments
 (0)