polygallery 0.1.9 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (309) hide show
  1. checksums.yaml +4 -4
  2. data/app/models/concerns/polygallery/acts_as_polyphoto.rb +37 -16
  3. data/app/models/polygallery/gallery.rb +0 -36
  4. data/app/models/polygallery/photo.rb +1 -0
  5. data/db/migrate/20150701180557_create_polygalleries_if_necessary.rb +30 -0
  6. data/db/migrate/20150701180956_add_associations_to_polygallery_photos.rb +24 -0
  7. data/lib/generators/polygallery/install/install_generator.rb +13 -1
  8. data/lib/generators/polygallery/install/templates/add_gallery_title.rb +9 -0
  9. data/lib/generators/polygallery/install/templates/polygallery_migration.rb +1 -1
  10. data/lib/polygallery/engine.rb +7 -0
  11. data/lib/polygallery/has_polygallery.rb +9 -15
  12. data/lib/polygallery/has_polyphotos.rb +29 -25
  13. data/lib/polygallery/version.rb +1 -1
  14. data/test/dummy/app/models/event.rb +11 -2
  15. data/test/dummy/db/schema.rb +4 -1
  16. data/test/dummy/log/development.log +78 -0
  17. data/test/dummy/log/test.log +10375 -0
  18. data/test/dummy/public/system/polygallery/photos/photos/000/000/001/custom/logo_placeholder_medium.png +0 -0
  19. data/test/dummy/public/system/polygallery/photos/photos/000/000/001/medium/logo_placeholder_medium.png +0 -0
  20. data/test/dummy/public/system/polygallery/photos/photos/000/000/001/thumb/logo_placeholder_medium.png +0 -0
  21. data/test/dummy/public/system/polygallery/photos/photos/000/000/002/custom/logo_placeholder_medium.png +0 -0
  22. data/test/dummy/public/system/polygallery/photos/photos/000/000/002/medium/logo_placeholder_medium.png +0 -0
  23. data/test/dummy/public/system/polygallery/photos/photos/000/000/002/thumb/logo_placeholder_medium.png +0 -0
  24. data/test/dummy/public/system/polygallery/photos/photos/000/000/003/custom/logo_placeholder_medium.png +0 -0
  25. data/test/dummy/public/system/polygallery/photos/photos/000/000/003/medium/logo_placeholder_medium.png +0 -0
  26. data/test/dummy/public/system/polygallery/photos/photos/000/000/003/thumb/logo_placeholder_medium.png +0 -0
  27. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/custom/logo_placeholder_medium.png +0 -0
  28. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/medium/cat1.jpg +0 -0
  29. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/medium/logo_placeholder_medium.png +0 -0
  30. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/original/cat1.jpg +0 -0
  31. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/thumb/cat1.jpg +0 -0
  32. data/test/dummy/public/system/polygallery/photos/photos/000/000/004/thumb/logo_placeholder_medium.png +0 -0
  33. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/custom/cat2.jpg +0 -0
  34. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/custom/logo_placeholder_medium.png +0 -0
  35. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/medium/cat2.jpg +0 -0
  36. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/medium/logo_placeholder_medium.png +0 -0
  37. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/original/cat2.jpg +0 -0
  38. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/thumb/cat2.jpg +0 -0
  39. data/test/dummy/public/system/polygallery/photos/photos/000/000/005/thumb/logo_placeholder_medium.png +0 -0
  40. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/custom/logo_placeholder_medium.png +0 -0
  41. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/medium/cat3.jpg +0 -0
  42. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/medium/logo_placeholder_medium.png +0 -0
  43. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/original/cat3.jpg +0 -0
  44. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/thumb/cat3.jpg +0 -0
  45. data/test/dummy/public/system/polygallery/photos/photos/000/000/006/thumb/logo_placeholder_medium.png +0 -0
  46. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/custom/logo_placeholder_medium.png +0 -0
  47. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/medium/cat1.jpg +0 -0
  48. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/medium/logo_placeholder_medium.png +0 -0
  49. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/original/cat1.jpg +0 -0
  50. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/thumb/cat1.jpg +0 -0
  51. data/test/dummy/public/system/polygallery/photos/photos/000/000/007/thumb/logo_placeholder_medium.png +0 -0
  52. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/custom/cat2.jpg +0 -0
  53. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/custom/logo_placeholder_medium.png +0 -0
  54. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/medium/cat2.jpg +0 -0
  55. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/medium/logo_placeholder_medium.png +0 -0
  56. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/original/cat2.jpg +0 -0
  57. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/thumb/cat2.jpg +0 -0
  58. data/test/dummy/public/system/polygallery/photos/photos/000/000/008/thumb/logo_placeholder_medium.png +0 -0
  59. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/custom/logo_placeholder_medium.png +0 -0
  60. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/medium/cat3.jpg +0 -0
  61. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/medium/logo_placeholder_medium.png +0 -0
  62. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/original/cat3.jpg +0 -0
  63. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/original/logo_placeholder_medium.png +0 -0
  64. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/test/logo_placeholder_medium.png +0 -0
  65. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/thumb/cat3.jpg +0 -0
  66. data/test/dummy/public/system/polygallery/photos/photos/000/000/009/thumb/logo_placeholder_medium.png +0 -0
  67. data/test/dummy/public/system/polygallery/photos/photos/000/000/010/custom/logo_placeholder_medium.png +0 -0
  68. data/test/dummy/public/system/polygallery/photos/photos/000/000/010/medium/logo_placeholder_medium.png +0 -0
  69. data/test/dummy/public/system/polygallery/photos/photos/000/000/010/original/logo_placeholder_medium.png +0 -0
  70. data/test/dummy/public/system/polygallery/photos/photos/000/000/010/thumb/logo_placeholder_medium.png +0 -0
  71. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/custom/cat1.jpg +0 -0
  72. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/custom/logo_placeholder_medium.png +0 -0
  73. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/medium/cat1.jpg +0 -0
  74. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/medium/logo_placeholder_medium.png +0 -0
  75. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/original/cat1.jpg +0 -0
  76. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/test/logo_placeholder_medium.png +0 -0
  77. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/thumb/cat1.jpg +0 -0
  78. data/test/dummy/public/system/polygallery/photos/photos/000/000/011/thumb/logo_placeholder_medium.png +0 -0
  79. data/test/dummy/public/system/polygallery/photos/photos/000/000/012/custom/logo_placeholder_medium.png +0 -0
  80. data/test/dummy/public/system/polygallery/photos/photos/000/000/012/medium/logo_placeholder_medium.png +0 -0
  81. data/test/dummy/public/system/polygallery/photos/photos/000/000/012/original/logo_placeholder_medium.png +0 -0
  82. data/test/dummy/public/system/polygallery/photos/photos/000/000/012/thumb/logo_placeholder_medium.png +0 -0
  83. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/custom/logo_placeholder_medium.png +0 -0
  84. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/medium/cat1.jpg +0 -0
  85. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/medium/logo_placeholder_medium.png +0 -0
  86. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/original/cat1.jpg +0 -0
  87. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/original/logo_placeholder_medium.png +0 -0
  88. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/thumb/cat1.jpg +0 -0
  89. data/test/dummy/public/system/polygallery/photos/photos/000/000/013/thumb/logo_placeholder_medium.png +0 -0
  90. data/test/dummy/public/system/polygallery/photos/photos/000/000/014/custom/logo_placeholder_medium.png +0 -0
  91. data/test/dummy/public/system/polygallery/photos/photos/000/000/014/medium/logo_placeholder_medium.png +0 -0
  92. data/test/dummy/public/system/polygallery/photos/photos/000/000/014/thumb/logo_placeholder_medium.png +0 -0
  93. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/custom/cat1.jpg +0 -0
  94. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/custom/logo_placeholder_medium.png +0 -0
  95. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/medium/cat1.jpg +0 -0
  96. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/medium/logo_placeholder_medium.png +0 -0
  97. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/original/cat1.jpg +0 -0
  98. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/original/logo_placeholder_medium.png +0 -0
  99. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/test/logo_placeholder_medium.png +0 -0
  100. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/thumb/cat1.jpg +0 -0
  101. data/test/dummy/public/system/polygallery/photos/photos/000/000/015/thumb/logo_placeholder_medium.png +0 -0
  102. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/custom/logo_placeholder_medium.png +0 -0
  103. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/medium/cat1.jpg +0 -0
  104. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/medium/logo_placeholder_medium.png +0 -0
  105. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/original/cat1.jpg +0 -0
  106. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/original/logo_placeholder_medium.png +0 -0
  107. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/thumb/cat1.jpg +0 -0
  108. data/test/dummy/public/system/polygallery/photos/photos/000/000/016/thumb/logo_placeholder_medium.png +0 -0
  109. data/test/dummy/public/system/polygallery/photos/photos/000/000/017/custom/logo_placeholder_medium.png +0 -0
  110. data/test/dummy/public/system/polygallery/photos/photos/000/000/017/medium/logo_placeholder_medium.png +0 -0
  111. data/test/dummy/public/system/polygallery/photos/photos/000/000/017/original/logo_placeholder_medium.png +0 -0
  112. data/test/dummy/public/system/polygallery/photos/photos/000/000/017/thumb/logo_placeholder_medium.png +0 -0
  113. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/custom/cat1.jpg +0 -0
  114. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/custom/logo_placeholder_medium.png +0 -0
  115. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/medium/cat1.jpg +0 -0
  116. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/medium/logo_placeholder_medium.png +0 -0
  117. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/original/cat1.jpg +0 -0
  118. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/original/logo_placeholder_medium.png +0 -0
  119. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/thumb/cat1.jpg +0 -0
  120. data/test/dummy/public/system/polygallery/photos/photos/000/000/018/thumb/logo_placeholder_medium.png +0 -0
  121. data/test/dummy/public/system/polygallery/photos/photos/000/000/019/custom/logo_placeholder_medium.png +0 -0
  122. data/test/dummy/public/system/polygallery/photos/photos/000/000/019/medium/logo_placeholder_medium.png +0 -0
  123. data/test/dummy/public/system/polygallery/photos/photos/000/000/019/original/logo_placeholder_medium.png +0 -0
  124. data/test/dummy/public/system/polygallery/photos/photos/000/000/019/thumb/logo_placeholder_medium.png +0 -0
  125. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/custom/cat1.jpg +0 -0
  126. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/custom/logo_placeholder_medium.png +0 -0
  127. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/medium/cat1.jpg +0 -0
  128. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/medium/logo_placeholder_medium.png +0 -0
  129. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/original/cat1.jpg +0 -0
  130. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/original/logo_placeholder_medium.png +0 -0
  131. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/thumb/cat1.jpg +0 -0
  132. data/test/dummy/public/system/polygallery/photos/photos/000/000/020/thumb/logo_placeholder_medium.png +0 -0
  133. data/test/dummy/public/system/polygallery/photos/photos/000/000/021/custom/logo_placeholder_medium.png +0 -0
  134. data/test/dummy/public/system/polygallery/photos/photos/000/000/021/medium/logo_placeholder_medium.png +0 -0
  135. data/test/dummy/public/system/polygallery/photos/photos/000/000/021/original/logo_placeholder_medium.png +0 -0
  136. data/test/dummy/public/system/polygallery/photos/photos/000/000/021/thumb/logo_placeholder_medium.png +0 -0
  137. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/custom/logo_placeholder_medium.png +0 -0
  138. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/medium/cat1.jpg +0 -0
  139. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/medium/logo_placeholder_medium.png +0 -0
  140. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/original/cat1.jpg +0 -0
  141. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/original/logo_placeholder_medium.png +0 -0
  142. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/thumb/cat1.jpg +0 -0
  143. data/test/dummy/public/system/polygallery/photos/photos/000/000/022/thumb/logo_placeholder_medium.png +0 -0
  144. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/custom/cat2.jpg +0 -0
  145. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/custom/logo_placeholder_medium.png +0 -0
  146. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/medium/cat2.jpg +0 -0
  147. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/medium/logo_placeholder_medium.png +0 -0
  148. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/original/cat2.jpg +0 -0
  149. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/original/logo_placeholder_medium.png +0 -0
  150. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/thumb/cat2.jpg +0 -0
  151. data/test/dummy/public/system/polygallery/photos/photos/000/000/023/thumb/logo_placeholder_medium.png +0 -0
  152. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/custom/logo_placeholder_medium.png +0 -0
  153. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/medium/cat3.jpg +0 -0
  154. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/medium/logo_placeholder_medium.png +0 -0
  155. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/original/cat3.jpg +0 -0
  156. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/original/logo_placeholder_medium.png +0 -0
  157. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/thumb/cat3.jpg +0 -0
  158. data/test/dummy/public/system/polygallery/photos/photos/000/000/024/thumb/logo_placeholder_medium.png +0 -0
  159. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/custom/logo_placeholder_medium.png +0 -0
  160. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/medium/cat1.jpg +0 -0
  161. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/medium/logo_placeholder_medium.png +0 -0
  162. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/original/cat1.jpg +0 -0
  163. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/original/logo_placeholder_medium.png +0 -0
  164. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/thumb/cat1.jpg +0 -0
  165. data/test/dummy/public/system/polygallery/photos/photos/000/000/025/thumb/logo_placeholder_medium.png +0 -0
  166. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/custom/cat2.jpg +0 -0
  167. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/custom/logo_placeholder_medium.png +0 -0
  168. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/medium/cat2.jpg +0 -0
  169. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/medium/logo_placeholder_medium.png +0 -0
  170. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/original/cat2.jpg +0 -0
  171. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/original/logo_placeholder_medium.png +0 -0
  172. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/thumb/cat2.jpg +0 -0
  173. data/test/dummy/public/system/polygallery/photos/photos/000/000/026/thumb/logo_placeholder_medium.png +0 -0
  174. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/custom/logo_placeholder_medium.png +0 -0
  175. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/medium/cat3.jpg +0 -0
  176. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/medium/logo_placeholder_medium.png +0 -0
  177. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/original/cat3.jpg +0 -0
  178. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/original/logo_placeholder_medium.png +0 -0
  179. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/thumb/cat3.jpg +0 -0
  180. data/test/dummy/public/system/polygallery/photos/photos/000/000/027/thumb/logo_placeholder_medium.png +0 -0
  181. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/custom/logo_placeholder_medium.png +0 -0
  182. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/medium/cat1.jpg +0 -0
  183. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/medium/logo_placeholder_medium.png +0 -0
  184. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/original/cat1.jpg +0 -0
  185. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/original/logo_placeholder_medium.png +0 -0
  186. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/thumb/cat1.jpg +0 -0
  187. data/test/dummy/public/system/polygallery/photos/photos/000/000/028/thumb/logo_placeholder_medium.png +0 -0
  188. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/custom/cat2.jpg +0 -0
  189. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/medium/cat2.jpg +0 -0
  190. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/medium/logo_placeholder_medium.png +0 -0
  191. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/original/cat2.jpg +0 -0
  192. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/original/logo_placeholder_medium.png +0 -0
  193. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/thumb/cat2.jpg +0 -0
  194. data/test/dummy/public/system/polygallery/photos/photos/000/000/029/thumb/logo_placeholder_medium.png +0 -0
  195. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/custom/logo_placeholder_medium.png +0 -0
  196. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/medium/cat3.jpg +0 -0
  197. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/medium/logo_placeholder_medium.png +0 -0
  198. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/original/cat3.jpg +0 -0
  199. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/original/logo_placeholder_medium.png +0 -0
  200. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/thumb/cat3.jpg +0 -0
  201. data/test/dummy/public/system/polygallery/photos/photos/000/000/030/thumb/logo_placeholder_medium.png +0 -0
  202. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/custom/logo_placeholder_medium.png +0 -0
  203. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/medium/cat1.jpg +0 -0
  204. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/medium/logo_placeholder_medium.png +0 -0
  205. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/original/cat1.jpg +0 -0
  206. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/original/logo_placeholder_medium.png +0 -0
  207. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/thumb/cat1.jpg +0 -0
  208. data/test/dummy/public/system/polygallery/photos/photos/000/000/031/thumb/logo_placeholder_medium.png +0 -0
  209. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/custom/cat2.jpg +0 -0
  210. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/custom/logo_placeholder_medium.png +0 -0
  211. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/medium/cat2.jpg +0 -0
  212. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/medium/logo_placeholder_medium.png +0 -0
  213. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/original/cat2.jpg +0 -0
  214. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/original/logo_placeholder_medium.png +0 -0
  215. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/thumb/cat2.jpg +0 -0
  216. data/test/dummy/public/system/polygallery/photos/photos/000/000/032/thumb/logo_placeholder_medium.png +0 -0
  217. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/medium/cat3.jpg +0 -0
  218. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/medium/logo_placeholder_medium.png +0 -0
  219. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/original/cat3.jpg +0 -0
  220. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/original/logo_placeholder_medium.png +0 -0
  221. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/thumb/cat3.jpg +0 -0
  222. data/test/dummy/public/system/polygallery/photos/photos/000/000/033/thumb/logo_placeholder_medium.png +0 -0
  223. data/test/dummy/public/system/polygallery/photos/photos/000/000/034/custom/logo_placeholder_medium.png +0 -0
  224. data/test/dummy/public/system/polygallery/photos/photos/000/000/034/medium/logo_placeholder_medium.png +0 -0
  225. data/test/dummy/public/system/polygallery/photos/photos/000/000/034/original/logo_placeholder_medium.png +0 -0
  226. data/test/dummy/public/system/polygallery/photos/photos/000/000/034/thumb/logo_placeholder_medium.png +0 -0
  227. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/custom/cat1.jpg +0 -0
  228. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/medium/cat1.jpg +0 -0
  229. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/medium/logo_placeholder_medium.png +0 -0
  230. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/original/cat1.jpg +0 -0
  231. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/original/logo_placeholder_medium.png +0 -0
  232. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/thumb/cat1.jpg +0 -0
  233. data/test/dummy/public/system/polygallery/photos/photos/000/000/035/thumb/logo_placeholder_medium.png +0 -0
  234. data/test/dummy/public/system/polygallery/photos/photos/000/000/036/custom/logo_placeholder_medium.png +0 -0
  235. data/test/dummy/public/system/polygallery/photos/photos/000/000/036/medium/logo_placeholder_medium.png +0 -0
  236. data/test/dummy/public/system/polygallery/photos/photos/000/000/036/original/logo_placeholder_medium.png +0 -0
  237. data/test/dummy/public/system/polygallery/photos/photos/000/000/036/thumb/logo_placeholder_medium.png +0 -0
  238. data/test/dummy/public/system/polygallery/photos/photos/000/000/037/medium/cat1.jpg +0 -0
  239. data/test/dummy/public/system/polygallery/photos/photos/000/000/037/original/cat1.jpg +0 -0
  240. data/test/dummy/public/system/polygallery/photos/photos/000/000/037/thumb/cat1.jpg +0 -0
  241. data/test/dummy/public/system/polygallery/photos/photos/000/000/038/custom/logo_placeholder_medium.png +0 -0
  242. data/test/dummy/public/system/polygallery/photos/photos/000/000/038/medium/logo_placeholder_medium.png +0 -0
  243. data/test/dummy/public/system/polygallery/photos/photos/000/000/038/original/logo_placeholder_medium.png +0 -0
  244. data/test/dummy/public/system/polygallery/photos/photos/000/000/038/thumb/logo_placeholder_medium.png +0 -0
  245. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/custom/cat1.jpg +0 -0
  246. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/medium/cat1.jpg +0 -0
  247. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/medium/logo_placeholder_medium.png +0 -0
  248. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/original/cat1.jpg +0 -0
  249. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/original/logo_placeholder_medium.png +0 -0
  250. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/thumb/cat1.jpg +0 -0
  251. data/test/dummy/public/system/polygallery/photos/photos/000/000/039/thumb/logo_placeholder_medium.png +0 -0
  252. data/test/dummy/public/system/polygallery/photos/photos/000/000/040/custom/logo_placeholder_medium.png +0 -0
  253. data/test/dummy/public/system/polygallery/photos/photos/000/000/040/medium/logo_placeholder_medium.png +0 -0
  254. data/test/dummy/public/system/polygallery/photos/photos/000/000/040/original/logo_placeholder_medium.png +0 -0
  255. data/test/dummy/public/system/polygallery/photos/photos/000/000/040/thumb/logo_placeholder_medium.png +0 -0
  256. data/test/dummy/public/system/polygallery/photos/photos/000/000/041/medium/logo_placeholder_medium.png +0 -0
  257. data/test/dummy/public/system/polygallery/photos/photos/000/000/041/original/logo_placeholder_medium.png +0 -0
  258. data/test/dummy/public/system/polygallery/photos/photos/000/000/041/thumb/logo_placeholder_medium.png +0 -0
  259. data/test/dummy/public/system/polygallery/photos/photos/000/000/042/custom/logo_placeholder_medium.png +0 -0
  260. data/test/dummy/public/system/polygallery/photos/photos/000/000/042/medium/logo_placeholder_medium.png +0 -0
  261. data/test/dummy/public/system/polygallery/photos/photos/000/000/042/original/logo_placeholder_medium.png +0 -0
  262. data/test/dummy/public/system/polygallery/photos/photos/000/000/042/thumb/logo_placeholder_medium.png +0 -0
  263. data/test/dummy/public/system/polygallery/photos/photos/000/000/044/custom/logo_placeholder_medium.png +0 -0
  264. data/test/dummy/public/system/polygallery/photos/photos/000/000/044/medium/logo_placeholder_medium.png +0 -0
  265. data/test/dummy/public/system/polygallery/photos/photos/000/000/044/original/logo_placeholder_medium.png +0 -0
  266. data/test/dummy/public/system/polygallery/photos/photos/000/000/044/thumb/logo_placeholder_medium.png +0 -0
  267. data/test/dummy/public/system/polygallery/photos/photos/000/000/045/medium/logo_placeholder_medium.png +0 -0
  268. data/test/dummy/public/system/polygallery/photos/photos/000/000/045/original/logo_placeholder_medium.png +0 -0
  269. data/test/dummy/public/system/polygallery/photos/photos/000/000/045/thumb/logo_placeholder_medium.png +0 -0
  270. data/test/dummy/public/system/polygallery/photos/photos/000/000/046/custom/logo_placeholder_medium.png +0 -0
  271. data/test/dummy/public/system/polygallery/photos/photos/000/000/046/medium/logo_placeholder_medium.png +0 -0
  272. data/test/dummy/public/system/polygallery/photos/photos/000/000/046/original/logo_placeholder_medium.png +0 -0
  273. data/test/dummy/public/system/polygallery/photos/photos/000/000/046/thumb/logo_placeholder_medium.png +0 -0
  274. data/test/dummy/public/system/polygallery/photos/photos/000/000/047/medium/logo_placeholder_medium.png +0 -0
  275. data/test/dummy/public/system/polygallery/photos/photos/000/000/047/original/logo_placeholder_medium.png +0 -0
  276. data/test/dummy/public/system/polygallery/photos/photos/000/000/047/thumb/logo_placeholder_medium.png +0 -0
  277. data/test/dummy/public/system/polygallery/photos/photos/000/000/048/custom/logo_placeholder_medium.png +0 -0
  278. data/test/dummy/public/system/polygallery/photos/photos/000/000/048/medium/logo_placeholder_medium.png +0 -0
  279. data/test/dummy/public/system/polygallery/photos/photos/000/000/048/original/logo_placeholder_medium.png +0 -0
  280. data/test/dummy/public/system/polygallery/photos/photos/000/000/048/thumb/logo_placeholder_medium.png +0 -0
  281. data/test/dummy/public/system/polygallery/photos/photos/000/000/049/medium/logo_placeholder_medium.png +0 -0
  282. data/test/dummy/public/system/polygallery/photos/photos/000/000/049/original/logo_placeholder_medium.png +0 -0
  283. data/test/dummy/public/system/polygallery/photos/photos/000/000/049/thumb/logo_placeholder_medium.png +0 -0
  284. data/test/dummy/public/system/polygallery/photos/photos/000/000/050/custom/logo_placeholder_medium.png +0 -0
  285. data/test/dummy/public/system/polygallery/photos/photos/000/000/050/medium/logo_placeholder_medium.png +0 -0
  286. data/test/dummy/public/system/polygallery/photos/photos/000/000/050/original/logo_placeholder_medium.png +0 -0
  287. data/test/dummy/public/system/polygallery/photos/photos/000/000/050/thumb/logo_placeholder_medium.png +0 -0
  288. data/test/dummy/public/system/polygallery/photos/photos/000/000/051/medium/logo_placeholder_medium.png +0 -0
  289. data/test/dummy/public/system/polygallery/photos/photos/000/000/051/original/logo_placeholder_medium.png +0 -0
  290. data/test/dummy/public/system/polygallery/photos/photos/000/000/051/thumb/logo_placeholder_medium.png +0 -0
  291. data/test/dummy/public/system/polygallery/photos/photos/000/000/052/custom/logo_placeholder_medium.png +0 -0
  292. data/test/dummy/public/system/polygallery/photos/photos/000/000/052/medium/logo_placeholder_medium.png +0 -0
  293. data/test/dummy/public/system/polygallery/photos/photos/000/000/052/original/logo_placeholder_medium.png +0 -0
  294. data/test/dummy/public/system/polygallery/photos/photos/000/000/052/thumb/logo_placeholder_medium.png +0 -0
  295. data/test/dummy/public/system/polygallery/photos/photos/000/000/053/medium/logo_placeholder_medium.png +0 -0
  296. data/test/dummy/public/system/polygallery/photos/photos/000/000/053/original/logo_placeholder_medium.png +0 -0
  297. data/test/dummy/public/system/polygallery/photos/photos/000/000/053/thumb/logo_placeholder_medium.png +0 -0
  298. data/test/dummy/spec/features/events_spec.rb +1 -1
  299. data/test/dummy/spec/models/events_spec.rb +98 -0
  300. data/test/dummy/spec/upload_files/cat1.jpg +0 -0
  301. data/test/dummy/spec/upload_files/cat2.jpg +0 -0
  302. data/test/dummy/spec/upload_files/cat3.jpg +0 -0
  303. data/test/dummy/spec/upload_files/cat4.jpg +0 -0
  304. data/test/dummy/tmp/cache/assets/test/sprockets/1dd8a1ad1294beb4de74919655bff9a6 +0 -0
  305. data/test/dummy/tmp/cache/assets/test/sprockets/60be7d49344e422d2fd9b6f9471598c3 +0 -0
  306. metadata +533 -5
  307. data/db/migrate/20140803171516_create_polygallery_galleries.rb +0 -12
  308. data/db/migrate/20140803171534_create_polygallery_photos.rb +0 -12
  309. data/db/migrate/20141001192141_add_sti_to_galleries_and_photos.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5f9abf3f0bd4b6b0b456186e42035e1c8e5eb303
4
- data.tar.gz: 52b44ca2121ff52b0f69b67d834e878ec4edd402
3
+ metadata.gz: a4c91e60af4f41c8aaa0976ae64ec0f5efa6e17d
4
+ data.tar.gz: 07821da031205f67c63918a383c16f418062055a
5
5
  SHA512:
6
- metadata.gz: 582fdfffbac40a713ecf29ab2b927b2b342fea7e87a51ab236b0f44ad9f3c17f801874c568e4a161227ceb284ddcdfb665e190a2c939edbef4ed86d3df5a3551
7
- data.tar.gz: f57230bd322d74bfd5a1f959260ca0337b73b8893e62bac7f339278eea7b5d754c1a660cb30a5e24b24b7fd0447004765300834f430df799524b3cfaaa27116b
6
+ metadata.gz: 9460848c90ebe20ba08478f4a91968f22ed8258497179a88f97a388faac6c20ed256d6afb53b73e2494b024a64674a97c256501b0877dc61f808965bea68870b
7
+ data.tar.gz: b0db985ec4ef235896cebda1165d6671af5e8cda43d1875cd05f1547ef655b2d1bfd53c64d60f9059e72089c250d50e5569cfeb75bf7ad89fcd3d65c85319ead
@@ -3,20 +3,20 @@ module Polygallery
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- attr_accessor :photo_to_upload, :polygallery_options,
7
- :galleryable_id, :galleryable_type, :gallery_title
8
- acts_as_polyphoto
9
6
  end
10
7
 
11
8
  module ClassMethods
12
9
  def acts_as_polyphoto(options={})
13
10
  defaults = self.polygallery_settings
14
11
  settings = defaults.deep_merge(options)
12
+
13
+ attr_accessor :photo_to_upload, :polygallery_options
15
14
 
16
15
  init_attachment settings[:paperclip]
16
+ init_associations settings
17
17
 
18
18
  after_initialize do
19
- @polygallery_settings = settings if settings == HasPolygallery::DEFAULTS
19
+ self.polygallery_options ||= self.polygallery_settings
20
20
  self.initialize_polyphoto
21
21
  end
22
22
 
@@ -24,40 +24,61 @@ module Polygallery
24
24
  end
25
25
 
26
26
  def polygallery_settings
27
- @polygallery_settings || HasPolygallery::DEFAULTS
27
+ HasPolygallery::DEFAULTS
28
28
  end
29
29
 
30
30
  def init_attachment(paperclip_settings)
31
31
  has_attached_file :photo,
32
- :styles => paperclip_settings[:styles],
33
- :default_url => paperclip_settings[:default_url]
32
+ :styles => ->(a) { a.instance.paperclip_settings[:styles] },
33
+ :default_url => paperclip_settings[:default_url]
34
34
  validations = polygallery_settings[:paperclip_validations]
35
35
  validates_attachment_content_type(:photo, :content_type =>
36
36
  validations[:content_type]) if validations[:content_type]
37
37
  validates_attachment_presence(:photo) if validations[:presence]
38
+
39
+ before_validation :process_photo_to_upload
40
+ end
41
+
42
+ def init_associations(settings=HasPolygallery::DEFAULTS)
43
+ belongs_to settings[:association_names][:gallery],
44
+ :class_name => settings[:associations][:gallery][:class_name],
45
+ :foreign_key => :gallery_id
46
+ belongs_to :galleryable, :polymorphic => true
38
47
  end
39
48
 
40
49
  end
41
50
 
42
51
  module LocalInstanceMethods
43
52
  def include_polygallery_settings(settings)
44
- @polygallery_settings = settings
53
+ self.polygallery_options = settings
45
54
  self.initialize_polyphoto
46
55
  end
47
56
 
48
57
  def initialize_polyphoto
49
- settings = self.polygallery_settings
50
-
51
- self.class.belongs_to settings[:association_names][:gallery],
52
- :class_name => settings[:associations][:gallery][:class_name],
53
- :foreign_key => :gallery_id
54
-
58
+ self.class.init_associations(self.polygallery_settings)
55
59
  self.init_attachment
56
- self.class.before_save :process_photo_to_upload
57
60
  end
58
61
 
59
62
  def polygallery_settings
60
- polygallery_options || @polygallery_settings || HasPolygallery::DEFAULTS
63
+ return self.polygallery_options if self.polygallery_options.present?
64
+ if self.gallery_title.present?
65
+ s = if self.galleryable.present?
66
+ galleryable.class.send(:"#{self.gallery_title}_settings")
67
+ elsif self.galleryable_type.present?
68
+ Kernel.const_get(self.galleryable_type)
69
+ .send(:"#{self.gallery_title}_settings")
70
+ end
71
+ return s if s.present?
72
+ # elsif respond_to?(:gallery) && gallery.present?
73
+ # return gallery.polygallery_settings
74
+ # elsif self.gallery_id.present?
75
+ # g = Kernel.const_get(self.galleryable_type).find(self.gallery_id)
76
+ # if g.present?
77
+ # self.gallery_title = g.title
78
+ # return self.polygallery_settings
79
+ # end
80
+ end
81
+ self.class.polygallery_settings
61
82
  # if gallery_title.present? && galleryable_type.present?
62
83
  # galleryable_class = Kernel.const_get(galleryable_type)
63
84
  # galleryable_class.send :"#{gallery_title}_settings"
@@ -1,41 +1,5 @@
1
1
  module Polygallery
2
2
  class Gallery < ActiveRecord::Base
3
-
4
- belongs_to :galleryable, :polymorphic => true
5
3
  has_polyphotos
6
-
7
- def settings
8
- if galleryable.present?
9
- galleryable.send("#{title}_settings".to_sym)
10
- elsif galleryable_id.present? && galleryable_type.present?
11
- puts 'Galleryable can\'t be loaded'
12
- klass = Object.const_get(galleryable_type)
13
- if klass.exists? :id => galleryable_id
14
- puts 'Galleryable found! Attempting to load now.'
15
- klass.find(galleryable_id).send("#{title}_settings".to_sym)
16
- else
17
- puts 'Galleryable still not found.'
18
- defaults
19
- end
20
- elsif galleryable_type.present?
21
- Object.const_get(galleryable_type).send("#{title}_settings".to_sym)
22
- else
23
- puts 'WARNING: Galleryable not found! Using default paperclip settings...'
24
- defaults
25
- end
26
- end
27
-
28
- def defaults
29
- if self.class_name.present?
30
- Kernel.const_get(self.class_name)::DEFAULTS
31
- else
32
- DEFAULTS
33
- end
34
- end
35
-
36
- def default_options
37
- @default_options ||= DEFAULTS
38
- end
39
-
40
4
  end
41
5
  end
@@ -1,5 +1,6 @@
1
1
  module Polygallery
2
2
  class Photo < ActiveRecord::Base
3
3
  include ActsAsPolyphoto
4
+ acts_as_polyphoto
4
5
  end
5
6
  end
@@ -0,0 +1,30 @@
1
+ class CreatePolygalleriesIfNecessary < ActiveRecord::Migration
2
+ def up
3
+ unless ActiveRecord::Base.connection.table_exists? 'polygallery_galleries'
4
+ create_table :polygallery_galleries do |t|
5
+ t.string :title, :default => 'gallery'
6
+ t.integer :default_photo_id
7
+ t.integer :galleryable_id
8
+ t.string :galleryable_type
9
+ t.string :class_name
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ unless ActiveRecord::Base.connection.table_exists? 'polygallery_photos'
15
+ create_table :polygallery_photos do |t|
16
+ t.integer :gallery_id
17
+ t.attachment :photo
18
+ t.string :title
19
+ t.text :caption
20
+ t.string :class_name
21
+
22
+ t.timestamps
23
+ end
24
+ end
25
+ end
26
+ def down
27
+ drop_table :polygallery_galleries
28
+ drop_table :polygallery_photos
29
+ end
30
+ end
@@ -0,0 +1,24 @@
1
+ class AddAssociationsToPolygalleryPhotos < ActiveRecord::Migration
2
+ def up
3
+ add_column :polygallery_photos, :gallery_title, :string
4
+ add_column :polygallery_photos, :galleryable_id, :integer
5
+ add_column :polygallery_photos, :galleryable_type, :string
6
+ if Polygallery::Gallery.any?
7
+ Polygallery::Gallery.all.each do |pg|
8
+ if pg.polygallery_photos.any?
9
+ pg.polygallery_photos.each do |pp|
10
+ pp.update_attributes :gallery_title => pg.title,
11
+ :galleryable_id => pg.galleryable_id,
12
+ :galleryable_type => pg.galleryable_type
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ def down
20
+ remove_column :polygallery_photos, :gallery_title
21
+ remove_column :polygallery_photos, :galleryable_id
22
+ remove_column :polygallery_photos, :galleryable_type
23
+ end
24
+ end
@@ -17,7 +17,19 @@ module Polygallery
17
17
  end
18
18
 
19
19
  def copy_migrations
20
- migration_template "polygallery_migration.rb", "db/migrate/create_polygalleries.rb"
20
+ # This is the old way of including migrations in a gem.
21
+ # Migrations are now automatically appended by the engine.
22
+ # Legacy code left commented below.
23
+
24
+ # dest_dir = Rails.root.join 'db', 'migrate'
25
+ # {
26
+ # 'polygallery_migration.rb' => 'create_polygalleries.rb',
27
+ # 'add_gallery_title.rb' => 'add_gallery_title_to_polyphotos.rb'
28
+ # }.each do |source, dest_name|
29
+ # unless self.class.migration_exists? dest_dir, dest_name
30
+ # migration_template source, dest_dir.join(dest_name)
31
+ # end
32
+ # end
21
33
  end
22
34
 
23
35
  def inject_engine_routing
@@ -0,0 +1,9 @@
1
+ class AddGalleryTitleToPolyphotos < ActiveRecord::Migration
2
+ def up
3
+ add_column :polygallery_photos, :gallery_title, :string
4
+ add_column :polygallery_photos, :gallery_title, :string
5
+ end
6
+ def down
7
+ remove_column :polygallery_photos, :gallery_title
8
+ end
9
+ end
@@ -19,4 +19,4 @@ class CreatePolygalleries < ActiveRecord::Migration
19
19
  t.timestamps
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -6,5 +6,12 @@ module Polygallery
6
6
 
7
7
  end
8
8
  end
9
+ initializer :append_migrations do |app|
10
+ unless app.root.to_s == root.to_s
11
+ config.paths['db/migrate'].expanded.each do |expanded_path|
12
+ app.config.paths['db/migrate'] << expanded_path
13
+ end
14
+ end
15
+ end
9
16
  end
10
17
  end
@@ -21,19 +21,10 @@ module Polygallery
21
21
  :photos => :photos
22
22
  },
23
23
  :nested_attributes => {
24
- :gallery => {
25
- :reject_if => :all_blank
26
- # proc {|attributes| false }
27
- # photo_attr_sets = attributes
28
- # .select{|k, _| k.include? 'photos_attributes' }
29
- # photo_attr_sets.select{|_, photo_sets|
30
- # photo_sets.select{|_, photo_attrs|
31
- # puts photo_attrs
32
- # photo_attrs.key? 'photo' }.empty? }.empty? }
33
- },
24
+ :gallery => { :reject_if => :all_blank },
34
25
  :photos => {
35
26
  :reject_if => proc {|attributes| !attributes.key?('photo') },
36
- :allow_destroy => true}
27
+ :allow_destroy => true }
37
28
  },
38
29
  :validates => {},
39
30
  :paperclip => {
@@ -58,7 +49,7 @@ module Polygallery
58
49
 
59
50
  associations = options[:associations]
60
51
  gallery_association = options[:associations][:gallery] if associations.present?
61
- gallery_class_name = gallery_association[:class_name] if gallery_association.present?
52
+ gallery_class_name = gallery_association[:class_name] if gallery_association.present?
62
53
  defaults = if gallery_class_name.present? && gallery_class_name != 'Polygallery::Gallery'
63
54
  Kernel.const_get(gallery_class_name)::POLYGALLERY_DEFAULTS
64
55
  else
@@ -66,7 +57,7 @@ module Polygallery
66
57
  end
67
58
  if options[:association_names].nil? && title.to_s != 'gallery'
68
59
  options[:association_names] = {
69
- :gallery => title.to_sym,
60
+ :gallery => :"#{title}",
70
61
  :photos => :"#{title.to_s.gsub('_gallery', '')}_photos"
71
62
  }
72
63
  end
@@ -120,8 +111,11 @@ module Polygallery
120
111
  gallery_association = send pg
121
112
  next if gallery_association.present?
122
113
  gallery_settings = send :"#{pg.to_s}_settings"
123
- gallery_association = send(:"#{pg.to_s}=", send(:"build_#{pg.to_s}",
124
- :polygallery_options => gallery_settings)) if gallery_association.nil?
114
+ if gallery_association.nil?
115
+ built_gallery = send :"build_#{pg.to_s}",
116
+ :polygallery_options => gallery_settings
117
+ gallery_association = send :"#{pg.to_s}=", built_gallery
118
+ end
125
119
  gallery_association.galleryable ||= self
126
120
  end
127
121
  end
@@ -19,13 +19,10 @@ module Polygallery
19
19
  end
20
20
 
21
21
  settings = defaults.deep_merge options
22
-
23
- has_many association_names[:photos], settings[:associations][:photos]
24
- accepts_nested_attributes_for association_names[:photos],
25
- settings[:nested_attributes][:photos]
22
+ init_associations settings
26
23
 
27
24
  after_initialize do
28
- @polygallery_settings = settings if settings == HasPolygallery::DEFAULTS
25
+ self.polygallery_options ||= self.polygallery_settings
29
26
  self.initialize_polygallery
30
27
  end
31
28
 
@@ -33,8 +30,17 @@ module Polygallery
33
30
  end
34
31
 
35
32
  def polygallery_settings
36
- @polygallery_settings || HasPolygallery::DEFAULTS
33
+ HasPolygallery::DEFAULTS
34
+ end
35
+
36
+ def init_associations(settings=HasPolygallery::DEFAULTS)
37
+ belongs_to :galleryable, :polymorphic => true
38
+ photos_name = settings[:association_names][:photos]
39
+ has_many photos_name, settings[:associations][:photos]
40
+ accepts_nested_attributes_for photos_name,
41
+ settings[:nested_attributes][:photos]
37
42
  end
43
+
38
44
  end
39
45
 
40
46
 
@@ -46,38 +52,36 @@ module Polygallery
46
52
  photo.gallery_title ||= title
47
53
  end
48
54
 
49
- # def polygallery_settings
50
- # Kernel.const_get(self.galleryable_type).send :"#{self.title}_settings"
51
- # end
52
-
53
55
  def include_polygallery_settings(settings)
54
- @polygallery_settings = self.polygallery_options = settings
56
+ self.polygallery_options = settings
55
57
  self.initialize_polygallery
56
58
  end
57
59
 
58
60
  def initialize_polygallery
59
- # settings = self.polygallery_settings
60
- # association_names = settings[:association_names]
61
- # self.class.has_many association_names[:photos],
62
- # settings[:associations][:photos].deep_merge({})
63
- # self.class.accepts_nested_attributes_for association_names[:photos],
64
- # settings[:nested_attributes][:photos]
61
+ settings = self.polygallery_settings
62
+ self.class.init_associations(settings)
65
63
  end
66
64
 
67
65
  def build_first_photo
68
- settings = polygallery_settings
69
- photo_association = send settings[:association_names][:photos]
66
+ photo_association = self.polygallery_photos
70
67
  photo_association.build(
71
- :polygallery_options => settings,
72
- :galleryable_id => galleryable_id,
73
- :galleryable_type => galleryable_type,
74
- :gallery_title => self.title
75
- ) unless photo_association.any?
68
+ :polygallery_options => self.polygallery_settings,
69
+ :galleryable_id => self.galleryable_id,
70
+ :galleryable_type => self.galleryable_type,
71
+ :gallery_title => self.title ) unless photo_association.any?
76
72
  end
77
73
 
78
74
  def polygallery_settings
79
- polygallery_options || @polygallery_settings || HasPolygallery::DEFAULTS
75
+ return self.polygallery_options if self.polygallery_options.present?
76
+ return Kernel.const_get(self.galleryable_type)
77
+ .send(:"#{self.title}_settings") if galleryable_type.present?
78
+ self.class.polygallery_settings
79
+ end
80
+
81
+ def polygallery_photos
82
+ self.send self.polygallery_settings[:association_names][:photos]
80
83
  end
84
+
81
85
  end
82
86
  end
83
87
  end
@@ -1,3 +1,3 @@
1
1
  module Polygallery
2
- VERSION = "0.1.9"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,6 +1,15 @@
1
1
  class Event < ActiveRecord::Base
2
2
 
3
- has_polygallery
4
- has_polygallery :custom_gallery, :paperclip => {:styles => {:custom => '500x500#'}}
3
+ has_polygallery # :paperclip => {:styles => {:test => '100x200#'}}
4
+ has_polygallery :custom_gallery,
5
+ :association_names => {
6
+ :gallery => :custom_gallery,
7
+ :photos => :custom_photos },
8
+ :paperclip => {:styles => {:custom => '500x500#'}}
9
+ has_polygallery :gallery_with_altered_style,
10
+ :association_names => {
11
+ :gallery => :gallery_with_altered_style,
12
+ :photos => :altered_photos },
13
+ :paperclip => {:styles => {:medium => '100x200#'}}
5
14
 
6
15
  end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended that you check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(version: 20150320165705) do
14
+ ActiveRecord::Schema.define(version: 20150701180956) do
15
15
 
16
16
  # These are extensions that must be enabled in order to support this database
17
17
  enable_extension "plpgsql"
@@ -43,6 +43,9 @@ ActiveRecord::Schema.define(version: 20150320165705) do
43
43
  t.string "class_name"
44
44
  t.datetime "created_at"
45
45
  t.datetime "updated_at"
46
+ t.string "gallery_title"
47
+ t.integer "galleryable_id"
48
+ t.string "galleryable_type"
46
49
  end
47
50
 
48
51
  end
@@ -37742,3 +37742,81 @@ Started GET "/assets/polygallery/thumbnail-missing.jpg" for 127.0.0.1 at 2015-03
37742
37742
  Polygallery::Gallery Load (0.2ms) SELECT "polygallery_galleries".* FROM "polygallery_galleries" WHERE "polygallery_galleries"."galleryable_id" = $1 AND "polygallery_galleries"."galleryable_type" = $2 AND "polygallery_galleries"."title" = 'gallery' LIMIT 1 [["galleryable_id", 14], ["galleryable_type", "Event"]]
37743
37743
  Polygallery::Gallery Load (0.2ms) SELECT "polygallery_galleries".* FROM "polygallery_galleries" WHERE "polygallery_galleries"."galleryable_id" = $1 AND "polygallery_galleries"."galleryable_type" = $2 AND "polygallery_galleries"."title" = 'custom_gallery' LIMIT 1 [["galleryable_id", 14], ["galleryable_type", "Event"]]
37744
37744
  Polygallery::Photo Load (0.4ms) SELECT "polygallery_photos".* FROM "polygallery_photos" INNER JOIN "polygallery_galleries" ON "polygallery_photos"."gallery_id" = "polygallery_galleries"."id" WHERE "polygallery_galleries"."galleryable_id" = $1 AND "polygallery_galleries"."galleryable_type" = $2 AND "polygallery_galleries"."title" = 'custom_gallery' [["galleryable_id", 14], ["galleryable_type", "Event"]]
37745
+  (169.0ms) CREATE TABLE "schema_migrations" ("version" character varying(255) NOT NULL) 
37746
+  (34.9ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
37747
+ ActiveRecord::SchemaMigration Load (1.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37748
+ Migrating to CreateEvents (20140803170839)
37749
+  (0.2ms) BEGIN
37750
+  (60.0ms) CREATE TABLE "events" ("id" serial primary key, "title" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
37751
+ SQL (15.6ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140803170839"]]
37752
+  (1.3ms) COMMIT
37753
+ Migrating to CreatePolygalleries (20150320165705)
37754
+  (15.4ms) BEGIN
37755
+  (58.9ms) CREATE TABLE "polygallery_galleries" ("id" serial primary key, "title" character varying(255) DEFAULT 'gallery', "default_photo_id" integer, "galleryable_id" integer, "galleryable_type" character varying(255), "class_name" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
37756
+  (21.0ms) CREATE TABLE "polygallery_photos" ("id" serial primary key, "gallery_id" integer, "photo_file_name" character varying(255), "photo_content_type" character varying(255), "photo_file_size" integer, "photo_updated_at" timestamp, "title" character varying(255), "caption" text, "class_name" character varying(255), "created_at" timestamp, "updated_at" timestamp)
37757
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150320165705"]]
37758
+  (30.4ms) COMMIT
37759
+ Migrating to CreatePolygalleriesIfNecessary (20150701180557)
37760
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
37761
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37762
+ Migrating to CreatePolygalleries (20150320165705)
37763
+  (0.1ms) BEGIN
37764
+  (54.2ms) DROP TABLE "polygallery_photos"
37765
+  (23.7ms) DROP TABLE "polygallery_galleries"
37766
+ SQL (33.3ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20150320165705'
37767
+  (1.6ms) COMMIT
37768
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37769
+ ActiveRecord::SchemaMigration Load (0.4ms) SELECT "schema_migrations".* FROM "schema_migrations"
37770
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37771
+ Migrating to CreateEvents (20140803170839)
37772
+  (0.1ms) BEGIN
37773
+  (1.2ms) DROP TABLE "events"
37774
+ SQL (0.6ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20140803170839'
37775
+  (16.3ms) COMMIT
37776
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
37777
+ ActiveRecord::SchemaMigration Load (0.3ms) SELECT "schema_migrations".* FROM "schema_migrations"
37778
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37779
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
37780
+ Migrating to CreateEvents (20140803170839)
37781
+  (0.2ms) BEGIN
37782
+  (37.8ms) CREATE TABLE "events" ("id" serial primary key, "title" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
37783
+ SQL (16.1ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20140803170839"]]
37784
+  (16.0ms) COMMIT
37785
+ Migrating to CreatePolygalleries (20150320165705)
37786
+  (15.4ms) BEGIN
37787
+  (72.0ms) CREATE TABLE "polygallery_galleries" ("id" serial primary key, "title" character varying(255) DEFAULT 'gallery', "default_photo_id" integer, "galleryable_id" integer, "galleryable_type" character varying(255), "class_name" character varying(255), "created_at" timestamp, "updated_at" timestamp) 
37788
+  (12.7ms) CREATE TABLE "polygallery_photos" ("id" serial primary key, "gallery_id" integer, "photo_file_name" character varying(255), "photo_content_type" character varying(255), "photo_file_size" integer, "photo_updated_at" timestamp, "title" character varying(255), "caption" text, "class_name" character varying(255), "created_at" timestamp, "updated_at" timestamp)
37789
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150320165705"]]
37790
+  (0.6ms) COMMIT
37791
+ Migrating to CreatePolygalleriesIfNecessary (20150701180557)
37792
+  (32.9ms) BEGIN
37793
+ SQL (0.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150701180557"]]
37794
+  (0.5ms) COMMIT
37795
+ Migrating to AddAssociationsToPolygalleryPhotos (20150701180956)
37796
+  (0.1ms) BEGIN
37797
+  (0.3ms) ALTER TABLE "polygallery_photos" ADD COLUMN "gallery_title" character varying(255)
37798
+  (0.3ms) ALTER TABLE "polygallery_photos" ADD COLUMN "galleryable_id" integer
37799
+  (0.3ms) ALTER TABLE "polygallery_photos" ADD COLUMN "galleryable_type" character varying(255)
37800
+ SQL (0.1ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150701180956"]]
37801
+  (16.1ms) COMMIT
37802
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37803
+ ActiveRecord::SchemaMigration Load (0.5ms) SELECT "schema_migrations".* FROM "schema_migrations"
37804
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37805
+ Migrating to AddAssociationsToPolygalleryPhotos (20150701180956)
37806
+  (0.1ms) BEGIN
37807
+  (0.7ms) ALTER TABLE "polygallery_photos" DROP "galleryable_type"
37808
+  (0.2ms) ALTER TABLE "polygallery_photos" DROP "galleryable_id"
37809
+  (0.2ms) ALTER TABLE "polygallery_photos" DROP "gallery_title"
37810
+ SQL (0.7ms) DELETE FROM "schema_migrations" WHERE "schema_migrations"."version" = '20150701180956'
37811
+  (15.7ms) COMMIT
37812
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"
37813
+ ActiveRecord::SchemaMigration Load (0.6ms) SELECT "schema_migrations".* FROM "schema_migrations"
37814
+ Migrating to AddAssociationsToPolygalleryPhotos (20150701180956)
37815
+  (0.2ms) BEGIN
37816
+  (35.3ms) ALTER TABLE "polygallery_photos" ADD COLUMN "gallery_title" character varying(255)
37817
+  (0.3ms) ALTER TABLE "polygallery_photos" ADD COLUMN "galleryable_id" integer
37818
+  (0.2ms) ALTER TABLE "polygallery_photos" ADD COLUMN "galleryable_type" character varying(255)
37819
+  (9.0ms) SELECT COUNT(*) FROM "polygallery_galleries"
37820
+ SQL (16.2ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) [["version", "20150701180956"]]
37821
+  (19.2ms) COMMIT
37822
+ ActiveRecord::SchemaMigration Load (0.2ms) SELECT "schema_migrations".* FROM "schema_migrations"