tennpipes-su 3.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.rdoc +70 -0
  4. data/Rakefile +22 -0
  5. data/lib/tennpipes-su.rb +35 -0
  6. data/lib/tennpipes-su/access_control.rb +191 -0
  7. data/lib/tennpipes-su/bootstrap-less/alerts.less +67 -0
  8. data/lib/tennpipes-su/bootstrap-less/badges.less +55 -0
  9. data/lib/tennpipes-su/bootstrap-less/bootstrap.less +49 -0
  10. data/lib/tennpipes-su/bootstrap-less/breadcrumbs.less +26 -0
  11. data/lib/tennpipes-su/bootstrap-less/button-groups.less +226 -0
  12. data/lib/tennpipes-su/bootstrap-less/buttons.less +155 -0
  13. data/lib/tennpipes-su/bootstrap-less/carousel.less +232 -0
  14. data/lib/tennpipes-su/bootstrap-less/close.less +33 -0
  15. data/lib/tennpipes-su/bootstrap-less/code.less +63 -0
  16. data/lib/tennpipes-su/bootstrap-less/component-animations.less +29 -0
  17. data/lib/tennpipes-su/bootstrap-less/dropdowns.less +213 -0
  18. data/lib/tennpipes-su/bootstrap-less/font-awesome/bordered-pulled.less +16 -0
  19. data/lib/tennpipes-su/bootstrap-less/font-awesome/core.less +12 -0
  20. data/lib/tennpipes-su/bootstrap-less/font-awesome/fixed-width.less +6 -0
  21. data/lib/tennpipes-su/bootstrap-less/font-awesome/font-awesome.less +17 -0
  22. data/lib/tennpipes-su/bootstrap-less/font-awesome/icons.less +412 -0
  23. data/lib/tennpipes-su/bootstrap-less/font-awesome/larger.less +13 -0
  24. data/lib/tennpipes-su/bootstrap-less/font-awesome/list.less +19 -0
  25. data/lib/tennpipes-su/bootstrap-less/font-awesome/mixins.less +20 -0
  26. data/lib/tennpipes-su/bootstrap-less/font-awesome/path.less +14 -0
  27. data/lib/tennpipes-su/bootstrap-less/font-awesome/rotated-flipped.less +9 -0
  28. data/lib/tennpipes-su/bootstrap-less/font-awesome/spinning.less +30 -0
  29. data/lib/tennpipes-su/bootstrap-less/font-awesome/stacked.less +20 -0
  30. data/lib/tennpipes-su/bootstrap-less/font-awesome/variables.less +381 -0
  31. data/lib/tennpipes-su/bootstrap-less/forms.less +419 -0
  32. data/lib/tennpipes-su/bootstrap-less/glyphicons.less +233 -0
  33. data/lib/tennpipes-su/bootstrap-less/grid.less +100 -0
  34. data/lib/tennpipes-su/bootstrap-less/input-groups.less +157 -0
  35. data/lib/tennpipes-su/bootstrap-less/jumbotron.less +44 -0
  36. data/lib/tennpipes-su/bootstrap-less/labels.less +64 -0
  37. data/lib/tennpipes-su/bootstrap-less/list-group.less +110 -0
  38. data/lib/tennpipes-su/bootstrap-less/media.less +56 -0
  39. data/lib/tennpipes-su/bootstrap-less/mixins.less +926 -0
  40. data/lib/tennpipes-su/bootstrap-less/modals.less +138 -0
  41. data/lib/tennpipes-su/bootstrap-less/navbar.less +616 -0
  42. data/lib/tennpipes-su/bootstrap-less/navs.less +242 -0
  43. data/lib/tennpipes-su/bootstrap-less/normalize.less +423 -0
  44. data/lib/tennpipes-su/bootstrap-less/pager.less +55 -0
  45. data/lib/tennpipes-su/bootstrap-less/pagination.less +88 -0
  46. data/lib/tennpipes-su/bootstrap-less/panels.less +230 -0
  47. data/lib/tennpipes-su/bootstrap-less/popovers.less +133 -0
  48. data/lib/tennpipes-su/bootstrap-less/print.less +101 -0
  49. data/lib/tennpipes-su/bootstrap-less/progress-bars.less +80 -0
  50. data/lib/tennpipes-su/bootstrap-less/responsive-utilities.less +93 -0
  51. data/lib/tennpipes-su/bootstrap-less/scaffolding.less +134 -0
  52. data/lib/tennpipes-su/bootstrap-less/tables.less +233 -0
  53. data/lib/tennpipes-su/bootstrap-less/tennpipes-su.less +18 -0
  54. data/lib/tennpipes-su/bootstrap-less/theme.less +247 -0
  55. data/lib/tennpipes-su/bootstrap-less/thumbnails.less +36 -0
  56. data/lib/tennpipes-su/bootstrap-less/tooltip.less +95 -0
  57. data/lib/tennpipes-su/bootstrap-less/type.less +296 -0
  58. data/lib/tennpipes-su/bootstrap-less/utilities.less +56 -0
  59. data/lib/tennpipes-su/bootstrap-less/variables.less +827 -0
  60. data/lib/tennpipes-su/bootstrap-less/wells.less +29 -0
  61. data/lib/tennpipes-su/generators/actions.rb +78 -0
  62. data/lib/tennpipes-su/generators/admin_app.rb +169 -0
  63. data/lib/tennpipes-su/generators/admin_page.rb +68 -0
  64. data/lib/tennpipes-su/generators/orm.rb +172 -0
  65. data/lib/tennpipes-su/generators/templates/account/activerecord.rb.tt +41 -0
  66. data/lib/tennpipes-su/generators/templates/account/couchrest.rb.tt +67 -0
  67. data/lib/tennpipes-su/generators/templates/account/datamapper.rb.tt +56 -0
  68. data/lib/tennpipes-su/generators/templates/account/dynamoid.rb.tt +55 -0
  69. data/lib/tennpipes-su/generators/templates/account/minirecord.rb.tt +44 -0
  70. data/lib/tennpipes-su/generators/templates/account/mongoid.rb.tt +54 -0
  71. data/lib/tennpipes-su/generators/templates/account/mongomapper.rb.tt +47 -0
  72. data/lib/tennpipes-su/generators/templates/account/ohm.rb.tt +70 -0
  73. data/lib/tennpipes-su/generators/templates/account/seeds.rb.tt +29 -0
  74. data/lib/tennpipes-su/generators/templates/account/sequel.rb.tt +53 -0
  75. data/lib/tennpipes-su/generators/templates/app.rb.tt +42 -0
  76. data/lib/tennpipes-su/generators/templates/app/controllers/base.rb.tt +5 -0
  77. data/lib/tennpipes-su/generators/templates/app/controllers/sessions.rb.tt +29 -0
  78. data/lib/tennpipes-su/generators/templates/assets/images/favicon.ico +0 -0
  79. data/lib/tennpipes-su/generators/templates/assets/images/font/FontAwesome.otf +0 -0
  80. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.eot +0 -0
  81. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.svg +414 -0
  82. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.ttf +0 -0
  83. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.woff +0 -0
  84. data/lib/tennpipes-su/generators/templates/assets/images/logo.png +0 -0
  85. data/lib/tennpipes-su/generators/templates/assets/javascripts/application.js +118 -0
  86. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/affix.js +137 -0
  87. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/alert.js +88 -0
  88. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/bootstrap.min.js +6 -0
  89. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/button.js +107 -0
  90. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/carousel.js +205 -0
  91. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/collapse.js +170 -0
  92. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/dropdown.js +147 -0
  93. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/modal.js +243 -0
  94. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/popover.js +110 -0
  95. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/scrollspy.js +153 -0
  96. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/tab.js +125 -0
  97. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/tooltip.js +399 -0
  98. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/transition.js +48 -0
  99. data/lib/tennpipes-su/generators/templates/assets/javascripts/jquery-1.11.0.min.js +4 -0
  100. data/lib/tennpipes-su/generators/templates/assets/stylesheets/application.css +353 -0
  101. data/lib/tennpipes-su/generators/templates/assets/stylesheets/bootstrap.css +4 -0
  102. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/FontAwesome.otf +0 -0
  103. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.eot +0 -0
  104. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.svg +414 -0
  105. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.ttf +0 -0
  106. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.woff +0 -0
  107. data/lib/tennpipes-su/generators/templates/erb/app/base/index.erb.tt +15 -0
  108. data/lib/tennpipes-su/generators/templates/erb/app/errors/403.erb.tt +3 -0
  109. data/lib/tennpipes-su/generators/templates/erb/app/errors/404.erb.tt +3 -0
  110. data/lib/tennpipes-su/generators/templates/erb/app/errors/500.erb.tt +3 -0
  111. data/lib/tennpipes-su/generators/templates/erb/app/layouts/application.erb.tt +64 -0
  112. data/lib/tennpipes-su/generators/templates/erb/app/layouts/error.erb.tt +23 -0
  113. data/lib/tennpipes-su/generators/templates/erb/app/sessions/new.erb.tt +44 -0
  114. data/lib/tennpipes-su/generators/templates/erb/page/_form.erb.tt +18 -0
  115. data/lib/tennpipes-su/generators/templates/erb/page/edit.erb.tt +10 -0
  116. data/lib/tennpipes-su/generators/templates/erb/page/index.erb.tt +81 -0
  117. data/lib/tennpipes-su/generators/templates/erb/page/new.erb.tt +9 -0
  118. data/lib/tennpipes-su/generators/templates/haml/app/base/index.haml.tt +12 -0
  119. data/lib/tennpipes-su/generators/templates/haml/app/errors/403.haml.tt +3 -0
  120. data/lib/tennpipes-su/generators/templates/haml/app/errors/404.haml.tt +3 -0
  121. data/lib/tennpipes-su/generators/templates/haml/app/errors/500.haml.tt +3 -0
  122. data/lib/tennpipes-su/generators/templates/haml/app/layouts/application.haml.tt +49 -0
  123. data/lib/tennpipes-su/generators/templates/haml/app/layouts/error.haml.tt +18 -0
  124. data/lib/tennpipes-su/generators/templates/haml/app/sessions/new.haml.tt +38 -0
  125. data/lib/tennpipes-su/generators/templates/haml/page/_form.haml.tt +16 -0
  126. data/lib/tennpipes-su/generators/templates/haml/page/edit.haml.tt +8 -0
  127. data/lib/tennpipes-su/generators/templates/haml/page/index.haml.tt +58 -0
  128. data/lib/tennpipes-su/generators/templates/haml/page/new.haml.tt +7 -0
  129. data/lib/tennpipes-su/generators/templates/page/controller.rb.tt +92 -0
  130. data/lib/tennpipes-su/generators/templates/slim/app/base/index.slim.tt +12 -0
  131. data/lib/tennpipes-su/generators/templates/slim/app/errors/403.slim.tt +3 -0
  132. data/lib/tennpipes-su/generators/templates/slim/app/errors/404.slim.tt +3 -0
  133. data/lib/tennpipes-su/generators/templates/slim/app/errors/500.slim.tt +3 -0
  134. data/lib/tennpipes-su/generators/templates/slim/app/layouts/application.slim.tt +48 -0
  135. data/lib/tennpipes-su/generators/templates/slim/app/layouts/error.slim.tt +19 -0
  136. data/lib/tennpipes-su/generators/templates/slim/app/sessions/new.slim.tt +37 -0
  137. data/lib/tennpipes-su/generators/templates/slim/page/_form.slim.tt +16 -0
  138. data/lib/tennpipes-su/generators/templates/slim/page/edit.slim.tt +8 -0
  139. data/lib/tennpipes-su/generators/templates/slim/page/index.slim.tt +56 -0
  140. data/lib/tennpipes-su/generators/templates/slim/page/new.slim.tt +7 -0
  141. data/lib/tennpipes-su/helpers/authentication_helpers.rb +108 -0
  142. data/lib/tennpipes-su/helpers/view_helpers.rb +87 -0
  143. data/lib/tennpipes-su/locale/admin/cs.yml +56 -0
  144. data/lib/tennpipes-su/locale/admin/da.yml +56 -0
  145. data/lib/tennpipes-su/locale/admin/de.yml +56 -0
  146. data/lib/tennpipes-su/locale/admin/en.yml +56 -0
  147. data/lib/tennpipes-su/locale/admin/es.yml +56 -0
  148. data/lib/tennpipes-su/locale/admin/fr.yml +56 -0
  149. data/lib/tennpipes-su/locale/admin/hu.yml +56 -0
  150. data/lib/tennpipes-su/locale/admin/it.yml +56 -0
  151. data/lib/tennpipes-su/locale/admin/ja.yml +57 -0
  152. data/lib/tennpipes-su/locale/admin/lv.yml +56 -0
  153. data/lib/tennpipes-su/locale/admin/nl.yml +56 -0
  154. data/lib/tennpipes-su/locale/admin/no.yml +56 -0
  155. data/lib/tennpipes-su/locale/admin/pl.yml +56 -0
  156. data/lib/tennpipes-su/locale/admin/pt_br.yml +56 -0
  157. data/lib/tennpipes-su/locale/admin/ro.yml +56 -0
  158. data/lib/tennpipes-su/locale/admin/ru.yml +57 -0
  159. data/lib/tennpipes-su/locale/admin/sv.yml +56 -0
  160. data/lib/tennpipes-su/locale/admin/tr.yml +56 -0
  161. data/lib/tennpipes-su/locale/admin/uk.yml +56 -0
  162. data/lib/tennpipes-su/locale/admin/zh_cn.yml +56 -0
  163. data/lib/tennpipes-su/locale/admin/zh_tw.yml +56 -0
  164. data/lib/tennpipes-su/locale/orm/cs.yml +12 -0
  165. data/lib/tennpipes-su/locale/orm/da.yml +12 -0
  166. data/lib/tennpipes-su/locale/orm/de.yml +12 -0
  167. data/lib/tennpipes-su/locale/orm/en.yml +12 -0
  168. data/lib/tennpipes-su/locale/orm/es.yml +12 -0
  169. data/lib/tennpipes-su/locale/orm/fr.yml +12 -0
  170. data/lib/tennpipes-su/locale/orm/hu.yml +12 -0
  171. data/lib/tennpipes-su/locale/orm/it.yml +12 -0
  172. data/lib/tennpipes-su/locale/orm/ja.yml +12 -0
  173. data/lib/tennpipes-su/locale/orm/lv.yml +12 -0
  174. data/lib/tennpipes-su/locale/orm/nl.yml +12 -0
  175. data/lib/tennpipes-su/locale/orm/no.yml +12 -0
  176. data/lib/tennpipes-su/locale/orm/pl.yml +38 -0
  177. data/lib/tennpipes-su/locale/orm/pt_br.yml +12 -0
  178. data/lib/tennpipes-su/locale/orm/ro.yml +12 -0
  179. data/lib/tennpipes-su/locale/orm/ru.yml +12 -0
  180. data/lib/tennpipes-su/locale/orm/sv.yml +12 -0
  181. data/lib/tennpipes-su/locale/orm/tr.yml +12 -0
  182. data/lib/tennpipes-su/locale/orm/uk.yml +12 -0
  183. data/lib/tennpipes-su/locale/orm/zh_cn.yml +12 -0
  184. data/lib/tennpipes-su/locale/orm/zh_tw.yml +12 -0
  185. data/test/fixtures/sequel.rb +72 -0
  186. data/test/generators/test_account_model_generator.rb +108 -0
  187. data/test/generators/test_admin_app_generator.rb +218 -0
  188. data/test/generators/test_admin_page_generator.rb +140 -0
  189. data/test/helper.rb +47 -0
  190. data/test/test_admin_application.rb +271 -0
  191. data/test/test_locale.rb +25 -0
  192. metadata +298 -0
@@ -0,0 +1,8 @@
1
+ %ul.nav.nav-tabs
2
+ %li=link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ %li=link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+ %li.active=link_to tag_icon(:edit, pat(:edit)), url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
5
+
6
+ .tabs-content
7
+ = form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :update, :id => @<%= @orm.name_singular %>.id), :method => :put, :class => 'form-horizontal' do |f|
8
+ =partial '<%= @orm.name_plural %>/form', :locals => { :f => f }
@@ -0,0 +1,58 @@
1
+ %ul.nav.nav-tabs
2
+ %li.active=link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ %li=link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+
5
+ .tabs-content
6
+ %table#list.table.table-striped.table-hover.table-condensed
7
+ %thead
8
+ %tr
9
+ %th.header.list-menu
10
+ .dropdown
11
+ %a.list-menu-toggle.dropdown-toggle{:href => '#', :'data-toggle' => :dropdown}
12
+ =tag_icon :magic
13
+ %span.caret
14
+ %ul.list-menu.dropdown-menu{:role => :menu}
15
+ %li.list-menu-wrapper=link_to tag_icon('check-square-o', pat(:select_all)), '#', :id => 'select-all', :class => 'list-menu-link'
16
+ %li.list-menu-wrapper.list-menu-wrapper-disabled
17
+ =link_to tag_icon('square-o', pat(:deselect_all)), '#', :id => 'deselect-all', :class => 'list-menu-link list-menu-link-disabled'
18
+ %li.list-menu-divider.divider
19
+ %li.list-menu-wrapper.list-menu-wrapper-disabled
20
+ =link_to tag_icon('trash-o', pat(:delete_selected)), '#', :id => 'delete-selected', :class => 'list-menu-link list-menu-link-disabled'
21
+ .list-menu-popover-delete-selected.popover.right
22
+ .arrow
23
+ %h3.popover-title=pat(:delete_selected_title)
24
+ .popover-content
25
+ = form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do
26
+ =hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true
27
+ =submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small'
28
+ .btn.btn-default.btn-small.cancel=pat(:cancel)
29
+ <%- @orm.columns.each_with_index do |column, i| -%>
30
+ %th.header= mat(:<%= @orm.name_singular %>, :<%= column.name %>)
31
+ <%- end -%>
32
+ %th.header.list-row-action-header
33
+
34
+ %tbody
35
+ -@<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>|
36
+ %tr.list-row
37
+ %td.list-column.list-selectable
38
+ =check_box_tag '<%= @orm.name_singular %>_ids[]', :value => <%= @orm.name_singular %>.id, :class => 'list-selectable-checkbox'
39
+ <%- @orm.columns.each_with_index do |column, i| -%>
40
+ <%- if column.name == "created_at" || column.name == "updated_at" -%>
41
+ %td.list-column=time_ago_in_words <%= @orm.name_singular %>.<%= column.name %>
42
+ <%- elsif column.type == :boolean -%>
43
+ %td.list-column= <%= @orm.name_singular %>.<%= column.name %> ? tag_icon(:ok) : tag_icon(:remove)
44
+ <%- else -%>
45
+ %td.list-column=<%= @orm.name_singular %>.<%= column.name %>
46
+ <%- end -%>
47
+ <%- end -%>
48
+ %td.list-column.list-row-action
49
+ .list-row-action-wrapper
50
+ =link_to tag_icon(:edit), :href => url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :rel => :tooltip, :title => "#{pat(:edit)} <%= @orm.name_singular %>", :class => 'list-row-action-wrapper-link'
51
+ =link_to tag_icon('trash-o'), :rel => :tooltip, :title => "#{pat(:delete)} <%= @orm.name_singular %>", :class => 'list-row-action-delete-one list-row-action-wrapper-link'
52
+ .popover.list-row-action-popover-delete-one.left
53
+ .arrow
54
+ %h3.popover-title=pat(:delete, :model => "<%= @orm.name_singular %>")
55
+ .popover-content
56
+ = form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do
57
+ =submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small'
58
+ .btn.btn-default.btn-small.cancel=pat(:cancel)
@@ -0,0 +1,7 @@
1
+ %ul.nav.nav-tabs
2
+ %li=link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ %li.active=link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+
5
+ .tabs-content
6
+ = form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :create), :class => 'form-horizontal' do |f|
7
+ =partial '<%= @orm.name_plural %>/form', :locals => { :f => f }
@@ -0,0 +1,92 @@
1
+ <%= @app_name %>::<%= @admin_name %>.controllers :<%= @orm.name_plural %> do
2
+ get :index do
3
+ @title = "<%= @orm.name_plural.capitalize %>"
4
+ @<%= @orm.name_plural %> = <%= @orm.all %>
5
+ render '<%= @orm.name_plural %>/index'
6
+ end
7
+
8
+ get :new do
9
+ @title = pat(:new_title, :model => '<%= @orm.name_singular %>')
10
+ @<%= @orm.name_singular %> = <%= @orm.build %>
11
+ render '<%= @orm.name_plural %>/new'
12
+ end
13
+
14
+ post :create do
15
+ @<%= @orm.name_singular %> = <%= @orm.build("params[:#{@orm.name_param}]") %>
16
+ if <%= @orm.save %>
17
+ @title = pat(:create_title, :model => "<%= @orm.name_singular %> #{@<%= @orm.name_singular %>.id}")
18
+ flash[:success] = pat(:create_success, :model => '<%= @orm.klass_name %>')
19
+ params[:save_and_continue] ? redirect(url(:<%= @orm.name_plural %>, :index)) : redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
20
+ else
21
+ @title = pat(:create_title, :model => '<%= @orm.name_singular %>')
22
+ flash.now[:error] = pat(:create_error, :model => '<%= @orm.name_singular %>')
23
+ render '<%= @orm.name_plural %>/new'
24
+ end
25
+ end
26
+
27
+ get :edit, :with => :id do
28
+ @title = pat(:edit_title, :model => "<%= @orm.name_singular %> #{params[:id]}")
29
+ @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
30
+ if @<%= @orm.name_singular %>
31
+ render '<%= @orm.name_plural %>/edit'
32
+ else
33
+ flash[:warning] = pat(:create_error, :model => '<%= @orm.name_singular %>', :id => "#{params[:id]}")
34
+ halt 404
35
+ end
36
+ end
37
+
38
+ put :update, :with => :id do
39
+ @title = pat(:update_title, :model => "<%= @orm.name_singular %> #{params[:id]}")
40
+ @<%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
41
+ if @<%= @orm.name_singular %>
42
+ if <%= @orm.update_attributes("params[:#{@orm.name_param}]") %>
43
+ flash[:success] = pat(:update_success, :model => '<%= @orm.name_singular.capitalize %>', :id => "#{params[:id]}")
44
+ params[:save_and_continue] ?
45
+ redirect(url(:<%= @orm.name_plural %>, :index)) :
46
+ redirect(url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id))
47
+ else
48
+ flash.now[:error] = pat(:update_error, :model => '<%= @orm.name_singular %>')
49
+ render '<%= @orm.name_plural %>/edit'
50
+ end
51
+ else
52
+ flash[:warning] = pat(:update_warning, :model => '<%= @orm.name_singular %>', :id => "#{params[:id]}")
53
+ halt 404
54
+ end
55
+ end
56
+
57
+ delete :destroy, :with => :id do
58
+ @title = "<%= @orm.name_plural.capitalize %>"
59
+ <%= @orm.name_singular %> = <%= @orm.find("params[:id]") %>
60
+ if <%= @orm.name_singular %>
61
+ if <%= @orm.destroy %>
62
+ flash[:success] = pat(:delete_success, :model => '<%= @orm.name_singular.capitalize %>', :id => "#{params[:id]}")
63
+ else
64
+ flash[:error] = pat(:delete_error, :model => '<%= @orm.name_singular %>')
65
+ end
66
+ redirect url(:<%= @orm.name_plural %>, :index)
67
+ else
68
+ flash[:warning] = pat(:delete_warning, :model => '<%= @orm.name_singular %>', :id => "#{params[:id]}")
69
+ halt 404
70
+ end
71
+ end
72
+
73
+ delete :destroy_many do
74
+ @title = "<%= @orm.name_plural.capitalize %>"
75
+ unless params[:<%= @orm.name_singular %>_ids]
76
+ flash[:error] = pat(:destroy_many_error, :model => '<%= @orm.name_singular %>')
77
+ redirect(url(:<%= @orm.name_plural %>, :index))
78
+ end
79
+ ids = params[:<%= @orm.name_param %>_ids].split(',').map(&:strip)
80
+ <%= @orm.name_plural %> = <%= @orm.find_by_ids("ids") %>
81
+ <% if @orm.name_singular == @admin_model %>
82
+ if <%= @orm.name_plural %>.include? current_account
83
+ flash[:error] = pat(:delete_error, :model => '<%= @orm.name_singular %>')
84
+ elsif <%= @orm.multiple_destroy(@orm.name_plural) %>
85
+ <% else %>
86
+ if <%= @orm.multiple_destroy(@orm.name_plural) %>
87
+ <% end %>
88
+ flash[:success] = pat(:destroy_many_success, :model => '<%= @orm.name_plural.capitalize %>', :ids => "#{ids.to_sentence}")
89
+ end
90
+ redirect url(:<%= @orm.name_plural %>, :index)
91
+ end
92
+ end
@@ -0,0 +1,12 @@
1
+ div class="base-text"
2
+ p Tennpipes is a ruby framework built upon the Sinatra web library
3
+ p It was created to make it fun and easy to code more advanced web applications while still adhering to the spirit that makes Sinatra great!
4
+ p Tennpipes comes shipped with a slick and beautiful Admin Interface, with the following features:
5
+
6
+ div class="base-icons"
7
+ div class="btn-group"
8
+ div class="btn btn-primary" title="Adapters for datamapper, sequel, activerecord, minirecord, mongomapper, mongoid, couchrest" = tag_icon("cogs fa-2x", "Orm Agnostic")
9
+ div class="btn btn-success" title="User Authentication Support, User Authorization Management" = tag_icon("group fa-2x", "Authentication")
10
+ div class="btn btn-info" title="Erb, Haml, Slim Rendering Support" = tag_icon("tasks fa-2x", "Template Agnostic")
11
+ div class="btn btn-warning" title="English, German, Russian, Danish, French, Brazilian and Italian localizations" = tag_icon("flag fa-2x", "Multi Language")
12
+ div class="btn btn-danger" title="You can create a new 'admin interface' by providing a single Model" = tag_icon("magic fa-2x", "Scaffold")
@@ -0,0 +1,3 @@
1
+ p = tag_icon 'minus-circle fa-3x'
2
+ h1 = pat('custom_errors.403.title')
3
+ p = pat('custom_errors.403.description')
@@ -0,0 +1,3 @@
1
+ p= tag_icon 'exclamation-triangle fa-3x'
2
+ h1= pat('custom_errors.404.title')
3
+ p= pat('custom_errors.404.description')
@@ -0,0 +1,3 @@
1
+ p = tag_icon 'flask fa-3x'
2
+ h1 = pat('custom_errors.500.title')
3
+ p = pat('custom_errors.500.description')
@@ -0,0 +1,48 @@
1
+ doctype 5
2
+ html lang='en'
3
+ head
4
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
5
+ <!--[if lt IE 9]>
6
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
7
+ <![endif]-->
8
+ meta content='text/html; charset=utf-8' http-equiv='Content-Type'
9
+ meta name='viewport' content='width=device-width,initial-scale=1'
10
+ title = @title.present? ? "#{@title} | Tennpipes Admin" : "Tennpipes Admin"
11
+ = favicon_tag 'favicon.ico'
12
+ link href='http://fonts.googleapis.com/css?family=Varela' rel='stylesheet'
13
+ = stylesheet_link_tag 'bootstrap', 'application'
14
+
15
+ body
16
+ div class='navbar navbar-fixed-top'
17
+ div class='navbar-inner'
18
+ div class='container'
19
+ = link_to 'Tennpipes', url(:base, :index), :class => 'navbar-brand', :title => 'Tennpipes Admin'
20
+
21
+ ul class='nav navbar-nav pull-right'
22
+ li class='navbar-edit-account' = link_to tag_icon(:user), url(:<%= @model_plural %>, :edit, :id => current_account.id), :title => pat(:profile), :class => 'navbar-nav-link'
23
+ li class='navbar-logout' = button_to(pat(:logout), url(:sessions, :destroy), :method => :delete, :class => 'navbar-nav-form') do
24
+ = content_tag :button, tag_icon(:'power-off'), :type => :submit, :title => pat(:logout), :class => 'navbar-nav-form-link'
25
+
26
+ ul class='nav navbar-nav pull-left'
27
+ - project_modules.each do |project_module|
28
+ li class=("navbar-module #{'active' if request.path_info =~ /^#{project_module.path}/}")
29
+ = link_to project_module.human_name, url(project_module.path)
30
+
31
+ div class='container main'
32
+ div class='main-wrapper'
33
+ = {:error => 'danger', :warning => 'warning', :success => 'success', :notice => 'info'}.map { |type, class_name| flash_tag(type, :class => "alert alert-#{class_name} fade in", :bootstrap => true) }.join.html_safe
34
+ div class='row' = yield
35
+ div class='main-wrapper-push'
36
+
37
+ footer
38
+ div class='footer-wrapper container'
39
+ p class='pull-left'
40
+ ' Copyright &copy; #{Time.now.year} Your Site -
41
+ b Powered by Tennpipes v.#{Tennpipes.version}
42
+ ul class='pull-right footer-links'
43
+ li = link_to tag_icon(:home, 'web'), 'http://www.tennpipesrb.com', :target => :_blank, :class => 'footer-links-link'
44
+ li = link_to tag_icon(:heart, 'blog'), 'http://www.tennpipesrb.com/blog', :target => :_blank, :class => 'footer-links-link'
45
+ li = link_to tag_icon(:github, 'code'), 'https://github.com/tennpipes/tennpipes-framework', :target => :_blank, :class => 'footer-links-link'
46
+ li = link_to tag_icon(:twitter, 'twitter'), 'http://twitter.com/tennpipesrb', :target => :_blank, :class => 'footer-links-link'
47
+
48
+ =javascript_include_tag 'jquery-1.11.0.min', (Tennpipes.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
@@ -0,0 +1,19 @@
1
+ doctype 5
2
+ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
+ head
4
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
5
+ <!--[if lt IE 9]>
6
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
7
+ <![endif]-->
8
+ meta content='text/html; charset=utf-8' http-equiv='Content-Type'
9
+ meta name='viewport' content='width=device-width,initial-scale=1'
10
+ title = @title.present? ? "#{@title} | Tennpipes Admin" : "#{pat(:custom_errors.title)} | Tennpipes Admin"
11
+ = favicon_tag 'favicon.ico'
12
+ link href='http://fonts.googleapis.com/css?family=Varela' rel='stylesheet'
13
+ = stylesheet_link_tag 'bootstrap', 'application'
14
+
15
+ body
16
+ div class="custom-error text-center"
17
+ div class="custom-error-body muted" = yield
18
+ div class="custom-error-footer"
19
+ = link_to tag_icon('arrow-left'),"#", :onclick => "history.go(-1);return false;", :class =>"custom-error-go-back btn btn-default pull-left", :title => "Go Back"
@@ -0,0 +1,37 @@
1
+ doctype 5
2
+ html lang="en" xmlns="http://www.w3.org/1999/xhtml"
3
+ head
4
+ <!-- Le HTML5 shim, for IE6-8 support of HTML elements -->
5
+ <!--[if lt IE 9]>
6
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
7
+ <![endif]-->
8
+ meta content='text/html; charset=utf-8' http-equiv='Content-Type'
9
+ meta name='viewport' content='width=device-width,initial-scale=1'
10
+ title = @title.present? ? "#{@title} | Tennpipes Admin" : "#{pat('login.title')} | Tennpipes Admin"
11
+ = favicon_tag 'favicon.ico'
12
+ = stylesheet_link_tag 'bootstrap', 'application'
13
+
14
+ body
15
+ = form_tag url(:sessions, :create), :class=>'login form-horizontal' do
16
+ div class="login-header modal-header"
17
+ div class="login-logo" = image_tag('logo.png', :alt => "Tennpipes's logo", :height => 250, :width => 193)
18
+ div class="login-body modal-body"
19
+ = {:error => 'danger', :warning => 'warning', :success => 'success', :notice => 'info'}.map { |type, class_name| flash_tag(type, :class => "alert alert-#{class_name} fade in", :bootstrap => true) }.join.html_safe
20
+
21
+ div class='form-group'
22
+ label for="email" class='col-lg-2 control-label' = pat('login.email')
23
+ div class='col-lg-10' = email_field_tag :email, :id => :email, :value => params[:email], :autofocus => true, :class => 'form-control'
24
+
25
+ div class='form-group'
26
+ label for="password" class='col-lg-2 control-label' = pat('login.password')
27
+ div class='col-lg-10' = password_field_tag :password, :id => :password, :class => 'form-control'
28
+
29
+ fieldset class='login-control-group-last control-group'
30
+ div class='login-controls controls'
31
+ label class="login-bypass-label checkbox"
32
+ = check_box_tag :bypass
33
+ | #{pat('login.bypass')}
34
+
35
+ div class="login-footer modal-footer"
36
+ = submit_tag(pat('login.sign_in'), :class => 'btn btn-primary pull-right')
37
+ = javascript_include_tag 'jquery-1.11.0.min', (Tennpipes.env == :production ? 'bootstrap/bootstrap.min' : %w[bootstrap/affix bootstrap/alert bootstrap/button bootstrap/carousel bootstrap/collapse bootstrap/dropdown bootstrap/tooltip bootstrap/transition bootstrap/modal bootstrap/popover bootstrap/scrollspy bootstrap/tab]), :application
@@ -0,0 +1,16 @@
1
+ <%- @orm.column_fields.each_with_index do |column, index| -%>
2
+ - error = <%= @orm.has_error(column[:name]) %>
3
+ fieldset class='control-group#{error ? ' has-error' : ''}'
4
+ = f.label :<%= column[:name] %>, :class => 'control-label'
5
+ div class='controls'
6
+ = f.<%= column[:field_type] %> :<%= column[:name] %>, :class => 'form-control input-large input-with-feedback'<%- if (index == 0) -%>, :autofocus => true<%- end -%>
7
+
8
+ span class='help-inline' = error ? f.error_message_on(:<%= column[:name] %>, :class => 'text-error') : pat(:example)
9
+ <%- end -%>
10
+
11
+ div class="form-actions"
12
+ = f.submit pat(:save), :class => 'btn btn-primary'
13
+ |&nbsp;
14
+ = f.submit pat(:save_and_continue), :class => 'btn btn-info', :name => 'save_and_continue'
15
+ |&nbsp;
16
+ = link_to pat(:cancel), url(:<%= @orm.name_plural %>, :index), :class => 'btn btn-default'
@@ -0,0 +1,8 @@
1
+ ul class="nav nav-tabs"
2
+ li = link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ li = link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+ li class="active" = link_to tag_icon(:edit, pat(:edit)), url(:<%= @orm.name_plural %>, :edit, :id => @<%= @orm.name_singular %>.id)
5
+
6
+ div class="tabs-content"
7
+ = form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :update, :id => @<%= @orm.name_singular %>.id), :method => :put, :class => 'form-horizontal' do |f|
8
+ = partial '<%= @orm.name_plural %>/form', :locals => { :f => f }
@@ -0,0 +1,56 @@
1
+ ul class="nav nav-tabs"
2
+ li class="active" = link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ li = link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+
5
+ div class="tabs-content"
6
+ table class="table table-striped table-hover table-condensed" id="list"
7
+ thead
8
+ tr
9
+ th class='header list-menu'
10
+ div class='dropdown'
11
+ a href='#' class='list-menu-toggle.dropdown-toggle dropdown-toggle' data-toggle='dropdown'
12
+ = tag_icon :magic
13
+ span class='caret'
14
+ ul class='list-menu dropdown-menu' role='dropdown'
15
+ li class='list-menu-wrapper' = link_to tag_icon('check-square-o', pat(:select_all)), '#', :id => 'select-all', :class => 'list-menu-link'
16
+ li class='list-menu-wrapper list-menu-wrapper-disabled' = link_to tag_icon('square-o', pat(:deselect_all)), '#', :id => 'deselect-all', :class => 'list-menu-link list-menu-link-disabled'
17
+ li class='list-menu-divider divider'
18
+ li class='list-menu-wrapper list-menu-wrapper-disabled'
19
+ = link_to tag_icon('trash-o', pat(:delete_selected)), '#', :id => 'delete-selected', :class => 'list-menu-link list-menu-link-disabled'
20
+ div class='list-menu-popover-delete-selected popover right'
21
+ div class='arrow'
22
+ h3 class='popover-title' = pat(:delete_selected_title)
23
+ div class='popover-content'
24
+ = form_tag url(:<%= @orm.name_plural %>, :destroy_many), :method => :delete do
25
+ = hidden_field_tag :<%= @orm.name_singular %>_ids, :'data-delete-many-ids' => true
26
+ = submit_tag pat(:delete), :class =>'list-menu-popover-delete-selected-btn btn btn-danger btn-small'
27
+ div class='btn btn-default btn-small cancel' = pat(:cancel)
28
+ <%- @orm.columns.each_with_index do |column, i| -%>
29
+ th class='header' = mat(:<%= @orm.name_singular %>, :<%= column.name %>)
30
+ <%- end -%>
31
+ th class='header list-row-action-header'
32
+
33
+ tbody
34
+ -@<%= @orm.name_plural %>.each do |<%= @orm.name_singular %>|
35
+ tr class='list-row'
36
+ td class='list-column list-selectable' = check_box_tag '<%= @orm.name_singular %>_ids[]', :value => <%= @orm.name_singular %>.id, :class => 'list-selectable-checkbox'
37
+ <%- @orm.columns.each_with_index do |column, i| -%>
38
+ <%- if column.name == 'created_at' || column.name == 'updated_at' -%>
39
+ td class='list-column' = time_ago_in_words <%= @orm.name_singular %>.<%= column.name %>
40
+ <%- elsif column.type == :boolean -%>
41
+ td class='list-column' = <%= @orm.name_singular %>.<%= column.name %> ? tag_icon(:ok) : tag_icon(:remove)
42
+ <%- else -%>
43
+ td class='list-column' = <%= @orm.name_singular %>.<%= column.name %>
44
+ <%- end -%>
45
+ <%- end -%>
46
+ td class='list-column list-row-action'
47
+ div class='list-row-action-wrapper'
48
+ = link_to tag_icon(:edit), :href => url(:<%= @orm.name_plural %>, :edit, :id => <%= @orm.name_singular %>.id), :rel => :tooltip, :title => "#{pat(:edit)} <%= @orm.name_singular %>", :class => 'list-row-action-wrapper-link'
49
+ = link_to tag_icon('trash-o'), :rel => :tooltip, :title => "#{pat(:delete)} <%= @orm.name_singular %>", :class => 'list-row-action-delete-one list-row-action-wrapper-link'
50
+ div class='popover list-row-action-popover-delete-one left'
51
+ div class='arrow'
52
+ h3 class='popover-title' = pat(:delete, :model => "<%= @orm.name_singular %>")
53
+ div class='popover-content'
54
+ = form_tag url(:<%= @orm.name_plural %>, :destroy, :id => <%= @orm.name_singular %>.id), :method => :delete do
55
+ = submit_tag pat(:delete), :class =>'list-row-action-popover-delete-one-btn btn btn-danger btn-small'
56
+ div class='btn btn-default btn-small cancel' = pat(:cancel)
@@ -0,0 +1,7 @@
1
+ ul class="nav nav-tabs"
2
+ li = link_to tag_icon(:list, pat(:list)), url(:<%= @orm.name_plural %>, :index)
3
+ li class="active" = link_to tag_icon(:plus, pat(:new)), url(:<%= @orm.name_plural %>, :new)
4
+
5
+ div class="tabs-content"
6
+ = form_for :<%= @orm.name_singular %>, url(:<%= @orm.name_plural %>, :create), :class => 'form-horizontal' do |f|
7
+ = partial '<%= @orm.name_plural %>/form', :locals => { :f => f }
@@ -0,0 +1,108 @@
1
+ module Tennpipes
2
+ module Admin
3
+ module Helpers
4
+ ##
5
+ # Common helpers used for authorization within an application.
6
+ #
7
+ module AuthenticationHelpers
8
+ ##
9
+ # Returns true if +current_account+ is logged and active.
10
+ #
11
+ def logged_in?
12
+ !current_account.nil?
13
+ end
14
+
15
+ ##
16
+ # Returns the current_account, it's an instance of Account model.
17
+ #
18
+ def current_account
19
+ @current_account ||= login_from_session
20
+ end
21
+
22
+ ##
23
+ # Override the current_account, you must provide an instance of Account model.
24
+ #
25
+ # @example
26
+ # set_current_account(Account.authenticate(params[:email], params[:password])
27
+ #
28
+ def set_current_account(account=nil)
29
+ session[settings.session_id] = account ? account.id : nil
30
+ @current_account = account
31
+ end
32
+
33
+ ##
34
+ # Returns true if the +current_account+ is allowed to see the requested path.
35
+ #
36
+ # For configure this role please refer to: +Tennpipes::Admin::AccessControl::Base+
37
+ #
38
+ def allowed?
39
+ access_control.allowed?(current_account, request.path_info)
40
+ end
41
+
42
+ ##
43
+ # Returns project modules for the current account.
44
+ #
45
+ def project_modules
46
+ access_control.project_modules(current_account)
47
+ end
48
+
49
+ ##
50
+ # Returns a helper useful in a +before_filter+ for check if
51
+ # an account are: +logged_in?+ and +allowed?+
52
+ #
53
+ # By default this method is used in Admin Apps.
54
+ #
55
+ def login_required
56
+ unless allowed?
57
+ store_location! if store_location
58
+ access_denied
59
+ end
60
+ end
61
+
62
+ ##
63
+ # Store in session[:return_to] the env['REQUEST_URI'].
64
+ #
65
+ def store_location!
66
+ session[:return_to] = "#{ENV['RACK_BASE_URI']}#{env['REQUEST_URI']}" if env['REQUEST_URI']
67
+ end
68
+
69
+ ##
70
+ # Redirect the account to the page that requested an authentication or
71
+ # if the account is not allowed/logged return it to a default page.
72
+ #
73
+ def redirect_back_or_default(default)
74
+ return_to = session.delete(:return_to)
75
+ redirect(return_to || default)
76
+ end
77
+
78
+ private
79
+
80
+ def access_denied
81
+ if login_page.present?
82
+ redirect url(login_page)
83
+ else
84
+ halt 401, "You don't have permission for this resource"
85
+ end
86
+ end
87
+
88
+ def login_page
89
+ settings.respond_to?(:login_page) && settings.login_page
90
+ end
91
+
92
+ def store_location
93
+ settings.respond_to?(:store_location) && settings.store_location
94
+ end
95
+
96
+ def login_from_session
97
+ admin_model_obj.find_by_id(session[settings.session_id]) if admin_model_obj
98
+ end
99
+
100
+ def admin_model_obj
101
+ @_admin_model_obj ||= settings.admin_model.constantize
102
+ rescue NameError
103
+ raise Tennpipes::Admin::AccessControlError, "You must define an #{settings.admin_model} Model"
104
+ end
105
+ end
106
+ end
107
+ end
108
+ end