spree-cms 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (254) hide show
  1. data/LICENSE +23 -0
  2. data/README.md +68 -0
  3. data/Rakefile +31 -0
  4. data/app/controllers/admin/content_categories_controller.rb +32 -0
  5. data/app/controllers/admin/content_images_controller.rb +21 -0
  6. data/app/controllers/admin/content_parts_controller.rb +27 -0
  7. data/app/controllers/content_category_controller.rb +9 -0
  8. data/app/controllers/content_part_controller.rb +8 -0
  9. data/app/helpers/cms_helpers.rb +15 -0
  10. data/app/models/content_category.rb +16 -0
  11. data/app/models/content_file.rb +8 -0
  12. data/app/models/content_image.rb +10 -0
  13. data/app/models/content_part.rb +58 -0
  14. data/app/views/admin/content_categories/_content_category.html.erb +5 -0
  15. data/app/views/admin/content_categories/index.html.erb +35 -0
  16. data/app/views/admin/content_categories/show.html.erb +30 -0
  17. data/app/views/admin/content_images/file_browser.html.erb +18 -0
  18. data/app/views/admin/content_images/index.html.erb +35 -0
  19. data/app/views/admin/content_parts/_content_part.html.erb +9 -0
  20. data/app/views/admin/content_parts/_form.html.erb +55 -0
  21. data/app/views/admin/content_parts/_sub_menu.html.erb +11 -0
  22. data/app/views/admin/content_parts/edit.html.erb +6 -0
  23. data/app/views/admin/content_parts/index.html.erb +25 -0
  24. data/app/views/admin/content_parts/new.html.erb +6 -0
  25. data/app/views/admin/shared/_ckeditor.html.erb +16 -0
  26. data/app/views/content_categories/_content_category_default.html.erb +3 -0
  27. data/app/views/content_category/show.html.erb +19 -0
  28. data/app/views/content_part/show.html.erb +2 -0
  29. data/app/views/content_parts/_content_part_default.html.erb +8 -0
  30. data/app/views/shared/cms/parts/_fubar_fubar_fubar.html.erb +1 -0
  31. data/config/locales/en.content_categories.yml +2 -0
  32. data/config/locales/en.content_parts.yml +2 -0
  33. data/config/routes.rb +28 -0
  34. data/db/migrate/0001_create_content_parts.rb +20 -0
  35. data/db/migrate/0002_create_content_categories.rb +19 -0
  36. data/db/migrate/0003_create_content_images.rb +17 -0
  37. data/db/migrate/0004_add_permalink_to_content_categories.rb +9 -0
  38. data/db/migrate/0005_add_overlay_image_id_to_content_parts.rb +9 -0
  39. data/db/migrate/0006_add_name_and_alt_to_content_images.rb +11 -0
  40. data/lib/cms.rb +17 -0
  41. data/lib/cms_hooks.rb +7 -0
  42. data/lib/tasks/cms.rake +1 -0
  43. data/lib/tasks/install.rake +25 -0
  44. data/public/ckeditor/adapters/jquery.js +6 -0
  45. data/public/ckeditor/ckeditor.js +141 -0
  46. data/public/ckeditor/ckeditor_basic.js +8 -0
  47. data/public/ckeditor/ckeditor_basic_source.js +20 -0
  48. data/public/ckeditor/ckeditor_source.js +25 -0
  49. data/public/ckeditor/config.js +11 -0
  50. data/public/ckeditor/contents.css +45 -0
  51. data/public/ckeditor/custom_config.js +28 -0
  52. data/public/ckeditor/images/spacer.gif +0 -0
  53. data/public/ckeditor/lang/_languages.js +6 -0
  54. data/public/ckeditor/lang/_translationstatus.txt +60 -0
  55. data/public/ckeditor/lang/af.js +6 -0
  56. data/public/ckeditor/lang/ar.js +6 -0
  57. data/public/ckeditor/lang/bg.js +6 -0
  58. data/public/ckeditor/lang/bn.js +6 -0
  59. data/public/ckeditor/lang/bs.js +6 -0
  60. data/public/ckeditor/lang/ca.js +6 -0
  61. data/public/ckeditor/lang/cs.js +6 -0
  62. data/public/ckeditor/lang/cy.js +6 -0
  63. data/public/ckeditor/lang/da.js +6 -0
  64. data/public/ckeditor/lang/de.js +6 -0
  65. data/public/ckeditor/lang/el.js +6 -0
  66. data/public/ckeditor/lang/en-au.js +6 -0
  67. data/public/ckeditor/lang/en-ca.js +6 -0
  68. data/public/ckeditor/lang/en-gb.js +6 -0
  69. data/public/ckeditor/lang/en.js +6 -0
  70. data/public/ckeditor/lang/eo.js +6 -0
  71. data/public/ckeditor/lang/es.js +6 -0
  72. data/public/ckeditor/lang/et.js +6 -0
  73. data/public/ckeditor/lang/eu.js +6 -0
  74. data/public/ckeditor/lang/fa.js +6 -0
  75. data/public/ckeditor/lang/fi.js +6 -0
  76. data/public/ckeditor/lang/fo.js +6 -0
  77. data/public/ckeditor/lang/fr-ca.js +6 -0
  78. data/public/ckeditor/lang/fr.js +6 -0
  79. data/public/ckeditor/lang/gl.js +6 -0
  80. data/public/ckeditor/lang/gu.js +6 -0
  81. data/public/ckeditor/lang/he.js +6 -0
  82. data/public/ckeditor/lang/hi.js +6 -0
  83. data/public/ckeditor/lang/hr.js +6 -0
  84. data/public/ckeditor/lang/hu.js +6 -0
  85. data/public/ckeditor/lang/is.js +6 -0
  86. data/public/ckeditor/lang/it.js +6 -0
  87. data/public/ckeditor/lang/ja.js +6 -0
  88. data/public/ckeditor/lang/km.js +6 -0
  89. data/public/ckeditor/lang/ko.js +6 -0
  90. data/public/ckeditor/lang/lt.js +6 -0
  91. data/public/ckeditor/lang/lv.js +6 -0
  92. data/public/ckeditor/lang/mn.js +6 -0
  93. data/public/ckeditor/lang/ms.js +6 -0
  94. data/public/ckeditor/lang/nb.js +6 -0
  95. data/public/ckeditor/lang/nl.js +6 -0
  96. data/public/ckeditor/lang/no.js +6 -0
  97. data/public/ckeditor/lang/pl.js +6 -0
  98. data/public/ckeditor/lang/pt-br.js +6 -0
  99. data/public/ckeditor/lang/pt.js +6 -0
  100. data/public/ckeditor/lang/ro.js +6 -0
  101. data/public/ckeditor/lang/ru.js +6 -0
  102. data/public/ckeditor/lang/sk.js +6 -0
  103. data/public/ckeditor/lang/sl.js +6 -0
  104. data/public/ckeditor/lang/sr-latn.js +6 -0
  105. data/public/ckeditor/lang/sr.js +6 -0
  106. data/public/ckeditor/lang/sv.js +6 -0
  107. data/public/ckeditor/lang/th.js +6 -0
  108. data/public/ckeditor/lang/tr.js +6 -0
  109. data/public/ckeditor/lang/uk.js +6 -0
  110. data/public/ckeditor/lang/vi.js +6 -0
  111. data/public/ckeditor/lang/zh-cn.js +6 -0
  112. data/public/ckeditor/lang/zh.js +6 -0
  113. data/public/ckeditor/plugins/a11yhelp/dialogs/a11yhelp.js +7 -0
  114. data/public/ckeditor/plugins/a11yhelp/lang/en.js +6 -0
  115. data/public/ckeditor/plugins/a11yhelp/lang/he.js +6 -0
  116. data/public/ckeditor/plugins/about/dialogs/about.js +6 -0
  117. data/public/ckeditor/plugins/about/dialogs/logo_ckeditor.png +0 -0
  118. data/public/ckeditor/plugins/adobeair/plugin.js +6 -0
  119. data/public/ckeditor/plugins/autogrow/plugin.js +6 -0
  120. data/public/ckeditor/plugins/clipboard/dialogs/paste.js +7 -0
  121. data/public/ckeditor/plugins/colordialog/dialogs/colordialog.js +7 -0
  122. data/public/ckeditor/plugins/dialog/dialogDefinition.js +4 -0
  123. data/public/ckeditor/plugins/div/dialogs/div.js +8 -0
  124. data/public/ckeditor/plugins/find/dialogs/find.js +9 -0
  125. data/public/ckeditor/plugins/flash/dialogs/flash.js +9 -0
  126. data/public/ckeditor/plugins/flash/images/placeholder.png +0 -0
  127. data/public/ckeditor/plugins/forms/dialogs/button.js +6 -0
  128. data/public/ckeditor/plugins/forms/dialogs/checkbox.js +6 -0
  129. data/public/ckeditor/plugins/forms/dialogs/form.js +6 -0
  130. data/public/ckeditor/plugins/forms/dialogs/hiddenfield.js +6 -0
  131. data/public/ckeditor/plugins/forms/dialogs/radio.js +6 -0
  132. data/public/ckeditor/plugins/forms/dialogs/select.js +9 -0
  133. data/public/ckeditor/plugins/forms/dialogs/textarea.js +6 -0
  134. data/public/ckeditor/plugins/forms/dialogs/textfield.js +6 -0
  135. data/public/ckeditor/plugins/forms/images/hiddenfield.gif +0 -0
  136. data/public/ckeditor/plugins/iframe/dialogs/iframe.js +7 -0
  137. data/public/ckeditor/plugins/iframe/images/placeholder.png +0 -0
  138. data/public/ckeditor/plugins/iframedialog/plugin.js +6 -0
  139. data/public/ckeditor/plugins/image/dialogs/image.js +13 -0
  140. data/public/ckeditor/plugins/link/dialogs/anchor.js +6 -0
  141. data/public/ckeditor/plugins/link/dialogs/link.js +11 -0
  142. data/public/ckeditor/plugins/link/images/anchor.gif +0 -0
  143. data/public/ckeditor/plugins/liststyle/dialogs/liststyle.js +6 -0
  144. data/public/ckeditor/plugins/pagebreak/images/pagebreak.gif +0 -0
  145. data/public/ckeditor/plugins/pastefromword/filter/default.js +10 -0
  146. data/public/ckeditor/plugins/pastetext/dialogs/pastetext.js +6 -0
  147. data/public/ckeditor/plugins/placeholder/dialogs/placeholder.js +6 -0
  148. data/public/ckeditor/plugins/placeholder/lang/en.js +6 -0
  149. data/public/ckeditor/plugins/placeholder/placeholder.gif +0 -0
  150. data/public/ckeditor/plugins/placeholder/plugin.js +6 -0
  151. data/public/ckeditor/plugins/scayt/dialogs/options.js +8 -0
  152. data/public/ckeditor/plugins/scayt/dialogs/toolbar.css +6 -0
  153. data/public/ckeditor/plugins/showblocks/images/block_address.png +0 -0
  154. data/public/ckeditor/plugins/showblocks/images/block_blockquote.png +0 -0
  155. data/public/ckeditor/plugins/showblocks/images/block_div.png +0 -0
  156. data/public/ckeditor/plugins/showblocks/images/block_h1.png +0 -0
  157. data/public/ckeditor/plugins/showblocks/images/block_h2.png +0 -0
  158. data/public/ckeditor/plugins/showblocks/images/block_h3.png +0 -0
  159. data/public/ckeditor/plugins/showblocks/images/block_h4.png +0 -0
  160. data/public/ckeditor/plugins/showblocks/images/block_h5.png +0 -0
  161. data/public/ckeditor/plugins/showblocks/images/block_h6.png +0 -0
  162. data/public/ckeditor/plugins/showblocks/images/block_p.png +0 -0
  163. data/public/ckeditor/plugins/showblocks/images/block_pre.png +0 -0
  164. data/public/ckeditor/plugins/smiley/dialogs/smiley.js +7 -0
  165. data/public/ckeditor/plugins/smiley/images/angel_smile.gif +0 -0
  166. data/public/ckeditor/plugins/smiley/images/angry_smile.gif +0 -0
  167. data/public/ckeditor/plugins/smiley/images/broken_heart.gif +0 -0
  168. data/public/ckeditor/plugins/smiley/images/confused_smile.gif +0 -0
  169. data/public/ckeditor/plugins/smiley/images/cry_smile.gif +0 -0
  170. data/public/ckeditor/plugins/smiley/images/devil_smile.gif +0 -0
  171. data/public/ckeditor/plugins/smiley/images/embaressed_smile.gif +0 -0
  172. data/public/ckeditor/plugins/smiley/images/envelope.gif +0 -0
  173. data/public/ckeditor/plugins/smiley/images/heart.gif +0 -0
  174. data/public/ckeditor/plugins/smiley/images/kiss.gif +0 -0
  175. data/public/ckeditor/plugins/smiley/images/lightbulb.gif +0 -0
  176. data/public/ckeditor/plugins/smiley/images/omg_smile.gif +0 -0
  177. data/public/ckeditor/plugins/smiley/images/regular_smile.gif +0 -0
  178. data/public/ckeditor/plugins/smiley/images/sad_smile.gif +0 -0
  179. data/public/ckeditor/plugins/smiley/images/shades_smile.gif +0 -0
  180. data/public/ckeditor/plugins/smiley/images/teeth_smile.gif +0 -0
  181. data/public/ckeditor/plugins/smiley/images/thumbs_down.gif +0 -0
  182. data/public/ckeditor/plugins/smiley/images/thumbs_up.gif +0 -0
  183. data/public/ckeditor/plugins/smiley/images/tounge_smile.gif +0 -0
  184. data/public/ckeditor/plugins/smiley/images/whatchutalkingabout_smile.gif +0 -0
  185. data/public/ckeditor/plugins/smiley/images/wink_smile.gif +0 -0
  186. data/public/ckeditor/plugins/specialchar/dialogs/specialchar.js +7 -0
  187. data/public/ckeditor/plugins/specialchar/lang/en.js +6 -0
  188. data/public/ckeditor/plugins/styles/styles/default.js +6 -0
  189. data/public/ckeditor/plugins/table/dialogs/table.js +9 -0
  190. data/public/ckeditor/plugins/tableresize/plugin.js +7 -0
  191. data/public/ckeditor/plugins/tabletools/dialogs/tableCell.js +8 -0
  192. data/public/ckeditor/plugins/templates/dialogs/templates.js +7 -0
  193. data/public/ckeditor/plugins/templates/templates/default.js +6 -0
  194. data/public/ckeditor/plugins/templates/templates/images/template1.gif +0 -0
  195. data/public/ckeditor/plugins/templates/templates/images/template2.gif +0 -0
  196. data/public/ckeditor/plugins/templates/templates/images/template3.gif +0 -0
  197. data/public/ckeditor/plugins/uicolor/dialogs/uicolor.js +7 -0
  198. data/public/ckeditor/plugins/uicolor/lang/en.js +6 -0
  199. data/public/ckeditor/plugins/uicolor/lang/he.js +6 -0
  200. data/public/ckeditor/plugins/uicolor/plugin.js +6 -0
  201. data/public/ckeditor/plugins/uicolor/uicolor.gif +0 -0
  202. data/public/ckeditor/plugins/uicolor/yui/assets/hue_bg.png +0 -0
  203. data/public/ckeditor/plugins/uicolor/yui/assets/hue_thumb.png +0 -0
  204. data/public/ckeditor/plugins/uicolor/yui/assets/picker_mask.png +0 -0
  205. data/public/ckeditor/plugins/uicolor/yui/assets/picker_thumb.png +0 -0
  206. data/public/ckeditor/plugins/uicolor/yui/assets/yui.css +6 -0
  207. data/public/ckeditor/plugins/uicolor/yui/yui.js +76 -0
  208. data/public/ckeditor/plugins/wsc/dialogs/ciframe.html +49 -0
  209. data/public/ckeditor/plugins/wsc/dialogs/tmpFrameset.html +52 -0
  210. data/public/ckeditor/plugins/wsc/dialogs/wsc.css +6 -0
  211. data/public/ckeditor/plugins/wsc/dialogs/wsc.js +7 -0
  212. data/public/ckeditor/skins/kama/dialog.css +9 -0
  213. data/public/ckeditor/skins/kama/editor.css +13 -0
  214. data/public/ckeditor/skins/kama/icons.png +0 -0
  215. data/public/ckeditor/skins/kama/icons_rtl.png +0 -0
  216. data/public/ckeditor/skins/kama/images/dialog_sides.gif +0 -0
  217. data/public/ckeditor/skins/kama/images/dialog_sides.png +0 -0
  218. data/public/ckeditor/skins/kama/images/dialog_sides_rtl.png +0 -0
  219. data/public/ckeditor/skins/kama/images/mini.gif +0 -0
  220. data/public/ckeditor/skins/kama/images/noimage.png +0 -0
  221. data/public/ckeditor/skins/kama/images/sprites.png +0 -0
  222. data/public/ckeditor/skins/kama/images/sprites_ie6.png +0 -0
  223. data/public/ckeditor/skins/kama/images/toolbar_start.gif +0 -0
  224. data/public/ckeditor/skins/kama/skin.js +7 -0
  225. data/public/ckeditor/skins/kama/templates.css +6 -0
  226. data/public/ckeditor/skins/office2003/dialog.css +9 -0
  227. data/public/ckeditor/skins/office2003/editor.css +14 -0
  228. data/public/ckeditor/skins/office2003/icons.png +0 -0
  229. data/public/ckeditor/skins/office2003/icons_rtl.png +0 -0
  230. data/public/ckeditor/skins/office2003/images/dialog_sides.gif +0 -0
  231. data/public/ckeditor/skins/office2003/images/dialog_sides.png +0 -0
  232. data/public/ckeditor/skins/office2003/images/dialog_sides_rtl.png +0 -0
  233. data/public/ckeditor/skins/office2003/images/mini.gif +0 -0
  234. data/public/ckeditor/skins/office2003/images/noimage.png +0 -0
  235. data/public/ckeditor/skins/office2003/images/sprites.png +0 -0
  236. data/public/ckeditor/skins/office2003/images/sprites_ie6.png +0 -0
  237. data/public/ckeditor/skins/office2003/skin.js +6 -0
  238. data/public/ckeditor/skins/office2003/templates.css +6 -0
  239. data/public/ckeditor/skins/v2/dialog.css +9 -0
  240. data/public/ckeditor/skins/v2/editor.css +13 -0
  241. data/public/ckeditor/skins/v2/icons.png +0 -0
  242. data/public/ckeditor/skins/v2/icons_rtl.png +0 -0
  243. data/public/ckeditor/skins/v2/images/dialog_sides.gif +0 -0
  244. data/public/ckeditor/skins/v2/images/dialog_sides.png +0 -0
  245. data/public/ckeditor/skins/v2/images/dialog_sides_rtl.png +0 -0
  246. data/public/ckeditor/skins/v2/images/mini.gif +0 -0
  247. data/public/ckeditor/skins/v2/images/noimage.png +0 -0
  248. data/public/ckeditor/skins/v2/images/sprites.png +0 -0
  249. data/public/ckeditor/skins/v2/images/sprites_ie6.png +0 -0
  250. data/public/ckeditor/skins/v2/images/toolbar_start.gif +0 -0
  251. data/public/ckeditor/skins/v2/skin.js +6 -0
  252. data/public/ckeditor/skins/v2/templates.css +6 -0
  253. data/public/ckeditor/themes/default/theme.js +8 -0
  254. metadata +332 -0
data/LICENSE ADDED
@@ -0,0 +1,23 @@
1
+ Redistribution and use in source and binary forms, with or without modification,
2
+ are permitted provided that the following conditions are met:
3
+
4
+ * Redistributions of source code must retain the above copyright notice,
5
+ this list of conditions and the following disclaimer.
6
+ * Redistributions in binary form must reproduce the above copyright notice,
7
+ this list of conditions and the following disclaimer in the documentation
8
+ and/or other materials provided with the distribution.
9
+ * Neither the name of the Rails Dog LLC nor the names of its
10
+ contributors may be used to endorse or promote products derived from this
11
+ software without specific prior written permission.
12
+
13
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
14
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
15
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
16
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,68 @@
1
+ Cms
2
+ ===
3
+
4
+ This is a simple CMS extension for Spree 0.40.3. I developed this as
5
+ a successor to the <link to other CMS plugin> plugin that my company
6
+ used before. Alas the data model is in no way compatible.
7
+
8
+ Content is organized through ContentParts. Each ContentPart has a title,
9
+ a body and a weight. The weight controls the order through which content
10
+ parts will be rendered: lighter (smaller) weights come first, if there
11
+ are parts with the same weight those are sorted by their last update's
12
+ date.
13
+
14
+ A content can also include an excerpt. This will mostly be used when
15
+ a short summary of the content is needed. A common use case is a shop's
16
+ landing page: on the index page we want to display an overview of all
17
+ written posts (thus the excerpt is shown), when a user clicks one of
18
+ those the full post (and thus it's body) is shown.
19
+
20
+ Each content should be assigned to a category. A category can define how
21
+ it's associated content_parts will be rendered through various knobs. The
22
+ plugin already includes default templates for normal use cases.
23
+
24
+ Customizing Views and Partials
25
+ ==============================
26
+
27
+ Now comes the magic.. you are expected to render objects as usual through
28
+ the partial helper in your view code, ie.:
29
+
30
+ Render the parts of a whole category:
31
+ <%= render ContentCategory.find_by_name("fubar fubar fubar") %>
32
+
33
+ Render a couple of parts:
34
+ <%= render ContentParts.all %>
35
+
36
+ Render a single content part:
37
+ <%= render ContentPart.first %>
38
+
39
+ You can customize almost everything with this scheme. When a category is
40
+ rendered the cms module looks up if there's a partial within (all relative
41
+ to your view-path) "shared/cms/categories/" named as the category (ie.:
42
+ "#{category.name.parameterize("_")}.html.erb"). If this file was found it
43
+ is used for rendering the category, if not, the content_categories template
44
+ "default_content_category" is rendered.
45
+
46
+ Exactly the same works with content parts, except that the partials should
47
+ be situated in "shared/cms/parts" and the default template is
48
+ "content_parts/content_part_default".
49
+
50
+ Build in WYSWIG Editor CKEditor
51
+ ===============================
52
+
53
+ This extension comes with the WYSWIG Editor CKEditor.
54
+ By default, all text areas in the admin interfaces uses the editor.
55
+ If you don't want to use it on a text area you have to use the class
56
+ attribute "excludeckeditor". You can customize the settings of the CKEditor
57
+ appearence in /public/ckeditor/custom_config.js.
58
+ If you want to render the HTML-Code inside your templates be sure to use
59
+ "<%=raw ".
60
+
61
+
62
+ How to install
63
+ ==============
64
+
65
+ Example goes here.
66
+
67
+
68
+ Copyright (c) 2011 Andreas Happe, released under the New BSD License
@@ -0,0 +1,31 @@
1
+ require File.expand_path('../../config/application', __FILE__)
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+ require 'rake/testtask'
6
+ require 'rake/packagetask'
7
+ require 'rake/gempackagetask'
8
+
9
+ spec = eval(File.read('cms.gemspec'))
10
+
11
+ Rake::GemPackageTask.new(spec) do |p|
12
+ p.gem_spec = spec
13
+ end
14
+
15
+ desc "Release to gemcutter"
16
+ task :release => :package do
17
+ require 'rake/gemcutter'
18
+ Rake::Gemcutter::Tasks.new(spec).define
19
+ Rake::Task['gem:push'].invoke
20
+ end
21
+
22
+ desc "Default Task"
23
+ task :default => [ :spec ]
24
+
25
+ require 'rspec/core/rake_task'
26
+ RSpec::Core::RakeTask.new
27
+
28
+ # require 'cucumber/rake/task'
29
+ # Cucumber::Rake::Task.new do |t|
30
+ # t.cucumber_opts = %w{--format pretty}
31
+ # end
@@ -0,0 +1,32 @@
1
+ class Admin::ContentCategoriesController < Admin::BaseController
2
+
3
+ resource_controller
4
+
5
+ index.before do
6
+ @new_category = ContentCategory.new
7
+ end
8
+
9
+ create do
10
+ wants.html { redirect_to admin_content_categories_path }
11
+
12
+ failure do
13
+ wants.html { redirect_to admin_content_categories_path }
14
+ end
15
+ end
16
+
17
+ destroy do
18
+ wants.html { redirect_to admin_content_categories_path }
19
+
20
+ failure do
21
+ wants.html { redirect_to admin_content_categories_path }
22
+ end
23
+ end
24
+
25
+ update do
26
+ wants.html { redirect_to admin_content_categories_path }
27
+
28
+ failure do
29
+ wants.html { redirect_to admin_content_categories_path }
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ class Admin::ContentImagesController < Admin::BaseController
2
+ resource_controller
3
+
4
+ index.before do
5
+ @content_images = ContentImage.where(:content_part_id => nil,
6
+ :content_part_as_overlay_id => nil)
7
+
8
+ @new_image = ContentImage.new
9
+ end
10
+
11
+ create.wants.html { redirect_to admin_content_images_path }
12
+ update.wants.html { redirect_to admin_content_images_path }
13
+ destroy.wants.html { redirect_to admin_content_images_path }
14
+ index.wants.html do
15
+ if params[:embedded] == "true"
16
+ render 'admin/content_images/file_browser', :layout => false
17
+ else
18
+ render 'admin/content_images/index'
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ class Admin::ContentPartsController < Admin::BaseController
2
+ resource_controller :belongs_to => :content_category
3
+
4
+ create.before do
5
+ @content_part.user = @current_user
6
+ end
7
+
8
+ new_action.before do
9
+ @content_category = ContentCategory.find(params[:content_category_id])
10
+ @content_part = @content_category.content_parts.new :user => @current_user
11
+ end
12
+
13
+ edit.before do
14
+ @content_category = ContentCategory.find(params[:content_category_id])
15
+ @content_part = @content_category.content_parts.find(params[:id])
16
+ end
17
+
18
+ create.wants.html { redirect_to admin_content_category_path(@content_part.category) }
19
+ update.wants.html { redirect_to admin_content_category_path(@content_part.category) }
20
+ destroy.wants.html { redirect_to admin_content_category_path(@content_part.category) }
21
+
22
+ protected
23
+
24
+ def parent_association
25
+ @parent_association ||= parent_object.content_parts
26
+ end
27
+ end
@@ -0,0 +1,9 @@
1
+ class ContentCategoryController < Spree::BaseController
2
+ resource_controller
3
+ actions :show, :index
4
+
5
+ def show
6
+ @contentCategory = ContentCategory.find(params[:id])
7
+ @contentParts = @contentCategory.content_parts
8
+ end
9
+ end
@@ -0,0 +1,8 @@
1
+ class ContentPartController < Spree::BaseController
2
+ resource_controller
3
+ actions :show, :index
4
+
5
+ def show
6
+ @contentPart = ContentPart.find(params[:id])
7
+ end
8
+ end
@@ -0,0 +1,15 @@
1
+ module CmsHelpers
2
+ def insert_full_category(category)
3
+ if category.is_a?(String)
4
+ category = ContentCategory.find_by_name(category)
5
+ elsif category.is_a?(ContentCategory)
6
+ # do nothing
7
+ else
8
+ raise category.inspect
9
+ end
10
+
11
+ if !category.nil?
12
+ # TODO: render the different partss
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,16 @@
1
+ class ContentCategory < ActiveRecord::Base
2
+ validates_presence_of :name
3
+ validates_uniqueness_of :name
4
+
5
+ before_save :update_permalink
6
+
7
+ has_many :content_parts, :foreign_key => 'category_id', :dependent => :nullify
8
+
9
+ named_scope :by_name, lambda { |name| { :conditions => { :name => name}}}
10
+
11
+ protected
12
+
13
+ def update_permalink
14
+ self.permalink = self.name.parameterize
15
+ end
16
+ end
@@ -0,0 +1,8 @@
1
+ # TODO: how to link this to a content_part?
2
+ class ContentFile < Asset
3
+
4
+ has_attached_file :attachment,
5
+ :url => "/assets/cmsfiles/:id/:basename.:extension",
6
+ :path => ":rails_root/public/assets/cmsfiles/:id/:basename.:extension"
7
+
8
+ end
@@ -0,0 +1,10 @@
1
+ class ContentImage < ActiveRecord::Base
2
+
3
+ belongs_to :content_part
4
+
5
+ belongs_to :content_part_as_overlay_image, :foreign_key => 'content_part_as_overlay_id'
6
+
7
+ has_attached_file :image,
8
+ :styles => { :medium => "167x250>" }
9
+
10
+ end
@@ -0,0 +1,58 @@
1
+ class ContentPart < ActiveRecord::Base
2
+
3
+ validates_presence_of :title, :body, :body_raw, :user_id
4
+ validates_numericality_of :weight
5
+ validates_uniqueness_of :permalink
6
+
7
+ belongs_to :user
8
+ belongs_to :category, :class_name => 'ContentCategory', :foreign_key => 'category_id'
9
+
10
+ # for use as a post/summary post in conjunction with the excerpt
11
+ has_one :image, :class_name => 'ContentImage', :dependent => :destroy
12
+ has_one :image_overlay, :foreign_key => "content_part_as_overlay_id", :class_name => 'ContentImage', :dependent => :destroy
13
+
14
+ default_scope :order => 'weight ASC, created_at DESC'
15
+
16
+ before_validation :process_body, :create_permalink
17
+
18
+ protected
19
+
20
+ def create_permalink
21
+ # do not update permalinks automatically. Ever.
22
+ return unless self.permalink.blank?
23
+
24
+ self.permalink = self.title.parameterize
25
+
26
+ if self.permalink.blank?
27
+ self.permalink = Digest::SHA1.hexdigest("fubar-#{Time.now.to_s}")
28
+ end
29
+ end
30
+
31
+ def process_body
32
+ self.body = self.body_raw
33
+ end
34
+
35
+ def image_path=(image)
36
+ self.build_image :image => image
37
+ end
38
+
39
+ def image_path
40
+ if self.image && self.image.image
41
+ self.image.image.url
42
+ else
43
+ ""
44
+ end
45
+ end
46
+
47
+ def image_overlay_path=(image)
48
+ self.build_image_overlay :image => image
49
+ end
50
+
51
+ def image_overlay_path
52
+ if self.image_overlay && self.image_overlay.image
53
+ self.image_overlay.image.url
54
+ else
55
+ ""
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,5 @@
1
+ <% begin %>
2
+ <%= render :partial => "shared/cms/categories/#{content_category.name.parameterize("_")}", :locals => content_category %>
3
+ <% rescue ActionView::MissingTemplate %>
4
+ <%= render :partial => "content_categories/content_category_default", :object => content_category %>
5
+ <% end %>
@@ -0,0 +1,35 @@
1
+ <%= render :partial => 'admin/content_parts/sub_menu' %>
2
+
3
+ <div class="new_resource">
4
+ <% form_for @new_category, :url => admin_content_categories_path do |f| %>
5
+ <%= f.label :name %>
6
+ <%= f.text_field :name %>
7
+ <%= f.label :show_image %>
8
+ <%= f.check_box :show_image %>
9
+ <%= f.label :paginated %>
10
+ <%= f.check_box :paginated %>
11
+ <%= f.submit %>
12
+ <% end %>
13
+ </div>
14
+
15
+ <table class="index" border="0" cellspacing="5" cellpadding="5">
16
+ <tr>
17
+ <th>Name</th>
18
+ <th>Show Image?</th>
19
+ <th>Paginated?</th>
20
+ <th>Part Count</th>
21
+ <th></th>
22
+ </tr>
23
+ <tbody>
24
+ <% @content_categories.each do |category|%>
25
+ <tr>
26
+ <td><%= category.name %></td>
27
+ <td><%= category.show_image %></td>
28
+ <td><%= category.paginated %></td>
29
+ <td><%= category.content_parts.count %></td>
30
+ <td><%= link_to "Destroy", admin_content_category_path(category), :method => :delete, :confirm => "Are you sure?"%></td>
31
+ </tr>
32
+ </tbody>
33
+ <% end %>
34
+ </table>
35
+ </div>
@@ -0,0 +1,30 @@
1
+ <%= render :partial => 'admin/content_parts/sub_menu' %>
2
+
3
+ <h1>Listing <%= @content_category.name %></h1>
4
+
5
+ <%= link_to "New Content", new_admin_content_category_content_part_path(@content_category) %>
6
+
7
+ <table class="index" border="0" cellspacing="5" cellpadding="5">
8
+ <tr>
9
+ <th>Title</th>
10
+ <th>Permalink</th>
11
+ <th>Weight</th>
12
+ <th>Published On</th>
13
+ <th></th>
14
+ </tr>
15
+ <tbody>
16
+ <% @content_category.content_parts.each do |content|%>
17
+ <tr>
18
+ <td><%= content.title %></td>
19
+ <td><%= content.permalink %></td>
20
+ <td><%= content.weight %></td>
21
+ <td></td>
22
+ <td>
23
+ <%= link_to "Edit", edit_admin_content_category_content_part_path(@content_category, content) %>
24
+ |
25
+ <%= link_to "Destroy", admin_content_category_content_part_path(@content_category, content), :method => :delete, :confirm => "Are you sure?"%>
26
+ </td>
27
+ </tr>
28
+ <% end %>
29
+ </tbody>
30
+ </table>
@@ -0,0 +1,18 @@
1
+ <table class="index" border="0" cellspacing="5" cellpadding="5">
2
+ <tr>
3
+ <th>Name</th>
4
+ <th>Alt Description</th>
5
+ <th>Upload Date</th>
6
+ <th>URL</th>
7
+ </tr>
8
+ <tbody>
9
+ <% @content_images.each do |image|%>
10
+ <tr>
11
+ <td><%= link_to_function image.name, "window.opener.CKEDITOR.tools.callFunction(#{params["CKEditorFuncNum"]}, \"#{image.image.url}\"); window.close();" %></td>
12
+ <td><%= image.alt %></td>
13
+ <td><%=l image.created_at.to_date %></td>
14
+ <td><%= image.image.url %></td>
15
+ </tr>
16
+ </tbody>
17
+ <% end %>
18
+ </table>
@@ -0,0 +1,35 @@
1
+ <%= render :partial => 'admin/content_parts/sub_menu' %>
2
+
3
+ <div class="new_resource">
4
+ <% form_for @new_image, :url => admin_content_images_path, :html => { :multipart => true} do |f| %>
5
+ <%= f.label :name %>
6
+ <%= f.text_field :name %>
7
+ <%= f.label :alt %>
8
+ <%= f.text_field :alt %>
9
+ <%= f.label :image %>
10
+ <%= f.file_field :image %>
11
+ <%= f.submit %>
12
+ <% end %>
13
+ </div>
14
+
15
+ <table class="index" border="0" cellspacing="5" cellpadding="5">
16
+ <tr>
17
+ <th>Name</th>
18
+ <th>Alt Description</th>
19
+ <th>Upload Date</th>
20
+ <th>URL</th>
21
+ <th></th>
22
+ </tr>
23
+ <tbody>
24
+ <% @content_images.each do |image|%>
25
+ <tr>
26
+ <td><%= image.name %></td>
27
+ <td><%= image.alt %></td>
28
+ <td><%=l image.created_at.to_date %></td>
29
+ <td><%= image.image.url %></td>
30
+ <td><%= link_to "Destroy", admin_content_image_path(image), :method => :delete, :confirm => "Are you sure?"%></td>
31
+ </tr>
32
+ </tbody>
33
+ <% end %>
34
+ </table>
35
+ </div>