flms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +3 -0
  3. data/Rakefile +33 -0
  4. data/app/assets/images/img/glyphicons-halflings-white.png +0 -0
  5. data/app/assets/images/img/glyphicons-halflings.png +0 -0
  6. data/app/assets/javascripts/flms/blocks/index.coffee +6 -0
  7. data/app/assets/javascripts/flms/bootstrap.js +6 -0
  8. data/app/assets/javascripts/flms/flms.js +17 -0
  9. data/app/assets/javascripts/flms/layout.coffee +8 -0
  10. data/app/assets/stylesheets/flms/blocks/index.sass +28 -0
  11. data/app/assets/stylesheets/flms/bootstrap.css +6159 -0
  12. data/app/assets/stylesheets/flms/flms.css +7 -0
  13. data/app/assets/stylesheets/flms/home.sass +30 -0
  14. data/app/assets/stylesheets/flms/layout.sass +19 -0
  15. data/app/assets/stylesheets/flms/login.sass +32 -0
  16. data/app/controllers/flms/admin_controller.rb +11 -0
  17. data/app/controllers/flms/application_controller.rb +4 -0
  18. data/app/controllers/flms/blocks_controller.rb +55 -0
  19. data/app/controllers/flms/dashboard_controller.rb +13 -0
  20. data/app/controllers/flms/pages_controller.rb +47 -0
  21. data/app/controllers/flms/sessions_controller.rb +16 -0
  22. data/app/controllers/flms/users_controller.rb +31 -0
  23. data/app/helpers/flms/application_helper.rb +4 -0
  24. data/app/models/flms/block.rb +10 -0
  25. data/app/models/flms/blocks_page.rb +8 -0
  26. data/app/models/flms/page.rb +14 -0
  27. data/app/models/flms/user.rb +10 -0
  28. data/app/views/flms/blocks/_form.html.haml +25 -0
  29. data/app/views/flms/blocks/edit.html.haml +3 -0
  30. data/app/views/flms/blocks/index.html.haml +41 -0
  31. data/app/views/flms/blocks/new.html.haml +2 -0
  32. data/app/views/flms/blocks/show.html.haml +1 -0
  33. data/app/views/flms/dashboard/index.html.haml +5 -0
  34. data/app/views/flms/pages/_form.html.haml +30 -0
  35. data/app/views/flms/pages/edit.html.haml +3 -0
  36. data/app/views/flms/pages/index.html.haml +21 -0
  37. data/app/views/flms/pages/new.html.haml +2 -0
  38. data/app/views/flms/pages/show.html.haml +8 -0
  39. data/app/views/flms/sessions/new.html.haml +21 -0
  40. data/app/views/flms/users/_form.html.haml +28 -0
  41. data/app/views/flms/users/index.html.haml +22 -0
  42. data/app/views/flms/users/new.html.haml +3 -0
  43. data/app/views/layouts/flms/admin.html.haml +40 -0
  44. data/app/views/layouts/flms/admin_login.html.haml +18 -0
  45. data/app/views/layouts/flms/application.html.erb +14 -0
  46. data/config/initializers/devise.rb +243 -0
  47. data/config/locales/devise.en.yml +59 -0
  48. data/config/routes.rb +23 -0
  49. data/db/migrate/20130208224914_flms_devise_create_users.rb +47 -0
  50. data/db/migrate/20130216032241_flms_create_pages.rb +12 -0
  51. data/db/migrate/20130302011705_create_flms_blocks.rb +10 -0
  52. data/db/migrate/20130302015459_create_flms_blocks_pages.rb +12 -0
  53. data/lib/flms.rb +7 -0
  54. data/lib/flms/engine.rb +5 -0
  55. data/lib/flms/version.rb +3 -0
  56. data/lib/tasks/flms_tasks.rake +26 -0
  57. data/spec/controllers/blocks_controller_spec.rb +61 -0
  58. data/spec/controllers/dashboard_controller_spec.rb +12 -0
  59. data/spec/controllers/pages_controller_spec.rb +60 -0
  60. data/spec/controllers/users_controller_spec.rb +37 -0
  61. data/spec/dummy/Rakefile +7 -0
  62. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  63. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  64. data/spec/dummy/app/controllers/application_controller.rb +12 -0
  65. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  66. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  67. data/spec/dummy/app/models/user.rb +8 -0
  68. data/spec/dummy/app/views/home/index.html.haml +10 -0
  69. data/spec/dummy/app/views/layouts/application.html.haml +10 -0
  70. data/spec/dummy/config.ru +4 -0
  71. data/spec/dummy/config/application.rb +69 -0
  72. data/spec/dummy/config/boot.rb +10 -0
  73. data/spec/dummy/config/database.yml +52 -0
  74. data/spec/dummy/config/environment.rb +5 -0
  75. data/spec/dummy/config/environments/development.rb +37 -0
  76. data/spec/dummy/config/environments/production.rb +67 -0
  77. data/spec/dummy/config/environments/test.rb +37 -0
  78. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  79. data/spec/dummy/config/initializers/devise.rb +244 -0
  80. data/spec/dummy/config/initializers/flms.rb +1 -0
  81. data/spec/dummy/config/initializers/inflections.rb +15 -0
  82. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  83. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  84. data/spec/dummy/config/initializers/session_store.rb +8 -0
  85. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  86. data/spec/dummy/config/locales/en.yml +5 -0
  87. data/spec/dummy/config/routes.rb +4 -0
  88. data/spec/dummy/db/schema.rb +60 -0
  89. data/spec/dummy/log/development.log +39893 -0
  90. data/spec/dummy/log/test.log +42855 -0
  91. data/spec/dummy/public/404.html +26 -0
  92. data/spec/dummy/public/422.html +26 -0
  93. data/spec/dummy/public/500.html +25 -0
  94. data/spec/dummy/public/favicon.ico +0 -0
  95. data/spec/dummy/script/rails +6 -0
  96. data/spec/dummy/tmp/cache/assets/C9D/180/sprockets%2Fad74b633d2447502477133032afac84b +0 -0
  97. data/spec/dummy/tmp/cache/assets/CAB/C80/sprockets%2Fc4e739111d82c7189113aeb228816ba8 +0 -0
  98. data/spec/dummy/tmp/cache/assets/CB9/E30/sprockets%2F588cf5763c29e490d026f24e8aa90343 +0 -0
  99. data/spec/dummy/tmp/cache/assets/CCF/210/sprockets%2F43b5c2ffc8a62726b4ed6234001571a4 +0 -0
  100. data/spec/dummy/tmp/cache/assets/CDB/510/sprockets%2Fd61745a24c4636f8813fa14038bac69a +0 -0
  101. data/spec/dummy/tmp/cache/assets/CDE/D90/sprockets%2Fcc733e310d9646637216c4ffe109ea35 +0 -0
  102. data/spec/dummy/tmp/cache/assets/CE4/6B0/sprockets%2F6e38aec803936176be248f507eb3432d +0 -0
  103. data/spec/dummy/tmp/cache/assets/CED/6A0/sprockets%2Fcc221f5201d658cf456836f8b5547f9d +0 -0
  104. data/spec/dummy/tmp/cache/assets/CF6/740/sprockets%2F0cb88349ae46593e396c4bd68854ed08 +0 -0
  105. data/spec/dummy/tmp/cache/assets/D01/E80/sprockets%2Fc1a3694915166d6a041afa4bb062fd84 +0 -0
  106. data/spec/dummy/tmp/cache/assets/D06/AF0/sprockets%2F02a9a4f214368781ba86ed42d5bef203 +0 -0
  107. data/spec/dummy/tmp/cache/assets/D07/250/sprockets%2Fa8bf27de087b582dc454910a060e0b84 +0 -0
  108. data/spec/dummy/tmp/cache/assets/D09/5C0/sprockets%2F7cd3521c63623eb6f02dbb514991a6f6 +0 -0
  109. data/spec/dummy/tmp/cache/assets/D0C/570/sprockets%2F7e3d63e1412ae56b44b23d95547f0cc7 +0 -0
  110. data/spec/dummy/tmp/cache/assets/D0D/510/sprockets%2Fa189f1a8718ff11152feb3c43c75b841 +0 -0
  111. data/spec/dummy/tmp/cache/assets/D1A/3F0/sprockets%2F84181c4b293f3a1c4efe9226652f9e6e +0 -0
  112. data/spec/dummy/tmp/cache/assets/D1E/1D0/sprockets%2Ffeec495723d877b92c74db2055516bc9 +0 -0
  113. data/spec/dummy/tmp/cache/assets/D2E/F10/sprockets%2F156bfd6b405a129f5f003243cf60aea9 +0 -0
  114. data/spec/dummy/tmp/cache/assets/D35/470/sprockets%2F2c0a647ea89470a8285b9acb2006dbd5 +0 -0
  115. data/spec/dummy/tmp/cache/assets/D3B/440/sprockets%2Fabe31f236167ba051f6ff849d0a7282f +0 -0
  116. data/spec/dummy/tmp/cache/assets/D3B/550/sprockets%2Fb61caf9834ac8c31691851ac024f26ef +0 -0
  117. data/spec/dummy/tmp/cache/assets/D44/A50/sprockets%2F7602cd388554ba54eb914c1b2d7ff68c +0 -0
  118. data/spec/dummy/tmp/cache/assets/D46/210/sprockets%2F45a8d49c8edbaf91f38ab1495430384c +0 -0
  119. data/spec/dummy/tmp/cache/assets/D4A/B40/sprockets%2F509d2dc1350975d781c50dffc58ef53f +0 -0
  120. data/spec/dummy/tmp/cache/assets/D54/DE0/sprockets%2F77af3e306bb966f71f83e90e2a8868db +0 -0
  121. data/spec/dummy/tmp/cache/assets/D5B/1F0/sprockets%2F4d98e747aa4bb9fc8859f49a45159e1c +0 -0
  122. data/spec/dummy/tmp/cache/assets/D65/690/sprockets%2F511f71e32f87da06df67250bb39abdc2 +0 -0
  123. data/spec/dummy/tmp/cache/assets/D6E/870/sprockets%2F3f77e0b5396013fd145a6fdd21bc9b7f +0 -0
  124. data/spec/dummy/tmp/cache/assets/D74/EA0/sprockets%2Fccfc557971c4d47336cab75db207b89a +0 -0
  125. data/spec/dummy/tmp/cache/assets/D77/D80/sprockets%2F7ad794c63274a9812dfbabc1dae69692 +0 -0
  126. data/spec/dummy/tmp/cache/assets/D79/DE0/sprockets%2F9e7131d002f39be972e9918bdfbbcc66 +0 -0
  127. data/spec/dummy/tmp/cache/assets/D7C/3A0/sprockets%2Fec63717067efd6b2daf3423edf70f689 +0 -0
  128. data/spec/dummy/tmp/cache/assets/D81/300/sprockets%2F9543b0420abb11b0a126a8384edddafe +0 -0
  129. data/spec/dummy/tmp/cache/assets/D81/400/sprockets%2F566656e2cc9e698b1dbbd56d6e2e6b36 +0 -0
  130. data/spec/dummy/tmp/cache/assets/D93/0C0/sprockets%2Fab900c084c9c51c312ee3457cee8cdc2 +0 -0
  131. data/spec/dummy/tmp/cache/assets/D98/FD0/sprockets%2F6f253bd2bf824ac38c69bfe1418a04be +0 -0
  132. data/spec/dummy/tmp/cache/assets/D9E/220/sprockets%2Fd129fcf804e89814c2f4abbe0336cba9 +0 -0
  133. data/spec/dummy/tmp/cache/assets/DA0/9F0/sprockets%2Fd7c0d94bf0df6b0e03f83dcaf8873631 +0 -0
  134. data/spec/dummy/tmp/cache/assets/DA3/920/sprockets%2F6c45b9f8e0152c78b3c9be1c2e8be53c +0 -0
  135. data/spec/dummy/tmp/cache/assets/DA5/BC0/sprockets%2F5b86068a872e5bd841750d6cbd2dfdbf +0 -0
  136. data/spec/dummy/tmp/cache/assets/DA8/4A0/sprockets%2Ff8ba39d58ace11df624bf7e24c7b5882 +0 -0
  137. data/spec/dummy/tmp/cache/assets/DA8/C30/sprockets%2Fb7d14d588a70a56d7ddac542eef557d6 +0 -0
  138. data/spec/dummy/tmp/cache/assets/DA9/370/sprockets%2Fdf257d496b11ea9c1bb7ee139d68c83e +0 -0
  139. data/spec/dummy/tmp/cache/assets/DAC/D80/sprockets%2Fb8ca14c15e0301b935aaaef327bdc40a +0 -0
  140. data/spec/dummy/tmp/cache/assets/DAE/F10/sprockets%2F46950fdbeed95ba83ca8e7215194ddf8 +0 -0
  141. data/spec/dummy/tmp/cache/assets/DB2/1F0/sprockets%2F9fe57997f92efbee3b03df4510a2df57 +0 -0
  142. data/spec/dummy/tmp/cache/assets/DB8/C30/sprockets%2Fca860af2d10e0c745b6e38b12dabe05f +0 -0
  143. data/spec/dummy/tmp/cache/assets/DC1/530/sprockets%2F4db0b289eee7dad03453a5924c20dcfa +0 -0
  144. data/spec/dummy/tmp/cache/assets/DC6/7D0/sprockets%2Ff7689ac5fafbf683c537892e6ff7f8c3 +0 -0
  145. data/spec/dummy/tmp/cache/assets/DCC/B80/sprockets%2Fb7ae6e7bfa8984c54a4dfaf0011617cd +0 -0
  146. data/spec/dummy/tmp/cache/assets/DCE/790/sprockets%2Fff77d67febbb3af024f721c0bb4c4749 +0 -0
  147. data/spec/dummy/tmp/cache/assets/DCF/0B0/sprockets%2F23db7ab96a5549546bbdd0bc2e6ea86f +0 -0
  148. data/spec/dummy/tmp/cache/assets/DD5/440/sprockets%2F9b3488ba6d62c3dcc809f8cd3dc2d1f5 +0 -0
  149. data/spec/dummy/tmp/cache/assets/DE6/B10/sprockets%2Fa0adf3fb2b0054d04dd44c08aff1d6c8 +0 -0
  150. data/spec/dummy/tmp/cache/assets/DF1/A10/sprockets%2Fa925a815ca0bff4d6f42fbdf0d323a4f +0 -0
  151. data/spec/dummy/tmp/cache/assets/DFA/FF0/sprockets%2F75699fed9ddaecd89464492eeeef90d8 +0 -0
  152. data/spec/dummy/tmp/cache/assets/DFD/540/sprockets%2F181ef7a7c275dd2872aa1ed1fcfab75f +0 -0
  153. data/spec/dummy/tmp/cache/assets/E0E/B50/sprockets%2Fe78fa5fc4cfb0979876d23ae1b1f3ffd +0 -0
  154. data/spec/dummy/tmp/cache/assets/E3A/110/sprockets%2Fb6d5158ff7ac6d2ca99bfe56a7ddd2e3 +0 -0
  155. data/spec/dummy/tmp/cache/assets/E6D/8B0/sprockets%2F9edfdf7e85cdd1a69b0eb14c6ce8ed19 +0 -0
  156. data/spec/factories/blocks.rb +6 -0
  157. data/spec/factories/pages.rb +6 -0
  158. data/spec/factories/users.rb +7 -0
  159. data/spec/features/blocks/create_spec.rb +19 -0
  160. data/spec/features/blocks/delete_spec.rb +17 -0
  161. data/spec/features/blocks/edit_spec.rb +20 -0
  162. data/spec/features/blocks/show_spec.rb +14 -0
  163. data/spec/features/dashboard_spec.rb +11 -0
  164. data/spec/features/login_spec.rb +50 -0
  165. data/spec/features/pages/create_spec.rb +18 -0
  166. data/spec/features/pages/delete_spec.rb +14 -0
  167. data/spec/features/pages/index_spec.rb +14 -0
  168. data/spec/features/pages/update_spec.rb +17 -0
  169. data/spec/features/users/create_spec.rb +20 -0
  170. data/spec/features/users/delete_spec.rb +13 -0
  171. data/spec/features/users/index_spec.rb +16 -0
  172. data/spec/flms_spec.rb +7 -0
  173. data/spec/models/block_spec.rb +14 -0
  174. data/spec/models/page_spec.rb +15 -0
  175. data/spec/models/user_spec.rb +5 -0
  176. data/spec/spec_helper.rb +53 -0
  177. data/spec/support/access_control.rb +87 -0
  178. data/spec/support/capybara_helpers.rb +7 -0
  179. data/spec/support/lets.rb +8 -0
  180. data/vendor/assets/javascripts/bootstrapSwitch.js +238 -0
  181. data/vendor/assets/javascripts/jquery-ui.js +2221 -0
  182. data/vendor/assets/stylesheets/bootstrapSwitch.css +210 -0
  183. data/vendor/assets/stylesheets/jquery-ui.css +88 -0
  184. metadata +607 -0
@@ -0,0 +1,7 @@
1
+ /*
2
+ * CSS for the flms pages.
3
+ *
4
+ *= require_tree .
5
+ *= require jquery-ui
6
+ *= require bootstrapSwitch
7
+ */
@@ -0,0 +1,30 @@
1
+ body
2
+ padding-top: 20px
3
+ padding-bottom: 40px
4
+
5
+ .container-narrow
6
+ margin: 0 auto
7
+ max-width: 700px
8
+
9
+ .container-narrow > hr
10
+ margin: 30px 0
11
+
12
+ /* Supporting marketing content */
13
+ .marketing
14
+ margin: 60px 0
15
+
16
+ .marketing p + h4
17
+ margin-top: 28px
18
+
19
+ h4
20
+ display: block
21
+ width: 100%
22
+ padding-top: 40px 0 0
23
+ margin-bottom: 20px
24
+ font-size: 21px
25
+ font-weight: normal
26
+ line-height: 40px
27
+ color: #333333
28
+ border: 0
29
+ border-bottom: 1px solid #e5e5e5
30
+
@@ -0,0 +1,19 @@
1
+ /* CSS for the layouts. */
2
+ .flash
3
+ position: absolute
4
+ top: 0
5
+ right: 0
6
+ width: 100%
7
+ height: 45px
8
+ color: white
9
+ font-size: 3em
10
+ text-align: center
11
+ padding-top: 20px
12
+ font-size: 2em
13
+
14
+ &.notice
15
+ background-color: rgb(0,150,0)
16
+
17
+ &.alert
18
+ background-color: rgb(150,0,0)
19
+
@@ -0,0 +1,32 @@
1
+ body.user_sessions.new,
2
+ body.user_passwords.new
3
+ background-color: #f5f5f5
4
+
5
+ .login
6
+
7
+ padding-top: 40px
8
+
9
+ .form-signin
10
+ max-width: 300px
11
+ padding: 19px 29px 29px
12
+ margin: 0 auto 20px
13
+ background-color: #fff
14
+ border: 1px solid #e5e5e5
15
+ -webkit-border-radius: 5px
16
+ -moz-border-radius: 5px
17
+ border-radius: 5px
18
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05)
19
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05)
20
+ box-shadow: 0 1px 2px rgba(0,0,0,.05)
21
+
22
+ .form-signin-heading, .checkbox
23
+ margin-bottom: 10px
24
+
25
+ input[type="text"],
26
+ input[type="password"],
27
+ input[type="email"]
28
+ font-size: 16px
29
+ height: auto
30
+ margin-bottom: 15px
31
+ padding: 7px 9px
32
+
@@ -0,0 +1,11 @@
1
+ require_dependency "flms/application_controller"
2
+
3
+ module Flms
4
+ class AdminController < ActionController::Base
5
+ layout 'flms/admin'
6
+
7
+ def index
8
+ end
9
+ end
10
+ end
11
+
@@ -0,0 +1,4 @@
1
+ module Flms
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,55 @@
1
+ require_dependency "flms/application_controller"
2
+
3
+ module Flms
4
+ class BlocksController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ layout 'flms/admin'
7
+
8
+ def index
9
+ @page = Flms::Page.find_by_url params[:page_id]
10
+ @blocks = @page.blocks
11
+ end
12
+
13
+ def show
14
+ @block = Block.find(params[:id])
15
+ end
16
+
17
+ def new
18
+ @page = Page.find_by_url params[:page_id]
19
+ @block = Block.new
20
+ end
21
+
22
+ def edit
23
+ @page = Page.find_by_url params[:page_id]
24
+ @block = Block.find(params[:id])
25
+ end
26
+
27
+ def create
28
+ @page = Page.find_by_url params[:page_id]
29
+ @block = Block.new(params[:block])
30
+ if @block.save
31
+ @block.pages << @page
32
+ redirect_to page_blocks_path(@page), notice: 'Block created.'
33
+ else
34
+ render action: "new"
35
+ end
36
+ end
37
+
38
+ def update
39
+ @page = Page.find_by_url params[:page_id]
40
+ @block = Block.find(params[:id])
41
+ if @block.update_attributes(params[:block])
42
+ redirect_to [@page, :blocks], notice: 'Block was successfully updated.'
43
+ else
44
+ render action: "edit"
45
+ end
46
+ end
47
+
48
+ def destroy
49
+ @page = Page.find_by_url params[:page_id]
50
+ @block = Block.find params[:id]
51
+ @block.destroy
52
+ redirect_to page_blocks_path(@page), notice: 'Block deleted'
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,13 @@
1
+ require_dependency "flms/application_controller"
2
+
3
+ module Flms
4
+ class DashboardController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ layout 'flms/admin'
7
+
8
+ def index
9
+ @pages = Page.all
10
+ end
11
+ end
12
+ end
13
+
@@ -0,0 +1,47 @@
1
+ require_dependency "flms/application_controller"
2
+
3
+ module Flms
4
+ class PagesController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ layout 'flms/admin'
7
+
8
+ def index
9
+ @pages = Page.all
10
+ end
11
+
12
+ def show
13
+ end
14
+
15
+ def new
16
+ @page = Page.new
17
+ end
18
+
19
+ def edit
20
+ @page = Page.find_by_url params[:id]
21
+ end
22
+
23
+ def create
24
+ @page = Page.new params[:page]
25
+ if @page.save
26
+ redirect_to pages_path, notice: 'Page was successfully created.'
27
+ else
28
+ render action: "new"
29
+ end
30
+ end
31
+
32
+ def update
33
+ @page = Page.find_by_url params[:id]
34
+ if @page.update_attributes params[:page]
35
+ redirect_to pages_path, notice: 'Page was successfully updated.'
36
+ else
37
+ render action: "edit"
38
+ end
39
+ end
40
+
41
+ def destroy
42
+ @page = Page.find_by_url params[:id]
43
+ @page.destroy
44
+ redirect_to pages_url
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,16 @@
1
+ module Flms
2
+ class SessionsController < Devise::SessionsController
3
+ layout 'flms/admin_login'
4
+
5
+ def new
6
+
7
+ # Fast-track to login for faster integration tests.
8
+ if Rails.env == 'test' && email = params.delete(:email)
9
+ return sign_in_and_redirect :user, User.where(email: email).first
10
+ end
11
+
12
+ render 'new'
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,31 @@
1
+ require_dependency "flms/application_controller"
2
+
3
+ module Flms
4
+ class UsersController < ApplicationController
5
+ before_filter :authenticate_user!
6
+ layout 'flms/admin'
7
+
8
+ def index
9
+ @users = Flms::User.all
10
+ end
11
+
12
+ def new
13
+ @user = Flms::User.new
14
+ end
15
+
16
+ def create
17
+ @user = Flms::User.new params[:user]
18
+ if @user.save
19
+ redirect_to users_path, notice: 'User created.'
20
+ else
21
+ render action: "new"
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ @user = Flms::User.find params[:id]
27
+ @user.destroy
28
+ redirect_to users_path
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ module Flms
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ module Flms
2
+ class Block < ActiveRecord::Base
3
+ attr_accessible :active, :name
4
+
5
+ has_many :blocks_pages, class_name: 'Flms::BlocksPage'
6
+ has_many :pages, through: :blocks_pages, class_name: 'Flms::Page'
7
+
8
+ validates :name, presence: true
9
+ end
10
+ end
@@ -0,0 +1,8 @@
1
+ module Flms
2
+ class BlocksPage < ActiveRecord::Base
3
+ attr_accessible :block_id, :page_id
4
+
5
+ belongs_to :block, class_name: 'Flms::Block'
6
+ belongs_to :page, class_name: 'Flms::Page'
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ module Flms
2
+ class Page < ActiveRecord::Base
3
+ attr_accessible :title, :url
4
+
5
+ has_many :blocks_pages
6
+ has_many :blocks, through: :blocks_pages
7
+
8
+ validates :title, :url, presence: true
9
+
10
+ def to_param
11
+ url
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ module Flms
2
+ class User < ActiveRecord::Base
3
+ # Include default devise modules. Others available are:
4
+ # :token_authenticatable, :confirmable, :lockable, :timeoutable and :omniauthable
5
+ devise :database_authenticatable, :registerable,
6
+ :recoverable, :rememberable, :trackable, :validatable
7
+
8
+ attr_accessible :email, :password, :password_confirmation, :remember_me
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ = form_for [@page, @block], html: {class: 'form-horizontal'} do |f|
2
+ %fieldset
3
+ %legend= caption
4
+
5
+ - if @block.errors.any?
6
+ #error_explanation
7
+ %h2= "#{pluralize(@block.errors.count, "error")} prohibited this block from being saved:"
8
+ %ul
9
+ - @block.errors.full_messages.each do |msg|
10
+ %li= msg
11
+
12
+ .control-group
13
+ = f.label :name, class: 'control-label'
14
+ .controls
15
+ = f.text_field :name, autofocus: true
16
+ %span.help-inline The internal name of this block.
17
+
18
+ .control-group
19
+ .controls
20
+ .actions
21
+ = f.submit class: 'btn btn-primary'
22
+ &nbsp; &nbsp; &nbsp;
23
+ = link_to 'Back', pages_path
24
+
25
+
@@ -0,0 +1,3 @@
1
+ .login.container
2
+ = render partial: 'form', locals: {caption: 'Update block'}
3
+
@@ -0,0 +1,41 @@
1
+ - content_for :js do
2
+ :javascript
3
+ $(function() {
4
+ new BlocksIndexPage();
5
+ });
6
+
7
+ %br
8
+ %h4 Blocks on page '#{@page.url}'
9
+
10
+ %table.table.table-striped.table-hover
11
+ %thead
12
+ %tr
13
+ %th Name
14
+ %th
15
+
16
+ %tbody.blocks
17
+ - @blocks.each do |block|
18
+ %tr.ui-state-default
19
+
20
+ %td.action
21
+ .switch.switch-mini
22
+ %input{type: 'checkbox'}
23
+
24
+ %td.name
25
+ = link_to block.name, page_block_path(@page, block)
26
+
27
+ %td.action
28
+ = link_to edit_page_block_path(@page, block), class: 'btn', title: 'edit' do
29
+ %i.icon-pencil
30
+
31
+ %td.action
32
+ = link_to page_block_path(@page, block), method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn', title: 'delete' do
33
+ %i.icon-trash
34
+
35
+ %br
36
+
37
+ = link_to new_page_block_path(@page), class: 'btn btn-success' do
38
+ %i.icon-plus.icon-white
39
+ New Block
40
+
41
+
@@ -0,0 +1,2 @@
1
+ .login.container
2
+ = render partial: 'form', locals: {caption: 'Create a new block'}
@@ -0,0 +1,5 @@
1
+ %h4 Statistics
2
+ Foo bar
3
+
4
+ %h4 Documentation
5
+
@@ -0,0 +1,30 @@
1
+ = form_for @page, html: {class: 'form-horizontal'} do |f|
2
+ %fieldset
3
+ %legend= caption
4
+
5
+ - if @page.errors.any?
6
+ #error_explanation
7
+ %h2= "#{pluralize(@page.errors.count, "error")} prohibited this page from being saved:"
8
+ %ul
9
+ - @page.errors.full_messages.each do |msg|
10
+ %li= msg
11
+
12
+ .control-group
13
+ = f.label :title, class: 'control-label'
14
+ .controls
15
+ = f.text_field :title, autofocus: true
16
+ %span.help-inline The internal title of this page.
17
+
18
+ .control-group
19
+ = f.label :url, class: 'control-label'
20
+ .controls
21
+ = f.text_field :url
22
+ %span.help-inline The URL under which this page should be accessible on the web.
23
+
24
+ .control-group
25
+ .controls
26
+ .actions
27
+ = f.submit class: 'btn btn-primary'
28
+ &nbsp; &nbsp; &nbsp;
29
+ = link_to 'Back', pages_path
30
+