polygallery 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 (168) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/images/polygallery/thumbnail-missing.jpg +0 -0
  6. data/app/assets/javascripts/polygallery/application.js +13 -0
  7. data/app/assets/javascripts/polygallery/galleries.js +2 -0
  8. data/app/assets/javascripts/polygallery/init.js +17 -0
  9. data/app/assets/javascripts/polygallery/photos.js +2 -0
  10. data/app/assets/javascripts/polygallery/polygallery.js.coffee +4 -0
  11. data/app/assets/stylesheets/polygallery/application.css +15 -0
  12. data/app/assets/stylesheets/polygallery/galleries.css +4 -0
  13. data/app/assets/stylesheets/polygallery/photos.css +4 -0
  14. data/app/controllers/polygallery/application_controller.rb +4 -0
  15. data/app/controllers/polygallery/galleries_controller.rb +6 -0
  16. data/app/controllers/polygallery/photos_controller.rb +6 -0
  17. data/app/helpers/polygallery/application_helper.rb +4 -0
  18. data/app/helpers/polygallery/galleries_helper.rb +4 -0
  19. data/app/helpers/polygallery/photos_helper.rb +4 -0
  20. data/app/models/polygallery/gallery.rb +22 -0
  21. data/app/models/polygallery/photo.rb +10 -0
  22. data/app/models/polygallery/polygallery.rb +7 -0
  23. data/app/views/layouts/polygallery/application.html.erb +14 -0
  24. data/app/views/polygallery/galleries/_fields_for.html.haml +5 -0
  25. data/app/views/polygallery/galleries/_simple_fields_for.html.haml +25 -0
  26. data/app/views/polygallery/photos/_fields_for.html.haml +3 -0
  27. data/app/views/polygallery/photos/_simple_fields_for.html.haml +9 -0
  28. data/config/routes.rb +6 -0
  29. data/db/migrate/20140803171516_create_polygallery_galleries.rb +12 -0
  30. data/db/migrate/20140803171534_create_polygallery_photos.rb +12 -0
  31. data/lib/generators/polygallery/install/install_generator.rb +37 -0
  32. data/lib/generators/polygallery/install/templates/polygallery_migration.rb +20 -0
  33. data/lib/polygallery.rb +6 -0
  34. data/lib/polygallery/engine.rb +10 -0
  35. data/lib/polygallery/glue.rb +9 -0
  36. data/lib/polygallery/has_polygallery.rb +46 -0
  37. data/lib/polygallery/railtie.rb +25 -0
  38. data/lib/polygallery/validators.rb +37 -0
  39. data/lib/polygallery/validators/polygallery_presence_validator.rb +30 -0
  40. data/lib/polygallery/version.rb +3 -0
  41. data/lib/polygallery/view_helpers.rb +21 -0
  42. data/lib/tasks/polygallery_tasks.rake +4 -0
  43. data/test/controllers/polygallery/galleries_controller_test.rb +9 -0
  44. data/test/controllers/polygallery/photos_controller_test.rb +9 -0
  45. data/test/dummy/README.rdoc +28 -0
  46. data/test/dummy/Rakefile +6 -0
  47. data/test/dummy/app/assets/javascripts/application.js +16 -0
  48. data/test/dummy/app/assets/javascripts/bootstrap.min.js +6 -0
  49. data/test/dummy/app/assets/javascripts/events.js +2 -0
  50. data/test/dummy/app/assets/javascripts/home.js +2 -0
  51. data/test/dummy/app/assets/stylesheets/application.css +17 -0
  52. data/test/dummy/app/assets/stylesheets/bootstrap-theme.min.css +5 -0
  53. data/test/dummy/app/assets/stylesheets/bootstrap.min.css +5 -0
  54. data/test/dummy/app/assets/stylesheets/events.css +4 -0
  55. data/test/dummy/app/assets/stylesheets/home.css +4 -0
  56. data/test/dummy/app/controllers/application_controller.rb +5 -0
  57. data/test/dummy/app/controllers/events_controller.rb +19 -0
  58. data/test/dummy/app/controllers/home_controller.rb +7 -0
  59. data/test/dummy/app/helpers/application_helper.rb +2 -0
  60. data/test/dummy/app/helpers/events_helper.rb +2 -0
  61. data/test/dummy/app/helpers/home_helper.rb +2 -0
  62. data/test/dummy/app/models/event.rb +5 -0
  63. data/test/dummy/app/views/home/index.html.haml +32 -0
  64. data/test/dummy/app/views/layouts/application.html.haml +21 -0
  65. data/test/dummy/bin/bundle +3 -0
  66. data/test/dummy/bin/rails +4 -0
  67. data/test/dummy/bin/rake +4 -0
  68. data/test/dummy/config.ru +4 -0
  69. data/test/dummy/config/application.rb +24 -0
  70. data/test/dummy/config/boot.rb +5 -0
  71. data/test/dummy/config/database.yml +85 -0
  72. data/test/dummy/config/environment.rb +5 -0
  73. data/test/dummy/config/environments/development.rb +37 -0
  74. data/test/dummy/config/environments/production.rb +83 -0
  75. data/test/dummy/config/environments/test.rb +39 -0
  76. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  77. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  78. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  79. data/test/dummy/config/initializers/inflections.rb +16 -0
  80. data/test/dummy/config/initializers/mime_types.rb +4 -0
  81. data/test/dummy/config/initializers/reload_lib.rb +9 -0
  82. data/test/dummy/config/initializers/session_store.rb +3 -0
  83. data/test/dummy/config/initializers/simple_form.rb +145 -0
  84. data/test/dummy/config/initializers/simple_form_bootstrap.rb +96 -0
  85. data/test/dummy/config/initializers/simple_form_fileinput.rb +15 -0
  86. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  87. data/test/dummy/config/locales/en.yml +23 -0
  88. data/test/dummy/config/locales/simple_form.en.yml +26 -0
  89. data/test/dummy/config/routes.rb +7 -0
  90. data/test/dummy/config/secrets.yml +22 -0
  91. data/test/dummy/db/migrate/20140803170839_create_events.rb +9 -0
  92. data/test/dummy/db/schema.rb +46 -0
  93. data/test/dummy/lib/templates/haml/scaffold/_form.html.haml +10 -0
  94. data/test/dummy/log/development.log +5483 -0
  95. data/test/dummy/public/404.html +67 -0
  96. data/test/dummy/public/422.html +67 -0
  97. data/test/dummy/public/500.html +66 -0
  98. data/test/dummy/public/favicon.ico +0 -0
  99. data/test/dummy/public/fonts/glyphicons-halflings-regular.eot +0 -0
  100. data/test/dummy/public/fonts/glyphicons-halflings-regular.svg +229 -0
  101. data/test/dummy/public/fonts/glyphicons-halflings-regular.ttf +0 -0
  102. data/test/dummy/public/fonts/glyphicons-halflings-regular.woff +0 -0
  103. data/test/dummy/test/controllers/events_controller_test.rb +7 -0
  104. data/test/dummy/test/controllers/home_controller_test.rb +7 -0
  105. data/test/dummy/test/fixtures/events.yml +7 -0
  106. data/test/dummy/test/helpers/events_helper_test.rb +4 -0
  107. data/test/dummy/test/helpers/home_helper_test.rb +4 -0
  108. data/test/dummy/test/models/event_test.rb +7 -0
  109. data/test/dummy/tmp/cache/assets/development/sprockets/05c0a42e9725c8eb8a83324cfdce4a16 +0 -0
  110. data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  111. data/test/dummy/tmp/cache/assets/development/sprockets/1c9faaf28d05409b88ad3113374d613c +0 -0
  112. data/test/dummy/tmp/cache/assets/development/sprockets/1e1c73f8892119a4dbc6ead7718b4472 +0 -0
  113. data/test/dummy/tmp/cache/assets/development/sprockets/1ecd715c01db7b05e5fc97838c7bdac7 +0 -0
  114. data/test/dummy/tmp/cache/assets/development/sprockets/23a02f793bdc3b6a6cbd015f184c6f6c +0 -0
  115. data/test/dummy/tmp/cache/assets/development/sprockets/2757fae967a52701ef3724ae5a76c4a8 +0 -0
  116. data/test/dummy/tmp/cache/assets/development/sprockets/2822de3b22c28bd5e718c9bf500457b2 +0 -0
  117. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  118. data/test/dummy/tmp/cache/assets/development/sprockets/30e3552cad42917377b8675173b87d6d +0 -0
  119. data/test/dummy/tmp/cache/assets/development/sprockets/311df7a951cd5c960bea25b750d24073 +0 -0
  120. data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  121. data/test/dummy/tmp/cache/assets/development/sprockets/39bcd7e5a58fb6e7114bbae6ac577fe6 +0 -0
  122. data/test/dummy/tmp/cache/assets/development/sprockets/3df3a0e2cf2fc334a9e6292941bae875 +0 -0
  123. data/test/dummy/tmp/cache/assets/development/sprockets/3edcdce4b73dab626737716f1fc4d97d +0 -0
  124. data/test/dummy/tmp/cache/assets/development/sprockets/40fc2f3d2a468a00e463f1d313cb1683 +0 -0
  125. data/test/dummy/tmp/cache/assets/development/sprockets/4d1647c172443398b0d023245fb13877 +0 -0
  126. data/test/dummy/tmp/cache/assets/development/sprockets/4daff1d5b8e6da6d2ed55886db193ef2 +0 -0
  127. data/test/dummy/tmp/cache/assets/development/sprockets/4ea33e825e6e38bd22dccab488a0255b +0 -0
  128. data/test/dummy/tmp/cache/assets/development/sprockets/61cd6f9b2dc23f35478fc14d5fb4f7df +0 -0
  129. data/test/dummy/tmp/cache/assets/development/sprockets/650d6a1ba71368c14b9fced6b6180b2d +0 -0
  130. data/test/dummy/tmp/cache/assets/development/sprockets/65dccf676de4439612547abc6451ba65 +0 -0
  131. data/test/dummy/tmp/cache/assets/development/sprockets/69bda14eaa1d8ad1ea1235abb619e366 +0 -0
  132. data/test/dummy/tmp/cache/assets/development/sprockets/6f562a48c0e855e0e4fdab624ba41eb9 +0 -0
  133. data/test/dummy/tmp/cache/assets/development/sprockets/7be9086c960bb4384c9d23a52e489f29 +0 -0
  134. data/test/dummy/tmp/cache/assets/development/sprockets/86f909bf5baee50515afadaa3ce2df8f +0 -0
  135. data/test/dummy/tmp/cache/assets/development/sprockets/88f812810562f1bc315ee991f8a30c4e +0 -0
  136. data/test/dummy/tmp/cache/assets/development/sprockets/8e5a9738e9bc15478e026d98335454f9 +0 -0
  137. data/test/dummy/tmp/cache/assets/development/sprockets/8f8936f164170e095c5ca2d0c2ae6127 +0 -0
  138. data/test/dummy/tmp/cache/assets/development/sprockets/a11d7eb71230eda394161e35aefa0a24 +0 -0
  139. data/test/dummy/tmp/cache/assets/development/sprockets/a32fea9e0a124a0fbd82afec0c27e0d4 +0 -0
  140. data/test/dummy/tmp/cache/assets/development/sprockets/a995a3b95e4a7b0e5b9fa7c49efd6b74 +0 -0
  141. data/test/dummy/tmp/cache/assets/development/sprockets/a9f028f7a492b5907ed80268be8f50f4 +0 -0
  142. data/test/dummy/tmp/cache/assets/development/sprockets/b878faf942403e313a5b103e5d80488e +0 -0
  143. data/test/dummy/tmp/cache/assets/development/sprockets/ba56eb60d599a0ca3d2f6b67772774c2 +0 -0
  144. data/test/dummy/tmp/cache/assets/development/sprockets/c0a32ddd5941d7ff3aca0ad92298608c +0 -0
  145. data/test/dummy/tmp/cache/assets/development/sprockets/c54e257d17c58c802e2870d68ff1bd39 +0 -0
  146. data/test/dummy/tmp/cache/assets/development/sprockets/c6d68ddd2f21544d3a6ac67934487535 +0 -0
  147. data/test/dummy/tmp/cache/assets/development/sprockets/c79813a3ee7359e3d7880d6b671f6f6d +0 -0
  148. data/test/dummy/tmp/cache/assets/development/sprockets/c9e5e8280743d98ec882539be0f91af5 +0 -0
  149. data/test/dummy/tmp/cache/assets/development/sprockets/cbe9afc48460e8e0bc42c314d5e594a0 +0 -0
  150. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  151. data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  152. data/test/dummy/tmp/cache/assets/development/sprockets/e01ccf02ec6a0fb2cb7189161c5850c5 +0 -0
  153. data/test/dummy/tmp/cache/assets/development/sprockets/e928c77266ca2960fa4a7fbb56b4e034 +0 -0
  154. data/test/dummy/tmp/cache/assets/development/sprockets/edbef6e0d0a4742346cf479f2c522eb0 +0 -0
  155. data/test/dummy/tmp/cache/assets/development/sprockets/ee77497db62576e6878e7815e80e8b5a +0 -0
  156. data/test/dummy/tmp/cache/assets/development/sprockets/f644fd75cbead0e58c847aa16546e2a8 +0 -0
  157. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  158. data/test/dummy/tmp/cache/assets/development/sprockets/fe0a04f09eb0c97bcc18973678e986a3 +0 -0
  159. data/test/fixtures/polygallery/galleries.yml +11 -0
  160. data/test/fixtures/polygallery/photos.yml +7 -0
  161. data/test/helpers/polygallery/galleries_helper_test.rb +6 -0
  162. data/test/helpers/polygallery/photos_helper_test.rb +6 -0
  163. data/test/integration/navigation_test.rb +10 -0
  164. data/test/models/polygallery/gallery_test.rb +9 -0
  165. data/test/models/polygallery/photo_test.rb +9 -0
  166. data/test/polygallery_test.rb +7 -0
  167. data/test/test_helper.rb +15 -0
  168. metadata +461 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb4e8d4e75bf266d80c19002472ec89dc5fb9a42
4
+ data.tar.gz: 675c1d9868782a397bf9bff24710ffd957dfe257
5
+ SHA512:
6
+ metadata.gz: c4c5682a0cda9a416c82d112f7e5ecd5bd420c507eeb5c562d4fa5b05b71a423e3be5e3631bd964a769bb949871c7b38b289c45a890e77b29a303e66def2a92f
7
+ data.tar.gz: b749dfddee94247485019f90ae757939c1036a4aaa3151103b35e344e40ce25fa9da0314a8c2c64ee4f5956e5747249260e43af7dc7079ad49ebb37ed0194782
@@ -0,0 +1,20 @@
1
+ Copyright 2014 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.
@@ -0,0 +1,3 @@
1
+ = Polygallery
2
+
3
+ This project rocks and uses MIT-LICENSE.
@@ -0,0 +1,34 @@
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 = 'Polygallery'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -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,17 @@
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 jquery
14
+ //= require jquery_ujs
15
+ //= require simple_form_fileinput/init
16
+ //= require cocoon
17
+ //= require polygallery/polygallery
@@ -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,4 @@
1
+ (($)->
2
+ $('.polygallery-cocoon-table').on 'cocoon:after-insert', (e, insertedItem)->
3
+ $(insertedItem).find('input[type=file]').bootstrapFileInput()
4
+ )(jQuery)
@@ -0,0 +1,15 @@
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 bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -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,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,4 @@
1
+ module Polygallery
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ require_dependency "polygallery/application_controller"
2
+
3
+ module Polygallery
4
+ class GalleriesController < ApplicationController
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ require_dependency "polygallery/application_controller"
2
+
3
+ module Polygallery
4
+ class PhotosController < ApplicationController
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module Polygallery
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Polygallery
2
+ module GalleriesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Polygallery
2
+ module PhotosHelper
3
+ end
4
+ end
@@ -0,0 +1,22 @@
1
+ module Polygallery
2
+ class Gallery < ActiveRecord::Base
3
+ attr_accessor :settings
4
+ DEFAULTS = {
5
+ :association => {
6
+ :class_name => 'Polygallery::Gallery',
7
+ :as => :galleryable,
8
+ :dependent => :destroy
9
+ },
10
+ :nested_attributes => {},
11
+ :validates => {}
12
+ }
13
+
14
+ belongs_to :galleryable, :polymorphic => true
15
+ has_many :photos, :class_name => 'Polygallery::Photo'
16
+ accepts_nested_attributes_for :photos
17
+ after_initialize do
18
+ self.photos.build
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,10 @@
1
+ module Polygallery
2
+ class Photo < ActiveRecord::Base
3
+
4
+ has_attached_file :photo, :styles => { :full => "1200x900>", :big_slide => "1200x600#", :medium => "480x270>", :slide => "550x260#", :grid => "260x172#", :thumb => "100x100#"}, :default_url => '/images/:style/missing.png'
5
+ validates_attachment_content_type :photo, :content_type => /\Aimage\/.*\Z/
6
+
7
+ belongs_to :gallery, :class_name => 'Polygallery::Gallery'
8
+
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Polygallery
2
+ module Polygallery
3
+ def self.table_name_prefix
4
+ 'polygallery_polygallery_'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Polygallery</title>
5
+ <%= stylesheet_link_tag "polygallery/application", media: "all" %>
6
+ <%= javascript_include_tag "polygallery/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ = fields_for gallery.title.to_sym do |ff|
2
+ = ff.hidden_field :title, :value => gallery.title.to_s
3
+
4
+ -#= fields_for_polygallery_photo
5
+ -#= ff.cktext_area :content, options.merge(name.is_a?(String) ? {:value => pb.content} : {})
@@ -0,0 +1,25 @@
1
+ = f.simple_fields_for gallery.title.to_sym do |ff|
2
+ = ff.input_field :title, :as => :hidden, :value => gallery.title
3
+
4
+ - if options[:label]
5
+ %h3.lead
6
+ = link_to_add_association 'Add Photo', ff, :photos, :partial => 'polygallery/photos/simple_fields_for', :class => 'btn btn-default btn-sm pull-right', :data => {:association_insertion_node => '.photo-receptacle', :association_insertion_method => 'append'}
7
+ - if options[:label] == true
8
+ = gallery.title.titleize
9
+ - else
10
+ = options[:label].titleize
11
+ #photos.polygallery-cocoon-table
12
+ %table.table.table-bordered.table-striped.table-condensed.polygallery-photos-table
13
+ %thead
14
+ %tr
15
+ %th.text-center{:style => 'width:85px;'} Photo
16
+ %th File
17
+ %th.text-center Actions
18
+ %tbody.photo-receptacle
19
+ = ff.simple_fields_for :photos do |pf|
20
+ = render :partial => 'polygallery/photos/simple_fields_for', :locals => {:f => pf}
21
+
22
+ -#- if !options[:label]
23
+ -# = ff.input_field :content, options[:input_html].merge({:as => :ckeditor})
24
+ -#- else
25
+ -#= ff.input :content, :as => :ckeditor, :label => options[:label].is_a?(String) ? options[:label] : name.to_s.titleize, :input_html => name.is_a?(String) ? options[:input_html].merge({:value => pb.content}) : options[:input_html]
@@ -0,0 +1,3 @@
1
+ -#= fields_for name do |ff|
2
+ -#= ff.hidden_field :name, :value => name.to_s
3
+ -#= ff.cktext_area :content, options.merge(name.is_a?(String) ? {:value => pb.content} : {})
@@ -0,0 +1,9 @@
1
+ %tr.nested-fields{:data => {:new => f.object.new_record?}}
2
+ %td.text-center
3
+ = image_tag f.object.photo.file? ? f.object.photo.url(:thumb) : image_path('polygallery/thumbnail-missing.jpg'), :class => 'img-responsive'
4
+ %td
5
+ = f.input_field :photo
6
+ = f.input_field :caption, :placeholder => "Caption... (optional)", :style => "margin-top:5px;", :as => :string
7
+ %td.text-center{:style => "width:51px;"}
8
+ = link_to_remove_association f, :class => 'btn btn-default btn-sm' do
9
+ %span.glyphicon.glyphicon-trash
@@ -0,0 +1,6 @@
1
+ Polygallery::Engine.routes.draw do
2
+ resources :photos
3
+
4
+ resources :galleries
5
+
6
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePolygalleryGalleries < ActiveRecord::Migration
2
+ def change
3
+ create_table :polygallery_galleries do |t|
4
+ t.string :title, :default => 'gallery'
5
+ t.integer :default_photo_id
6
+ t.integer :galleryable_id
7
+ t.string :galleryable_type
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePolygalleryPhotos < ActiveRecord::Migration
2
+ def change
3
+ create_table :polygallery_photos do |t|
4
+ t.integer :gallery_id
5
+ t.attachment :photo
6
+ t.string :title
7
+ t.text :caption
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,37 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module Polygallery
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "Create a migration to add the Polygallery models to your project."
9
+
10
+ def self.next_migration_number(path)
11
+ unless @prev_migration_nr
12
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
13
+ else
14
+ @prev_migration_nr += 1
15
+ end
16
+ @prev_migration_nr.to_s
17
+ end
18
+
19
+ def copy_migrations
20
+ migration_template "polygallery_migration.rb", "db/migrate/create_polygalleries.rb"
21
+ end
22
+
23
+ def inject_engine_routing
24
+ inject_into_file 'config/routes.rb', :after => 'Application.routes.draw do' do
25
+ "\n\nmount Polygallery::Engine => '/polygallery'\n"
26
+ end
27
+ end
28
+
29
+ def inject_js_initializer
30
+ inject_into_file 'app/assets/javascripts/application.js', :before => '//= require_tree .' do
31
+ "//= require polygallery/init\n"
32
+ end
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,20 @@
1
+ class CreatePolygalleryGalleries < ActiveRecord::Migration
2
+ def change
3
+ create_table :polygallery_galleries do |t|
4
+ t.string :title, :default => 'gallery'
5
+ t.integer :default_photo_id
6
+ t.integer :galleryable_id
7
+ t.string :galleryable_type
8
+
9
+ t.timestamps
10
+ end
11
+ create_table :polygallery_photos do |t|
12
+ t.integer :gallery_id
13
+ t.attachment :photo
14
+ t.string :title
15
+ t.text :caption
16
+
17
+ t.timestamps
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,6 @@
1
+ require "polygallery/engine"
2
+ require "polygallery/has_polygallery"
3
+ require "polygallery/railtie" if defined? Rails
4
+
5
+ module Polygallery
6
+ end
@@ -0,0 +1,10 @@
1
+ module Polygallery
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Polygallery
4
+ initializer 'polygallery_engine.action_controller' do |app|
5
+ ActiveSupport.on_load :action_controller do
6
+
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,9 @@
1
+ require 'polygallery/validators'
2
+
3
+ module Polygallery
4
+ module Glue
5
+ def self.included(base)
6
+ base.send :include, Validators
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,46 @@
1
+ module Polygallery
2
+ module HasPolygallery
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ end
8
+
9
+ module ClassMethods
10
+ def has_polygallery(title='gallery', options={})
11
+ defaults = Polygallery::Gallery::DEFAULTS
12
+ settings = defaults.deep_merge(options)
13
+ has_one title.to_sym, -> { where(:title => title.to_s) }, settings[:association]
14
+ accepts_nested_attributes_for title.to_sym, settings[:nested_attributes]
15
+ after_initialize do
16
+ send("build_#{title.to_s}".to_sym) if send(title.to_sym).nil?
17
+ send(title.to_sym).settings = settings
18
+ end
19
+ include Polygallery::HasPolygallery::LocalInstanceMethods
20
+ end
21
+
22
+ def polygalleries
23
+ self.reflect_on_all_associations(:has_one).select{|a| a.foreign_key == 'galleryable_id'}.map(&:name)
24
+ end
25
+
26
+ def has_polygallery?(title)
27
+ self.polygalleries.include?(title)
28
+ end
29
+ end
30
+
31
+ module LocalInstanceMethods
32
+ def polygalleries
33
+ Polygallery::Gallery.select('polygallery_galleries.title')
34
+ .where(:galleryable => self)
35
+ .group('polygallery_galleries.title')
36
+ .map(&:title)
37
+ end
38
+
39
+ def has_polygallery?(title)
40
+ polygalleries.include?(title)
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ ActiveRecord::Base.send :include, Polygallery::HasPolygallery