rails_detail 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (250) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +165 -0
  3. data/README.md +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/config/rails_detail_manifest.js +3 -0
  6. data/app/assets/javascripts/controllers/rails_detail_my/contents/index.ready.js +1 -0
  7. data/app/assets/javascripts/controllers/rails_detail_my/entity_items/index.js +45 -0
  8. data/app/assets/javascripts/controllers/rails_detail_my/pictures/index.ready.js +18 -0
  9. data/app/assets/javascripts/knowledge.js +47 -0
  10. data/app/assets/javascripts/rails_detail/application.js +4 -0
  11. data/app/assets/stylesheets/rails_detail/application.css +14 -0
  12. data/app/controllers/rails_detail_admin/base_controller.rb +5 -0
  13. data/app/controllers/rails_detail_admin/items_controller.rb +76 -0
  14. data/app/controllers/rails_detail_admin/lists_controller.rb +60 -0
  15. data/app/controllers/rails_detail_my/base_controller.rb +7 -0
  16. data/app/controllers/rails_detail_my/entity_items_controller.rb +51 -0
  17. data/app/controllers/rails_detail_my/items_controller.rb +10 -0
  18. data/app/controllers/rails_detail_my/knowledges_controller.rb +124 -0
  19. data/app/controllers/rails_detail_my/majors_controller.rb +68 -0
  20. data/app/controllers/rails_detail_my/minors_controller.rb +64 -0
  21. data/app/controllers/rails_detail_my/notes_controller.rb +47 -0
  22. data/app/controllers/rails_detail_my/parts_controller.rb +74 -0
  23. data/app/controllers/rails_detail_my/pictures_controller.rb +76 -0
  24. data/app/controllers/rails_detail_my/sections_controller.rb +62 -0
  25. data/app/controllers/rails_detail_my/solos_controller.rb +96 -0
  26. data/app/controllers/rails_detail_my/sources_controller.rb +79 -0
  27. data/app/controllers/rails_detail_my/taxon_items_controller.rb +66 -0
  28. data/app/controllers/rails_detail_my/wikis_controller.rb +104 -0
  29. data/app/models/rails_detail/concerns/content_model.rb +13 -0
  30. data/app/models/rails_detail/concerns/item_model.rb +24 -0
  31. data/app/models/rails_detail/concerns/taxon_model.rb +9 -0
  32. data/app/models/rails_detail/content.rb +12 -0
  33. data/app/models/rails_detail/contents/banner.rb +7 -0
  34. data/app/models/rails_detail/contents/link.rb +5 -0
  35. data/app/models/rails_detail/contents/note.rb +6 -0
  36. data/app/models/rails_detail/contents/picture.rb +7 -0
  37. data/app/models/rails_detail/entity_item.rb +18 -0
  38. data/app/models/rails_detail/item.rb +7 -0
  39. data/app/models/rails_detail/list.rb +6 -0
  40. data/app/models/rails_detail/taxon_item.rb +14 -0
  41. data/app/views/layouts/the_detail.html.erb +22 -0
  42. data/app/views/rails_detail_admin/answers/_answer.html.erb +14 -0
  43. data/app/views/rails_detail_admin/answers/_form.html.erb +16 -0
  44. data/app/views/rails_detail_admin/answers/edit.html.erb +11 -0
  45. data/app/views/rails_detail_admin/answers/index.html.erb +31 -0
  46. data/app/views/rails_detail_admin/answers/new.html.erb +22 -0
  47. data/app/views/rails_detail_admin/answers/show.html.erb +19 -0
  48. data/app/views/rails_detail_admin/base/_nav.html.erb +3 -0
  49. data/app/views/rails_detail_admin/items/_form.html.erb +8 -0
  50. data/app/views/rails_detail_admin/items/edit.html.erb +13 -0
  51. data/app/views/rails_detail_admin/items/index.html.erb +50 -0
  52. data/app/views/rails_detail_admin/items/new.html.erb +13 -0
  53. data/app/views/rails_detail_admin/items/show.html.erb +31 -0
  54. data/app/views/rails_detail_admin/lists/_form.html.erb +5 -0
  55. data/app/views/rails_detail_admin/lists/edit.html.erb +12 -0
  56. data/app/views/rails_detail_admin/lists/index.html.erb +36 -0
  57. data/app/views/rails_detail_admin/lists/new.html.erb +16 -0
  58. data/app/views/rails_detail_admin/lists/taxon.html.erb +44 -0
  59. data/app/views/rails_detail_admin/sections/_form.html.erb +22 -0
  60. data/app/views/rails_detail_admin/sections/_select.html.erb +38 -0
  61. data/app/views/rails_detail_admin/sections/_show_section.html.erb +22 -0
  62. data/app/views/rails_detail_admin/sections/edit.html.erb +17 -0
  63. data/app/views/rails_detail_admin/sections/index.html.erb +18 -0
  64. data/app/views/rails_detail_admin/sections/new.html.erb +13 -0
  65. data/app/views/rails_detail_admin/sources/_form.html.erb +8 -0
  66. data/app/views/rails_detail_admin/sources/edit.html.erb +6 -0
  67. data/app/views/rails_detail_admin/sources/index.html.erb +21 -0
  68. data/app/views/rails_detail_admin/sources/new.html.erb +5 -0
  69. data/app/views/rails_detail_admin/sources/show.html.erb +5 -0
  70. data/app/views/rails_detail_admin/wikis/_breadcrumb.html.erb +6 -0
  71. data/app/views/rails_detail_admin/wikis/_nav.html.erb +16 -0
  72. data/app/views/rails_detail_admin/wikis/_nav_index.html.erb +5 -0
  73. data/app/views/rails_detail_admin/wikis/_push.html.erb +10 -0
  74. data/app/views/rails_detail_admin/wikis/_search.html.erb +21 -0
  75. data/app/views/rails_detail_admin/wikis/_section.html.erb +72 -0
  76. data/app/views/rails_detail_admin/wikis/_solo.html.erb +26 -0
  77. data/app/views/rails_detail_admin/wikis/fade_form.js.erb +9 -0
  78. data/app/views/rails_detail_admin/wikis/index.html.erb +24 -0
  79. data/app/views/rails_detail_admin/wikis/show.html.erb +33 -0
  80. data/app/views/rails_detail_my/answers/_answer.html.erb +14 -0
  81. data/app/views/rails_detail_my/answers/_form.html.erb +16 -0
  82. data/app/views/rails_detail_my/answers/edit.html.erb +11 -0
  83. data/app/views/rails_detail_my/answers/index.html.erb +31 -0
  84. data/app/views/rails_detail_my/answers/new.html.erb +22 -0
  85. data/app/views/rails_detail_my/answers/show.html.erb +19 -0
  86. data/app/views/rails_detail_my/details/_form.html.erb +29 -0
  87. data/app/views/rails_detail_my/details/_major.html.erb +21 -0
  88. data/app/views/rails_detail_my/details/_minor.html.erb +25 -0
  89. data/app/views/rails_detail_my/details/_nav.html/347/232/204/345/211/257/346/234/254.erb +14 -0
  90. data/app/views/rails_detail_my/details/edit.html.erb +37 -0
  91. data/app/views/rails_detail_my/details/fade_form.js.erb +9 -0
  92. data/app/views/rails_detail_my/details/index.html.erb +10 -0
  93. data/app/views/rails_detail_my/details/search.json.jbuilder +5 -0
  94. data/app/views/rails_detail_my/details/show.html.erb +52 -0
  95. data/app/views/rails_detail_my/entity_items/_edit.html.erb +15 -0
  96. data/app/views/rails_detail_my/entity_items/_new.html.erb +16 -0
  97. data/app/views/rails_detail_my/entity_items/_taxon_item.html.erb +26 -0
  98. data/app/views/rails_detail_my/entity_items/create.js.erb +23 -0
  99. data/app/views/rails_detail_my/entity_items/destroy.js.erb +26 -0
  100. data/app/views/rails_detail_my/entity_items/edit.js.erb +5 -0
  101. data/app/views/rails_detail_my/entity_items/index.html.erb +40 -0
  102. data/app/views/rails_detail_my/entity_items/new.js.erb +7 -0
  103. data/app/views/rails_detail_my/entity_items/show.html.erb +0 -0
  104. data/app/views/rails_detail_my/entity_items/update.js.erb +1 -0
  105. data/app/views/rails_detail_my/knowledges/_form.html.erb +7 -0
  106. data/app/views/rails_detail_my/knowledges/_sort.html.erb +15 -0
  107. data/app/views/rails_detail_my/knowledges/_td.html.erb +14 -0
  108. data/app/views/rails_detail_my/knowledges/edit.html.erb +12 -0
  109. data/app/views/rails_detail_my/knowledges/index.html.erb +46 -0
  110. data/app/views/rails_detail_my/knowledges/new.html.erb +13 -0
  111. data/app/views/rails_detail_my/knowledges/new_belong.html.erb +36 -0
  112. data/app/views/rails_detail_my/knowledges/show.html.erb +44 -0
  113. data/app/views/rails_detail_my/majors/_form.html.erb +7 -0
  114. data/app/views/rails_detail_my/majors/_new.html.erb +5 -0
  115. data/app/views/rails_detail_my/majors/create.js.erb +4 -0
  116. data/app/views/rails_detail_my/majors/index.html.erb +39 -0
  117. data/app/views/rails_detail_my/majors/index2.html.erb +38 -0
  118. data/app/views/rails_detail_my/majors/new.html.erb +3 -0
  119. data/app/views/rails_detail_my/majors/new.js.erb +1 -0
  120. data/app/views/rails_detail_my/majors/show.html.erb +21 -0
  121. data/app/views/rails_detail_my/minors/_form.html.erb +7 -0
  122. data/app/views/rails_detail_my/minors/_new.html.erb +7 -0
  123. data/app/views/rails_detail_my/minors/_part.html.erb +59 -0
  124. data/app/views/rails_detail_my/minors/create.js.erb +10 -0
  125. data/app/views/rails_detail_my/minors/index.html.erb +41 -0
  126. data/app/views/rails_detail_my/minors/new.html.erb +1 -0
  127. data/app/views/rails_detail_my/minors/new.js.erb +1 -0
  128. data/app/views/rails_detail_my/minors/show.html.erb +22 -0
  129. data/app/views/rails_detail_my/notes/_add_link.html.erb +6 -0
  130. data/app/views/rails_detail_my/notes/_form.html.erb +4 -0
  131. data/app/views/rails_detail_my/notes/_new.html.erb +2 -0
  132. data/app/views/rails_detail_my/notes/_note.html.erb +16 -0
  133. data/app/views/rails_detail_my/notes/_show.html.erb +9 -0
  134. data/app/views/rails_detail_my/notes/create.js.erb +2 -0
  135. data/app/views/rails_detail_my/notes/edit.js.erb +1 -0
  136. data/app/views/rails_detail_my/notes/new.html.erb +2 -0
  137. data/app/views/rails_detail_my/notes/new.js.erb +24 -0
  138. data/app/views/rails_detail_my/notes/show.html.erb +2 -0
  139. data/app/views/rails_detail_my/notes/update.js.erb +1 -0
  140. data/app/views/rails_detail_my/parts/_new.html.erb +7 -0
  141. data/app/views/rails_detail_my/parts/_part.html.erb +59 -0
  142. data/app/views/rails_detail_my/parts/create.js.erb +10 -0
  143. data/app/views/rails_detail_my/parts/index.html.erb +39 -0
  144. data/app/views/rails_detail_my/parts/new.html.erb +1 -0
  145. data/app/views/rails_detail_my/parts/new.js.erb +1 -0
  146. data/app/views/rails_detail_my/parts/show.html.erb +22 -0
  147. data/app/views/rails_detail_my/pictures/_add_link.html.erb +6 -0
  148. data/app/views/rails_detail_my/pictures/_edit.html.erb +8 -0
  149. data/app/views/rails_detail_my/pictures/_index.html.erb +9 -0
  150. data/app/views/rails_detail_my/pictures/_new.html.erb +12 -0
  151. data/app/views/rails_detail_my/pictures/_search_form.html.erb +7 -0
  152. data/app/views/rails_detail_my/pictures/_show.html.erb +17 -0
  153. data/app/views/rails_detail_my/pictures/create.js.erb +2 -0
  154. data/app/views/rails_detail_my/pictures/destroy.js.erb +1 -0
  155. data/app/views/rails_detail_my/pictures/edit.js.erb +2 -0
  156. data/app/views/rails_detail_my/pictures/index.html.erb +2 -0
  157. data/app/views/rails_detail_my/pictures/new.html.erb +2 -0
  158. data/app/views/rails_detail_my/pictures/new.js.erb +1 -0
  159. data/app/views/rails_detail_my/pictures/show.html.erb +10 -0
  160. data/app/views/rails_detail_my/pictures/update.js.erb +1 -0
  161. data/app/views/rails_detail_my/sections/_form.html.erb +22 -0
  162. data/app/views/rails_detail_my/sections/_select.html.erb +38 -0
  163. data/app/views/rails_detail_my/sections/_show_section.html.erb +22 -0
  164. data/app/views/rails_detail_my/sections/edit.html.erb +17 -0
  165. data/app/views/rails_detail_my/sections/index.html.erb +18 -0
  166. data/app/views/rails_detail_my/sections/new.html.erb +13 -0
  167. data/app/views/rails_detail_my/solos/_new.html.erb +5 -0
  168. data/app/views/rails_detail_my/solos/create.js.erb +4 -0
  169. data/app/views/rails_detail_my/solos/edit.js.erb +1 -0
  170. data/app/views/rails_detail_my/solos/index.html.erb +38 -0
  171. data/app/views/rails_detail_my/solos/new.html.erb +3 -0
  172. data/app/views/rails_detail_my/solos/show.html.erb +21 -0
  173. data/app/views/rails_detail_my/sorts/_form.html.erb +29 -0
  174. data/app/views/rails_detail_my/sorts/_head.html.erb +24 -0
  175. data/app/views/rails_detail_my/sorts/_sort.html.erb +49 -0
  176. data/app/views/rails_detail_my/sorts/_sub.html.erb +16 -0
  177. data/app/views/rails_detail_my/sorts/edit.html.erb +14 -0
  178. data/app/views/rails_detail_my/sorts/edit_father.html.erb +17 -0
  179. data/app/views/rails_detail_my/sorts/pic.html.erb +46 -0
  180. data/app/views/rails_detail_my/sorts/search.json.jbuilder +6 -0
  181. data/app/views/rails_detail_my/sorts/show.html.erb +17 -0
  182. data/app/views/rails_detail_my/sorts/sub.js.erb +5 -0
  183. data/app/views/rails_detail_my/sources/_form.html.erb +8 -0
  184. data/app/views/rails_detail_my/sources/edit.html.erb +6 -0
  185. data/app/views/rails_detail_my/sources/index.html.erb +21 -0
  186. data/app/views/rails_detail_my/sources/new.html.erb +5 -0
  187. data/app/views/rails_detail_my/sources/show.html.erb +5 -0
  188. data/app/views/rails_detail_my/taxon_items/_form.html.erb +4 -0
  189. data/app/views/rails_detail_my/taxon_items/_new.html.erb +13 -0
  190. data/app/views/rails_detail_my/taxon_items/_new_list.html.erb +13 -0
  191. data/app/views/rails_detail_my/taxon_items/_taxon_item.html.erb +5 -0
  192. data/app/views/rails_detail_my/taxon_items/create.js.erb +1 -0
  193. data/app/views/rails_detail_my/taxon_items/destroy.js.erb +1 -0
  194. data/app/views/rails_detail_my/taxon_items/edit.html.erb +14 -0
  195. data/app/views/rails_detail_my/taxon_items/edit.js.erb +5 -0
  196. data/app/views/rails_detail_my/taxon_items/index.html.erb +40 -0
  197. data/app/views/rails_detail_my/taxon_items/new.html.erb +9 -0
  198. data/app/views/rails_detail_my/taxon_items/new.js.erb +28 -0
  199. data/app/views/rails_detail_my/taxon_items/update.js.erb +1 -0
  200. data/app/views/rails_detail_my/wikis/_head.html.erb +24 -0
  201. data/app/views/rails_detail_my/wikis/_head.html/347/232/204/345/211/257/346/234/254.erb +34 -0
  202. data/app/views/rails_detail_my/wikis/_sub.html.erb +16 -0
  203. data/app/views/rails_detail_my/wikis/create.js.erb +3 -0
  204. data/app/views/rails_detail_my/wikis/edit.html.erb +14 -0
  205. data/app/views/rails_detail_my/wikis/edit.html/347/232/204/345/211/257/346/234/254.erb +14 -0
  206. data/app/views/rails_detail_my/wikis/edit_father.html.erb +17 -0
  207. data/app/views/rails_detail_my/wikis/index.html.erb +41 -0
  208. data/app/views/rails_detail_my/wikis/new.js.erb +3 -0
  209. data/app/views/rails_detail_my/wikis/pic.html.erb +46 -0
  210. data/app/views/rails_detail_my/wikis/search.json.jbuilder +6 -0
  211. data/app/views/rails_detail_my/wikis/show.html.erb +17 -0
  212. data/app/views/rails_detail_my/wikis/show.html/347/232/204/345/211/257/346/234/254.erb +25 -0
  213. data/app/views/rails_detail_my/wikis/sub.js.erb +5 -0
  214. data/app/views/wikis/_form.html.erb +29 -0
  215. data/app/views/wikis/_head.html.erb +34 -0
  216. data/app/views/wikis/_nav.html.erb +2 -0
  217. data/app/views/wikis/_sort.html.erb +15 -0
  218. data/app/views/wikis/edit.html.erb +14 -0
  219. data/app/views/wikis/index.html.erb +20 -0
  220. data/app/views/wikis/new.html.erb +11 -0
  221. data/app/views/wikis/show.html.erb +25 -0
  222. data/config/locales/zh.yml +10 -0
  223. data/config/routes.rb +31 -0
  224. data/db/20171115144429_create_lists.rb +39 -0
  225. data/db/migrate/20150723122558_create_knowledge.rb +16 -0
  226. data/db/migrate_backup/20150801141208_add_parent_id_to_knowledge.rb +23 -0
  227. data/db/migrate_backup/20150801154145_add_column_to_wikis.rb +8 -0
  228. data/db/migrate_backup/20150801154531_add_position_to_knowledges.rb +6 -0
  229. data/db/migrate_backup/20150801163012_add_wiki_histories_to_wiki.rb +5 -0
  230. data/db/migrate_backup/20150802015359_change_wiki_histories_count.rb +5 -0
  231. data/db/migrate_backup/20150802134532_add_active_to_wikis.rb +6 -0
  232. data/db/migrate_backup/20150802154605_add_type_to_wiki_histroy.rb +8 -0
  233. data/db/migrate_backup/20150802161426_add_major_records_count_to_know.rb +6 -0
  234. data/db/migrate_backup/20150905144632_create_konwledage_items.rb +21 -0
  235. data/db/migrate_backup/20150907124021_remove_photo_id_from_items.rb +8 -0
  236. data/db/migrate_backup/20150919025025_rename_wiki_to_content.rb +7 -0
  237. data/db/migrate_backup/20151214033632_create_parts.rb +12 -0
  238. data/db/migrate_backup/schema.rb +186 -0
  239. data/lib/rails_detail.rb +26 -0
  240. data/lib/rails_detail/config.rb +19 -0
  241. data/lib/rails_detail/engine.rb +28 -0
  242. data/lib/rails_detail/version.rb +3 -0
  243. data/lib/tasks/the_detail_tasks.rake +4 -0
  244. data/test/controllers/knowledges_controller_test.rb +49 -0
  245. data/test/controllers/the_detail/pictures_controller_test.rb +48 -0
  246. data/test/integration/navigation_test.rb +10 -0
  247. data/test/system/the_detail/pictures_test.rb +41 -0
  248. data/test/test_helper.rb +18 -0
  249. data/test/the_detail_test.rb +7 -0
  250. metadata +346 -0
@@ -0,0 +1,60 @@
1
+ class RailsDetailAdmin::ListsController < RailsDetailAdmin::BaseController
2
+ before_action :set_list, only: [:edit, :update, :destroy]
3
+
4
+ def index
5
+ @lists = List.page(params[:page])
6
+ end
7
+
8
+ def new
9
+ @list = List.new
10
+ end
11
+
12
+ def create
13
+ @list = List.new list_params
14
+
15
+ respond_to do |format|
16
+ if @list.save
17
+ format.html { redirect_to admin_lists_url notice: 'Item type was successfully created.' }
18
+ format.json { render json: @list, status: :created, location: @list }
19
+ else
20
+ format.html { render action: "new" }
21
+ format.json { render json: @list.errors, status: :unprocessable_entity }
22
+ end
23
+ end
24
+ end
25
+
26
+ def edit
27
+ end
28
+
29
+ def update
30
+
31
+ respond_to do |format|
32
+ if @list.update list_params
33
+ format.html { redirect_to admin_lists_url, notice: 'Item type was successfully updated.' }
34
+ format.json { head :no_content }
35
+ else
36
+ format.html { render action: "edit" }
37
+ format.json { render json: @list.errors, status: :unprocessable_entity }
38
+ end
39
+ end
40
+ end
41
+
42
+ def destroy
43
+ @list.destroy
44
+
45
+ respond_to do |format|
46
+ format.html { redirect_to admin_lists_url }
47
+ format.json { head :no_content }
48
+ end
49
+ end
50
+
51
+ private
52
+ def set_list
53
+ @list = List.find params[:id]
54
+ end
55
+
56
+ def list_params
57
+ params.fetch(:list, {}).permit(:name, :kind)
58
+ end
59
+
60
+ end
@@ -0,0 +1,7 @@
1
+ class RailsDetailMy::BaseController < ApplicationController
2
+ default_form_builder 'RailsDetailBuilder' do |config|
3
+
4
+ end
5
+
6
+
7
+ end
@@ -0,0 +1,51 @@
1
+ class RailsDetailMy::EntityItemsController < RailsDetailMy::BaseController
2
+ before_action :set_entity
3
+ before_action :set_entity_item, only: [:show, :edit, :update, :destroy]
4
+
5
+ def index
6
+ @items_hash = @entity.items
7
+ @entity_items = EntityItem.includes(:taxon_item).where(entity_type: params[:entity_type], entity_id: params[:entity_id]).page(params[:page])
8
+ end
9
+
10
+ def show
11
+ end
12
+
13
+ def new
14
+ @entity_item = @entity.entity_items.find_or_initialize_by(taxon_item_id: params[:taxon_item_id])
15
+ end
16
+
17
+ def create
18
+ @entity_item = @entity.entity_items.find_or_initialize_by(taxon_item_id: entity_item_params[:taxon_item_id])
19
+ @entity_item.value = entity_item_params[:value]
20
+
21
+ respond_to do |format|
22
+ if @entity_item.save
23
+ @entity_item.taxon_item.entity_item_id = @entity_item.id
24
+ format.js
25
+ format.html { redirect_to @entity_item, notice: 'Taxon item was successfully created.' }
26
+ else
27
+ format.js
28
+ format.html { render :new }
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ def destroy
35
+ @entity_item.destroy
36
+ end
37
+
38
+ private
39
+ def set_entity
40
+ @entity = params[:entity_type].safe_constantize&.find_by(id: params[:entity_id])
41
+ end
42
+
43
+ def set_entity_item
44
+ @entity_item = EntityItem.find(params[:id])
45
+ end
46
+
47
+ def entity_item_params
48
+ params.fetch(:entity_item, {}).permit(:taxon_item_id, :value)
49
+ end
50
+
51
+ end
@@ -0,0 +1,10 @@
1
+ class RailsDetailMy::ItemsController < RailsDetailMy::BaseController
2
+
3
+ def search
4
+ @items = Item.where(list_id: params[:list_id])
5
+ results = @items.map { |x| { value: x.id, text: x.name, name: x.name } }
6
+
7
+ render json: { values: results }
8
+ end
9
+
10
+ end
@@ -0,0 +1,124 @@
1
+ class RailsDetailMy::KnowledgesController < RailsDetailMy::BaseController
2
+
3
+ def index
4
+ @knowledges = Knowledge.roots.page(params[:page])
5
+ end
6
+
7
+ def new
8
+ parent_id = params[:parent_id] || 0
9
+ @knowledge = Knowledge.new(parent_id: parent_id)
10
+ end
11
+
12
+ def create
13
+ @knowledge = Knowledge.new(knowledge_params)
14
+ @parent = Knowledge.find_by(id: knowledge_params[:parent_id])
15
+
16
+ if @knowledge.save
17
+ if knowledge_params[:parent_id] == 0
18
+ redirect_to admin_knowledges_url, notice: 'Knowledge was successfully created.'
19
+ else
20
+ redirect_to admin_knowledge_url(@parent.parent), notice: 'Knowledge was successfully created.'
21
+ end
22
+ else
23
+ render :new
24
+ end
25
+ end
26
+
27
+ def new_belong
28
+ if params[:type].present? && params[:id].present?
29
+ @knowable = params[:type].safe_constantize.find(params[:id])
30
+ end
31
+ end
32
+
33
+ def create_belong
34
+ if params[:type].present? && params[:id].present?
35
+ @knowable = params[:type].safe_constantize.find(params[:id])
36
+ @knowable.update(knowledge_id: @knowledge)
37
+ end
38
+ end
39
+
40
+ def show
41
+ end
42
+
43
+ def child
44
+ @knowledges = @knowledge.children
45
+
46
+ respond_to do |format|
47
+ format.js
48
+ end
49
+ end
50
+
51
+ def edit
52
+ end
53
+
54
+ def update
55
+ if @knowledge.update(knowledge_params)
56
+ redirect_to admin_knowledges_url, notice: 'Knowledge was successfully updated.'
57
+ else
58
+ render :edit
59
+ end
60
+ end
61
+
62
+ def destroy
63
+ @knowledge.destroy
64
+ redirect_to admin_knowledges_url, notice: 'Knowledge was successfully destroyed.'
65
+ end
66
+
67
+ private
68
+ def set_knowledge
69
+ @knowledge = Knowledge.find(params[:id])
70
+ end
71
+
72
+ def knowledge_params
73
+ params[:knowledge].permit(:name, :parent_id)
74
+ end
75
+
76
+
77
+ def search
78
+ @knowledges = Knowledge.where('name like ?', "%#{params[:q]}%")
79
+
80
+ respond_to do |format|
81
+ format.json
82
+ end
83
+ end
84
+
85
+ def show
86
+ @knowledge = Knowledge.includes(:children => :content).find params[:id]
87
+ end
88
+
89
+ def edit
90
+ @knowledge = Knowledge.includes(:children => :wiki).find params[:id]
91
+ end
92
+
93
+ def sub
94
+ if params[:sup]
95
+ @sup = Sort.find params[:sup]
96
+ @sort = Sort.new(:position => @sup.position.to_i+1)
97
+ else
98
+ @parent = Sort.find params[:id]
99
+ @sort = Sort.new(:position => params[:position])
100
+ end
101
+ end
102
+
103
+ def create_sub
104
+ @parent = Sort.find params[:id]
105
+ @sort = @parent.children.new sort_params
106
+ @sort.insert_at(params[:sort][:position].to_i)
107
+
108
+ respond_to do |format|
109
+ if @sort.save
110
+ format.html { redirect_to :back, :notice => "添加成功" }
111
+ format.json { render json: @sort, status: :created, location: @sort }
112
+ else
113
+ format.html { render :action => 'sub' }
114
+ format.json { render json: @sort.errors, status: :unprocessable_entity }
115
+ end
116
+ end
117
+ end
118
+
119
+ def fade_form
120
+ end
121
+
122
+
123
+
124
+ end
@@ -0,0 +1,68 @@
1
+ class RailsDetailMy::MajorsController < RailsDetailMy::BaseController
2
+ before_action :set_major, only: [:pass, :update]
3
+ before_action :set_knowledge
4
+
5
+
6
+ def index
7
+ @wikis = @knowledge.major_records.page(params[:page])
8
+ end
9
+
10
+
11
+ def new
12
+ @wiki = @knowledge.major_records.build
13
+
14
+ respond_to do |format|
15
+ format.js
16
+ end
17
+ end
18
+
19
+ def create
20
+ @major = @knowledge.major_records.build
21
+ @major.body = wiki_params[:body]
22
+ @major.commit_message = wiki_params[:commit_message]
23
+ @major.commit_id = current_user.id
24
+
25
+ respond_to do |format|
26
+ if @major.save
27
+ format.js
28
+ else
29
+ format.js { head :on_content }
30
+ end
31
+ end
32
+ end
33
+
34
+ def pass
35
+ @wiki.status_passed!
36
+
37
+ if @wiki == @knowledge.major_records.first
38
+ @wiki.set_active
39
+ end
40
+
41
+ redirect_to knowledge_majors_url(@knowledge)
42
+ end
43
+
44
+ def destroy
45
+ @wiki.destroy
46
+
47
+ respond_to do |format|
48
+ format.html { redirect_to admin_sorts_url }
49
+ format.json { head :no_content }
50
+ end
51
+ end
52
+
53
+
54
+ private
55
+
56
+ def set_major
57
+ @wiki = MajorRecord.find params[:id]
58
+ end
59
+
60
+ def set_knowledge
61
+ @knowledge = Knowledge.find params[:knowledge_id]
62
+ end
63
+
64
+ def wiki_params
65
+ params[:wiki].permit(:body, :commit_message)
66
+ end
67
+
68
+ end
@@ -0,0 +1,64 @@
1
+ class RailsDetailMy::MinorsController < RailsDetailMy::BaseController
2
+ before_action :set_minor, :only => [:pass]
3
+ before_action :set_knowledge
4
+
5
+ def index
6
+ @wikis = @knowledge.minor_records.page(params[:page])
7
+ end
8
+
9
+
10
+ def new
11
+ @wiki = @knowledge.minor_records.build
12
+
13
+ respond_to do |format|
14
+ format.js
15
+ end
16
+ end
17
+
18
+ def create
19
+ @minor = @knowledge.minor_records.build
20
+ @minor.body = wiki_params[:body]
21
+ @minor.commit_message = wiki_params[:commit_message]
22
+ @minor.commit_id = current_user.id
23
+ @minor.save
24
+
25
+ respond_to do |format|
26
+ format.js
27
+ end
28
+ end
29
+
30
+ def pass
31
+ @wiki.status_passed!
32
+
33
+ if @wiki == @knowledge.minor_records.first
34
+ @wiki.set_active
35
+ end
36
+
37
+ redirect_to knowledge_minors_url(@knowledge)
38
+ end
39
+
40
+ def destroy
41
+ @wiki.destroy
42
+
43
+ respond_to do |format|
44
+ format.html { redirect_to admin_sorts_url }
45
+ format.json { head :no_content }
46
+ end
47
+ end
48
+
49
+
50
+ private
51
+ def set_minor
52
+ @wiki = MinorRecord.find params[:id]
53
+ end
54
+
55
+ def set_knowledge
56
+ @knowledge = Knowledge.find params[:knowledge_id]
57
+ end
58
+
59
+ def wiki_params
60
+ params[:wiki].permit(:body, :commit_message)
61
+ end
62
+
63
+
64
+ end
@@ -0,0 +1,47 @@
1
+ class RailsDetailMy::NotesController < RailsDetailMy::BaseController
2
+ before_action :set_note
3
+
4
+ def show
5
+ end
6
+
7
+ def edit
8
+
9
+ end
10
+
11
+ def update
12
+ @note.assign_attributes note_params
13
+ respond_to do |format|
14
+ if @note.save
15
+ format.html { redirect_to @content, notice: 'Picture was successfully updated.' }
16
+ format.json { render :show, status: :ok, location: @content }
17
+ format.js
18
+ else
19
+ format.html { render :edit }
20
+ format.json { render json: @content.errors, status: :unprocessable_entity }
21
+ end
22
+ end
23
+ end
24
+
25
+ def destroy
26
+ @content.destroy
27
+ respond_to do |format|
28
+ format.html { redirect_to pictures_url, notice: 'Picture was successfully destroyed.' }
29
+ format.json { head :no_content }
30
+ end
31
+ end
32
+
33
+ private
34
+ def set_note
35
+ @note = Note.find_or_initialize_by(detail_type: params[:detail_type], detail_id: params[:detail_id])
36
+ end
37
+
38
+ def note_params
39
+ params[:note].permit(
40
+ :title,
41
+ :body,
42
+ :key,
43
+ :type
44
+ )
45
+ end
46
+
47
+ end
@@ -0,0 +1,74 @@
1
+ class RailsDetailMy::PartsController < RailsDetailMy::BaseController
2
+ before_action :set_wiki, :only => [:new, :create]
3
+
4
+ def index
5
+ @sort = Sort.find params[:sort_id]
6
+ @parts = @sort.parts.order(id: :desc)
7
+
8
+ respond_to do |format|
9
+ format.html
10
+ format.json { render json: @parts }
11
+ end
12
+ end
13
+
14
+ def new
15
+ @part = Part.new
16
+ respond_to do |format|
17
+ format.html
18
+ format.js
19
+ format.json { render json: @part }
20
+ end
21
+ end
22
+
23
+ def create
24
+ @sort = Sort.find params[:sort_id]
25
+ @part = @sort.parts.build part_params
26
+
27
+
28
+ respond_to do |format|
29
+ if @part.save
30
+ format.html { redirect_to sort_parts_path(sort), :notice => '添加成功!' }
31
+ format.js
32
+ format.json { render json: @part, status: :created, location: @part }
33
+ else
34
+ format.html { render action: "new" }
35
+ format.js { render :status => 406 }
36
+ format.json { render json: @part.errors, status: :unprocessable_entity }
37
+ end
38
+ end
39
+ end
40
+
41
+ def show
42
+ @sort = Sort.find params[:sort_id]
43
+ @part = Part.find(params[:id])
44
+
45
+ respond_to do |format|
46
+ format.html
47
+ format.js
48
+ format.json { render json: @part }
49
+ end
50
+ end
51
+
52
+ def destroy
53
+ @sort = Sort.find params[:sort_id]
54
+ @part = Part.find(params[:id])
55
+ @part.destroy
56
+
57
+ respond_to do |format|
58
+ format.html { redirect_to parts_url }
59
+ format.json { head :no_content }
60
+ end
61
+ end
62
+
63
+ private
64
+
65
+ def set_wiki
66
+ @solo = Solo.find params[:wiki_id]
67
+ end
68
+
69
+ def part_params
70
+ params.require(:part).permit(:content, :reason).merge(:user_id => current_user.id)
71
+ end
72
+
73
+
74
+ end