humpyard 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (197) hide show
  1. data/Gemfile +28 -0
  2. data/README.rdoc +61 -0
  3. data/VERSION +1 -0
  4. data/app/controllers/humpyard/assets_controller.rb +123 -0
  5. data/app/controllers/humpyard/elements_controller.rb +200 -0
  6. data/app/controllers/humpyard/errors_controller.rb +8 -0
  7. data/app/controllers/humpyard/pages_controller.rb +365 -0
  8. data/app/helpers/humpyard/pages_helper.rb +19 -0
  9. data/app/models/humpyard/asset.rb +22 -0
  10. data/app/models/humpyard/assets/paperclip_asset.rb +48 -0
  11. data/app/models/humpyard/assets/youtube_asset.rb +38 -0
  12. data/app/models/humpyard/element.rb +57 -0
  13. data/app/models/humpyard/elements/box_element.rb +15 -0
  14. data/app/models/humpyard/elements/media_element.rb +13 -0
  15. data/app/models/humpyard/elements/news_element.rb +13 -0
  16. data/app/models/humpyard/elements/sitemap_element.rb +11 -0
  17. data/app/models/humpyard/elements/text_element.rb +49 -0
  18. data/app/models/humpyard/news_item.rb +42 -0
  19. data/app/models/humpyard/page.rb +153 -0
  20. data/app/models/humpyard/pages/news_page.rb +71 -0
  21. data/app/models/humpyard/pages/static_page.rb +25 -0
  22. data/app/models/humpyard/pages/virtual_page.rb +30 -0
  23. data/app/views/humpyard/assets/_edit.html.haml +15 -0
  24. data/app/views/humpyard/assets/_index.html.haml +24 -0
  25. data/app/views/humpyard/assets/_list.html.haml +4 -0
  26. data/app/views/humpyard/assets/_list_item.html.haml +1 -0
  27. data/app/views/humpyard/assets/_show.html.haml +38 -0
  28. data/app/views/humpyard/assets/_show_asset.html.haml +3 -0
  29. data/app/views/humpyard/assets/destroy.js.erb +4 -0
  30. data/app/views/humpyard/assets/paperclip_assets/_edit.html.haml +4 -0
  31. data/app/views/humpyard/assets/paperclip_assets/_info_table.html.haml +10 -0
  32. data/app/views/humpyard/assets/paperclip_assets/_show.html.haml +12 -0
  33. data/app/views/humpyard/assets/youtube_assets/_edit.html.haml +4 -0
  34. data/app/views/humpyard/assets/youtube_assets/_show.html.haml +5 -0
  35. data/app/views/humpyard/common/_head.html.haml +8 -0
  36. data/app/views/humpyard/common/_page_construct.html.haml +45 -0
  37. data/app/views/humpyard/elements/_edit.html.haml +25 -0
  38. data/app/views/humpyard/elements/_inline_edit.haml +0 -0
  39. data/app/views/humpyard/elements/_new.html.haml +1 -0
  40. data/app/views/humpyard/elements/_show.html.haml +29 -0
  41. data/app/views/humpyard/elements/_show_container.html.haml +3 -0
  42. data/app/views/humpyard/elements/_show_view.html.haml +2 -0
  43. data/app/views/humpyard/elements/box_elements/_edit.html.haml +4 -0
  44. data/app/views/humpyard/elements/box_elements/_inline_edit.html.haml +0 -0
  45. data/app/views/humpyard/elements/box_elements/_show.html.haml +5 -0
  46. data/app/views/humpyard/elements/destroy.js.erb +1 -0
  47. data/app/views/humpyard/elements/error.js.erb +1 -0
  48. data/app/views/humpyard/elements/media_elements/_edit.html.haml +7 -0
  49. data/app/views/humpyard/elements/media_elements/_show.html.haml +8 -0
  50. data/app/views/humpyard/elements/news_elements/_edit.html.haml +5 -0
  51. data/app/views/humpyard/elements/news_elements/_inline_edit.html.haml +0 -0
  52. data/app/views/humpyard/elements/news_elements/_show.html.haml +4 -0
  53. data/app/views/humpyard/elements/sitemap_elements/_edit.html.haml +5 -0
  54. data/app/views/humpyard/elements/sitemap_elements/_inline_edit.html.haml +0 -0
  55. data/app/views/humpyard/elements/sitemap_elements/_show.html.haml +3 -0
  56. data/app/views/humpyard/elements/sitemap_elements/_show_part.html.haml +12 -0
  57. data/app/views/humpyard/elements/text_elements/_edit.html.haml +4 -0
  58. data/app/views/humpyard/elements/text_elements/_inline_edit.html.haml +0 -0
  59. data/app/views/humpyard/elements/text_elements/_show.html.haml +4 -0
  60. data/app/views/humpyard/pages/_content.html.haml +2 -0
  61. data/app/views/humpyard/pages/_edit.html.haml +39 -0
  62. data/app/views/humpyard/pages/_index.html.haml +23 -0
  63. data/app/views/humpyard/pages/_show.html.haml +16 -0
  64. data/app/views/humpyard/pages/_subtree.html.haml +6 -0
  65. data/app/views/humpyard/pages/_tree.html.haml +3 -0
  66. data/app/views/humpyard/pages/destroy.js.erb +4 -0
  67. data/app/views/humpyard/pages/news_pages/_detail.html.haml +10 -0
  68. data/app/views/humpyard/pages/news_pages/_edit.html.haml +3 -0
  69. data/app/views/humpyard/pages/news_pages/_show.html.haml +5 -0
  70. data/app/views/humpyard/pages/show.html.haml +3 -0
  71. data/app/views/humpyard/pages/static_pages/_edit.html.haml +1 -0
  72. data/app/views/humpyard/pages/static_pages/_show.html.haml +1 -0
  73. data/app/views/humpyard/pages/virtual_pages/_edit.html.haml +7 -0
  74. data/app/views/humpyard/pages/virtual_pages/_show.html.haml +4 -0
  75. data/app/views/humpyard/pages/welcome.html.haml +13 -0
  76. data/compass/stylesheets/_humpyard.scss +12 -0
  77. data/compass/stylesheets/humpyard/_backend.scss +1 -0
  78. data/compass/stylesheets/humpyard/_base.scss +144 -0
  79. data/compass/stylesheets/humpyard/_ie.scss +1 -0
  80. data/compass/stylesheets/humpyard/_jquery_ui_overrides.scss +380 -0
  81. data/compass/stylesheets/humpyard/_print.scss +3 -0
  82. data/config/locales/de.yml +84 -0
  83. data/config/locales/en.yml +81 -0
  84. data/config/routes.rb +38 -0
  85. data/db/migrate/20100321134138_base.rb +60 -0
  86. data/db/migrate/20100330204700_create_box_element.rb +24 -0
  87. data/db/migrate/20100401153655_page_template.rb +11 -0
  88. data/db/migrate/20100409195732_page_types.rb +26 -0
  89. data/db/migrate/20100413230623_element_yield.rb +14 -0
  90. data/db/migrate/20100415132312_news_page.rb +48 -0
  91. data/db/migrate/20100415193423_page_i18n_name.rb +27 -0
  92. data/db/migrate/20100415213700_create_news_element.rb +12 -0
  93. data/db/migrate/20100703120000_shared_elements.rb +9 -0
  94. data/db/migrate/20101001142534_page_modified_at.rb +11 -0
  95. data/db/migrate/20101003100138_create_sitemap_elements.rb +13 -0
  96. data/db/migrate/20101003122108_create_humpyard_pages_virtual_pages.rb +11 -0
  97. data/db/migrate/20101006070503_page_cache_control.rb +9 -0
  98. data/db/migrate/20101104173743_create_media.rb +36 -0
  99. data/db/migrate/20110425230524_media_with_link.rb +9 -0
  100. data/lib/generators/humpyard.rb +114 -0
  101. data/lib/generators/humpyard/auth/auth_generator.rb +191 -0
  102. data/lib/generators/humpyard/auth/templates/authlogic/README +9 -0
  103. data/lib/generators/humpyard/auth/templates/authlogic/controllers/user_sessions_controller.rb +22 -0
  104. data/lib/generators/humpyard/auth/templates/authlogic/migration.rb +17 -0
  105. data/lib/generators/humpyard/auth/templates/authlogic/models/ability.rb +12 -0
  106. data/lib/generators/humpyard/auth/templates/authlogic/models/user.rb +7 -0
  107. data/lib/generators/humpyard/auth/templates/authlogic/models/user_session.rb +6 -0
  108. data/lib/generators/humpyard/auth/templates/authlogic/views/user_sessions/new.html.haml +12 -0
  109. data/lib/generators/humpyard/auth/templates/custom/README +8 -0
  110. data/lib/generators/humpyard/auth/templates/devise/README +14 -0
  111. data/lib/generators/humpyard/auth/templates/devise/models/ability.rb +14 -0
  112. data/lib/generators/humpyard/auth/templates/fake/README +0 -0
  113. data/lib/generators/humpyard/auth/templates/fake/models/ability.rb +12 -0
  114. data/lib/generators/humpyard/auth/templates/simple/README +16 -0
  115. data/lib/generators/humpyard/auth/templates/simple/config/humpyard_users.yml +2 -0
  116. data/lib/generators/humpyard/auth/templates/simple/controllers/user_sessions_controller.rb +39 -0
  117. data/lib/generators/humpyard/auth/templates/simple/models/ability.rb +12 -0
  118. data/lib/generators/humpyard/auth/templates/simple/views/user_sessions/new.html.haml +15 -0
  119. data/lib/generators/humpyard/element/USAGE +7 -0
  120. data/lib/generators/humpyard/element/element_generator.rb +82 -0
  121. data/lib/generators/humpyard/element/templates/_edit.html.haml +12 -0
  122. data/lib/generators/humpyard/element/templates/_inline_edit.html.haml +0 -0
  123. data/lib/generators/humpyard/element/templates/_show.html.haml +9 -0
  124. data/lib/generators/humpyard/element/templates/fixtures.yml +23 -0
  125. data/lib/generators/humpyard/element/templates/migration.rb +16 -0
  126. data/lib/generators/humpyard/element/templates/model.rb +11 -0
  127. data/lib/generators/humpyard/element/templates/tests/rspec/model.rb +7 -0
  128. data/lib/generators/humpyard/element/templates/tests/shoulda/model.rb +7 -0
  129. data/lib/generators/humpyard/element/templates/tests/test_unit/model.rb +7 -0
  130. data/lib/generators/humpyard/page/USAGE +7 -0
  131. data/lib/generators/humpyard/page/page_generator.rb +80 -0
  132. data/lib/generators/humpyard/page/templates/_edit.html.haml +7 -0
  133. data/lib/generators/humpyard/page/templates/_show.html.haml +4 -0
  134. data/lib/generators/humpyard/page/templates/fixtures.yml +23 -0
  135. data/lib/generators/humpyard/page/templates/migration.rb +16 -0
  136. data/lib/generators/humpyard/page/templates/model.rb +37 -0
  137. data/lib/generators/humpyard/page/templates/tests/rspec/model.rb +7 -0
  138. data/lib/generators/humpyard/page/templates/tests/shoulda/model.rb +7 -0
  139. data/lib/generators/humpyard/page/templates/tests/test_unit/model.rb +7 -0
  140. data/lib/generators/humpyard/skeleton/USAGE +6 -0
  141. data/lib/generators/humpyard/skeleton/skeleton_generator.rb +99 -0
  142. data/lib/generators/humpyard/skeleton/templates/compass.config +14 -0
  143. data/lib/generators/humpyard/skeleton/templates/images/ajax-loader.gif +0 -0
  144. data/lib/generators/humpyard/skeleton/templates/images/grid.png +0 -0
  145. data/lib/generators/humpyard/skeleton/templates/initializers/compass.rb +16 -0
  146. data/lib/generators/humpyard/skeleton/templates/initializers/haml.rb +3 -0
  147. data/lib/generators/humpyard/skeleton/templates/initializers/humpyard.rb +20 -0
  148. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/images/jstree/d.png +0 -0
  149. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/images/jstree/throbber.gif +0 -0
  150. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-1.5.1.js +8316 -0
  151. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-humpyard.js +790 -0
  152. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-rails.js +157 -0
  153. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery-ui-1.8.10.js +11544 -0
  154. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery.form-2.64.js +803 -0
  155. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/javascripts/jquery.jstree.js +3510 -0
  156. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  157. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  158. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  159. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  160. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  161. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  162. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  163. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  164. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
  165. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
  166. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
  167. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
  168. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
  169. data/lib/generators/humpyard/skeleton/templates/javascripts/jquery-ui-18/stylesheets/smoothness/jquery-ui-1.8.10.css +573 -0
  170. data/lib/generators/humpyard/skeleton/templates/stylesheets/ie.sass +15 -0
  171. data/lib/generators/humpyard/skeleton/templates/stylesheets/ie.scss +16 -0
  172. data/lib/generators/humpyard/skeleton/templates/stylesheets/partials/_base.sass +12 -0
  173. data/lib/generators/humpyard/skeleton/templates/stylesheets/partials/_base.scss +11 -0
  174. data/lib/generators/humpyard/skeleton/templates/stylesheets/print.sass +3 -0
  175. data/lib/generators/humpyard/skeleton/templates/stylesheets/print.scss +3 -0
  176. data/lib/generators/humpyard/skeleton/templates/stylesheets/screen.sass +78 -0
  177. data/lib/generators/humpyard/skeleton/templates/stylesheets/screen.scss +90 -0
  178. data/lib/generators/humpyard/skeleton/templates/views/layout.html.haml +28 -0
  179. data/lib/html_to_textile.rb +220 -0
  180. data/lib/humpyard.rb +70 -0
  181. data/lib/humpyard/action_controller/base.rb +24 -0
  182. data/lib/humpyard/active_model/naming.rb +29 -0
  183. data/lib/humpyard/active_model/translation.rb +26 -0
  184. data/lib/humpyard/active_model/validators/publish_range.rb +14 -0
  185. data/lib/humpyard/active_record/acts/asset.rb +68 -0
  186. data/lib/humpyard/active_record/acts/container_element.rb +26 -0
  187. data/lib/humpyard/active_record/acts/element.rb +89 -0
  188. data/lib/humpyard/active_record/acts/page.rb +101 -0
  189. data/lib/humpyard/active_record/has/title_for_url.rb +75 -0
  190. data/lib/humpyard/compass.rb +6 -0
  191. data/lib/humpyard/config.rb +235 -0
  192. data/lib/humpyard/engine.rb +7 -0
  193. data/lib/humpyard/uri_parser.rb +16 -0
  194. data/lib/humpyard/uri_parser/assets_uri_parser.rb +15 -0
  195. data/lib/humpyard/uri_parser/pages_uri_parser.rb +15 -0
  196. data/lib/tasks/humpyard.rake +103 -0
  197. metadata +331 -0
@@ -0,0 +1,15 @@
1
+ @import blueprint
2
+
3
+ +blueprint-ie
4
+
5
+ // Note :
6
+ //
7
+ // Compass will center text to fix IE6 container centering.
8
+ // This means all your texts will be centered under all version of IE by default.
9
+ // Please don't forget to restore the correct behavior to your main container (but not the body tag!)
10
+ //
11
+ // Example :
12
+ //
13
+ // .container, .footer {
14
+ // text-align: left;
15
+ // }
@@ -0,0 +1,16 @@
1
+ @import "blueprint";
2
+
3
+ @include blueprint-ie;
4
+
5
+ // Note :
6
+ //
7
+ // Compass will center text to fix IE6 container centering.
8
+ // This means all your texts will be centered under all version of IE by default.
9
+ // Please don't forget to restore the correct behavior to your main container (but not the body tag!)
10
+ //
11
+ // Example :
12
+ //
13
+ // .container, .footer {
14
+ // text-align: left;
15
+ // }
16
+
@@ -0,0 +1,12 @@
1
+ // Here is where you can define your constants for your application and to configure the blueprint framework.
2
+ // Feel free to delete these if you want keep the defaults:
3
+
4
+ $blueprint_grid_columns: 24
5
+
6
+ $blueprint_container_size: 800px
7
+
8
+ $blueprint_grid_margin: 10px
9
+
10
+ // Use this to calculate the width based on the total width.
11
+ // Or you can set !blueprint_grid_width to a fixed value and unset !blueprint_container_size -- it will be calculated for you.
12
+ $blueprint_grid_width: ($blueprint_container_size + $blueprint_grid_margin) / $blueprint_grid_columns - $blueprint_grid_margin
@@ -0,0 +1,11 @@
1
+ // Here is where you can define your constants for your application and to configure the blueprint framework.
2
+ // Feel free to delete these if you want keep the defaults:
3
+
4
+ $blueprint_grid_columns: 24;
5
+ $blueprint_container_size: 800px;
6
+ $blueprint_grid_margin: 10px;
7
+
8
+ // Use this to calculate the width based on the total width.
9
+ // Or you can set !blueprint_grid_width to a fixed value and unset !blueprint_container_size -- it will be calculated for you.
10
+ $blueprint_grid_width: ($blueprint_container_size + $blueprint_grid_margin) / $blueprint_grid_columns - $blueprint_grid_margin;
11
+
@@ -0,0 +1,3 @@
1
+ @import blueprint
2
+
3
+ +blueprint-print
@@ -0,0 +1,3 @@
1
+ @import "blueprint";
2
+
3
+ @include blueprint-print;
@@ -0,0 +1,78 @@
1
+ // This import applies a global reset to any page that imports this stylesheet.
2
+ @import blueprint/reset
3
+
4
+ // To configure blueprint, edit the partials/base.sass file.
5
+ @import partials/base
6
+
7
+ // Import all the default blueprint modules so that we can access their mixins.
8
+ @import blueprint
9
+
10
+ // Import the non-default scaffolding module.
11
+ @import blueprint/scaffolding
12
+
13
+ // Import the humpyard module
14
+ @import humpyard/base
15
+
16
+ // To generate css equivalent to the blueprint css but with your configuration applied, uncomment:
17
+ +blueprint
18
+
19
+ //Recommended Blueprint configuration with scoping and semantic layout:
20
+
21
+ +blueprint-scaffolding("#hy-body")
22
+
23
+ +humpyard-base
24
+
25
+ body.hy-logged-in
26
+ form
27
+ // TODO: remove blueprint dependencies
28
+ // for our own jquery-ui froms
29
+ // write our own macros for form layout
30
+ +blueprint-form-layout
31
+ +blueprint-form-borders(#bbbbbb, #666666, #cccccc)
32
+ +blueprint-form-sizes(400px, 400px, 250px)
33
+
34
+ #hy-body
35
+ +blueprint-typography(true)
36
+ +blueprint-utilities
37
+ +blueprint-debug
38
+ +blueprint-interaction
39
+ // Remove the scaffolding when you're ready to start doing visual design.
40
+ // Or leave it in if you're happy with how blueprint looks out-of-the-box
41
+ padding: 10px
42
+ font-size: 14px
43
+ .flash
44
+ border:
45
+ width: 1px
46
+ style: solid
47
+ color: #999
48
+ background: #ccc
49
+ padding: 5px
50
+ #flash_error
51
+ border-color: #f99
52
+ background: #fcc
53
+ form
54
+ +blueprint-form
55
+ .container
56
+ +container
57
+ #header, #footer
58
+ +column($blueprint_grid_columns)
59
+ #footer
60
+ border-top: 1px solid $font_color
61
+ #sidebar
62
+ // One third of the grid columns, rounding down. With 24 cols, this is 8.
63
+ $sidebar_columns: floor($blueprint_grid_columns / 6)
64
+ +column($sidebar_columns)
65
+ p
66
+ +box
67
+ #content
68
+ // Two thirds of the grid columns, rounding up.
69
+ // With 24 cols, this is 16.
70
+ $content_columns: ceil(5 * $blueprint_grid_columns / 6)
71
+ // true means it's the last column in the row
72
+ +column($content_columns, true)
73
+ .box-element
74
+ background: #ddd
75
+ padding: 5px
76
+ .box-element-content
77
+ border: 1px solid #fdd
78
+ background: #fff
@@ -0,0 +1,90 @@
1
+ // This import applies a global reset to any page that imports this stylesheet.
2
+ @import "blueprint/reset";
3
+ // To configure blueprint, edit the partials/base.sass file.
4
+ @import "partials/base";
5
+ // Import all the default blueprint modules so that we can access their mixins.
6
+ @import "blueprint";
7
+ // Import the non-default scaffolding module.
8
+ @import "blueprint/scaffolding";
9
+ // Import the humpyard module
10
+ @import "humpyard/base";
11
+
12
+ // To generate css equivalent to the blueprint css but with your configuration applied, uncomment:
13
+ @include blueprint;
14
+
15
+ //Recommended Blueprint configuration with scoping and semantic layout:
16
+
17
+ @include blueprint-scaffolding("#hy-body");
18
+ @include humpyard-base;
19
+
20
+ body.hy-logged-in {
21
+ form {
22
+ // TODO: remove blueprint dependencies
23
+ // for our own jquery-ui froms
24
+ // write our own macros for form layout
25
+ @include blueprint-form-layout;
26
+ @include blueprint-form-borders(#bbb, #666, #ccc);
27
+ @include blueprint-form-sizes(400px, 400px, 250px);
28
+ }
29
+ }
30
+
31
+ #hy-body {
32
+ @include blueprint-typography(true);
33
+ @include blueprint-utilities;
34
+ @include blueprint-debug;
35
+ @include blueprint-interaction;
36
+ // Remove the scaffolding when you're ready to start doing visual design.
37
+ // Or leave it in if you're happy with how blueprint looks out-of-the-box
38
+
39
+ padding: 10px;
40
+ font-size: 14px;
41
+
42
+ .flash {
43
+ border-width: 1px;
44
+ border-style: solid;
45
+ border-color: #999;
46
+ background: #ccc;
47
+ padding: 5px;
48
+ }
49
+ #flash_error {
50
+ border-color: #f99;
51
+ background: #fcc;
52
+ }
53
+
54
+ form {
55
+ @include blueprint-form;
56
+ }
57
+ .container {
58
+ @include container;
59
+ }
60
+ #header, #footer {
61
+ @include column($blueprint_grid_columns)
62
+ }
63
+ #footer {
64
+ border-top: 1px solid $font_color;
65
+ }
66
+ #sidebar {
67
+ // One third of the grid columns, rounding down. With 24 cols, this is 8.
68
+ $sidebar_columns: floor($blueprint_grid_columns / 6);
69
+ @include column($sidebar_columns);
70
+ p {
71
+ @include box;
72
+ }
73
+ }
74
+ #content {
75
+ // Two thirds of the grid columns, rounding up.
76
+ // With 24 cols, this is 16.
77
+ $content_columns: ceil(5 * $blueprint_grid_columns / 6);
78
+ // true means it's the last column in the row
79
+ @include column($content_columns, true);
80
+
81
+ .box-element {
82
+ background: #ddd;
83
+ padding: 5px;
84
+ .box-element-content {
85
+ border: 1px solid #fdd;
86
+ background: #fff;
87
+ }
88
+ }
89
+ }
90
+ }
@@ -0,0 +1,28 @@
1
+ !!! Strict
2
+ %html{html_attrs(I18n.locale)}
3
+ %head
4
+ =render :partial => 'humpyard/common/head'
5
+ <% if options[:js_framework] -%>
6
+ = stylesheet_link_tag 'smoothness/jquery-ui-1.8.10.css'
7
+ = javascript_include_tag 'jquery-1.5.1', 'jquery-ui-1.8.10', 'jquery.form-2.64', 'jquery.jstree', 'jquery-rails', 'jquery-humpyard'
8
+ <% end -%>
9
+ = csrf_meta_tag
10
+ = page_body do
11
+ .container
12
+ - flash.each do |name, msg|
13
+ = content_tag :div, msg, :id => "flash_#{name}", :class => 'flash'
14
+ #header.span-24{"class"=>"last"}
15
+ %h1
16
+ = @content_for_title
17
+ #menu.span-24{"class"=>"last"}
18
+ - if Humpyard::Page.root_page
19
+ - Humpyard::Page.root_page.child_pages.each do |page|
20
+ = link_to page.title, page.human_url
21
+ #content.span-16
22
+ = yield
23
+ #sidebar.span-8{"class"=>"last"}
24
+ .box
25
+ = yield :sidebar
26
+ #footer.span-24{"class"=>"last"}
27
+ %p
28
+ This is just a template
@@ -0,0 +1,220 @@
1
+ require "nokogiri"
2
+
3
+ class HtmlToTextile
4
+ class Document < ::Nokogiri::XML::SAX::Document
5
+ def valid_tags
6
+ ['a','p','br','u','b','i','strong','em','ul','ol','li','sup','sub', 'ins', 'del', 'h1', 'h2', 'h3', 'table', 'tr', 'td', 'th']
7
+ end
8
+
9
+ def tree
10
+ @tree ||= []
11
+ end
12
+
13
+ def stack
14
+ @stack ||= []
15
+ end
16
+
17
+ def start_element name, attrs = []
18
+ if valid_tags.include? name
19
+ attrs_hash = {}
20
+ while key = attrs.shift do
21
+ value = attrs.shift
22
+ attrs_hash[key] = value
23
+ end
24
+
25
+
26
+ stack << {
27
+ 'name' => name,
28
+ 'content' => [],
29
+ 'attrs' => attrs_hash
30
+ }
31
+ end
32
+ end
33
+
34
+ def end_element name
35
+ if valid_tags.include? name
36
+ content = stack.pop
37
+ if stack.empty? or stack.last['content'].nil?
38
+ tree << content
39
+ else
40
+ stack.last['content'] << content
41
+ end
42
+ end
43
+ end
44
+
45
+ def characters string
46
+ if stack.last.nil? or stack.last['content'].nil?
47
+ stack << "#{string}"
48
+ else
49
+ stack.last['content'] << "#{string}"
50
+ end
51
+ end
52
+
53
+ def to_textile
54
+ ##ActiveRecord::Base.logger.debug "### tree START"
55
+ ##ActiveRecord::Base.logger.debug @tree.inspect
56
+ ##ActiveRecord::Base.logger.debug "### tree END"
57
+ #ActiveRecord::Base.logger.debug "### HTML START"
58
+ to_html
59
+ #ActiveRecord::Base.logger.debug "### HTML END"
60
+
61
+ textile = ''
62
+ tree.each do |content|
63
+ textile += _to_textile_tag content
64
+ end
65
+
66
+ #ActiveRecord::Base.logger.debug "### TEXTILE START"
67
+ #ActiveRecord::Base.logger.debug textile
68
+ #ActiveRecord::Base.logger.debug "### TEXTILE END"
69
+
70
+ return textile
71
+ end
72
+
73
+ def to_html
74
+ @html = ''
75
+ tree.each do |content|
76
+ _to_html_tag content
77
+ end
78
+ return @html
79
+ end
80
+
81
+ private
82
+ def _to_html_tag content, indent = 0
83
+ if content.class == String
84
+ #ActiveRecord::Base.logger.debug "#{(' ' * indent)}#{content.to_s.gsub("\n", "#{' ' * indent}")}"
85
+ @html += "#{content}"
86
+ elsif content.class == Hash
87
+ if ['br','img'].include? content['name']
88
+ #ActiveRecord::Base.logger.debug "#{(' ' * indent)}<#{content['name']} />"
89
+ @html += "<#{content['name']} />"
90
+ else
91
+ #ActiveRecord::Base.logger.debug "#{(' ' * indent)}<#{content['name']}>"
92
+ @html += "<#{content['name']}>"
93
+ _to_html_tag(content['content'], indent + 2)
94
+ #ActiveRecord::Base.logger.debug "#{(' ' * indent)}</#{content['name']}>"
95
+ @html += "</#{content['name']}>"
96
+ end
97
+ elsif content.class == Array
98
+ content.each do |element|
99
+ _to_html_tag element, indent
100
+ end
101
+ end
102
+ end
103
+
104
+ def _to_textile_tag content, indent = 0
105
+ textile = ''
106
+ if content.class == String
107
+ ##ActiveRecord::Base.logger.debug "Content: #{content}"
108
+ textile += "#{content}"
109
+ elsif content.class == Hash
110
+ if ['u','b','strong','i','em','del','ins', 'sub', 'sup'].include? content['name']
111
+ literals = {
112
+ 'u' => '+',
113
+ 'b' => '*',
114
+ 'strong' => '*',
115
+ 'i' => '_',
116
+ 'em' => '_',
117
+ 'del' => '-',
118
+ 'ins' => '+',
119
+ 'sub' => '~',
120
+ 'sup' => '^'
121
+ }
122
+ inner_parsed_textile = _spaces _to_textile_tag(content['content'])
123
+ if inner_parsed_textile[:content].blank?
124
+ #ActiveRecord::Base.logger.debug "#{inner_parsed_textile[:leading]}#{inner_parsed_textile[:tailing]}"
125
+ textile += "#{inner_parsed_textile[:leading]}#{inner_parsed_textile[:tailing]}"
126
+ else
127
+ #ActiveRecord::Base.logger.debug "#{inner_parsed_textile[:leading]}[#{literals[content['name']]}#{inner_parsed_textile[:content]}#{literals[content['name']]}]#{inner_parsed_textile[:tailing]}"
128
+ textile += "#{inner_parsed_textile[:leading]}[#{literals[content['name']]}#{inner_parsed_textile[:content]}#{literals[content['name']]}]#{inner_parsed_textile[:tailing]}"
129
+ end
130
+ elsif ['br'].include? content['name']
131
+ #ActiveRecord::Base.logger.debug "\n"
132
+ textile += "\n"
133
+ elsif ['p','h1','h2','h3'].include? content['name']
134
+ if content['attrs']['style'] and a = content['attrs']['style'][/text-align:[\ ]?([^;]*)/,1] and not a.nil?
135
+ #ActiveRecord::Base.logger.debug 'strip1'
136
+ alignment = case a.strip.downcase
137
+ when 'left' then '<'
138
+ when 'right' then '>'
139
+ when 'center' then '='
140
+ else ''
141
+ end
142
+ else
143
+ alignment = ''
144
+ end
145
+ #ActiveRecord::Base.logger.debug "\n#{"#{content['name']}#{alignment}. " unless indent > 0}#{_to_textile_tag(content['content'], indent).strip}#\n\n"
146
+ textile += "\n#{content['name']}#{alignment}. "
147
+ textile += _to_textile_tag(content['content'], indent).strip
148
+ textile += "\n\n"
149
+ elsif ['a'].include? content['name']
150
+ inner_parsed_textile = _spaces _to_textile_tag(content['content'])
151
+ if inner_parsed_textile[:content].blank?
152
+ #ActiveRecord::Base.logger.debug "#{inner_parsed_textile[:leading]}#{inner_parsed_textile[:tailing]}"
153
+ textile += "#{inner_parsed_textile[:leading]}#{inner_parsed_textile[:tailing]}"
154
+ else
155
+ #ActiveRecord::Base.logger.debug "#{inner_parsed_textile[:leading]}[\"#{inner_parsed_textile[:content]}\":#{content['attrs']['href'].blank? ? '#' : content['attrs']['href']}]#{inner_parsed_textile[:tailing]}"
156
+ textile += "#{inner_parsed_textile[:leading]}[\"#{inner_parsed_textile[:content]}\":#{content['attrs']['href'].blank? ? '#' : content['attrs']['href']}]#{inner_parsed_textile[:tailing]}"
157
+ end
158
+ elsif ['ul','ol'].include? content['name']
159
+ literals = {
160
+ 'ul' => '*',
161
+ 'ol' => '#'
162
+ }
163
+
164
+ content['content'].each do |element|
165
+ if element.class == Hash and element['name'] == 'li'
166
+ #ActiveRecord::Base.logger.debug "\n #{literals[content['name']]} #{_to_textile_tag element, indent +2}"
167
+ textile += "\n #{literals[content['name']]} "
168
+ textile += _to_textile_tag element, indent +2
169
+ end
170
+ end
171
+ textile += "\n"
172
+ elsif ['table'].include? content['name']
173
+ textile += "\n"
174
+ content['content'].each do |row|
175
+ if row.class == Hash and row['name'] == 'tr'
176
+ row['content'].each do |element|
177
+ if element.class == Hash and ['td', 'th'].include? element['name']
178
+ #ActiveRecord::Base.logger.debug "|#{element['name'] == 'th' ? '_.' : ''} #{_to_textile_tag(element, indent +2).strip.gsub(/\n{2,}/, "\n")} "
179
+ textile += "|#{element['name'] == 'th' ? '_.' : ''} #{_to_textile_tag(element, indent +2).strip.gsub(/\n{2,}/, "\n")} "
180
+ end
181
+ end
182
+ textile += "|\n"
183
+ end
184
+ end
185
+ else
186
+ #ActiveRecord::Base.logger.debug _to_textile_tag content['content'], indent
187
+ textile += _to_textile_tag content['content'], indent
188
+ end
189
+ elsif content.class == Array
190
+ content.each do |element|
191
+ #ActiveRecord::Base.logger.debug _to_textile_tag element, indent
192
+ textile += _to_textile_tag element, indent
193
+ end
194
+ end
195
+
196
+ return textile
197
+ end
198
+
199
+ def _spaces string
200
+ parsed = {:content => string}
201
+ string.gsub(/^(\s*)?(\S*)(\s*)?$/) {|s| parsed = {:leading => $1, :content => $2, :tailing => $3} }
202
+ parsed
203
+ end
204
+ end
205
+
206
+ def initialize(string)
207
+ @tree = []
208
+ @document = Document.new
209
+ parser = ::Nokogiri::HTML::SAX::Parser.new(@document)
210
+ parser.parse(string)
211
+ end
212
+
213
+ def to_textile
214
+ @document.to_textile
215
+ end
216
+
217
+ def to_html
218
+ @document.to_html
219
+ end
220
+ end