kuztuscms 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,115 @@
1
+ .CodeMirror {
2
+ line-height: 1em;
3
+ font-family: monospace;
4
+ border: 1px solid #ccc;
5
+ }
6
+
7
+ .CodeMirror-scroll {
8
+ height: auto;
9
+ overflow-y: hidden;
10
+ overflow-x: auto;
11
+ width: 100%
12
+ /* This is needed to prevent an IE[67] bug where the scrolled content
13
+ is visible outside of the scrolling box. */
14
+ position: relative;
15
+ outline: none;
16
+ }
17
+
18
+ .CodeMirror-gutter {
19
+ position: absolute; left: 0; top: 0;
20
+ z-index: 10;
21
+ background-color: #f7f7f7;
22
+ border-right: 1px solid #eee;
23
+ min-width: 2em;
24
+ height: 100%;
25
+ }
26
+ .CodeMirror-gutter-text {
27
+ color: #aaa;
28
+ text-align: right;
29
+ padding: .4em .2em .4em .4em;
30
+ white-space: pre !important;
31
+ }
32
+ .CodeMirror-lines {
33
+ padding: .4em;
34
+ white-space: pre;
35
+ }
36
+
37
+ .CodeMirror pre {
38
+ -moz-border-radius: 0;
39
+ -webkit-border-radius: 0;
40
+ -o-border-radius: 0;
41
+ border-radius: 0;
42
+ border-width: 0; margin: 0; padding: 0; background: transparent;
43
+ font-family: inherit;
44
+ font-size: inherit;
45
+ padding: 0; margin: 0;
46
+ white-space: pre;
47
+ word-wrap: normal;
48
+ }
49
+
50
+ .CodeMirror-wrap pre {
51
+ word-wrap: break-word;
52
+ white-space: pre-wrap;
53
+ }
54
+ .CodeMirror-wrap .CodeMirror-scroll {
55
+ overflow-x: hidden;
56
+ }
57
+
58
+ .CodeMirror textarea {
59
+ outline: none !important;
60
+ }
61
+
62
+ .CodeMirror pre.CodeMirror-cursor {
63
+ z-index: 10;
64
+ position: absolute;
65
+ visibility: hidden;
66
+ border-left: 1px solid black;
67
+ border-right:none;
68
+ width:0;
69
+ }
70
+ .CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
71
+ .CodeMirror-focused pre.CodeMirror-cursor {
72
+ visibility: visible;
73
+ }
74
+
75
+ div.CodeMirror-selected { background: #d9d9d9; }
76
+ .CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
77
+
78
+ .CodeMirror-searching {
79
+ background: #ffa;
80
+ background: rgba(255, 255, 0, .4);
81
+ }
82
+
83
+ /* Default theme */
84
+
85
+ .cm-s-default span.cm-keyword {color: #708;}
86
+ .cm-s-default span.cm-atom {color: #219;}
87
+ .cm-s-default span.cm-number {color: #164;}
88
+ .cm-s-default span.cm-def {color: #00f;}
89
+ .cm-s-default span.cm-variable {color: black;}
90
+ .cm-s-default span.cm-variable-2 {color: #05a;}
91
+ .cm-s-default span.cm-variable-3 {color: #085;}
92
+ .cm-s-default span.cm-property {color: black;}
93
+ .cm-s-default span.cm-operator {color: black;}
94
+ .cm-s-default span.cm-comment {color: #a50;}
95
+ .cm-s-default span.cm-string {color: #a11;}
96
+ .cm-s-default span.cm-string-2 {color: #f50;}
97
+ .cm-s-default span.cm-meta {color: #555;}
98
+ .cm-s-default span.cm-error {color: #f00;}
99
+ .cm-s-default span.cm-qualifier {color: #555;}
100
+ .cm-s-default span.cm-builtin {color: #30a;}
101
+ .cm-s-default span.cm-bracket {color: #cc7;}
102
+ .cm-s-default span.cm-tag {color: #170;}
103
+ .cm-s-default span.cm-attribute {color: #00c;}
104
+ .cm-s-default span.cm-header {color: #a0a;}
105
+ .cm-s-default span.cm-quote {color: #090;}
106
+ .cm-s-default span.cm-hr {color: #999;}
107
+ .cm-s-default span.cm-link {color: #00c;}
108
+
109
+ span.cm-header, span.cm-strong {font-weight: bold;}
110
+ span.cm-em {font-style: italic;}
111
+ span.cm-emstrong {font-style: italic; font-weight: bold;}
112
+ span.cm-link {text-decoration: underline;}
113
+
114
+ div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
115
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
@@ -0,0 +1,53 @@
1
+ module Kuztuscms
2
+ class ArticlesController < KuztuscmsController
3
+ # GET /articles
4
+ def index
5
+ @articles = Article.all
6
+ end
7
+
8
+ # GET /articles/1
9
+ def show
10
+ @article = Article.find(params[:id])
11
+ end
12
+
13
+ # GET /articles/new
14
+ def new
15
+ @article = Article.new
16
+ end
17
+
18
+ # GET /articles/1/edit
19
+ def edit
20
+ @article = Article.find(params[:id])
21
+ end
22
+
23
+ # POST /articles
24
+ def create
25
+ @article = Article.new(params[:article])
26
+
27
+ if @article.save
28
+ redirect_to articles_url, notice: 'Article was successfully created.'
29
+ else
30
+ render action: "new"
31
+ end
32
+ end
33
+
34
+ # PUT /articles/1
35
+ def update
36
+ @article = Article.find(params[:id])
37
+
38
+ if @article.update_attributes(params[:article])
39
+ redirect_to articles_url, notice: 'Article was successfully updated.'
40
+ else
41
+ render action: "edit"
42
+ end
43
+ end
44
+
45
+ # DELETE /articles/1
46
+ def destroy
47
+ @article = Article.find(params[:id])
48
+ @article.destroy
49
+
50
+ redirect_to articles_url
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,6 @@
1
+ module Kuztuscms
2
+ class HomeController < KuztuscmsController
3
+ def index
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,75 @@
1
+ module Kuztuscms
2
+ class LayoutsController < KuztuscmsController
3
+ before_filter :build_locales_list, :only => [:new, :edit, :create, :update]
4
+ before_filter :build_handlers_list, :only => [:new, :edit, :create, :update]
5
+ before_filter :build_formats_list, :only => [:new, :edit, :create, :update]
6
+
7
+ # GET /layouts
8
+ def index
9
+ @layouts = Layout.all
10
+ end
11
+
12
+ # GET /layouts/1
13
+ def show
14
+ @layout = Layout.find(params[:id])
15
+ end
16
+
17
+ # GET /layouts/new
18
+ def new
19
+ @layout = Layout.new(:format => 'html', :body => Layout.find_by_path('default').body)
20
+ end
21
+
22
+ # GET /layouts/1/edit
23
+ def edit
24
+ @layout = Layout.find(params[:id])
25
+ end
26
+
27
+ # POST /layouts
28
+ def create
29
+ @layout = Layout.new(params[:layout])
30
+ @layout.partial = false
31
+
32
+ if @layout.save
33
+ redirect_to layouts_url, notice: 'Layout was successfully created.'
34
+ else
35
+ render action: "new"
36
+ end
37
+ end
38
+
39
+ # PUT /layouts/1
40
+ def update
41
+ @layout = Layout.find(params[:id])
42
+
43
+ if @layout.update_attributes(params[:layout])
44
+ redirect_to layouts_url, notice: 'Layout was successfully updated.'
45
+ else
46
+ render action: "edit"
47
+ end
48
+ end
49
+
50
+ # DELETE /layouts/1
51
+ def destroy
52
+ @layout = Layout.find(params[:id])
53
+ if @layout.path == 'default'
54
+ redirect_to layouts_url, notice: 'You cannot delete default layout'
55
+ else
56
+ @layout.destroy
57
+ redirect_to layouts_url, notice: 'Layout was successfully deleted.'
58
+ end
59
+ end
60
+
61
+ private
62
+
63
+ def build_formats_list
64
+ @formats = Mime::SET.symbols.map(&:to_s)
65
+ end
66
+
67
+ def build_locales_list
68
+ @locales = I18n.available_locales.map(&:to_s)
69
+ end
70
+
71
+ def build_handlers_list
72
+ @handlers = ActionView::Template::Handlers.extensions.map(&:to_s)
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,73 @@
1
+ module Kuztuscms
2
+ class PagesController < KuztuscmsController
3
+ append_view_path Kuztuscms::Resolver.instance
4
+
5
+ before_filter :build_articles_list, :only => [:new, :edit, :create, :update]
6
+ before_filter :build_layouts_list, :only => [:new, :edit, :create, :update]
7
+
8
+ # GET /pages
9
+ def index
10
+ @pages = Page.all
11
+ end
12
+
13
+ def show
14
+ if @page = Page.find_by_path(params[:page])
15
+ @settings = Kuztuscms::Settings
16
+ @article = @page.article
17
+ render :layout => @page.layout.path
18
+ else
19
+ raise ActionController::RoutingError.new('Not Found')
20
+ end
21
+ end
22
+
23
+ # GET /pages/new
24
+ def new
25
+ @page = Page.new
26
+ end
27
+
28
+ # GET /pages/1/edit
29
+ def edit
30
+ @page = Page.find(params[:id])
31
+ end
32
+
33
+ # POST /pages
34
+ def create
35
+ @page = Page.new(params[:page])
36
+
37
+ if @page.save
38
+ redirect_to kuztuscms.pages_url, notice: 'Page was successfully created.'
39
+ else
40
+ render action: "new"
41
+ end
42
+ end
43
+
44
+ # PUT /pages/1
45
+ def update
46
+ @page = Page.find(params[:id])
47
+
48
+ if @page.update_attributes(params[:page])
49
+ redirect_to kuztuscms.pages_url, notice: 'Page was successfully updated.'
50
+ else
51
+ render action: "edit"
52
+ end
53
+ end
54
+
55
+ # DELETE /pages/1
56
+ def destroy
57
+ @page = Page.find(params[:id])
58
+ @page.destroy
59
+
60
+ redirect_to kuztuscms.pages_url
61
+ end
62
+
63
+ private
64
+
65
+ def build_layouts_list
66
+ @layouts = Layout.all
67
+ end
68
+
69
+ def build_articles_list
70
+ @articles = Article.all
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,48 @@
1
+ module Kuztuscms
2
+ class SettingsController < KuztuscmsController
3
+ # GET /settings
4
+ def index
5
+ @settings = Setting.all
6
+ end
7
+
8
+ # GET /settings/new
9
+ def new
10
+ @setting = Setting.new
11
+ end
12
+
13
+ # GET /settings/1/edit
14
+ def edit
15
+ @setting = Setting.find(params[:id])
16
+ end
17
+
18
+ # POST /settings
19
+ def create
20
+ @setting = Setting.new(params[:setting])
21
+
22
+ if @setting.save
23
+ redirect_to settings_url, notice: 'Setting was successfully created.'
24
+ else
25
+ render action: "new"
26
+ end
27
+ end
28
+
29
+ # PUT /settings/1
30
+ def update
31
+ @setting = Setting.find(params[:id])
32
+
33
+ if @setting.update_attributes(params[:setting])
34
+ redirect_to settings_url, notice: 'Setting was successfully updated.'
35
+ else
36
+ render action: "edit"
37
+ end
38
+ end
39
+
40
+ # DELETE /settings/1
41
+ def destroy
42
+ @setting = Setting.find(params[:id])
43
+ @setting.destroy
44
+
45
+ redirect_to settings_url
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,72 @@
1
+ module Kuztuscms
2
+ class TemplatesController < KuztuscmsController
3
+ before_filter :build_locales_list, :only => [:new, :edit, :create, :update]
4
+ before_filter :build_handlers_list, :only => [:new, :edit, :create, :update]
5
+ before_filter :build_formats_list, :only => [:new, :edit, :create, :update]
6
+
7
+ # GET /templates
8
+ def index
9
+ @templates = Template.all
10
+ end
11
+
12
+ # GET /templates/1
13
+ def show
14
+ @template = Template.find(params[:id])
15
+ end
16
+
17
+ # GET /templates/new
18
+ def new
19
+ @template = Template.new(:format => 'html')
20
+ end
21
+
22
+ # GET /templates/1/edit
23
+ def edit
24
+ @template = Template.find(params[:id])
25
+ end
26
+
27
+ # POST /templates
28
+ def create
29
+ @template = Template.new(params[:template])
30
+ @template.partial = true
31
+
32
+ if @template.save
33
+ redirect_to templates_url, notice: 'Template was successfully created.'
34
+ else
35
+ render action: "new"
36
+ end
37
+ end
38
+
39
+ # PUT /templates/1
40
+ def update
41
+ @template = Template.find(params[:id])
42
+
43
+ if @template.update_attributes(params[:template])
44
+ redirect_to templates_url, notice: 'Template was successfully updated.'
45
+ else
46
+ render action: "edit"
47
+ end
48
+ end
49
+
50
+ # DELETE /templates/1
51
+ def destroy
52
+ @template = Template.find(params[:id])
53
+ @template.destroy
54
+
55
+ redirect_to templates_url
56
+ end
57
+
58
+ private
59
+
60
+ def build_formats_list
61
+ @formats = Mime::SET.symbols.map(&:to_s)
62
+ end
63
+
64
+ def build_locales_list
65
+ @locales = I18n.available_locales.map(&:to_s)
66
+ end
67
+
68
+ def build_handlers_list
69
+ @handlers = ActionView::Template::Handlers.extensions.map(&:to_s)
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,74 @@
1
+ module Kuztuscms
2
+ class UsersController < KuztuscmsController
3
+ before_filter :authenticate_for_cms!, :except => [:new, :create]
4
+
5
+ # GET /users
6
+ def index
7
+ @users = User.all
8
+ end
9
+
10
+ # GET /users/1
11
+ def show
12
+ @user = User.find(params[:id])
13
+ end
14
+
15
+ # GET /users/new
16
+ def new
17
+ check_first_user
18
+ @user = User.new
19
+ end
20
+
21
+ # GET /users/1/edit
22
+ def edit
23
+ @user = User.find(params[:id])
24
+ end
25
+
26
+ # POST /users
27
+ def create
28
+ check_first_user
29
+ @user = User.new(params[:user])
30
+
31
+ if @user.save
32
+ if @first_user
33
+ sign_in @user
34
+ Settings.set 'devise-mailer-sender', @user.email
35
+ redirect_to root_url
36
+ else
37
+ redirect_to @user, notice: 'User was successfully created.'
38
+ end
39
+ else
40
+ render action: "new"
41
+ end
42
+ end
43
+
44
+ # PUT /users/1
45
+ def update
46
+ @user = User.find(params[:id])
47
+
48
+ if @user.update_attributes(params[:user])
49
+ redirect_to @user, notice: 'User was successfully updated.'
50
+ else
51
+ render action: "edit"
52
+ end
53
+ end
54
+
55
+ # DELETE /users/1
56
+ def destroy
57
+ @user = User.find(params[:id])
58
+ @user.destroy
59
+
60
+ redirect_to kuztuscms.users_url
61
+ end
62
+
63
+ private
64
+
65
+ def check_first_user
66
+ if User.count > 0
67
+ authenticate_user!
68
+ @first_user = false
69
+ else
70
+ @first_user = true
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,23 @@
1
+ class KuztuscmsController < ActionController::Base
2
+ before_filter :authenticate_for_cms!
3
+ layout 'kuztuscms/application'
4
+
5
+ private
6
+
7
+ def authenticate_for_cms!
8
+ if Kuztuscms::User.count > 0
9
+ authenticate_user!
10
+ else
11
+ redirect_to :controller => :users, :action => :new
12
+ end
13
+ end
14
+
15
+ def after_sign_out_path_for(resource_or_scope)
16
+ kuztuscms.root_path
17
+ end
18
+
19
+ def signed_in_root_path(resource_or_scope)
20
+ kuztuscms.root_path
21
+ end
22
+
23
+ end
@@ -0,0 +1,4 @@
1
+ module Kuztuscms
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Kuztuscms
2
+ class Article < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,14 @@
1
+ module Kuztuscms
2
+ class Layout < ActiveRecord::Base
3
+ validates :body, :path, :presence => true
4
+ validates :path, :format => { :with => /\A[a-z0-9_]+\z/, :message => "Only lowercase letters, numbers and dashes allowed"}
5
+
6
+ validates :format, :inclusion => Mime::SET.symbols.map(&:to_s)
7
+ validates :locale, :inclusion => I18n.available_locales.map(&:to_s)
8
+ validates :handler, :inclusion => ActionView::Template::Handlers.extensions.map(&:to_s)
9
+
10
+ after_save do
11
+ Kuztuscms::Resolver.instance.clear_cache
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,8 @@
1
+ module Kuztuscms
2
+ class Page < ActiveRecord::Base
3
+ belongs_to :layout, :foreign_key => :layout_id, :class_name => 'Layout'
4
+ belongs_to :article, :foreign_key => :article_id, :class_name => 'Article'
5
+
6
+ validates :name, :path, :layout_id, :article_id, :presence => true
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ module Kuztuscms
2
+ class Setting < ActiveRecord::Base
3
+ validates :value, :presence => true
4
+ validates :key, :uniqueness => true,
5
+ :format => { :with => /\A[a-z0-9_-]+\z/, :message => "Only lowercase letters, numbers and dashes allowed"},
6
+ :presence => true
7
+ after_save do
8
+ Kuztuscms::Settings.clear_cache
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Kuztuscms
2
+ class Template < ActiveRecord::Base
3
+ validates :body, :path, :presence => true
4
+ validates :path, :format => { :with => /\A[a-z0-9_-]+\z/, :message => "Only lowercase letters, numbers and dashes allowed"}
5
+
6
+ validates :format, :inclusion => Mime::SET.symbols.map(&:to_s)
7
+ validates :locale, :inclusion => I18n.available_locales.map(&:to_s)
8
+ validates :handler, :inclusion => ActionView::Template::Handlers.extensions.map(&:to_s)
9
+
10
+ after_save do
11
+ Kuztuscms::Resolver.instance.clear_cache
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ module Kuztuscms
2
+ class User < ActiveRecord::Base
3
+ # Include default devise modules. Others available are:
4
+ # :confirmable, :encryptable, :validatable, :registerable and :omniauthable
5
+ devise :database_authenticatable, :recoverable, :timeoutable, :rememberable,
6
+ :trackable, :lockable, :token_authenticatable, :validatable, :authentication_keys => [:username]
7
+
8
+ # Setup accessible (or protected) attributes for your model
9
+ attr_accessible :username, :email, :password, :password_confirmation, :remember_me
10
+
11
+ validates_presence_of :username
12
+ validates_uniqueness_of :username
13
+
14
+ def self.find_for_database_authentication(warden_conditions)
15
+ conditions = warden_conditions.dup
16
+ username = conditions.delete(:username)
17
+ where(conditions).where(["lower(username) = :value", { :value => username.strip.downcase }]).first
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ <br><br>
2
+
3
+ <%- if controller_name != 'sessions' %>
4
+ <%= link_to "Sign in", new_session_path(resource_name) %><br>
5
+ <% end -%>
6
+
7
+ <%- if devise_mapping.registerable? && controller_name != 'registrations' %>
8
+ <%= link_to "Sign up", new_registration_path(resource_name) %><br>
9
+ <% end -%>
10
+
11
+ <%- if devise_mapping.recoverable? && controller_name != 'passwords' %>
12
+ <%= link_to "Forgot your password?", new_password_path(resource_name) %><br>
13
+ <% end -%>
14
+
15
+ <%- if devise_mapping.confirmable? && controller_name != 'confirmations' %>
16
+ <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br>
17
+ <% end -%>
18
+
19
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
20
+ <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br>
21
+ <% end -%>
22
+
23
+ <%- if devise_mapping.omniauthable? %>
24
+ <%- resource_class.omniauth_providers.each do |provider| %>
25
+ <%= link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider) %><br>
26
+ <% end -%>
27
+ <% end -%>
@@ -0,0 +1,12 @@
1
+ <h2>Resend confirmation instructions</h2>
2
+
3
+ <%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
4
+ <%= devise_error_messages! %>
5
+
6
+ <div><%= f.label :email %><br />
7
+ <%= f.email_field :email %></div>
8
+
9
+ <div><%= f.submit "Resend confirmation instructions" %></div>
10
+ <% end %>
11
+
12
+ <%= render "links" %>
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account email through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>