simple_dragonfly_preview 0.0.1

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 (146) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +32 -0
  4. data/app/assets/images/simple_dragonfly_preview/default.png +0 -0
  5. data/app/assets/images/simple_dragonfly_preview/spinner.png +0 -0
  6. data/app/controllers/simple_dragonfly_preview/image_controller.rb +16 -0
  7. data/app/inputs/image_preview_input.rb +17 -0
  8. data/app/views/simple_dragonfly_preview/image/_form.html.erb +19 -0
  9. data/app/views/simple_dragonfly_preview/image/iframe.html.erb +26 -0
  10. data/config/routes.rb +6 -0
  11. data/lib/simple_dragonfly_preview/engine.rb +6 -0
  12. data/lib/simple_dragonfly_preview/version.rb +3 -0
  13. data/lib/simple_dragonfly_preview.rb +4 -0
  14. data/lib/tasks/simple_dragonfly_preview_tasks.rake +4 -0
  15. data/test/controllers/image_preview_controller_test.rb +7 -0
  16. data/test/dummy/README.rdoc +28 -0
  17. data/test/dummy/Rakefile +6 -0
  18. data/test/dummy/app/assets/javascripts/application.js +13 -0
  19. data/test/dummy/app/assets/javascripts/users.js +2 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  22. data/test/dummy/app/assets/stylesheets/users.css +4 -0
  23. data/test/dummy/app/controllers/application_controller.rb +5 -0
  24. data/test/dummy/app/controllers/users_controller.rb +58 -0
  25. data/test/dummy/app/helpers/application_helper.rb +2 -0
  26. data/test/dummy/app/helpers/users_helper.rb +2 -0
  27. data/test/dummy/app/models/user.rb +5 -0
  28. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  29. data/test/dummy/app/views/users/_form.html.erb +22 -0
  30. data/test/dummy/app/views/users/edit.html.erb +6 -0
  31. data/test/dummy/app/views/users/index.html.erb +31 -0
  32. data/test/dummy/app/views/users/new.html.erb +5 -0
  33. data/test/dummy/app/views/users/show.html.erb +19 -0
  34. data/test/dummy/bin/bundle +3 -0
  35. data/test/dummy/bin/rails +4 -0
  36. data/test/dummy/bin/rake +4 -0
  37. data/test/dummy/config/application.rb +24 -0
  38. data/test/dummy/config/boot.rb +5 -0
  39. data/test/dummy/config/database.yml +25 -0
  40. data/test/dummy/config/environment.rb +5 -0
  41. data/test/dummy/config/environments/development.rb +29 -0
  42. data/test/dummy/config/environments/production.rb +80 -0
  43. data/test/dummy/config/environments/test.rb +36 -0
  44. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/test/dummy/config/initializers/dragonfly.rb +1 -0
  46. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  47. data/test/dummy/config/initializers/inflections.rb +16 -0
  48. data/test/dummy/config/initializers/mime_types.rb +5 -0
  49. data/test/dummy/config/initializers/secret_token.rb +12 -0
  50. data/test/dummy/config/initializers/session_store.rb +3 -0
  51. data/test/dummy/config/initializers/simple_form.rb +145 -0
  52. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  53. data/test/dummy/config/locales/en.yml +23 -0
  54. data/test/dummy/config/locales/simple_form.en.yml +26 -0
  55. data/test/dummy/config/routes.rb +58 -0
  56. data/test/dummy/config.ru +4 -0
  57. data/test/dummy/db/development.sqlite3 +0 -0
  58. data/test/dummy/db/migrate/20131106190012_create_users.rb +11 -0
  59. data/test/dummy/db/schema.rb +24 -0
  60. data/test/dummy/lib/templates/erb/scaffold/_form.html.erb +13 -0
  61. data/test/dummy/log/development.log +4065 -0
  62. data/test/dummy/public/404.html +58 -0
  63. data/test/dummy/public/422.html +58 -0
  64. data/test/dummy/public/500.html +57 -0
  65. data/test/dummy/public/favicon.ico +0 -0
  66. data/test/dummy/public/system/dragonfly/development/2013/11/06/17_17_07_379_file +0 -0
  67. data/test/dummy/public/system/dragonfly/development/2013/11/06/17_17_07_379_file.meta +0 -0
  68. data/test/dummy/public/system/dragonfly/development/2013/11/06/19_47_44_909_file +0 -0
  69. data/test/dummy/public/system/dragonfly/development/2013/11/06/19_47_44_909_file.meta +0 -0
  70. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_02_19_732_file +0 -0
  71. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_02_19_732_file.meta +0 -0
  72. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_05_04_413_file +0 -0
  73. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_05_04_413_file.meta +0 -0
  74. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_11_27_417_file +0 -0
  75. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_11_27_417_file.meta +0 -0
  76. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_12_04_402_file +0 -0
  77. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_12_04_402_file.meta +0 -0
  78. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_13_31_438_file +0 -0
  79. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_13_31_438_file.meta +0 -0
  80. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_14_00_53_file +0 -0
  81. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_14_00_53_file.meta +0 -0
  82. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_14_53_100_file +0 -0
  83. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_14_53_100_file.meta +0 -0
  84. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_20_26_483_file +0 -0
  85. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_20_26_483_file.meta +0 -0
  86. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_23_29_213_file +0 -0
  87. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_23_29_213_file.meta +0 -0
  88. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_24_09_631_file +0 -0
  89. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_24_09_631_file.meta +0 -0
  90. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_30_19_219_file +0 -0
  91. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_30_19_219_file.meta +0 -0
  92. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_30_36_584_file +0 -0
  93. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_30_36_584_file.meta +0 -0
  94. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_48_08_938_file +0 -0
  95. data/test/dummy/public/system/dragonfly/development/2013/11/06/20_48_08_938_file.meta +0 -0
  96. data/test/dummy/public/system/dragonfly/development/2013/11/06/21_31_39_624_file +0 -0
  97. data/test/dummy/public/system/dragonfly/development/2013/11/06/21_31_39_624_file.meta +0 -0
  98. data/test/dummy/tmp/cache/assets/development/sprockets/0800f54ee19cf3cee10b956fa9786799 +0 -0
  99. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  100. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  101. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  102. data/test/dummy/tmp/cache/assets/development/sprockets/371bf96e99717688ed7313a0c53f4212 +0 -0
  103. data/test/dummy/tmp/cache/assets/development/sprockets/4050a4e5062ab95c9f32e9b6940821ea +0 -0
  104. data/test/dummy/tmp/cache/assets/development/sprockets/510da110ae528e2d22533be39ff696c5 +0 -0
  105. data/test/dummy/tmp/cache/assets/development/sprockets/5f1a0d05e77ca8b9a1fc2a47e17a8174 +0 -0
  106. data/test/dummy/tmp/cache/assets/development/sprockets/6fc757c2c8329244ca95d6909865bbc2 +0 -0
  107. data/test/dummy/tmp/cache/assets/development/sprockets/87b209c0c9da28094a8d5581a21262c6 +0 -0
  108. data/test/dummy/tmp/cache/assets/development/sprockets/8cecc47a3ddd0a9848bf1d1cbe60383d +0 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/bbcddcc7335ba72d83d17571509087ca +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/cebc6db0bbb8120f430da3970b173d2f +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/f56253b5f374fff1a33fbbc9881c9124 +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  115. data/test/dummy/tmp/dragonfly/cache/body/58/b6fa2d2a74a3ef1fea5845ac9573e2d25f5286 +0 -0
  116. data/test/dummy/tmp/dragonfly/cache/body/7b/32780ab9b84841f36f1576b37a0cd5476252d4 +0 -0
  117. data/test/dummy/tmp/dragonfly/cache/body/83/304fe1783b6b597cee1dd99a53c9184cb96e5d +0 -0
  118. data/test/dummy/tmp/dragonfly/cache/body/cc/a80f62f140fe784594a1ce19e96084f6e4770c +0 -0
  119. data/test/dummy/tmp/dragonfly/cache/body/f6/4b1a2917301497c041917973f735ed587195b9 +0 -0
  120. data/test/dummy/tmp/dragonfly/cache/body/f6/f56b06a206c11d9093474da07df840bf5ea613 +0 -0
  121. data/test/dummy/tmp/dragonfly/cache/body/f7/9d14e20c87fa050f16093012c5ea8d815626f9 +0 -0
  122. data/test/dummy/tmp/dragonfly/cache/meta/01/e17596e376d0db6d720322f860991275563642 +0 -0
  123. data/test/dummy/tmp/dragonfly/cache/meta/03/7a3dcab9043427874569c1f414ba35600d2c36 +0 -0
  124. data/test/dummy/tmp/dragonfly/cache/meta/0c/8799b7bd12cf2b3645e38245ced7829d14f106 +0 -0
  125. data/test/dummy/tmp/dragonfly/cache/meta/12/65e1ff41d2014dea8a39a8de17a99be8d2f581 +0 -0
  126. data/test/dummy/tmp/dragonfly/cache/meta/14/757d5b9e46a9079107921e45ffe2bc96720eb5 +0 -0
  127. data/test/dummy/tmp/dragonfly/cache/meta/2a/9077525d0d3b2430a7792085fd18cb329deda0 +0 -0
  128. data/test/dummy/tmp/dragonfly/cache/meta/2d/1b0e400901a88a4bb203208c4b8d55a28312ee +0 -0
  129. data/test/dummy/tmp/dragonfly/cache/meta/33/c4106eaf95f852b802f2f16b293db599b59f0e +0 -0
  130. data/test/dummy/tmp/dragonfly/cache/meta/62/9a4d46f66e07fcaa95abfa10ba28e620453c27 +0 -0
  131. data/test/dummy/tmp/dragonfly/cache/meta/6f/9a6334a80e6d672ea03cf3021dc2240ca41f74 +0 -0
  132. data/test/dummy/tmp/dragonfly/cache/meta/73/e422186fab924ced8a5191a5c61e9d0a9e6cf6 +0 -0
  133. data/test/dummy/tmp/dragonfly/cache/meta/95/dce4906519fc41c551c82122a43a4e7c6471a7 +0 -0
  134. data/test/dummy/tmp/dragonfly/cache/meta/a6/3d35e5d8ca31cdd7f4d357f0094e1e3e07bc23 +0 -0
  135. data/test/dummy/tmp/dragonfly/cache/meta/a7/c81c66c7e20b6cf2dff682a7f8191d233983d9 +0 -0
  136. data/test/dummy/tmp/dragonfly/cache/meta/ab/f78311e13b624fbd7162145233dafe5669e05e +0 -0
  137. data/test/dummy/tmp/dragonfly/cache/meta/af/2eda96ffffa526ea422e0aa89603ada5311939 +0 -0
  138. data/test/dummy/tmp/dragonfly/cache/meta/d4/9b42d53788ac422a69911bde13971ffa91ce66 +0 -0
  139. data/test/dummy/tmp/dragonfly/cache/meta/e5/b9dbb1462a34c756f8a2e6a0ead7fd2d35ba2f +0 -0
  140. data/test/dummy/tmp/dragonfly/cache/meta/ef/62aeb6dfe3d09905fb65647fba51728b0cdfb8 +0 -0
  141. data/test/dummy/tmp/dragonfly/cache/meta/f6/254e02b41e832883906facda80b957356c48bf +0 -0
  142. data/test/helpers/image_preview_helper_test.rb +4 -0
  143. data/test/integration/navigation_test.rb +10 -0
  144. data/test/simple_dragonfly_preview_test.rb +7 -0
  145. data/test/test_helper.rb +15 -0
  146. metadata +360 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 41945e1037fce2888dbfec825daddddc17da0bd1
4
+ data.tar.gz: bdb0d460dca0b1f4ba18e87bd1f386104be81b49
5
+ SHA512:
6
+ metadata.gz: 2ff8a5b0e3fced8e1f541f6535cf14f2596848a39c6d24d0149d61ccc90b43e134de201a1b02cb41e719c5b80c3d96ac6e8849be0967992e016176075941a8f4
7
+ data.tar.gz: 54a0d816813030851a8ac2e9e13409ef03124f42e98dba76e04fa625cfab9509da16381919747cca28c30af28624c7b3d14b83f5cd90dace4298a69a134d436e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2013 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'SimpleDragonflyPreview'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
22
+ require 'rake/testtask'
23
+
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = false
29
+ end
30
+
31
+
32
+ task default: :test
@@ -0,0 +1,16 @@
1
+ class SimpleDragonflyPreview::ImageController < ApplicationController
2
+ layout false
3
+
4
+ def upload
5
+ if params[:image].present?
6
+ app = Dragonfly[:images]
7
+ uid = app.store(params[:image].tempfile)
8
+ @image = app.fetch(uid)
9
+ @retained_image = Dragonfly::Serializer.json_encode(uid: @image.uid) if @image
10
+ end
11
+ render :iframe
12
+ end
13
+
14
+ def iframe
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+
2
+ class ImagePreviewInput < SimpleForm::Inputs::Base
3
+ def input
4
+ resize = options.delete(:size) || '100x80#'
5
+ size = resize.sub(/\D$/,'')
6
+
7
+ template.render("simple_dragonfly_preview/image/form",
8
+ f: @builder,
9
+ attribute_name: attribute_name.to_s,
10
+ retained_id: (@builder.lookup_model_names + ["retained", attribute_name.to_s]).join("_"),
11
+ image_id: (@builder.lookup_model_names + [attribute_name.to_s, "preview"]).join("_"),
12
+ size: size,
13
+ resize: resize )
14
+ end
15
+ end
16
+
17
+
@@ -0,0 +1,19 @@
1
+ <table>
2
+ <tr>
3
+ <td>
4
+ <% if f.object.send("#{attribute_name}_uid") %>
5
+ <%= image_tag f.object.send(attribute_name).thumb(resize).url, size: size, id: image_id %>
6
+ <div>
7
+ <%= f.label("remove_#{attribute_name}", "Remove?") %>
8
+ <%= f.check_box("remove_#{attribute_name}") %>
9
+ </div>
10
+ <% else %>
11
+ <%= image_tag "simple_dragonfly_preview/default.png", size: size, id: image_id %>
12
+ <% end %>
13
+ </td>
14
+ <td>
15
+ <%= content_tag(:iframe, nil, src: simple_dragonfly_preview_iframe_path(retained_id: retained_id, image_id: image_id), width:"400", height:"50", frameborder:"0") %>
16
+ </td>
17
+ </tr>
18
+ </table>
19
+ <%= f.hidden_field("retained_#{attribute_name}") %>
@@ -0,0 +1,26 @@
1
+ <html>
2
+ <head>
3
+ <style>body, form{margin: 0px;}</style>
4
+ </head>
5
+ <body>
6
+ <%= form_tag simple_dragonfly_preview_upload_path, multipart: true, id: "image_preview_form" do %>
7
+ <%= hidden_field_tag :retained_id, params[:retained_id] %>
8
+ <%= hidden_field_tag :image_id, params[:image_id] %>
9
+ <%= file_field_tag :image %>
10
+ <% end %>
11
+
12
+ <script type="text/javascript">
13
+ //automatically submit the form
14
+ document.getElementById("image").onchange = function() {
15
+ // window.parent.document.getElementById("<%= params[:image_id] %>").src = "<%= image_path('loader.png')%>";
16
+ document.getElementById("image_preview_form").submit();
17
+ };
18
+
19
+ <% if @image %>
20
+ //update the retained image field
21
+ window.parent.document.getElementById("<%= params[:retained_id] %>").value = "<%= @retained_image %>";
22
+ window.parent.document.getElementById("<%= params[:image_id] %>").src = "<%= @image.thumb('145x145#').url %>";
23
+ <% end %>
24
+ </script>
25
+ </body>
26
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,6 @@
1
+ Rails.application.routes.draw do
2
+ namespace :simple_dragonfly_preview do
3
+ get "iframe", to: "image#iframe"
4
+ post "upload", to: "image#upload"
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require "simple_form"
2
+
3
+ module SimpleDragonflyPreview
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module SimpleDragonflyPreview
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "simple_dragonfly_preview/engine"
2
+
3
+ module SimpleDragonflyPreview
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :simple_dragonfly_preview do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class ImagePreviewControllerTest < ActionController::TestCase
4
+ # test "the truth" do
5
+ # assert true
6
+ # end
7
+ end
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Dummy::Application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,58 @@
1
+ class UsersController < ApplicationController
2
+ before_action :set_user, only: [:show, :edit, :update, :destroy]
3
+
4
+ # GET /users
5
+ def index
6
+ @users = User.all
7
+ end
8
+
9
+ # GET /users/1
10
+ def show
11
+ end
12
+
13
+ # GET /users/new
14
+ def new
15
+ @user = User.new
16
+ end
17
+
18
+ # GET /users/1/edit
19
+ def edit
20
+ end
21
+
22
+ # POST /users
23
+ def create
24
+ @user = User.new(user_params)
25
+
26
+ if @user.save
27
+ redirect_to @user, notice: 'User was successfully created.'
28
+ else
29
+ render action: 'new'
30
+ end
31
+ end
32
+
33
+ # PATCH/PUT /users/1
34
+ def update
35
+ if @user.update(user_params)
36
+ redirect_to @user, notice: 'User was successfully updated.'
37
+ else
38
+ render action: 'edit'
39
+ end
40
+ end
41
+
42
+ # DELETE /users/1
43
+ def destroy
44
+ @user.destroy
45
+ redirect_to users_url, notice: 'User was successfully destroyed.'
46
+ end
47
+
48
+ private
49
+ # Use callbacks to share common setup or constraints between actions.
50
+ def set_user
51
+ @user = User.find(params[:id])
52
+ end
53
+
54
+ # Only allow a trusted parameter "white list" through.
55
+ def user_params
56
+ params.require(:user).permit(:name, :email, :avatar, :retained_avatar, :remove_avatar)
57
+ end
58
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,5 @@
1
+ class User < ActiveRecord::Base
2
+ image_accessor :avatar
3
+
4
+ validates :email, :name, presence: true
5
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Dummy</title>
5
+ <%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
6
+ <%= javascript_include_tag "application", "data-turbolinks-track" => true %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,22 @@
1
+ <%= simple_form_for(@user) do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+
15
+ <%= f.input :name %>
16
+ <%= f.input :email %>
17
+ <%= f.input :avatar, as: :image_preview, size: "100x100#" %>
18
+
19
+ <div class="actions">
20
+ <%= f.submit %>
21
+ </div>
22
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @user %> |
6
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,31 @@
1
+ <h1>Listing users</h1>
2
+
3
+ <table>
4
+ <thead>
5
+ <tr>
6
+ <th>Name</th>
7
+ <th>Email</th>
8
+ <th>Avatar uid</th>
9
+ <th></th>
10
+ <th></th>
11
+ <th></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% @users.each do |user| %>
17
+ <tr>
18
+ <td><%= user.name %></td>
19
+ <td><%= user.email %></td>
20
+ <td><%= user.avatar_uid %></td>
21
+ <td><%= link_to 'Show', user %></td>
22
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
23
+ <td><%= link_to 'Destroy', user, method: :delete, data: { confirm: 'Are you sure?' } %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <br>
30
+
31
+ <%= link_to 'New User', new_user_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New user</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,19 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>Name:</strong>
5
+ <%= @user.name %>
6
+ </p>
7
+
8
+ <p>
9
+ <strong>Email:</strong>
10
+ <%= @user.email %>
11
+ </p>
12
+
13
+ <p>
14
+ <strong>Avatar uid:</strong>
15
+ <%= @user.avatar_uid %>
16
+ </p>
17
+
18
+ <%= link_to 'Edit', edit_user_path(@user) %> |
19
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../config/boot'
3
+ require 'rake'
4
+ Rake.application.run
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require(*Rails.groups)
6
+ require "simple_dragonfly_preview"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
+ # config.time_zone = 'Central Time (US & Canada)'
17
+
18
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
+ # config.i18n.default_locale = :de
21
+ end
22
+ end
23
+
24
+
@@ -0,0 +1,5 @@
1
+ # Set up gems listed in the Gemfile.
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
+
4
+ require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
5
+ $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ development:
7
+ adapter: sqlite3
8
+ database: db/development.sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ # Warning: The database defined as "test" will be erased and
13
+ # re-generated from your development database when you run "rake".
14
+ # Do not set this db to the same as development or production.
15
+ test:
16
+ adapter: sqlite3
17
+ database: db/test.sqlite3
18
+ pool: 5
19
+ timeout: 5000
20
+
21
+ production:
22
+ adapter: sqlite3
23
+ database: db/production.sqlite3
24
+ pool: 5
25
+ timeout: 5000
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require File.expand_path('../application', __FILE__)
3
+
4
+ # Initialize the Rails application.
5
+ Dummy::Application.initialize!
@@ -0,0 +1,29 @@
1
+ Dummy::Application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
+
4
+ # In the development environment your application's code is reloaded on
5
+ # every request. This slows down response time but is perfect for development
6
+ # since you don't have to restart the web server when you make code changes.
7
+ config.cache_classes = false
8
+
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
+
12
+ # Show full error reports and disable caching.
13
+ config.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send.
17
+ config.action_mailer.raise_delivery_errors = false
18
+
19
+ # Print deprecation notices to the Rails logger.
20
+ config.active_support.deprecation = :log
21
+
22
+ # Raise an error on page load if there are pending migrations
23
+ config.active_record.migration_error = :page_load
24
+
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
29
+ end