rails_admin_content_builder 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +4 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +8 -0
  7. data/CODE_OF_CONDUCT.md +49 -0
  8. data/Gemfile +12 -0
  9. data/LICENSE.txt +21 -0
  10. data/README.md +129 -0
  11. data/Rakefile +21 -0
  12. data/app/assets/images/cb-image-default.jpg +0 -0
  13. data/app/assets/images/cb-loading.svg +1 -0
  14. data/app/assets/images/cb-snippet-image-text.jpg +0 -0
  15. data/app/assets/images/cb-snippet-image.jpg +0 -0
  16. data/app/assets/images/cb-snippet-quote-text.jpg +0 -0
  17. data/app/assets/images/cb-snippet-quote.jpg +0 -0
  18. data/app/assets/images/cb-snippet-text-image.jpg +0 -0
  19. data/app/assets/images/cb-snippet-text-quote.jpg +0 -0
  20. data/app/assets/images/cb-snippet-text.jpg +0 -0
  21. data/app/assets/images/cb-snippet-video.jpg +0 -0
  22. data/app/assets/images/cb-video-default.jpg +0 -0
  23. data/app/assets/javascripts/rails_admin/content_builder.js.erb +295 -0
  24. data/app/assets/stylesheets/rails_admin/content_builder.scss +238 -0
  25. data/app/controllers/rails_admin_content_builder/content_builder_controller.rb +19 -0
  26. data/app/helpers/rails_admin_content_builder/content_builder_helpers.rb +32 -0
  27. data/app/models/rails_admin_content_builder/content_builder.rb +27 -0
  28. data/app/models/rails_admin_content_builder/content_builder_category.rb +12 -0
  29. data/app/models/rails_admin_content_builder/content_builder_image.rb +10 -0
  30. data/app/views/.gitkeep +0 -0
  31. data/app/views/rails_admin/main/content_builder.html.erb +42 -0
  32. data/bin/console +14 -0
  33. data/bin/setup +8 -0
  34. data/config/initializers/assets.rb +11 -0
  35. data/config/locales/content_builder.en.yml +17 -0
  36. data/config/locales/content_builder.pt-BR.yml +17 -0
  37. data/config/routes.rb +5 -0
  38. data/lib/generators/rails_admin_content_builder_generator.rb +32 -0
  39. data/lib/generators/templates/content_builder_image_uploader.rb +54 -0
  40. data/lib/generators/templates/create_content_builder_category_migration.rb +10 -0
  41. data/lib/generators/templates/create_content_builder_image_migration.rb +10 -0
  42. data/lib/generators/templates/create_content_builder_migration.rb +16 -0
  43. data/lib/generators/templates/rails_admin_content_builder.rb +37 -0
  44. data/lib/rails_admin_content_builder.rb +55 -0
  45. data/lib/rails_admin_content_builder/engine.rb +26 -0
  46. data/lib/rails_admin_content_builder/version.rb +3 -0
  47. data/rails_admin_content_builder.gemspec +42 -0
  48. data/screenshot/image1.png +0 -0
  49. data/spec/controllers/rails_admin_content_builder/content_builder_controller_spec.rb +19 -0
  50. data/spec/dummy/Gemfile +11 -0
  51. data/spec/dummy/Gemfile.lock +217 -0
  52. data/spec/dummy/Rakefile +6 -0
  53. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  54. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  55. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  56. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  57. data/spec/dummy/app/uploaders/content_builder_image_uploader.rb +54 -0
  58. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  59. data/spec/dummy/bin/bundle +3 -0
  60. data/spec/dummy/bin/rails +4 -0
  61. data/spec/dummy/bin/rake +4 -0
  62. data/spec/dummy/bin/setup +29 -0
  63. data/spec/dummy/config.ru +4 -0
  64. data/spec/dummy/config/application.rb +31 -0
  65. data/spec/dummy/config/boot.rb +5 -0
  66. data/spec/dummy/config/database.yml +25 -0
  67. data/spec/dummy/config/environment.rb +5 -0
  68. data/spec/dummy/config/environments/development.rb +41 -0
  69. data/spec/dummy/config/environments/production.rb +79 -0
  70. data/spec/dummy/config/environments/test.rb +42 -0
  71. data/spec/dummy/config/initializers/assets.rb +11 -0
  72. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  74. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  75. data/spec/dummy/config/initializers/inflections.rb +16 -0
  76. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  77. data/spec/dummy/config/initializers/rails_admin.rb +37 -0
  78. data/spec/dummy/config/initializers/rails_admin_content_builder.rb +37 -0
  79. data/spec/dummy/config/initializers/session_store.rb +3 -0
  80. data/spec/dummy/config/initializers/simple_form.rb +165 -0
  81. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  82. data/spec/dummy/config/locales/en.yml +23 -0
  83. data/spec/dummy/config/locales/simple_form.en.yml +31 -0
  84. data/spec/dummy/config/routes.rb +57 -0
  85. data/spec/dummy/config/secrets.yml +22 -0
  86. data/spec/dummy/db/development.sqlite3 +0 -0
  87. data/spec/dummy/db/migrate/20160713200802_create_content_builder_categories.rb +10 -0
  88. data/spec/dummy/db/migrate/20160713200803_create_content_builders.rb +15 -0
  89. data/spec/dummy/db/migrate/20160713200804_create_content_builder_images.rb +10 -0
  90. data/spec/dummy/db/schema.rb +46 -0
  91. data/spec/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
  92. data/spec/dummy/log/development.log +1182 -0
  93. data/spec/dummy/public/404.html +67 -0
  94. data/spec/dummy/public/422.html +67 -0
  95. data/spec/dummy/public/500.html +66 -0
  96. data/spec/dummy/public/favicon.ico +0 -0
  97. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/center_example.jpg +0 -0
  98. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/example.jpg +0 -0
  99. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/1/left_or_right_example.jpg +0 -0
  100. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/center_example.jpg +0 -0
  101. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/example.jpg +0 -0
  102. data/spec/dummy/public/uploads/rails_admin_content_builder/content_builder_image/image/2/left_or_right_example.jpg +0 -0
  103. data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/center_example.jpg +0 -0
  104. data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/example.jpg +0 -0
  105. data/spec/dummy/public/uploads/tmp/1461693110-14578-0001-7683/left_or_right_example.jpg +0 -0
  106. data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/center_example.jpg +0 -0
  107. data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/example.jpg +0 -0
  108. data/spec/dummy/public/uploads/tmp/1461693202-14651-0001-6505/left_or_right_example.jpg +0 -0
  109. data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/center_example.jpg +0 -0
  110. data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/example.jpg +0 -0
  111. data/spec/dummy/public/uploads/tmp/1461693245-14728-0001-4392/left_or_right_example.jpg +0 -0
  112. data/spec/factories/content_builder_categories.rb +5 -0
  113. data/spec/factories/content_builder_images.rb +6 -0
  114. data/spec/factories/content_builders.rb +10 -0
  115. data/spec/features/create_content_builder_category_spec.rb +18 -0
  116. data/spec/features/create_content_builder_spec.rb +34 -0
  117. data/spec/features/status_content_builder_spec.rb +28 -0
  118. data/spec/fixtures/assets/example.jpg +0 -0
  119. data/spec/helpers/rails_admin_content_builder/content_builder_helper_spec.rb +33 -0
  120. data/spec/models/rails_admin_content_builder/content_builder_category_spec.rb +11 -0
  121. data/spec/models/rails_admin_content_builder/content_builder_image_spec.rb +11 -0
  122. data/spec/models/rails_admin_content_builder/content_builder_spec.rb +44 -0
  123. data/spec/spec_helper.rb +36 -0
  124. data/spec/version_spec.rb +7 -0
  125. data/vendor/assets/stylesheets/rails_admin_content_builder.scss +214 -0
  126. metadata +3100 -0
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/404.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The page you were looking for doesn't exist.</h1>
62
+ <p>You may have mistyped the address or the page may have moved.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,67 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/422.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>The change you wanted was rejected.</h1>
62
+ <p>Maybe you tried to change something you didn't have access to.</p>
63
+ </div>
64
+ <p>If you are the application owner check the logs for more information.</p>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,66 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ body {
8
+ background-color: #EFEFEF;
9
+ color: #2E2F30;
10
+ text-align: center;
11
+ font-family: arial, sans-serif;
12
+ margin: 0;
13
+ }
14
+
15
+ div.dialog {
16
+ width: 95%;
17
+ max-width: 33em;
18
+ margin: 4em auto 0;
19
+ }
20
+
21
+ div.dialog > div {
22
+ border: 1px solid #CCC;
23
+ border-right-color: #999;
24
+ border-left-color: #999;
25
+ border-bottom-color: #BBB;
26
+ border-top: #B00100 solid 4px;
27
+ border-top-left-radius: 9px;
28
+ border-top-right-radius: 9px;
29
+ background-color: white;
30
+ padding: 7px 12% 0;
31
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
32
+ }
33
+
34
+ h1 {
35
+ font-size: 100%;
36
+ color: #730E15;
37
+ line-height: 1.5em;
38
+ }
39
+
40
+ div.dialog > p {
41
+ margin: 0 0 1em;
42
+ padding: 1em;
43
+ background-color: #F7F7F7;
44
+ border: 1px solid #CCC;
45
+ border-right-color: #999;
46
+ border-left-color: #999;
47
+ border-bottom-color: #999;
48
+ border-bottom-left-radius: 4px;
49
+ border-bottom-right-radius: 4px;
50
+ border-top-color: #DADADA;
51
+ color: #666;
52
+ box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
53
+ }
54
+ </style>
55
+ </head>
56
+
57
+ <body>
58
+ <!-- This file lives in public/500.html -->
59
+ <div class="dialog">
60
+ <div>
61
+ <h1>We're sorry, but something went wrong.</h1>
62
+ </div>
63
+ <p>If you are the application owner check the logs for more information.</p>
64
+ </div>
65
+ </body>
66
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ FactoryGirl.define do
2
+ factory :content_builder_category, class: RailsAdminContentBuilder::ContentBuilderCategory do
3
+ name { Faker::Lorem.characters }
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ FactoryGirl.define do
2
+ factory :content_builder_image, class: RailsAdminContentBuilder::ContentBuilderImage do
3
+ image { Rack::Test::UploadedFile.new(File.join('spec', 'fixtures', 'assets', 'example.jpg')) }
4
+ content_builder factory: :content_builder
5
+ end
6
+ end
@@ -0,0 +1,10 @@
1
+ FactoryGirl.define do
2
+ factory :content_builder, class: RailsAdminContentBuilder::ContentBuilder do
3
+ title { Faker::Lorem.characters }
4
+ date_publish { Time.now }
5
+ written_by { Faker::Name.name }
6
+ content ''
7
+ content_builder_category factory: :content_builder_category
8
+ status false
9
+ end
10
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'create content builder category', :type => :feature do
4
+
5
+ before(:each) do
6
+ @model_name = 'rails_admin_content_builder~content_builder_category'
7
+ end
8
+
9
+ scenario 'first step', js: false do
10
+ visit rails_admin.new_path(model_name: @model_name)
11
+
12
+ fill_in('Name', with: Faker::Lorem.characters)
13
+
14
+ click_button('Save')
15
+
16
+ expect(page).to have_content('Content builder category successfully created')
17
+ end
18
+ end
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'create content builder', :type => :feature do
4
+
5
+ before(:each) do
6
+ @model_name = 'rails_admin_content_builder~content_builder'
7
+ end
8
+
9
+ scenario 'first step', js: false do
10
+ category = FactoryGirl.create(:content_builder_category)
11
+ visit rails_admin.new_path(model_name: @model_name)
12
+
13
+ fill_in('Title', with: Faker::Lorem.characters)
14
+ fill_in('Date publish', with: 'April 25, 2016 15:48')
15
+ fill_in('Written by', with: Faker::Internet.url)
16
+ select(category.name, :from => 'Content builder category')
17
+
18
+ click_button('Save')
19
+
20
+ expect(page).to have_content('Content builder successfully created')
21
+ end
22
+
23
+ scenario 'second step', js: false do
24
+ content = FactoryGirl.create(:content_builder)
25
+ visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
26
+
27
+ # find('a[href="#"][data-snippet="1"]').click
28
+ # find('img[alt="Snippet text"]').click
29
+
30
+ click_button('Save')
31
+
32
+ expect(page).to have_content('Successfully updated')
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ feature 'change status content builder', :type => :feature do
4
+
5
+ before(:each) do
6
+ @model_name = 'rails_admin_content_builder~content_builder'
7
+ end
8
+
9
+ scenario 'publish', js: false do
10
+ content = FactoryGirl.create(:content_builder)
11
+ visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
12
+
13
+ click_button('Publish')
14
+
15
+ expect(page).to have_content('Successfully updated')
16
+ expect(page).to have_selector("input[type=submit][name='unpublish']")
17
+ end
18
+
19
+ scenario 'unpublish', js: false do
20
+ content = FactoryGirl.create(:content_builder, status: true)
21
+ visit rails_admin.content_builder_path(model_name: @model_name, id: content.id)
22
+
23
+ click_button('Unpublish')
24
+
25
+ expect(page).to have_content('Successfully updated')
26
+ expect(page).to have_selector("input[type=submit][name='publish']")
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+
3
+ describe RailsAdminContentBuilder::ContentBuilderHelpers, type: :helper do
4
+ describe "#content_created" do
5
+ it "return object content" do
6
+ expect(helper.content_created).to eq(RailsAdminContentBuilder::ContentBuilder)
7
+ end
8
+ end
9
+
10
+ describe "#all_contents_created" do
11
+ it "return all contents abjects with status true" do
12
+ content = FactoryGirl.create(:content_builder, status: true)
13
+ expect(helper.all_contents_created).to include(content)
14
+ end
15
+
16
+ it "not return all contents objects with status false" do
17
+ content = FactoryGirl.create(:content_builder, status: false)
18
+ expect(helper.all_contents_created).not_to include(content)
19
+ end
20
+ end
21
+
22
+ describe "#find_content_created_by_slug" do
23
+ it "return contents objects by slug with status true" do
24
+ content = FactoryGirl.create(:content_builder, status: true)
25
+ expect(helper.find_content_created_by_slug(content.slug)).to eq(content)
26
+ end
27
+
28
+ it "return contents objects by slug with status true" do
29
+ content = FactoryGirl.create(:content_builder, status: false)
30
+ expect(helper.find_content_created_by_slug(content.slug)).not_to eq(content)
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RailsAdminContentBuilder::ContentBuilderCategory, :type => :model do
4
+ describe 'validates' do
5
+ it { should validate_presence_of(:name) }
6
+ end
7
+
8
+ describe 'associations' do
9
+ it { should have_many(:content_builders) }
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RailsAdminContentBuilder::ContentBuilderImage, :type => :model do
4
+ describe 'validates' do
5
+ it { should validate_presence_of(:image) }
6
+ end
7
+
8
+ describe 'associations' do
9
+ it { should belong_to(:content_builder) }
10
+ end
11
+ end
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RailsAdminContentBuilder::ContentBuilder, :type => :model do
4
+ describe 'validates' do
5
+ it { should validate_presence_of(:title) }
6
+ it { should validate_presence_of(:date_publish) }
7
+ it { should validate_presence_of(:written_by) }
8
+ end
9
+
10
+ describe 'associations' do
11
+ it { should have_many(:content_builder_images) }
12
+ it { should belong_to(:content_builder_category) }
13
+ end
14
+
15
+ describe 'search' do
16
+ content = FactoryGirl.create(:content_builder)
17
+
18
+ it 'should return a searched content by title' do
19
+ output = RailsAdminContentBuilder::ContentBuilder.search(content.title).last
20
+ expect(output).to eq(content)
21
+ end
22
+
23
+ it 'should return a searched content by content' do
24
+ output = RailsAdminContentBuilder::ContentBuilder.search(content.content).last
25
+ expect(output).to eq(content)
26
+ end
27
+ end
28
+
29
+ describe 'content_sanitized' do
30
+ it 'should return only tag "div p img figure figcaption a iframe"' do
31
+ @content_input = '<div></div><input/><mytag myattr="teste"></mytag><p></p><img/><figure></figure><figcaption></figcaption><a></a><iframe></iframe><textarea>'
32
+ @content_output = '<div></div><p></p><img><figure></figure><figcaption></figcaption><a></a><iframe></iframe>'
33
+ content = FactoryGirl.create(:content_builder, content: @content_input)
34
+ expect(content.content_sanitized).to eq(@content_output)
35
+ end
36
+
37
+ it 'should return only attrs "src class alt href allowfullscreen frameborder height width"' do
38
+ @content_input = '<div class="test" data-method="test"></div><input/><p id="test"></p><img src="test" id="test"/><figure></figure><figcaption></figcaption><a href="#"></a><iframe></iframe><textarea>'
39
+ @content_output = '<div class="test"></div><p></p><img src="test"><figure></figure><figcaption></figcaption><a href="#"></a><iframe></iframe>'
40
+ content = FactoryGirl.create(:content_builder, content: @content_input)
41
+ expect(content.content_sanitized).to eq(@content_output)
42
+ end
43
+ end
44
+ end