kuztuscms 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/.gitignore +9 -0
  2. data/.rvmrc +55 -0
  3. data/Gemfile +18 -0
  4. data/Gemfile.lock +156 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.rdoc +12 -0
  7. data/Rakefile +29 -0
  8. data/app/assets/images/kuztuscms/.gitkeep +0 -0
  9. data/app/assets/images/kuztuscms/glyphicons-halflings-white.png +0 -0
  10. data/app/assets/images/kuztuscms/glyphicons-halflings.png +0 -0
  11. data/app/assets/javascripts/kuztuscms/.DS_Store +0 -0
  12. data/app/assets/javascripts/kuztuscms/application.js +15 -0
  13. data/app/assets/javascripts/kuztuscms/bootstrap.js +1720 -0
  14. data/app/assets/javascripts/kuztuscms/codemirror-compressed.js +1 -0
  15. data/app/assets/stylesheets/kuztuscms/.DS_Store +0 -0
  16. data/app/assets/stylesheets/kuztuscms/application.css.scss +16 -0
  17. data/app/assets/stylesheets/kuztuscms/bootstrap-responsive.css +581 -0
  18. data/app/assets/stylesheets/kuztuscms/bootstrap.css +3496 -0
  19. data/app/assets/stylesheets/kuztuscms/codemirror.css +115 -0
  20. data/app/controllers/kuztuscms/articles_controller.rb +53 -0
  21. data/app/controllers/kuztuscms/home_controller.rb +6 -0
  22. data/app/controllers/kuztuscms/layouts_controller.rb +75 -0
  23. data/app/controllers/kuztuscms/pages_controller.rb +73 -0
  24. data/app/controllers/kuztuscms/settings_controller.rb +48 -0
  25. data/app/controllers/kuztuscms/templates_controller.rb +72 -0
  26. data/app/controllers/kuztuscms/users_controller.rb +74 -0
  27. data/app/controllers/kuztuscms_controller.rb +23 -0
  28. data/app/helpers/kuztuscms/application_helper.rb +4 -0
  29. data/app/models/kuztuscms/article.rb +4 -0
  30. data/app/models/kuztuscms/layout.rb +14 -0
  31. data/app/models/kuztuscms/page.rb +8 -0
  32. data/app/models/kuztuscms/setting.rb +11 -0
  33. data/app/models/kuztuscms/template.rb +14 -0
  34. data/app/models/kuztuscms/user.rb +20 -0
  35. data/app/views/devise/_links.erb +27 -0
  36. data/app/views/devise/confirmations/new.html.erb +12 -0
  37. data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
  38. data/app/views/devise/mailer/reset_password_instructions.html.erb +8 -0
  39. data/app/views/devise/mailer/unlock_instructions.html.erb +7 -0
  40. data/app/views/devise/passwords/edit.html.erb +16 -0
  41. data/app/views/devise/passwords/new.html.erb +18 -0
  42. data/app/views/devise/registrations/edit.html.erb +25 -0
  43. data/app/views/devise/registrations/new.html.erb +21 -0
  44. data/app/views/devise/sessions/new.html.erb +31 -0
  45. data/app/views/devise/unlocks/new.html.erb +19 -0
  46. data/app/views/kuztuscms/articles/_form.html.erb +35 -0
  47. data/app/views/kuztuscms/articles/edit.html.erb +1 -0
  48. data/app/views/kuztuscms/articles/index.html.erb +22 -0
  49. data/app/views/kuztuscms/articles/new.html.erb +1 -0
  50. data/app/views/kuztuscms/articles/show.html.erb +4 -0
  51. data/app/views/kuztuscms/home/index.html.erb +1 -0
  52. data/app/views/kuztuscms/layouts/_form.html.erb +58 -0
  53. data/app/views/kuztuscms/layouts/edit.html.erb +2 -0
  54. data/app/views/kuztuscms/layouts/index.html.erb +32 -0
  55. data/app/views/kuztuscms/layouts/new.html.erb +2 -0
  56. data/app/views/kuztuscms/pages/_form.html.erb +72 -0
  57. data/app/views/kuztuscms/pages/edit.html.erb +1 -0
  58. data/app/views/kuztuscms/pages/index.html.erb +28 -0
  59. data/app/views/kuztuscms/pages/new.html.erb +1 -0
  60. data/app/views/kuztuscms/pages/show.html.erb +1 -0
  61. data/app/views/kuztuscms/settings/_form.html.erb +35 -0
  62. data/app/views/kuztuscms/settings/edit.html.erb +1 -0
  63. data/app/views/kuztuscms/settings/index.html.erb +24 -0
  64. data/app/views/kuztuscms/settings/new.html.erb +1 -0
  65. data/app/views/kuztuscms/shared/_codemirror.html.erb +20 -0
  66. data/app/views/kuztuscms/templates/_form.html.erb +58 -0
  67. data/app/views/kuztuscms/templates/edit.html.erb +3 -0
  68. data/app/views/kuztuscms/templates/index.html.erb +28 -0
  69. data/app/views/kuztuscms/templates/new.html.erb +2 -0
  70. data/app/views/kuztuscms/users/_form.html.erb +56 -0
  71. data/app/views/kuztuscms/users/edit.html.erb +1 -0
  72. data/app/views/kuztuscms/users/index.html.erb +28 -0
  73. data/app/views/kuztuscms/users/new.html.erb +1 -0
  74. data/app/views/kuztuscms/users/show.html.erb +15 -0
  75. data/app/views/layouts/kuztuscms/application.html.erb +57 -0
  76. data/config/initializers/devise.rb +225 -0
  77. data/config/initializers/resolver.rb +65 -0
  78. data/config/locales/devise.en.yml +57 -0
  79. data/config/locales/en.yml +5 -0
  80. data/config/routes.rb +18 -0
  81. data/db/migrate/20120218074040_devise_create_kuztuscms_users.rb +52 -0
  82. data/db/migrate/20120218075211_create_kuztuscms_pages.rb +15 -0
  83. data/db/migrate/20120311080242_create_kuztuscms_templates.rb +38 -0
  84. data/db/migrate/20120311141419_create_kuztuscms_articles.rb +10 -0
  85. data/db/migrate/20120311173954_create_kuztuscms_layouts.rb +43 -0
  86. data/db/migrate/20120316081613_create_kuztuscms_settings.rb +10 -0
  87. data/kuztuscms.gemspec +33 -0
  88. data/lib/kuztuscms/engine.rb +13 -0
  89. data/lib/kuztuscms/settings.rb +26 -0
  90. data/lib/kuztuscms/version.rb +3 -0
  91. data/lib/kuztuscms.rb +7 -0
  92. data/lib/tasks/kuztuscms_tasks.rake +4 -0
  93. data/script/rails +8 -0
  94. data/spec/controllers/kuztuscms/articles_controller_spec.rb +164 -0
  95. data/spec/controllers/kuztuscms/languages_controller_spec.rb +164 -0
  96. data/spec/controllers/kuztuscms/layouts_controller_spec.rb +164 -0
  97. data/spec/controllers/kuztuscms/pages_controller_spec.rb +164 -0
  98. data/spec/controllers/kuztuscms/settings_controller_spec.rb +164 -0
  99. data/spec/controllers/kuztuscms/templates_controller_spec.rb +164 -0
  100. data/spec/controllers/kuztuscms/translations_controller_spec.rb +164 -0
  101. data/spec/dummy/README.rdoc +261 -0
  102. data/spec/dummy/Rakefile +7 -0
  103. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  104. data/spec/dummy/app/assets/javascripts/home.js +2 -0
  105. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  106. data/spec/dummy/app/assets/stylesheets/home.css +4 -0
  107. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  108. data/spec/dummy/app/controllers/home_controller.rb +4 -0
  109. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  110. data/spec/dummy/app/helpers/home_helper.rb +2 -0
  111. data/spec/dummy/app/mailers/.gitkeep +0 -0
  112. data/spec/dummy/app/models/.gitkeep +0 -0
  113. data/spec/dummy/app/views/home/index.html.erb +3 -0
  114. data/spec/dummy/app/views/layouts/application.html.erb +16 -0
  115. data/spec/dummy/config/application.rb +62 -0
  116. data/spec/dummy/config/boot.rb +10 -0
  117. data/spec/dummy/config/database.yml +25 -0
  118. data/spec/dummy/config/environment.rb +5 -0
  119. data/spec/dummy/config/environments/development.rb +38 -0
  120. data/spec/dummy/config/environments/production.rb +67 -0
  121. data/spec/dummy/config/environments/test.rb +37 -0
  122. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  123. data/spec/dummy/config/initializers/inflections.rb +15 -0
  124. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  125. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  126. data/spec/dummy/config/initializers/session_store.rb +8 -0
  127. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  128. data/spec/dummy/config/locales/en.yml +9 -0
  129. data/spec/dummy/config/locales/ru.yml +5 -0
  130. data/spec/dummy/config/routes.rb +8 -0
  131. data/spec/dummy/config.ru +4 -0
  132. data/spec/dummy/db/migrate/20120313083011_devise_create_kuztuscms_users.kuztuscms.rb +59 -0
  133. data/spec/dummy/db/migrate/20120313083012_create_kuztuscms_pages.kuztuscms.rb +16 -0
  134. data/spec/dummy/db/migrate/20120313083013_create_kuztuscms_templates.kuztuscms.rb +15 -0
  135. data/spec/dummy/db/migrate/20120313083014_create_kuztuscms_articles.kuztuscms.rb +11 -0
  136. data/spec/dummy/db/migrate/20120313083015_create_kuztuscms_layouts.kuztuscms.rb +41 -0
  137. data/spec/dummy/db/migrate/20120316084434_create_kuztuscms_settings.kuztuscms.rb +11 -0
  138. data/spec/dummy/db/schema.rb +90 -0
  139. data/spec/dummy/lib/assets/.gitkeep +0 -0
  140. data/spec/dummy/log/.gitkeep +0 -0
  141. data/spec/dummy/public/404.html +26 -0
  142. data/spec/dummy/public/422.html +26 -0
  143. data/spec/dummy/public/500.html +25 -0
  144. data/spec/dummy/public/favicon.ico +0 -0
  145. data/spec/dummy/script/rails +6 -0
  146. data/spec/helpers/kuztuscms/articles_helper_spec.rb +15 -0
  147. data/spec/helpers/kuztuscms/languages_helper_spec.rb +15 -0
  148. data/spec/helpers/kuztuscms/layouts_helper_spec.rb +15 -0
  149. data/spec/helpers/kuztuscms/pages_helper_spec.rb +15 -0
  150. data/spec/helpers/kuztuscms/settings_helper_spec.rb +15 -0
  151. data/spec/helpers/kuztuscms/templates_helper_spec.rb +15 -0
  152. data/spec/helpers/kuztuscms/translations_helper_spec.rb +15 -0
  153. data/spec/models/kuztuscms/article_spec.rb +5 -0
  154. data/spec/models/kuztuscms/language_spec.rb +5 -0
  155. data/spec/models/kuztuscms/layout_spec.rb +5 -0
  156. data/spec/models/kuztuscms/page_spec.rb +5 -0
  157. data/spec/models/kuztuscms/setting_spec.rb +5 -0
  158. data/spec/models/kuztuscms/template_spec.rb +5 -0
  159. data/spec/models/kuztuscms/translation_spec.rb +5 -0
  160. data/spec/models/kuztuscms/user_spec.rb +5 -0
  161. data/spec/routing/kuztuscms/articles_routing_spec.rb +35 -0
  162. data/spec/routing/kuztuscms/languages_routing_spec.rb +35 -0
  163. data/spec/routing/kuztuscms/layouts_routing_spec.rb +35 -0
  164. data/spec/routing/kuztuscms/pages_routing_spec.rb +35 -0
  165. data/spec/routing/kuztuscms/settings_routing_spec.rb +35 -0
  166. data/spec/routing/kuztuscms/templates_routing_spec.rb +35 -0
  167. data/spec/routing/kuztuscms/translations_routing_spec.rb +35 -0
  168. data/spec/views/kuztuscms/articles/edit.html.erb_spec.rb +20 -0
  169. data/spec/views/kuztuscms/articles/index.html.erb_spec.rb +24 -0
  170. data/spec/views/kuztuscms/articles/new.html.erb_spec.rb +20 -0
  171. data/spec/views/kuztuscms/articles/show.html.erb_spec.rb +18 -0
  172. data/spec/views/kuztuscms/languages/edit.html.erb_spec.rb +22 -0
  173. data/spec/views/kuztuscms/languages/index.html.erb_spec.rb +28 -0
  174. data/spec/views/kuztuscms/languages/new.html.erb_spec.rb +22 -0
  175. data/spec/views/kuztuscms/languages/show.html.erb_spec.rb +21 -0
  176. data/spec/views/kuztuscms/layouts/edit.html.erb_spec.rb +20 -0
  177. data/spec/views/kuztuscms/layouts/index.html.erb_spec.rb +24 -0
  178. data/spec/views/kuztuscms/layouts/new.html.erb_spec.rb +20 -0
  179. data/spec/views/kuztuscms/layouts/show.html.erb_spec.rb +18 -0
  180. data/spec/views/kuztuscms/pages/edit.html.erb_spec.rb +15 -0
  181. data/spec/views/kuztuscms/pages/index.html.erb_spec.rb +14 -0
  182. data/spec/views/kuztuscms/pages/new.html.erb_spec.rb +15 -0
  183. data/spec/views/kuztuscms/pages/show.html.erb_spec.rb +11 -0
  184. data/spec/views/kuztuscms/settings/edit.html.erb_spec.rb +20 -0
  185. data/spec/views/kuztuscms/settings/index.html.erb_spec.rb +24 -0
  186. data/spec/views/kuztuscms/settings/new.html.erb_spec.rb +20 -0
  187. data/spec/views/kuztuscms/settings/show.html.erb_spec.rb +18 -0
  188. data/spec/views/kuztuscms/templates/edit.html.erb_spec.rb +28 -0
  189. data/spec/views/kuztuscms/templates/index.html.erb_spec.rb +40 -0
  190. data/spec/views/kuztuscms/templates/new.html.erb_spec.rb +28 -0
  191. data/spec/views/kuztuscms/templates/show.html.erb_spec.rb +30 -0
  192. data/spec/views/kuztuscms/translations/edit.html.erb_spec.rb +28 -0
  193. data/spec/views/kuztuscms/translations/index.html.erb_spec.rb +40 -0
  194. data/spec/views/kuztuscms/translations/new.html.erb_spec.rb +28 -0
  195. data/spec/views/kuztuscms/translations/show.html.erb_spec.rb +30 -0
  196. data/test/integration/kuztuscms/setting_test.rb +7 -0
  197. metadata +351 -0
@@ -0,0 +1,56 @@
1
+ <%= form_for [kuztuscms, @user], :html => { :class => 'form-horizontal' } do |f| %>
2
+ <% if @user.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @user.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+ <fieldset>
14
+ <legend>
15
+ <% if @first_user %>
16
+ <%= 'Please create admin user' %>
17
+ <% else %>
18
+ <%= controller.action_name.capitalize %> User
19
+ <% end %>
20
+ </legend>
21
+
22
+ <div class="control-group">
23
+ <%= f.label :username, :class => 'control-label' %>
24
+ <div class="controls">
25
+ <%= f.text_field :username, :class => 'text_field' %>
26
+ </div>
27
+ </div>
28
+
29
+ <div class="control-group">
30
+ <%= f.label :email, :class => 'control-label' %>
31
+ <div class="controls">
32
+ <%= f.email_field :email, :class => 'text_field' %>
33
+ </div>
34
+ </div>
35
+
36
+ <div class="control-group">
37
+ <%= f.label :password, :class => 'control-label' %>
38
+ <div class="controls">
39
+ <%= f.password_field :password, :class => 'text_field' %>
40
+ </div>
41
+ </div>
42
+
43
+ <div class="control-group">
44
+ <%= f.label :password_confirmation, :class => 'control-label' %>
45
+ <div class="controls">
46
+ <%= f.password_field :password_confirmation, :class => 'text_field' %>
47
+ </div>
48
+ </div>
49
+
50
+ <div class="form-actions">
51
+ <%= f.submit nil, :class => 'btn btn-primary' %>
52
+ <%= link_to 'Cancel', kuztuscms.users_path, :class => 'btn' %>
53
+ </div>
54
+ </fieldset>
55
+ <% end %>
56
+
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,28 @@
1
+ <h1>Users</h1>
2
+ <table class="table table-striped">
3
+ <thead>
4
+ <tr>
5
+ <th>ID</th>
6
+ <th>Username</th>
7
+ <th>Email</th>
8
+ <th>Created at</th>
9
+ <th>Actions</th>
10
+ </tr>
11
+ </thead>
12
+ <tbody>
13
+ <% @users.each do |user| %>
14
+ <tr>
15
+ <td><%= user.id %></td>
16
+ <td><%= link_to user.username, user_path(user) %></td>
17
+ <td><%= user.email %></td>
18
+ <td><%= user.created_at %></td>
19
+ <td>
20
+ <%= link_to 'Edit', kuztuscms.edit_user_path(user), :class => 'btn btn-mini' %>
21
+ <%= link_to 'Destroy', kuztuscms.user_path(user), :method => :delete, :confirm => 'Are you sure?', :class => 'btn btn-mini btn-danger' %>
22
+ </td>
23
+ </tr>
24
+ <% end %>
25
+ </tbody>
26
+ </table>
27
+
28
+ <%= link_to 'New', kuztuscms.new_user_path, :class => 'btn btn-primary' %>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,15 @@
1
+ <p>
2
+ <b>Username:</b>
3
+ <%= @user.username %>
4
+ </p>
5
+
6
+ <p>
7
+ <b>Email:</b>
8
+ <%= @user.email %>
9
+ </p>
10
+
11
+ <div class="form-actions">
12
+ <%= link_to 'Back', users_path, :class => 'btn' %>
13
+ <%= link_to 'Edit', edit_user_path(@user), :class => 'btn' %>
14
+ <%= link_to 'Delete', user_path(@user), :method => 'delete', :confirm => 'Are you sure?', :class => 'btn btn-danger' %>
15
+ </div>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Kuztuscms</title>
5
+ <!--[if lt IE 9]>
6
+ <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script>
7
+ <![endif]-->
8
+ <%= stylesheet_link_tag "kuztuscms/application", :media => "all" %>
9
+ <%= javascript_include_tag "kuztuscms/application" %>
10
+ <%= yield :javascripts %>
11
+ <%= yield :stylesheets %>
12
+ <%= csrf_meta_tags %>
13
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
14
+ </head>
15
+ <body>
16
+ <div class="navbar navbar-fixed-top">
17
+ <div class="navbar-inner">
18
+ <div class="container">
19
+ <a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
20
+ <span class="icon-bar"></span>
21
+ <span class="icon-bar"></span>
22
+ <span class="icon-bar"></span>
23
+ </a>
24
+ <%= link_to 'KuztusCMS', kuztuscms.root_url, :class => 'brand' %>
25
+ <div class="nav-collapse">
26
+ <ul class="nav">
27
+ <li><%= link_to 'Pages', kuztuscms.pages_url %></li>
28
+ <li><%= link_to 'Articles', kuztuscms.articles_url %></li>
29
+ <li><%= link_to 'Layouts', kuztuscms.layouts_url %></li>
30
+ <li><%= link_to 'Templates', kuztuscms.templates_url %></li>
31
+ <li><%= link_to 'Settings', kuztuscms.settings_url %></li>
32
+ <li><%= link_to 'Users', kuztuscms.users_url %></li>
33
+ </ul>
34
+ <ul class="nav pull-right">
35
+ <li><%= link_to 'Sign out', kuztuscms.destroy_user_session_url, :method => :delete %> </li>
36
+ </ul>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ </div>
41
+ <div class=container>
42
+ <div class=row>
43
+ <div class=span12>
44
+ <% if alert %>
45
+ <div class="alert"> <a class="close" data-dismiss="alert">×</a> <%= alert %> </div>
46
+ <% end %>
47
+ <% if notice %>
48
+ <div class="alert alert-info"> <a class="close" data-dismiss="alert">×</a> <%= notice %> </div>
49
+ <% end %>
50
+
51
+ <%= yield %>
52
+ </div>
53
+ </div>
54
+ </div>
55
+
56
+ </body>
57
+ </html>
@@ -0,0 +1,225 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth.
2
+ # Many of these configuration options can be set straight in your model.
3
+ Devise.setup do |config|
4
+ config.parent_controller = "KuztuscmsController"
5
+ config.router_name = :kuztuscms
6
+ # ==> Mailer Configuration
7
+ # Configure the e-mail address which will be shown in Devise::Mailer,
8
+ # note that it will be overwritten if you use your own mailer class with default "from" parameter.
9
+ config.mailer_sender = Proc.new{|scope| Kuztuscms::Settings.get('devise-mailer-sender')}
10
+
11
+ # Configure the class responsible to send e-mails.
12
+ # config.mailer = "Devise::Mailer"
13
+
14
+ # Automatically apply schema changes in tableless databases
15
+ config.apply_schema = false
16
+
17
+ # ==> ORM configuration
18
+ # Load and configure the ORM. Supports :active_record (default) and
19
+ # :mongoid (bson_ext recommended) by default. Other ORMs may be
20
+ # available as additional gems.
21
+ require 'devise/orm/active_record'
22
+
23
+ # ==> Configuration for any authentication mechanism
24
+ # Configure which keys are used when authenticating a user. The default is
25
+ # just :email. You can configure it to use [:username, :subdomain], so for
26
+ # authenticating a user, both parameters are required. Remember that those
27
+ # parameters are used only when authenticating and not when retrieving from
28
+ # session. If you need permissions, you should implement that in a before filter.
29
+ # You can also supply a hash where the value is a boolean determining whether
30
+ # or not authentication should be aborted when the value is not present.
31
+ # config.authentication_keys = [ :email ]
32
+
33
+ # Configure parameters from the request object used for authentication. Each entry
34
+ # given should be a request method and it will automatically be passed to the
35
+ # find_for_authentication method and considered in your model lookup. For instance,
36
+ # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
37
+ # The same considerations mentioned for authentication_keys also apply to request_keys.
38
+ # config.request_keys = []
39
+
40
+ # Configure which authentication keys should be case-insensitive.
41
+ # These keys will be downcased upon creating or modifying a user and when used
42
+ # to authenticate or find a user. Default is :email.
43
+ config.case_insensitive_keys = [ :email ]
44
+
45
+ # Configure which authentication keys should have whitespace stripped.
46
+ # These keys will have whitespace before and after removed upon creating or
47
+ # modifying a user and when used to authenticate or find a user. Default is :email.
48
+ config.strip_whitespace_keys = [ :email ]
49
+
50
+ # Tell if authentication through request.params is enabled. True by default.
51
+ # It can be set to an array that will enable params authentication only for the
52
+ # given strategies, for example, `config.params_authenticatable = [:database]` will
53
+ # enable it only for database (email + password) authentication.
54
+ # config.params_authenticatable = true
55
+
56
+ # Tell if authentication through HTTP Basic Auth is enabled. False by default.
57
+ # It can be set to an array that will enable http authentication only for the
58
+ # given strategies, for example, `config.http_authenticatable = [:token]` will
59
+ # enable it only for token authentication.
60
+ # config.http_authenticatable = false
61
+
62
+ # If http headers should be returned for AJAX requests. True by default.
63
+ # config.http_authenticatable_on_xhr = true
64
+
65
+ # The realm used in Http Basic Authentication. "Application" by default.
66
+ # config.http_authentication_realm = "Application"
67
+
68
+ # It will change confirmation, password recovery and other workflows
69
+ # to behave the same regardless if the e-mail provided was right or wrong.
70
+ # Does not affect registerable.
71
+ # config.paranoid = true
72
+
73
+ # By default Devise will store the user in session. You can skip storage for
74
+ # :http_auth and :token_auth by adding those symbols to the array below.
75
+ # Notice that if you are skipping storage for all authentication paths, you
76
+ # may want to disable generating routes to Devise's sessions controller by
77
+ # passing :skip => :sessions to `devise_for` in your config/routes.rb
78
+ config.skip_session_storage = [:http_auth]
79
+
80
+ # ==> Configuration for :database_authenticatable
81
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
82
+ # using other encryptors, it sets how many times you want the password re-encrypted.
83
+ #
84
+ # Limiting the stretches to just one in testing will increase the performance of
85
+ # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
86
+ # a value less than 10 in other environments.
87
+ config.stretches = Rails.env.test? ? 1 : 10
88
+
89
+ # Setup a pepper to generate the encrypted password.
90
+ # config.pepper = "f0805a30a59a9eeda4fd4cca242f64ac75562cc5b421888dfe4f2d723bdbe9156b570bef9548810ff42615c57fa31b46f378389f000831587fffc36a9eb20ae2"
91
+
92
+ # ==> Configuration for :confirmable
93
+ # A period that the user is allowed to access the website even without
94
+ # confirming his account. For instance, if set to 2.days, the user will be
95
+ # able to access the website for two days without confirming his account,
96
+ # access will be blocked just in the third day. Default is 0.days, meaning
97
+ # the user cannot access the website without confirming his account.
98
+ # config.allow_unconfirmed_access_for = 2.days
99
+
100
+ # If true, requires any email changes to be confirmed (exctly the same way as
101
+ # initial account confirmation) to be applied. Requires additional unconfirmed_email
102
+ # db field (see migrations). Until confirmed new email is stored in
103
+ # unconfirmed email column, and copied to email column on successful confirmation.
104
+ config.reconfirmable = true
105
+
106
+ # Defines which key will be used when confirming an account
107
+ # config.confirmation_keys = [ :email ]
108
+
109
+ # ==> Configuration for :rememberable
110
+ # The time the user will be remembered without asking for credentials again.
111
+ config.remember_for = 2.weeks
112
+
113
+ # If true, extends the user's remember period when remembered via cookie.
114
+ # config.extend_remember_period = false
115
+
116
+ # If true, uses the password salt as remember token. This should be turned
117
+ # to false if you are not using database authenticatable.
118
+ config.use_salt_as_remember_token = true
119
+
120
+ # Options to be passed to the created cookie. For instance, you can set
121
+ # :secure => true in order to force SSL only cookies.
122
+ # config.cookie_options = {}
123
+
124
+ # ==> Configuration for :validatable
125
+ # Range for password length. Default is 6..128.
126
+ # config.password_length = 6..128
127
+
128
+ # Email regex used to validate email formats. It simply asserts that
129
+ # an one (and only one) @ exists in the given string. This is mainly
130
+ # to give user feedback and not to assert the e-mail validity.
131
+ # config.email_regexp = /\A[^@]+@[^@]+\z/
132
+
133
+ # ==> Configuration for :timeoutable
134
+ # The time you want to timeout the user session without activity. After this
135
+ # time the user will be asked for credentials again. Default is 30 minutes.
136
+ config.timeout_in = 30.minutes
137
+
138
+ # ==> Configuration for :lockable
139
+ # Defines which strategy will be used to lock an account.
140
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
141
+ # :none = No lock strategy. You should handle locking by yourself.
142
+ config.lock_strategy = :failed_attempts
143
+
144
+ # Defines which key will be used when locking and unlocking an account
145
+ # config.unlock_keys = [ :email ]
146
+
147
+ # Defines which strategy will be used to unlock an account.
148
+ # :email = Sends an unlock link to the user email
149
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
150
+ # :both = Enables both strategies
151
+ # :none = No unlock strategy. You should handle unlocking by yourself.
152
+ config.unlock_strategy = :both
153
+
154
+ # Number of authentication tries before locking an account if lock_strategy
155
+ # is failed attempts.
156
+ config.maximum_attempts = 5
157
+
158
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
159
+ config.unlock_in = 1.hour
160
+
161
+ # ==> Configuration for :recoverable
162
+ #
163
+ # Defines which key will be used when recovering the password for an account
164
+ # config.reset_password_keys = [ :email ]
165
+
166
+ # Time interval you can reset your password with a reset password key.
167
+ # Don't put a too small interval or your users won't have the time to
168
+ # change their passwords.
169
+ config.reset_password_within = 6.hours
170
+
171
+ # ==> Configuration for :encryptable
172
+ # Allow you to use another encryption algorithm besides bcrypt (default). You can use
173
+ # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
174
+ # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
175
+ # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
176
+ # REST_AUTH_SITE_KEY to pepper)
177
+ config.encryptor = :bcrypt
178
+
179
+ # ==> Configuration for :token_authenticatable
180
+ # Defines name of the authentication token params key
181
+ # config.token_authentication_key = :auth_token
182
+
183
+ # ==> Scopes configuration
184
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
185
+ # "users/sessions/new". It's turned off by default because it's slower if you
186
+ # are using only default views.
187
+ # config.scoped_views = false
188
+
189
+ # Configure the default scope given to Warden. By default it's the first
190
+ # devise role declared in your routes (usually :user).
191
+ # config.default_scope = :user
192
+
193
+ # Configure sign_out behavior.
194
+ # Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
195
+ # The default is true, which means any logout action will sign out all active scopes.
196
+ # config.sign_out_all_scopes = true
197
+
198
+ # ==> Navigation configuration
199
+ # Lists the formats that should be treated as navigational. Formats like
200
+ # :html, should redirect to the sign in page when the user does not have
201
+ # access, but formats like :xml or :json, should return 401.
202
+ #
203
+ # If you have any extra navigational formats, like :iphone or :mobile, you
204
+ # should add them to the navigational formats lists.
205
+ #
206
+ # The "*/*" below is required to match Internet Explorer requests.
207
+ # config.navigational_formats = ["*/*", :html]
208
+
209
+ # The default HTTP method used to sign out a resource. Default is :delete.
210
+ config.sign_out_via = :delete
211
+
212
+ # ==> OmniAuth
213
+ # Add a new OmniAuth provider. Check the wiki for more information on setting
214
+ # up on your models and hooks.
215
+ # config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
216
+
217
+ # ==> Warden configuration
218
+ # If you want to use other strategies, that are not supported by Devise, or
219
+ # change the failure app, you can configure them inside the config.warden block.
220
+ #
221
+ # config.warden do |manager|
222
+ # manager.intercept_401 = false
223
+ # manager.default_strategies(:scope => :user).unshift :some_external_strategy
224
+ # end
225
+ end
@@ -0,0 +1,65 @@
1
+ module Kuztuscms
2
+ class Resolver < ActionView::Resolver
3
+ require "singleton"
4
+ include Singleton
5
+
6
+ def find_templates(name, prefix, partial, details)
7
+ conditions = {
8
+ :path => normalize_path(name, prefix),
9
+ :locale => normalize_array(details[:locale]).first,
10
+ :format => normalize_array(details[:formats]).first,
11
+ :handler => normalize_array(details[:handlers]),
12
+ :partial => partial || false
13
+ }
14
+
15
+ if prefix == 'layouts'
16
+ Layout.where(conditions).map do |record|
17
+ initialize_template(record)
18
+ end
19
+ else
20
+ Template.where(conditions).map do |record|
21
+ initialize_template(record)
22
+ end
23
+ end
24
+ end
25
+
26
+ # Normalize name and prefix, so the tuple ["index", "users"] becomes
27
+ # "users/index" and the tuple ["template", nil] becomes "template".
28
+ def normalize_path(name, prefix)
29
+ return name if prefix == "kuztuscms/pages"
30
+ return name if prefix == "layouts"
31
+
32
+ prefix.present? ? "#{prefix}/#{name}" : name
33
+ end
34
+
35
+ # Normalize arrays by converting all symbols to strings.
36
+ def normalize_array(array)
37
+ array.map(&:to_s)
38
+ end
39
+
40
+ # Initialize an ActionView::Template object based on the record found.
41
+ def initialize_template(record)
42
+ source = record.body
43
+ identifier = "Template - #{record.id} - #{record.path.inspect}"
44
+ handler = ActionView::Template.registered_template_handler(record.handler)
45
+
46
+ details = {
47
+ :format => Mime[record.format],
48
+ :updated_at => record.updated_at,
49
+ :virtual_path => virtual_path(record.path, record.partial)
50
+ }
51
+
52
+ ActionView::Template.new(source, identifier, handler, details)
53
+ end
54
+
55
+ # Make paths as "users/user" become "users/_user" for partials.
56
+ def virtual_path(path, partial)
57
+ return path unless partial
58
+ if index = path.rindex("/")
59
+ path.insert(index + 1, "_")
60
+ else
61
+ "_#{path}"
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,57 @@
1
+ # Additional translations at https://github.com/plataformatec/devise/wiki/I18n
2
+
3
+ en:
4
+ errors:
5
+ messages:
6
+ expired: "has expired, please request a new one"
7
+ not_found: "not found"
8
+ already_confirmed: "was already confirmed, please try signing in"
9
+ not_locked: "was not locked"
10
+ not_saved:
11
+ one: "1 error prohibited this %{resource} from being saved:"
12
+ other: "%{count} errors prohibited this %{resource} from being saved:"
13
+
14
+ devise:
15
+ failure:
16
+ already_authenticated: 'You are already signed in.'
17
+ unauthenticated: 'You need to sign in or sign up before continuing.'
18
+ unconfirmed: 'You have to confirm your account before continuing.'
19
+ locked: 'Your account is locked.'
20
+ invalid: 'Invalid username or password.'
21
+ invalid_token: 'Invalid authentication token.'
22
+ timeout: 'Your session expired, please sign in again to continue.'
23
+ inactive: 'Your account was not activated yet.'
24
+ sessions:
25
+ signed_in: 'Signed in successfully.'
26
+ signed_out: 'Signed out successfully.'
27
+ passwords:
28
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
29
+ updated: 'Your password was changed successfully. You are now signed in.'
30
+ updated_not_active: 'Your password was changed successfully.'
31
+ send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
32
+ confirmations:
33
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
34
+ send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
35
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
36
+ registrations:
37
+ signed_up: 'Welcome! You have signed up successfully.'
38
+ signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
39
+ signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
40
+ signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
41
+ updated: 'You updated your account successfully.'
42
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
43
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
44
+ unlocks:
45
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
46
+ unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
47
+ send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
48
+ omniauth_callbacks:
49
+ success: 'Successfully authorized from %{kind} account.'
50
+ failure: 'Could not authorize you from %{kind} because "%{reason}".'
51
+ mailer:
52
+ confirmation_instructions:
53
+ subject: 'Confirmation instructions'
54
+ reset_password_instructions:
55
+ subject: 'Reset password instructions'
56
+ unlock_instructions:
57
+ subject: 'Unlock Instructions'
@@ -0,0 +1,5 @@
1
+ en:
2
+ activerecord:
3
+ attributes:
4
+ user:
5
+ username: "Username"
data/config/routes.rb ADDED
@@ -0,0 +1,18 @@
1
+ Kuztuscms::Engine.routes.draw do
2
+
3
+ devise_for :users,
4
+ :class_name => "Kuztuscms::User",
5
+ :module => :devise,
6
+ :path => :accounts
7
+
8
+ resources :pages
9
+ resources :users
10
+ resources :articles
11
+ resources :templates, :except => :show
12
+ resources :layouts, :except => :show
13
+ resources :settings, :except => :show
14
+
15
+ get '/*page' => 'pages#show'
16
+
17
+ root :to => 'home#index'
18
+ end
@@ -0,0 +1,52 @@
1
+ class DeviseCreateKuztuscmsUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table(:kuztuscms_users) do |t|
4
+ t.string :email
5
+
6
+ ## Database authenticatable
7
+ t.string :username, :null => false, :default => ""
8
+ t.string :encrypted_password, :null => false, :default => ""
9
+
10
+ ## Recoverable
11
+ t.string :reset_password_token
12
+ t.datetime :reset_password_sent_at
13
+
14
+ ## Rememberable
15
+ t.datetime :remember_created_at
16
+
17
+ ## Trackable
18
+ t.integer :sign_in_count, :default => 0
19
+ t.datetime :current_sign_in_at
20
+ t.datetime :last_sign_in_at
21
+ t.string :current_sign_in_ip
22
+ t.string :last_sign_in_ip
23
+
24
+ ## Encryptable
25
+ t.string :password_salt
26
+
27
+ ## Confirmable
28
+ # t.string :confirmation_token
29
+ # t.datetime :confirmed_at
30
+ # t.datetime :confirmation_sent_at
31
+ # t.string :unconfirmed_email # Only if using reconfirmable
32
+
33
+ ## Lockable
34
+ t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
35
+ t.string :unlock_token # Only if unlock strategy is :email or :both
36
+ t.datetime :locked_at
37
+
38
+ ## Token authenticatable
39
+ t.string :authentication_token
40
+
41
+
42
+ t.timestamps
43
+ end
44
+
45
+ add_index :kuztuscms_users, :email, :unique => true
46
+ add_index :kuztuscms_users, :reset_password_token, :unique => true
47
+ # add_index :kuztuscms_users, :confirmation_token, :unique => true
48
+ add_index :kuztuscms_users, :unlock_token, :unique => true
49
+ add_index :kuztuscms_users, :authentication_token, :unique => true
50
+
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ class CreateKuztuscmsPages < ActiveRecord::Migration
2
+ def change
3
+ create_table :kuztuscms_pages do |t|
4
+ t.string :name
5
+ t.string :title
6
+ t.string :path
7
+ t.text :description
8
+ t.text :keywords
9
+ t.integer :layout_id
10
+ t.integer :article_id
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ class CreateKuztuscmsTemplates < ActiveRecord::Migration
2
+ def change
3
+ create_table :kuztuscms_templates do |t|
4
+ t.text :body
5
+ t.string :path
6
+ t.string :format
7
+ t.string :locale
8
+ t.string :handler
9
+ t.boolean :partial, :default => false
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ body = <<EOF
15
+ <% if code = @settings.get('google-analytics') %>
16
+ <script type="text/javascript">
17
+ var _gaq = _gaq || [];
18
+ _gaq.push(['_setAccount', '<%= code %>']);
19
+ _gaq.push(['_trackPageview']);
20
+
21
+ (function() {
22
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
23
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
24
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
25
+ })();
26
+ </script>
27
+ <% end %>
28
+ EOF
29
+ Kuztuscms::Template.create(
30
+ :body => body,
31
+ :path => 'google-analytics',
32
+ :format => 'html',
33
+ :locale => 'en',
34
+ :handler => 'erb',
35
+ :partial => true
36
+ )
37
+ end
38
+ end
@@ -0,0 +1,10 @@
1
+ class CreateKuztuscmsArticles < ActiveRecord::Migration
2
+ def change
3
+ create_table :kuztuscms_articles do |t|
4
+ t.string :name
5
+ t.text :body
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end