paginas 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (198) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/paginas.js +5 -0
  3. data/app/controllers/paginas/application_controller.rb +3 -1
  4. data/app/controllers/paginas/categories_controller.rb +43 -0
  5. data/app/controllers/paginas/pages_controller.rb +10 -15
  6. data/app/helpers/paginas/application_helper.rb +41 -0
  7. data/app/helpers/paginas/categories_helper.rb +4 -0
  8. data/app/helpers/paginas/pages_helper.rb +0 -0
  9. data/app/models/paginas/category.rb +5 -0
  10. data/app/models/paginas/page.rb +1 -0
  11. data/app/views/paginas/categories/_form.html.erb +25 -0
  12. data/app/views/paginas/categories/edit.html.erb +6 -0
  13. data/app/views/paginas/categories/index.html.erb +31 -0
  14. data/app/views/paginas/categories/new.html.erb +5 -0
  15. data/app/views/paginas/categories/show.html.erb +18 -0
  16. data/app/views/paginas/pages/_form.html.erb +8 -0
  17. data/app/views/paginas/pages/display.html.erb +1 -1
  18. data/app/views/paginas/pages/featured.html.erb +1 -1
  19. data/app/views/paginas/pages/index.html.erb +2 -0
  20. data/app/views/paginas/pages/show.html.erb +2 -0
  21. data/config/routes.rb +1 -0
  22. data/db/migrate/20150212133316_create_paginas_pages.rb +1 -1
  23. data/db/migrate/20150213135047_add_show_title_to_paginas_pages.rb +5 -0
  24. data/db/migrate/20150213154421_create_paginas_categories.rb +10 -0
  25. data/db/migrate/20150213155126_add_ref_to_paginas_pages.rb +5 -0
  26. data/lib/generators/paginas/views_generator.rb +2 -1
  27. data/lib/paginas.rb +0 -1
  28. data/lib/paginas/version.rb +1 -1
  29. data/test/controllers/paginas/categories_controller_test.rb +51 -0
  30. data/test/dummy/app/views/layouts/application.html.erb +2 -0
  31. data/test/dummy/db/development.sqlite3 +0 -0
  32. data/test/dummy/db/schema.rb +15 -4
  33. data/test/dummy/log/development.log +7107 -0
  34. data/test/dummy/tmp/cache/assets/development/sprockets/0af4c8229b96d670ece643ab86d847fc +0 -0
  35. data/test/dummy/tmp/cache/assets/development/sprockets/0ee8d3e5b36596acfcc7aac1e2c53afb +0 -0
  36. data/test/dummy/tmp/cache/assets/development/sprockets/1551e0fd7a443780df1664ebdeb18ac1 +0 -0
  37. data/test/dummy/tmp/cache/assets/development/sprockets/1a00a5d48b33b4f7efca9b6bbdd63bcd +0 -0
  38. data/test/dummy/tmp/cache/assets/development/sprockets/21011cd5ad02024ed642796a38699cb5 +0 -0
  39. data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  40. data/test/dummy/tmp/cache/assets/development/sprockets/3f9f0b85e5027ef9cabe4fc1f96b9a67 +0 -0
  41. data/test/dummy/tmp/cache/assets/development/sprockets/479d3bb4bd6dcf93c1f6fd7fc4e8f484 +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/5549bda2a1379ba359a508ac6eef4fed +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/68a9c8d9374226e8006a035b0fdc68d6 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/68d83dd802c75113a5e2d20da57bb19f +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/74e2e79aaabf24d2f9c9c0db1a848506 +0 -0
  46. data/test/dummy/tmp/cache/assets/development/sprockets/7796585c12a75e75f99a2ce3d64f3685 +0 -0
  47. data/test/dummy/tmp/cache/assets/development/sprockets/8591abf6e2c5e4c2c9a5d9cba884191d +0 -0
  48. data/test/dummy/tmp/cache/assets/development/sprockets/85c1359d66fb12cd68b8606117cd98ba +0 -0
  49. data/test/dummy/tmp/cache/assets/development/sprockets/8f19f695aa102b3306cd7bc524877aaf +0 -0
  50. data/test/dummy/tmp/cache/assets/development/sprockets/a868a2b2a5302aeed2e5608d656d5ff4 +0 -0
  51. data/test/dummy/tmp/cache/assets/development/sprockets/b0d1d14e7cf764cbc39a931d8dd3f2de +0 -0
  52. data/test/dummy/tmp/cache/assets/development/sprockets/b265df7d299afb2b854d0d677f534b64 +0 -0
  53. data/test/dummy/tmp/cache/assets/development/sprockets/c2a90a25a0d9740bacd317b21a773000 +0 -0
  54. data/test/dummy/tmp/cache/assets/development/sprockets/cd5ec00cd445991e3f11ed6c5736cb63 +0 -0
  55. data/test/dummy/tmp/cache/assets/development/sprockets/cfa9226df92e47e7f6cb7b5668b8bad2 +0 -0
  56. data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  57. data/test/dummy/tmp/cache/assets/development/sprockets/d3ae97f3eebfface2dbfa809fff4cb9f +0 -0
  58. data/test/dummy/tmp/cache/assets/development/sprockets/da017253c0d60d236728d78f022cd203 +0 -0
  59. data/test/dummy/tmp/cache/assets/development/sprockets/e6081e190935ce01a7b64d0bcc7a8912 +0 -0
  60. data/test/dummy/tmp/cache/assets/development/sprockets/f0089f75e018e7d19b6fe81ab885cd8e +0 -0
  61. data/test/dummy/tmp/cache/assets/development/sprockets/f5afae3a18a58341a8853b2f935b2b5e +0 -0
  62. data/test/dummy/tmp/cache/assets/development/sprockets/f760d05f8aef4eb68d32f2a6aee2cb7d +0 -0
  63. data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  64. data/test/dummy/tmp/cache/assets/development/sprockets/fd1680f1ef8200c9748a7ad805cd4c75 +0 -0
  65. data/test/dummy/tmp/cache/assets/development/sprockets/fd3186407a9ce29b3b8f07f85f2dede0 +0 -0
  66. data/test/dummy/tmp/pids/server.pid +1 -1
  67. data/test/dummy2/README.rdoc +28 -0
  68. data/test/dummy2/Rakefile +6 -0
  69. data/test/dummy2/app/assets/javascripts/application.js +14 -0
  70. data/test/dummy2/app/assets/stylesheets/application.css +15 -0
  71. data/test/dummy2/app/controllers/application_controller.rb +5 -0
  72. data/test/dummy2/app/controllers/categories_controller.rb +2 -0
  73. data/test/dummy2/app/controllers/pages_controller.rb +2 -0
  74. data/test/dummy2/app/helpers/application_helper.rb +2 -0
  75. data/test/dummy2/app/views/layouts/application.html.erb +16 -0
  76. data/test/dummy2/app/views/paginas/categories/_form.html.erb +25 -0
  77. data/test/dummy2/app/views/paginas/categories/edit.html.erb +6 -0
  78. data/test/dummy2/app/views/paginas/categories/index.html.erb +31 -0
  79. data/test/dummy2/app/views/paginas/categories/new.html.erb +5 -0
  80. data/test/dummy2/app/views/paginas/categories/show.html.erb +18 -0
  81. data/test/{dummy → dummy2}/app/views/paginas/pages/_form.html.erb +8 -0
  82. data/test/dummy2/app/views/paginas/pages/display.html.erb +2 -0
  83. data/test/{dummy → dummy2}/app/views/paginas/pages/edit.html.erb +0 -0
  84. data/test/{dummy → dummy2}/app/views/paginas/pages/featured.html.erb +1 -1
  85. data/test/{dummy → dummy2}/app/views/paginas/pages/index.html.erb +2 -0
  86. data/test/{dummy → dummy2}/app/views/paginas/pages/new.html.erb +0 -0
  87. data/test/{dummy → dummy2}/app/views/paginas/pages/show.html.erb +2 -0
  88. data/{app → test/dummy2/app}/views/paginas/shared/keep +0 -0
  89. data/test/dummy2/bin/bundle +3 -0
  90. data/test/dummy2/bin/rails +4 -0
  91. data/test/dummy2/bin/rake +4 -0
  92. data/test/dummy2/bin/setup +29 -0
  93. data/test/dummy2/categories/_form.html.erb +38 -0
  94. data/test/dummy2/categories/display.html.erb +2 -0
  95. data/test/dummy2/categories/edit.html.erb +6 -0
  96. data/test/dummy2/categories/featured.html.erb +5 -0
  97. data/test/dummy2/categories/index.html.erb +31 -0
  98. data/test/dummy2/categories/new.html.erb +5 -0
  99. data/test/dummy2/categories/show.html.erb +10 -0
  100. data/test/dummy2/config.ru +4 -0
  101. data/test/dummy2/config/application.rb +26 -0
  102. data/test/dummy2/config/boot.rb +5 -0
  103. data/test/dummy2/config/database.yml +25 -0
  104. data/test/dummy2/config/environment.rb +5 -0
  105. data/test/dummy2/config/environments/development.rb +41 -0
  106. data/test/dummy2/config/environments/production.rb +79 -0
  107. data/test/dummy2/config/environments/test.rb +42 -0
  108. data/test/dummy2/config/initializers/assets.rb +11 -0
  109. data/test/dummy2/config/initializers/backtrace_silencers.rb +7 -0
  110. data/test/dummy2/config/initializers/cookies_serializer.rb +3 -0
  111. data/test/dummy2/config/initializers/filter_parameter_logging.rb +4 -0
  112. data/test/dummy2/config/initializers/inflections.rb +16 -0
  113. data/test/dummy2/config/initializers/mime_types.rb +4 -0
  114. data/test/dummy2/config/initializers/session_store.rb +3 -0
  115. data/test/dummy2/config/initializers/wrap_parameters.rb +14 -0
  116. data/test/dummy2/config/locales/en.yml +23 -0
  117. data/test/dummy2/config/routes.rb +4 -0
  118. data/test/dummy2/config/secrets.yml +22 -0
  119. data/test/dummy2/db/development.sqlite3 +0 -0
  120. data/test/dummy2/db/schema.rb +35 -0
  121. data/test/dummy2/log/development.log +8474 -0
  122. data/test/dummy2/public/404.html +67 -0
  123. data/test/dummy2/public/422.html +67 -0
  124. data/test/dummy2/public/500.html +66 -0
  125. data/test/dummy2/public/favicon.ico +0 -0
  126. data/test/dummy2/tmp/cache/assets/development/sprockets/005bd567a7d66421fbef453fe21291ef +0 -0
  127. data/test/dummy2/tmp/cache/assets/development/sprockets/0af4c8229b96d670ece643ab86d847fc +0 -0
  128. data/test/dummy2/tmp/cache/assets/development/sprockets/0b561bb0f5e27b0811d8f78da0b0a961 +0 -0
  129. data/test/dummy2/tmp/cache/assets/development/sprockets/0d13d323f5ada0f6982ed7004e7b7956 +0 -0
  130. data/test/dummy2/tmp/cache/assets/development/sprockets/0d47ad626385700d816d2237b60e4405 +0 -0
  131. data/test/dummy2/tmp/cache/assets/development/sprockets/0ee8d3e5b36596acfcc7aac1e2c53afb +0 -0
  132. data/test/dummy2/tmp/cache/assets/development/sprockets/0f9097e7e4fe024b14ad4ae2a74ac107 +0 -0
  133. data/test/dummy2/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
  134. data/test/dummy2/tmp/cache/assets/development/sprockets/1551e0fd7a443780df1664ebdeb18ac1 +0 -0
  135. data/test/dummy2/tmp/cache/assets/development/sprockets/1a00a5d48b33b4f7efca9b6bbdd63bcd +0 -0
  136. data/test/dummy2/tmp/cache/assets/development/sprockets/21011cd5ad02024ed642796a38699cb5 +0 -0
  137. data/test/dummy2/tmp/cache/assets/development/sprockets/2335821218ad3f7fb88a7e033bd928d3 +0 -0
  138. data/test/dummy2/tmp/cache/assets/development/sprockets/2a6137c114f81313e7f4d24aabf5f742 +0 -0
  139. data/test/dummy2/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
  140. data/test/dummy2/tmp/cache/assets/development/sprockets/31007be9c9b15ceb79a3575e593f1666 +0 -0
  141. data/test/dummy2/tmp/cache/assets/development/sprockets/34c30def6edca7cd4ccc028324e69732 +0 -0
  142. data/test/dummy2/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
  143. data/test/dummy2/tmp/cache/assets/development/sprockets/3ccca1a97ac09ec192a60c94fa00adb3 +0 -0
  144. data/test/dummy2/tmp/cache/assets/development/sprockets/3f9f0b85e5027ef9cabe4fc1f96b9a67 +0 -0
  145. data/test/dummy2/tmp/cache/assets/development/sprockets/41485660f2da3e5246495eca44b5d586 +0 -0
  146. data/test/dummy2/tmp/cache/assets/development/sprockets/43a987fa7ec0cbb1e8a6bd5e3a4e4b8d +0 -0
  147. data/test/dummy2/tmp/cache/assets/development/sprockets/479d3bb4bd6dcf93c1f6fd7fc4e8f484 +0 -0
  148. data/test/dummy2/tmp/cache/assets/development/sprockets/4ccd723c93040294ae2c7d4bdd241927 +0 -0
  149. data/test/dummy2/tmp/cache/assets/development/sprockets/5549bda2a1379ba359a508ac6eef4fed +0 -0
  150. data/test/dummy2/tmp/cache/assets/development/sprockets/591767e1239aceceb8eae71f91d40c2c +0 -0
  151. data/test/dummy2/tmp/cache/assets/development/sprockets/5ca1d924e33e6d2326ea666473d1b957 +0 -0
  152. data/test/dummy2/tmp/cache/assets/development/sprockets/614d6dfbd87dfef1f5409cdf648b4ef8 +0 -0
  153. data/test/dummy2/tmp/cache/assets/development/sprockets/6870a0f5e39c9a385cd7d42d1eacc23a +0 -0
  154. data/test/dummy2/tmp/cache/assets/development/sprockets/68a9c8d9374226e8006a035b0fdc68d6 +0 -0
  155. data/test/dummy2/tmp/cache/assets/development/sprockets/68d83dd802c75113a5e2d20da57bb19f +0 -0
  156. data/test/dummy2/tmp/cache/assets/development/sprockets/6aff79b1163157bafd663772e01e02b9 +0 -0
  157. data/test/dummy2/tmp/cache/assets/development/sprockets/6ff1394e29e0bf6efa5e2aaaa5599857 +0 -0
  158. data/test/dummy2/tmp/cache/assets/development/sprockets/74e2e79aaabf24d2f9c9c0db1a848506 +0 -0
  159. data/test/dummy2/tmp/cache/assets/development/sprockets/7796585c12a75e75f99a2ce3d64f3685 +0 -0
  160. data/test/dummy2/tmp/cache/assets/development/sprockets/79f273cae0828923dde1ef8c2398a097 +0 -0
  161. data/test/dummy2/tmp/cache/assets/development/sprockets/7e4eb3e4ae47796be38b017098742457 +0 -0
  162. data/test/dummy2/tmp/cache/assets/development/sprockets/8591abf6e2c5e4c2c9a5d9cba884191d +0 -0
  163. data/test/dummy2/tmp/cache/assets/development/sprockets/85c1359d66fb12cd68b8606117cd98ba +0 -0
  164. data/test/dummy2/tmp/cache/assets/development/sprockets/8f19f695aa102b3306cd7bc524877aaf +0 -0
  165. data/test/dummy2/tmp/cache/assets/development/sprockets/9245581aa4bb65f432f558fab76a6394 +0 -0
  166. data/test/dummy2/tmp/cache/assets/development/sprockets/a056f25be69aad65535c6119795b97a7 +0 -0
  167. data/test/dummy2/tmp/cache/assets/development/sprockets/a0a7a60c30730860ddb157961fa79cc6 +0 -0
  168. data/test/dummy2/tmp/cache/assets/development/sprockets/a4f760a14b35ee198d29bdc6657a6d61 +0 -0
  169. data/test/dummy2/tmp/cache/assets/development/sprockets/a868a2b2a5302aeed2e5608d656d5ff4 +0 -0
  170. data/test/dummy2/tmp/cache/assets/development/sprockets/a9cc70badbab7d39abf8d96de550f53d +0 -0
  171. data/test/dummy2/tmp/cache/assets/development/sprockets/abc2c4b52cfa5dec5d6d5f5bac7f7d7f +0 -0
  172. data/test/dummy2/tmp/cache/assets/development/sprockets/b0d1d14e7cf764cbc39a931d8dd3f2de +0 -0
  173. data/test/dummy2/tmp/cache/assets/development/sprockets/b265df7d299afb2b854d0d677f534b64 +0 -0
  174. data/test/dummy2/tmp/cache/assets/development/sprockets/bac590af4a9c32bd96a7954f161597fd +0 -0
  175. data/test/dummy2/tmp/cache/assets/development/sprockets/c2a90a25a0d9740bacd317b21a773000 +0 -0
  176. data/test/dummy2/tmp/cache/assets/development/sprockets/cb0b8f15d2f703e80dad62daa69e27b1 +0 -0
  177. data/test/dummy2/tmp/cache/assets/development/sprockets/cd5ec00cd445991e3f11ed6c5736cb63 +0 -0
  178. data/test/dummy2/tmp/cache/assets/development/sprockets/cd7fd8f917317ac993444f56a0dd0259 +0 -0
  179. data/test/dummy2/tmp/cache/assets/development/sprockets/cfa9226df92e47e7f6cb7b5668b8bad2 +0 -0
  180. data/test/dummy2/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
  181. data/test/dummy2/tmp/cache/assets/development/sprockets/d05c052069448c7d8dce96727613e470 +0 -0
  182. data/test/dummy2/tmp/cache/assets/development/sprockets/d3ae97f3eebfface2dbfa809fff4cb9f +0 -0
  183. data/test/dummy2/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
  184. data/test/dummy2/tmp/cache/assets/development/sprockets/da017253c0d60d236728d78f022cd203 +0 -0
  185. data/test/dummy2/tmp/cache/assets/development/sprockets/e6081e190935ce01a7b64d0bcc7a8912 +0 -0
  186. data/test/dummy2/tmp/cache/assets/development/sprockets/ec454ae07815a55a5b9bb5d5eb9de78b +0 -0
  187. data/test/dummy2/tmp/cache/assets/development/sprockets/f0089f75e018e7d19b6fe81ab885cd8e +0 -0
  188. data/test/dummy2/tmp/cache/assets/development/sprockets/f5afae3a18a58341a8853b2f935b2b5e +0 -0
  189. data/test/dummy2/tmp/cache/assets/development/sprockets/f760d05f8aef4eb68d32f2a6aee2cb7d +0 -0
  190. data/test/dummy2/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
  191. data/test/dummy2/tmp/cache/assets/development/sprockets/fd1680f1ef8200c9748a7ad805cd4c75 +0 -0
  192. data/test/dummy2/tmp/cache/assets/development/sprockets/fd3186407a9ce29b3b8f07f85f2dede0 +0 -0
  193. data/test/fixtures/paginas/categories.yml +9 -0
  194. data/test/models/paginas/category_test.rb +9 -0
  195. metadata +323 -19
  196. data/app/assets/javascripts/paginas/pages.js +0 -2
  197. data/app/assets/stylesheets/paginas/pages.css +0 -4
  198. data/test/dummy/app/views/paginas/pages/display.html.erb +0 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 21f21d442944522ab4692034eefcb99d7acf81f2
4
- data.tar.gz: 84c1dcf0739ced4800eb7608f48b721de4d1f585
3
+ metadata.gz: d9586cf18c392b5e33aa55d42cd03f42207a107b
4
+ data.tar.gz: 5f4c578603b3428a5ee3a604b8029fc880cca2ef
5
5
  SHA512:
6
- metadata.gz: 5703832b65ba0a33fc87fc191161a0f1383e92c1b75ea8f030ce05e555e80c5b85715aa5a0af9ca477156e680695573a5ea00efdf9018796aafac8d9ec5059f6
7
- data.tar.gz: c4598da271f2a2c9d49e23fd1bea16928d9f14e0d014e2512e7bf3cb5d01eff03df8e03cf02a7ce6d1f4abe0f7859900bcf6ea3e17ddb7b2757b97274c91ef40
6
+ metadata.gz: c8ca5f974318c84503a598183c5669721063703eb6b55862def0a2dcb85dc78a0e65d08823d221022f6ed89d05a79888fd9f5cc9bf9fa0d97994577d12a9b1b9
7
+ data.tar.gz: 2610e9bd6e74593cf989543eda8e7fed048899b14c502adc9e4feadadd930ca9916b81583d2b27d3ad784d89c6a549f4c3206c92f9f82756c76affd37214f025
@@ -1 +1,6 @@
1
1
  //= require tinymce
2
+
3
+ if( typeof jQuery != 'undefined')
4
+ {
5
+ $(document).on('page:receive',function(){tinymce.remove()});
6
+ }
@@ -1,3 +1,5 @@
1
1
  class Paginas::ApplicationController < ApplicationController
2
-
2
+ rescue_from ActiveRecord::RecordNotFound do |exception|
3
+ redirect_to root_url, :alert => exception.message
4
+ end
3
5
  end
@@ -0,0 +1,43 @@
1
+ require_dependency "paginas/application_controller"
2
+ module Paginas
3
+ class CategoriesController < ApplicationController
4
+ before_action :set_category, only: [:show, :edit, :update, :destroy]
5
+ def index
6
+ @categories = Category.all
7
+ end
8
+ def show
9
+ end
10
+ def new
11
+ @category = Category.new
12
+ end
13
+ def edit
14
+ end
15
+ def create
16
+ @category = Category.new(category_params)
17
+ if @category.save
18
+ redirect_to @category, notice: 'Category was successfully created.'
19
+ else
20
+ render :new
21
+ end
22
+ end
23
+ def update
24
+ if @category.update(category_params)
25
+ redirect_to @category, notice: 'Category was successfully updated.'
26
+ else
27
+ render :edit
28
+ end
29
+ end
30
+ def destroy
31
+ @category.destroy
32
+ redirect_to categories_url, notice: 'Category was successfully destroyed.'
33
+ end
34
+
35
+ private
36
+ def set_category
37
+ @category = Category.find(params[:id])
38
+ end
39
+ def category_params
40
+ params.require(:category).permit(:name, :description)
41
+ end
42
+ end
43
+ end
@@ -1,9 +1,8 @@
1
1
  require_dependency "paginas/application_controller"
2
-
3
2
  module Paginas
4
3
  class PagesController < ApplicationController
5
4
  before_action :set_page, only: [:display,:show, :edit, :update, :destroy]
6
-
5
+ before_action :set_categories, only: [:edit,:new,:update,:destroy]
7
6
  def index
8
7
  @pages = Page.all
9
8
  end
@@ -11,7 +10,6 @@ module Paginas
11
10
  @pages = Page.where(featured: true)
12
11
  render :featured
13
12
  end
14
-
15
13
  def show
16
14
  end
17
15
  def display
@@ -19,20 +17,16 @@ module Paginas
19
17
  def new
20
18
  @page = Page.new
21
19
  end
22
-
23
20
  def edit
24
21
  end
25
-
26
22
  def create
27
23
  @page = Page.new(page_params)
28
-
29
24
  if @page.save
30
25
  redirect_to @page, notice: 'Page was successfully created.'
31
26
  else
32
27
  render :new
33
28
  end
34
29
  end
35
-
36
30
  def update
37
31
  if @page.update(page_params)
38
32
  redirect_to @page, notice: 'Page was successfully updated.'
@@ -40,19 +34,20 @@ module Paginas
40
34
  render :edit
41
35
  end
42
36
  end
43
-
44
37
  def destroy
45
38
  @page.destroy
46
39
  redirect_to pages_url, notice: 'Page was successfully destroyed.'
47
40
  end
48
41
 
49
42
  private
50
- def set_page
51
- @page = Page.find(params[:id])
52
- end
53
-
54
- def page_params
55
- params.require(:page).permit(:title, :text, :featured)
56
- end
43
+ def set_categories
44
+ @categories = Category.all
45
+ end
46
+ def set_page
47
+ @page = Page.find(params[:id])
48
+ end
49
+ def page_params
50
+ params.require(:page).permit(:title, :text, :featured,:show_title,:category_id)
51
+ end
57
52
  end
58
53
  end
@@ -1,5 +1,46 @@
1
1
  module Paginas
2
2
  module ApplicationHelper
3
+ def paginas_menu_helper_by_pages(ids,options = {})
4
+ options[:item_style] ||= "[link]"
5
+ options[:item_separator] ||= " | "
6
+ options[:group_style] ||= "[items]"
7
+ options[:active_class] ||= ""
8
+
9
+ output = ''
10
+ separator = ''
11
+ ids.each do |key,id|
12
+ output += separator
13
+ output += options[:item_style].gsub(/\[link\]/, link_to(key ,display_path(id)))
14
+ if separator == ''
15
+ separator= options[:item_separator]
16
+ end
17
+ end
18
+ output = options[:group_style].gsub(/\[items\]/, output)
19
+ output = output.gsub(/\[active\]/, output)
20
+
21
+ return output.html_safe
22
+ end
23
+ def paginas_menu_helper_by_cat(catid,options = {})
24
+ options[:item_style] ||= "[link]"
25
+ options[:item_separator] ||= " | "
26
+ options[:group_style] ||= "[items]"
27
+ options[:active_class] ||= ""
28
+
29
+ output = ''
30
+ separator = ''
31
+ Category.find(catid).pages.each do |page|
32
+ output += separator
33
+ output += options[:item_style].gsub(/\[link\]/, link_to(page.title ,display_path(page.id)))
34
+ if separator == ''
35
+ separator= options[:item_separator]
36
+ end
37
+ end
38
+ output = options[:group_style].gsub(/\[items\]/, output)
39
+ output = output.gsub(/\[active\]/, output)
40
+
41
+ return output.html_safe
42
+ end
43
+
3
44
  def method_missing(method, *args, &block)
4
45
  if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)
5
46
  main_app.send(method, *args)
@@ -0,0 +1,4 @@
1
+ module Paginas
2
+ module CategoriesHelper
3
+ end
4
+ end
File without changes
@@ -0,0 +1,5 @@
1
+ module Paginas
2
+ class Category < ActiveRecord::Base
3
+ has_many :pages, :dependent => :destroy
4
+ end
5
+ end
@@ -1,5 +1,6 @@
1
1
  module Paginas
2
2
  class Page < ActiveRecord::Base
3
+ belongs_to :category
3
4
  validates :title, presence: true
4
5
  end
5
6
  end
@@ -0,0 +1,25 @@
1
+ <%= form_for(@category) do |f| %>
2
+ <% if @category.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@category.errors.count, "error") %> prohibited this category from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @category.errors.full_messages.each do |message| %>
8
+ <li><%= message %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :name %><br>
16
+ <%= f.text_field :name %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :description %><br>
20
+ <%= f.text_area :description %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing Category</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @category %> |
6
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,31 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <h1>Listing Categories</h1>
4
+
5
+ <table>
6
+ <thead>
7
+ <tr>
8
+ <th>ID</th>
9
+ <th>Name</th>
10
+ <th>Description</th>
11
+ <th colspan="3"></th>
12
+ </tr>
13
+ </thead>
14
+
15
+ <tbody>
16
+ <% @categories.each do |category| %>
17
+ <tr>
18
+ <td><%= category.id %></td>
19
+ <td><%= category.name %></td>
20
+ <td><%= category.description %></td>
21
+ <td><%= link_to 'Show', category %></td>
22
+ <td><%= link_to 'Edit', edit_category_path(category) %></td>
23
+ <td><%= link_to 'Destroy', category, method: :delete, data: { confirm: 'Are you sure?' } %></td>
24
+ </tr>
25
+ <% end %>
26
+ </tbody>
27
+ </table>
28
+
29
+ <br>
30
+
31
+ <%= link_to 'New Category', new_category_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New Category</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', categories_path %>
@@ -0,0 +1,18 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <strong>ID:</strong>
5
+ <%= @category.id %>
6
+ </p>
7
+ <p>
8
+ <strong>Name:</strong>
9
+ <%= @category.name %>
10
+ </p>
11
+
12
+ <p>
13
+ <strong>Description:</strong>
14
+ <%= @category.description %>
15
+ </p>
16
+
17
+ <%= link_to 'Edit', edit_category_path(@category) %> |
18
+ <%= link_to 'Back', categories_path %>
@@ -15,10 +15,18 @@
15
15
  <%= f.label :title %><br>
16
16
  <%= f.text_field :title %>
17
17
  </div>
18
+ <div class="field">
19
+ <%= f.label :show_title %><br>
20
+ <%= f.check_box :show_title %>
21
+ </div>
18
22
  <div class="field">
19
23
  <%= f.label :featured %><br>
20
24
  <%= f.check_box :featured %>
21
25
  </div>
26
+ <div class="field">
27
+ <%= f.label :category_id %><br>
28
+ <%= f.select :category_id,options_from_collection_for_select(@categories,:id,:name,f.object.category_id) %>
29
+ </div>
22
30
  <div class="field">
23
31
  <%= f.label :text %><br>
24
32
  <%= f.text_area :text, :class => "tinymce", :rows => 20, :cols => 80 %>
@@ -1,2 +1,2 @@
1
- <h3><%= @page.title %> </h3>
1
+ <%=(@page.show_title)? "<h3>#{@page.title}</h3>".html_safe : "" %>
2
2
  <div><%= @page.text.html_safe %></div>
@@ -1,5 +1,5 @@
1
1
  <% @pages.each do |page| %>
2
- <h3><%= page.title %></h3>
2
+ <%=(page.show_title)? "<h3>#{page.title}</h3>".html_safe : "" %>
3
3
  <div><%= page.text.html_safe %></div>
4
4
  </tr>
5
5
  <% end %>
@@ -7,6 +7,7 @@
7
7
  <tr>
8
8
  <th>Title</th>
9
9
  <th>Featured</th>
10
+ <th>Category</th>
10
11
  <th colspan="3"></th>
11
12
  </tr>
12
13
  </thead>
@@ -16,6 +17,7 @@
16
17
  <tr>
17
18
  <td><%= page.title %></td>
18
19
  <td><%= page.featured %></td>
20
+ <td><%= page.category.name %></td>
19
21
  <td><%= link_to 'Show', page %></td>
20
22
  <td><%= link_to 'Edit', edit_page_path(page) %></td>
21
23
  <td><%= link_to 'Destroy', page, method: :delete, data: { confirm: "Are you sure?" } %></td>
@@ -2,6 +2,8 @@
2
2
 
3
3
  <h3><%= @page.title %> </h3>
4
4
 
5
+ <label>Page Link</label>
6
+ <%= text_field_tag :link, display_url(@page), :readonly => 'readonly' %>
5
7
  <div><%= @page.text.html_safe %></div>
6
8
 
7
9
  <%= link_to 'Edit', edit_page_path(@page) %> |
@@ -1,4 +1,5 @@
1
1
  Paginas::Engine.routes.draw do
2
+ resources :categories
2
3
  resources :pages
3
4
  get 'featured', to: 'pages#featured'
4
5
  get 'display/:id', to: 'pages#display', as: "display"
@@ -4,7 +4,7 @@ class CreatePaginasPages < ActiveRecord::Migration
4
4
  t.string :title
5
5
  t.text :text
6
6
  t.boolean :featured, :default => false
7
-
7
+
8
8
  t.timestamps null: false
9
9
  end
10
10
  end
@@ -0,0 +1,5 @@
1
+ class AddShowTitleToPaginasPages < ActiveRecord::Migration
2
+ def change
3
+ add_column :paginas_pages, :show_title, :boolean, :default => false
4
+ end
5
+ end
@@ -0,0 +1,10 @@
1
+ class CreatePaginasCategories < ActiveRecord::Migration
2
+ def change
3
+ create_table :paginas_categories do |t|
4
+ t.string :name
5
+ t.text :description
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddRefToPaginasPages < ActiveRecord::Migration
2
+ def change
3
+ add_reference :paginas_pages, :category, index: true
4
+ end
5
+ end
@@ -35,6 +35,7 @@ module Paginas
35
35
  end
36
36
  else
37
37
  view_directory :pages
38
+ view_directory :categories
38
39
  end
39
40
  end
40
41
 
@@ -63,7 +64,7 @@ module Paginas
63
64
 
64
65
  # Override copy_views to just copy mailer and shared.
65
66
  def copy_views
66
- view_directory :shared
67
+ # view_directory :shared
67
68
  end
68
69
  end
69
70
 
@@ -1,4 +1,3 @@
1
1
  require "paginas/engine"
2
-
3
2
  module Paginas
4
3
  end
@@ -1,3 +1,3 @@
1
1
  module Paginas
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,51 @@
1
+ require 'test_helper'
2
+
3
+ module Paginas
4
+ class CategoriesControllerTest < ActionController::TestCase
5
+ setup do
6
+ @category = categories(:one)
7
+ end
8
+
9
+ test "should get index" do
10
+ get :index
11
+ assert_response :success
12
+ assert_not_nil assigns(:categories)
13
+ end
14
+
15
+ test "should get new" do
16
+ get :new
17
+ assert_response :success
18
+ end
19
+
20
+ test "should create category" do
21
+ assert_difference('Category.count') do
22
+ post :create, category: { description: @category.description, name: @category.name }
23
+ end
24
+
25
+ assert_redirected_to category_path(assigns(:category))
26
+ end
27
+
28
+ test "should show category" do
29
+ get :show, id: @category
30
+ assert_response :success
31
+ end
32
+
33
+ test "should get edit" do
34
+ get :edit, id: @category
35
+ assert_response :success
36
+ end
37
+
38
+ test "should update category" do
39
+ patch :update, id: @category, category: { description: @category.description, name: @category.name }
40
+ assert_redirected_to category_path(assigns(:category))
41
+ end
42
+
43
+ test "should destroy category" do
44
+ assert_difference('Category.count', -1) do
45
+ delete :destroy, id: @category
46
+ end
47
+
48
+ assert_redirected_to categories_path
49
+ end
50
+ end
51
+ end