kuhsaft 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. data/.gitignore +13 -3
  2. data/.rspec +4 -0
  3. data/.rvmrc +47 -0
  4. data/Gemfile +1 -3
  5. data/Guardfile +25 -0
  6. data/Rakefile +28 -2
  7. data/app/controllers/kuhsaft/admin/assets_controller.rb +41 -0
  8. data/app/controllers/kuhsaft/admin/pages_controller.rb +54 -0
  9. data/app/controllers/kuhsaft/pages_controller.rb +11 -0
  10. data/app/models/kuhsaft/asset.rb +4 -0
  11. data/app/models/kuhsaft/localized_page.rb +19 -0
  12. data/app/models/kuhsaft/page.rb +113 -0
  13. data/app/models/kuhsaft/page_part.rb +12 -0
  14. data/app/models/kuhsaft/page_parts/base.rb +26 -0
  15. data/app/models/kuhsaft/page_parts/content.rb +8 -0
  16. data/app/models/kuhsaft/page_parts/markdown.rb +7 -0
  17. data/app/stylesheets/kuhsaft/admin/ie.sass +0 -0
  18. data/app/stylesheets/kuhsaft/admin/partials/_assets.sass +12 -0
  19. data/app/stylesheets/kuhsaft/admin/partials/_buttons.sass +216 -0
  20. data/app/stylesheets/kuhsaft/admin/partials/_generic.sass +29 -0
  21. data/app/stylesheets/kuhsaft/admin/partials/_pages.sass +38 -0
  22. data/app/stylesheets/kuhsaft/admin/print.sass +0 -0
  23. data/app/stylesheets/kuhsaft/admin/screen.sass +8 -0
  24. data/app/uploaders/kuhsaft/asset_uploader.rb +47 -0
  25. data/app/views/kuhsaft/admin/assets/_form.html.haml +3 -0
  26. data/app/views/kuhsaft/admin/assets/_list.html.haml +7 -0
  27. data/app/views/kuhsaft/admin/assets/edit.html.haml +1 -0
  28. data/app/views/kuhsaft/admin/assets/index.html.haml +3 -0
  29. data/app/views/kuhsaft/admin/assets/new.html.haml +1 -0
  30. data/app/views/kuhsaft/admin/pages/_branch.html.haml +10 -0
  31. data/app/views/kuhsaft/admin/pages/_form.html.haml +11 -0
  32. data/app/views/kuhsaft/admin/pages/edit.html.haml +1 -0
  33. data/app/views/kuhsaft/admin/pages/index.html.haml +17 -0
  34. data/app/views/kuhsaft/admin/pages/new.html.haml +1 -0
  35. data/app/views/kuhsaft/admin/pages/show.html.haml +0 -0
  36. data/app/views/kuhsaft/pages/index.html.haml +0 -0
  37. data/app/views/kuhsaft/pages/show.html.haml +0 -0
  38. data/app/views/layouts/kuhsaft/admin.html.haml +21 -0
  39. data/config/initializers/compass.rb +3 -0
  40. data/config/initializers/generators.rb +7 -0
  41. data/config/locales/kuhsaft.en.yml +20 -0
  42. data/config/routes.rb +9 -0
  43. data/db/migrate/20110302101530_create_kuhsaft_pages.rb +14 -0
  44. data/db/migrate/20110302113020_create_kuhsaft_localized_pages.rb +19 -0
  45. data/db/migrate/20110302125123_create_page_part_contents.rb +14 -0
  46. data/db/migrate/20110307162621_create_assets.rb +12 -0
  47. data/kuhsaft.gemspec +19 -2
  48. data/lib/kuhsaft.rb +3 -1
  49. data/lib/kuhsaft/engine.rb +19 -0
  50. data/lib/kuhsaft/version.rb +1 -1
  51. data/public/images/css3buttons_backgrounds.png +0 -0
  52. data/public/images/css3buttons_icons.png +0 -0
  53. data/public/images/drag-handle.png +0 -0
  54. data/public/javascripts/kuhsaft/admin/jquery-1.4.4.js +7179 -0
  55. data/public/javascripts/kuhsaft/admin/jquery-ui-1.8.10.custom.min.js +110 -0
  56. data/public/javascripts/kuhsaft/admin/rails.js +157 -0
  57. data/spec/controllers/admin_assets_controller_spec.rb +26 -0
  58. data/spec/controllers/admin_pages_controller_spec.rb +33 -0
  59. data/spec/controllers/pages_controller_spec.rb +18 -0
  60. data/spec/dummy/Rakefile +7 -0
  61. data/spec/dummy/app/controllers/application_controller.rb +8 -0
  62. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  63. data/spec/dummy/app/views/layouts/application.html.erb +13 -0
  64. data/spec/dummy/config.ru +4 -0
  65. data/spec/dummy/config/application.rb +45 -0
  66. data/spec/dummy/config/boot.rb +10 -0
  67. data/spec/dummy/config/database.yml +22 -0
  68. data/spec/dummy/config/environment.rb +5 -0
  69. data/spec/dummy/config/environments/development.rb +26 -0
  70. data/spec/dummy/config/environments/production.rb +49 -0
  71. data/spec/dummy/config/environments/test.rb +35 -0
  72. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  73. data/spec/dummy/config/initializers/inflections.rb +10 -0
  74. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  75. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  76. data/spec/dummy/config/initializers/session_store.rb +8 -0
  77. data/spec/dummy/config/locales/en.yml +5 -0
  78. data/spec/dummy/config/routes.rb +58 -0
  79. data/spec/dummy/db/migrate/.gitkeep +0 -0
  80. data/spec/dummy/public/404.html +26 -0
  81. data/spec/dummy/public/422.html +26 -0
  82. data/spec/dummy/public/500.html +26 -0
  83. data/spec/dummy/public/favicon.ico +0 -0
  84. data/spec/dummy/public/images/spec-image.png +0 -0
  85. data/spec/dummy/script/rails +6 -0
  86. data/spec/factories.rb +26 -0
  87. data/spec/integration/navigation_spec.rb +9 -0
  88. data/spec/kuhsaft_spec.rb +7 -0
  89. data/spec/models/asset_spec.rb +23 -0
  90. data/spec/models/localized_page_spec.rb +67 -0
  91. data/spec/models/page_part_content_spec.rb +22 -0
  92. data/spec/models/page_part_spec.rb +17 -0
  93. data/spec/models/page_spec.rb +144 -0
  94. data/spec/routing/assets_routing_spec.rb +56 -0
  95. data/spec/routing/pages_routing_spec.rb +79 -0
  96. data/spec/spec_helper.rb +52 -0
  97. metadata +390 -9
File without changes
@@ -0,0 +1,12 @@
1
+ li
2
+ .thumb, .link
3
+ +float_left
4
+ .date
5
+ +float_right
6
+
7
+ .link, .date
8
+ padding: 10px
9
+
10
+ .thumb
11
+ border-right: 1px solid #888
12
+ border-left: 1px solid #888
@@ -0,0 +1,216 @@
1
+ a
2
+ &.button
3
+ display: inline-block
4
+ padding: 3px 5px 3px 5px
5
+ font-family: 'lucida grande', tahoma, verdana, arial, sans-serif
6
+ font-size: 12px
7
+ color: #3C3C3D
8
+ text-shadow: 1px 1px 0 #FFFFFF
9
+ background: #ececec url('../../../images/css3buttons_backgrounds.png') 0 0 no-repeat
10
+ white-space: nowrap
11
+ overflow: visible
12
+ cursor: pointer
13
+ text-decoration: none
14
+ border: 1px solid #CACACA
15
+ -webkit-border-radius: 2px
16
+ -moz-border-radius: 2px
17
+ -webkit-background-clip: padding-box
18
+ border-radius: 2px
19
+ outline: none
20
+ position: relative
21
+ zoom: 1
22
+ *display: inline
23
+ &.primary
24
+ font-weight: bold
25
+ &:hover
26
+ color: #FFFFFF
27
+ border-color: #388AD4
28
+ text-decoration: none
29
+ text-shadow: -1px -1px 0 rgba(0, 0, 0, 0.3)
30
+ background-position: 0 -40px
31
+ background-color: #2D7DC5
32
+ &:active, &.active
33
+ background-position: 0 -81px
34
+ border-color: #347BBA
35
+ background-color: #0F5EA2
36
+ color: #FFFFFF
37
+ text-shadow: none
38
+ &:active
39
+ top: 1px
40
+ &.negative
41
+ &:hover
42
+ color: #FFFFFF
43
+ background-position: 0 -121px
44
+ background-color: #D84743
45
+ border-color: #911D1B
46
+ &:active, &.active
47
+ background-position: 0 -161px
48
+ background-color: #A5211E
49
+ border-color: #911D1B
50
+ &.pill
51
+ -webkit-border-radius: 19px
52
+ -moz-border-radius: 19px
53
+ border-radius: 19px
54
+ padding: 2px 10px 2px 10px
55
+ &.left
56
+ -webkit-border-bottom-right-radius: 0px
57
+ -webkit-border-top-right-radius: 0px
58
+ -moz-border-radius-bottomright: 0px
59
+ -moz-border-radius-topright: 0px
60
+ border-bottom-right-radius: 0px
61
+ border-top-right-radius: 0px
62
+ margin-right: 0px
63
+ &.middle
64
+ margin-right: 0px
65
+ margin-left: 0px
66
+ -webkit-border-radius: 0px
67
+ -moz-border-radius: 0px
68
+ border-radius: 0px
69
+ border-left: none
70
+ &.right
71
+ -webkit-border-bottom-left-radius: 0px
72
+ -webkit-border-top-left-radius: 0px
73
+ -moz-border-radius-bottomleft: 0px
74
+ -moz-border-radius-topleft: 0px
75
+ border-top-left-radius: 0px
76
+ border-bottom-left-radius: 0px
77
+ margin-left: 0px
78
+ border-left: none
79
+ &.left:active, &.middle:active, &.right:active
80
+ top: 0px
81
+ &.big
82
+ font-size: 16px
83
+ padding-left: 17px
84
+ padding-right: 17px
85
+ span.icon
86
+ display: inline-block
87
+ width: 14px
88
+ height: 12px
89
+ margin: auto 7px auto auto
90
+ position: relative
91
+ top: 2px
92
+ background-image: url('../../../images/css3buttons_icons.png')
93
+ background-repeat: no-repeat
94
+ &.big.button span.icon
95
+ top: 0px
96
+ &.button
97
+ span.icon.book
98
+ background-position: 0 0
99
+ &:hover span.icon.book
100
+ background-position: 0 -15px
101
+ span.icon.calendar
102
+ background-position: 0 -30px
103
+ &:hover span.icon.calendar
104
+ background-position: 0 -45px
105
+ span.icon.chat
106
+ background-position: 0 -60px
107
+ &:hover span.icon.chat
108
+ background-position: 0 -75px
109
+ span.icon.check
110
+ background-position: 0 -90px
111
+ &:hover span.icon.check
112
+ background-position: 0 -103px
113
+ span.icon.clock
114
+ background-position: 0 -116px
115
+ &:hover span.icon.clock
116
+ background-position: 0 -131px
117
+ span.icon.cog
118
+ background-position: 0 -146px
119
+ &:hover span.icon.cog
120
+ background-position: 0 -161px
121
+ span.icon.comment
122
+ background-position: 0 -176px
123
+ &:hover span.icon.comment
124
+ background-position: 0 -190px
125
+ span.icon.cross
126
+ background-position: 0 -204px
127
+ &:hover span.icon.cross
128
+ background-position: 0 -219px
129
+ span.icon.downarrow
130
+ background-position: 0 -234px
131
+ &:hover span.icon.downarrow
132
+ background-position: 0 -249px
133
+ span.icon.fork
134
+ background-position: 0 -264px
135
+ &:hover span.icon.fork
136
+ background-position: 0 -279px
137
+ span.icon.heart
138
+ background-position: 0 -294px
139
+ &:hover span.icon.heart
140
+ background-position: 0 -308px
141
+ span.icon.home
142
+ background-position: 0 -322px
143
+ &:hover span.icon.home
144
+ background-position: 0 -337px
145
+ span.icon.key
146
+ background-position: 0 -352px
147
+ &:hover span.icon.key
148
+ background-position: 0 -367px
149
+ span.icon.leftarrow
150
+ background-position: 0 -382px
151
+ &:hover span.icon.leftarrow
152
+ background-position: 0 -397px
153
+ span.icon.lock
154
+ background-position: 0 -412px
155
+ &:hover span.icon.lock
156
+ background-position: 0 -427px
157
+ span.icon.loop
158
+ background-position: 0 -442px
159
+ &:hover span.icon.loop
160
+ background-position: 0 -457px
161
+ span.icon.magnifier
162
+ background-position: 0 -472px
163
+ &:hover span.icon.magnifier
164
+ background-position: 0 -487px
165
+ span.icon.mail
166
+ background-position: 0 -502px
167
+ &:hover span.icon.mail
168
+ background-position: 0 -514px
169
+ span.icon.move
170
+ background-position: 0 -526px
171
+ &:hover span.icon.move
172
+ background-position: 0 -541px
173
+ span.icon.pen
174
+ background-position: 0 -556px
175
+ &:hover span.icon.pen
176
+ background-position: 0 -571px
177
+ span.icon.pin
178
+ background-position: 0 -586px
179
+ &:hover span.icon.pin
180
+ background-position: 0 -601px
181
+ span.icon.plus
182
+ background-position: 0 -616px
183
+ &:hover span.icon.plus
184
+ background-position: 0 -631px
185
+ span.icon.reload
186
+ background-position: 0 -646px
187
+ &:hover span.icon.reload
188
+ background-position: 0 -660px
189
+ span.icon.rightarrow
190
+ background-position: 0 -674px
191
+ &:hover span.icon.rightarrow
192
+ background-position: 0 -689px
193
+ span.icon.rss
194
+ background-position: 0 -704px
195
+ &:hover span.icon.rss
196
+ background-position: 0 -719px
197
+ span.icon.tag
198
+ background-position: 0 -734px
199
+ &:hover span.icon.tag
200
+ background-position: 0 -749px
201
+ span.icon.trash
202
+ background-position: 0 -764px
203
+ &:hover span.icon.trash
204
+ background-position: 0 -779px
205
+ span.icon.unlock
206
+ background-position: 0 -794px
207
+ &:hover span.icon.unlock
208
+ background-position: 0 -809px
209
+ span.icon.uparrow
210
+ background-position: 0 -824px
211
+ &:hover span.icon.uparrow
212
+ background-position: 0 -839px
213
+ span.icon.user
214
+ background-position: 0 -854px
215
+ &:hover span.icon.user
216
+ background-position: 0 -869px
@@ -0,0 +1,29 @@
1
+ body
2
+ line-height: 135%
3
+ font-size: 12px
4
+
5
+ a
6
+ text-decoration: none
7
+ +link-colors(#000, #666, #000, #000, #000)
8
+
9
+ .clear
10
+ clear: both
11
+
12
+ .toolbar
13
+ padding: 5px 0px
14
+ a
15
+ +float_right
16
+
17
+ .module-nav
18
+ +horizontal-list(10px)
19
+ font-size: 18px
20
+ line-height: 26px
21
+
22
+ .list
23
+ border-top: 1px solid #444
24
+ li
25
+ border-bottom: 1px solid #444
26
+
27
+ #kuhsaft-wrapper
28
+ margin: 50px auto
29
+ max-width: 900px
@@ -0,0 +1,38 @@
1
+ .pages
2
+ ul.pages-root
3
+ border-top: 1px solid #555
4
+ border-bottom: 1px solid #555
5
+
6
+ ul
7
+ border-top: 1px solid #555
8
+
9
+ li
10
+ border-bottom: 1px solid #555
11
+
12
+ li
13
+ padding: 0px 0px 0px 15px
14
+
15
+ li:last-child
16
+ border: 0px
17
+
18
+ a.edit
19
+ margin-top: 4px
20
+ +float_left
21
+
22
+ .page-branch
23
+ margin: 5px 0px
24
+ background: url(../../../images/drag-handle.png) no-repeat
25
+ padding-left: 25px
26
+
27
+ .new-child, .delete
28
+ margin-left: 10px
29
+ visibility: hidden
30
+ +float_right
31
+
32
+ &:hover
33
+ .new-child, .delete
34
+ visibility: visible
35
+
36
+ form
37
+ input, label
38
+ display: block
@@ -0,0 +1,8 @@
1
+ @import compass/reset
2
+ @import compass/utilities
3
+ @import compass/css3
4
+
5
+ @import partials/generic
6
+ @import partials/buttons
7
+ @import partials/pages
8
+ @import partials/assets
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+
3
+ class Kuhsaft::AssetUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or ImageScience support:
6
+ include CarrierWave::RMagick
7
+ #include CarrierWave::ImageScience
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ storage :file
11
+ # storage :s3
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
22
+ # end
23
+
24
+ # Process files as they are uploaded:
25
+ # process :scale => [200, 300]
26
+ #
27
+ # def scale(width, height)
28
+ # # do something
29
+ # end
30
+
31
+ # Create different versions of your uploaded files:
32
+ version :thumb do
33
+ process :resize_to_fill => [50, 50]
34
+ end
35
+
36
+ # Add a white list of extensions which are allowed to be uploaded.
37
+ # For images you might use something like this:
38
+ def extension_white_list
39
+ %w(jpg jpeg png)
40
+ end
41
+
42
+ # Override the filename of the uploaded files:
43
+ # def filename
44
+ # "something.jpg" if original_filename
45
+ # end
46
+
47
+ end
@@ -0,0 +1,3 @@
1
+ = simple_form_for @asset, :url => url, :html => { :multipart => true } do |f|
2
+ = f.input :file, :as => :file
3
+ = f.button :submit
@@ -0,0 +1,7 @@
1
+ %ul.list
2
+ - @assets.each do |asset|
3
+ %li
4
+ .thumb= image_tag asset.file.thumb.url
5
+ .link= link_to File.basename(asset.file.url), asset.file.url, :target => '_new'
6
+ .date= asset.updated_at
7
+ .clear
@@ -0,0 +1 @@
1
+ = render :partial => 'form', :locals => { :url => edit_admin_asset_path(@asset) }
@@ -0,0 +1,3 @@
1
+ - content_for :toolbar do
2
+ = link_to t('.create'), new_admin_asset_path, :class => 'button'
3
+ = render 'list'
@@ -0,0 +1 @@
1
+ = render :partial => 'form', :locals => { :url => admin_assets_path }
@@ -0,0 +1,10 @@
1
+ - unless pages.blank?
2
+ - pages.each do |page|
3
+ %li.page-branch{ :'data-id' => page.id }
4
+ = link_to page.title, edit_admin_page_path(page), :class => :edit
5
+ = link_to t('kuhsaft.admin.pages.index.add'), new_admin_page_path(:parent_id => page.id), :class => 'new-child button'
6
+ = link_to t('kuhsaft.admin.pages.index.delete'), admin_page_path(page), :confirm => t('kuhsaft.admin.pages.index.confirm'), :method => :delete, :class => 'delete button negative' if page.childs.empty?
7
+ .clear
8
+ - unless page.childs.empty?
9
+ %ul.sortable
10
+ = render :partial => 'branch', :locals => { :pages => page.childs }
@@ -0,0 +1,11 @@
1
+ - Kuhsaft::Page.translation_locales.each do |locale|
2
+ = link_to locale.to_s, url.call(:translation_locale => locale), :class => 'button'
3
+ = simple_form_for @page, :url => url.call(:translation_locale => Kuhsaft::Page.current_translation_locale) do |f|
4
+ %p= t('kuhsaft.admin.pages.current_translation_locale', :translation_locale => Kuhsaft::Page.current_translation_locale)
5
+ = f.input :title
6
+ = f.input :slug
7
+ = f.input :keywords
8
+ = f.input :description, :as => :text
9
+ = f.input :body, :as => :text
10
+ = f.input :parent_id, :as => :hidden, :input_html => { :value => params[:parent_id] } if params[:parent_id].present?
11
+ = f.button :submit
@@ -0,0 +1 @@
1
+ = render :partial => 'form', :locals => { :url => Proc.new { |attrs| edit_admin_page_path(@page.id, attrs) }}
@@ -0,0 +1,17 @@
1
+ - content_for :toolbar do
2
+ = link_to t('.create'), new_admin_page_path, :class => 'button'
3
+ - content_for :scripts do
4
+ :javascript
5
+ $("ul.sortable").sortable({
6
+ containment: 'parent',
7
+ update: function(event, ui){
8
+ var self = $(ui.item),
9
+ prev = self.prev(),
10
+ id = prev.length > 0 ? prev.data('id') : '',
11
+ sid = self.data('id')
12
+ $.post('/admin/pages/'+sid, {reposition:id, _method: 'put'})
13
+ }
14
+ })
15
+
16
+ %ul.pages-root.sortable
17
+ = render :partial => 'branch', :locals => { :pages => @pages }
@@ -0,0 +1 @@
1
+ = render :partial => 'form', :locals => { :url => Proc.new { |attrs| admin_pages_path(attrs) } }
File without changes
@@ -0,0 +1,21 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ = stylesheet_link_tag 'kuhsaft/admin/screen.css', :media => 'screen, projection'
5
+ = stylesheet_link_tag 'kuhsaft/admin/print.css', :media => 'print'
6
+ /[if IE]
7
+ = stylesheet_link_tag 'kuhsaft/admin/ie.css', :media => 'screen, projection'
8
+ = csrf_meta_tag
9
+ = javascript_include_tag 'kuhsaft/admin/jquery-1.4.4.js'
10
+ = javascript_include_tag 'kuhsaft/admin/jquery-ui-1.8.10.custom.min.js'
11
+ = javascript_include_tag 'kuhsaft/admin/rails.js'
12
+ %body{ :class => "#{controller_name}" }
13
+ #kuhsaft-wrapper
14
+ %ul.module-nav
15
+ %li= link_to t('.pages_nav'), admin_pages_path
16
+ %li= link_to t('.assets_nav'), admin_assets_path
17
+ .toolbar
18
+ = yield :toolbar
19
+ .clear
20
+ = yield
21
+ = yield :scripts