rails_detail 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +165 -0
- data/README.md +3 -0
- data/Rakefile +37 -0
- data/app/assets/config/rails_detail_manifest.js +3 -0
- data/app/assets/javascripts/controllers/rails_detail_my/contents/index.ready.js +1 -0
- data/app/assets/javascripts/controllers/rails_detail_my/entity_items/index.js +45 -0
- data/app/assets/javascripts/controllers/rails_detail_my/pictures/index.ready.js +18 -0
- data/app/assets/javascripts/knowledge.js +47 -0
- data/app/assets/javascripts/rails_detail/application.js +4 -0
- data/app/assets/stylesheets/rails_detail/application.css +14 -0
- data/app/controllers/rails_detail_admin/base_controller.rb +5 -0
- data/app/controllers/rails_detail_admin/items_controller.rb +76 -0
- data/app/controllers/rails_detail_admin/lists_controller.rb +60 -0
- data/app/controllers/rails_detail_my/base_controller.rb +7 -0
- data/app/controllers/rails_detail_my/entity_items_controller.rb +51 -0
- data/app/controllers/rails_detail_my/items_controller.rb +10 -0
- data/app/controllers/rails_detail_my/knowledges_controller.rb +124 -0
- data/app/controllers/rails_detail_my/majors_controller.rb +68 -0
- data/app/controllers/rails_detail_my/minors_controller.rb +64 -0
- data/app/controllers/rails_detail_my/notes_controller.rb +47 -0
- data/app/controllers/rails_detail_my/parts_controller.rb +74 -0
- data/app/controllers/rails_detail_my/pictures_controller.rb +76 -0
- data/app/controllers/rails_detail_my/sections_controller.rb +62 -0
- data/app/controllers/rails_detail_my/solos_controller.rb +96 -0
- data/app/controllers/rails_detail_my/sources_controller.rb +79 -0
- data/app/controllers/rails_detail_my/taxon_items_controller.rb +66 -0
- data/app/controllers/rails_detail_my/wikis_controller.rb +104 -0
- data/app/models/rails_detail/concerns/content_model.rb +13 -0
- data/app/models/rails_detail/concerns/item_model.rb +24 -0
- data/app/models/rails_detail/concerns/taxon_model.rb +9 -0
- data/app/models/rails_detail/content.rb +12 -0
- data/app/models/rails_detail/contents/banner.rb +7 -0
- data/app/models/rails_detail/contents/link.rb +5 -0
- data/app/models/rails_detail/contents/note.rb +6 -0
- data/app/models/rails_detail/contents/picture.rb +7 -0
- data/app/models/rails_detail/entity_item.rb +18 -0
- data/app/models/rails_detail/item.rb +7 -0
- data/app/models/rails_detail/list.rb +6 -0
- data/app/models/rails_detail/taxon_item.rb +14 -0
- data/app/views/layouts/the_detail.html.erb +22 -0
- data/app/views/rails_detail_admin/answers/_answer.html.erb +14 -0
- data/app/views/rails_detail_admin/answers/_form.html.erb +16 -0
- data/app/views/rails_detail_admin/answers/edit.html.erb +11 -0
- data/app/views/rails_detail_admin/answers/index.html.erb +31 -0
- data/app/views/rails_detail_admin/answers/new.html.erb +22 -0
- data/app/views/rails_detail_admin/answers/show.html.erb +19 -0
- data/app/views/rails_detail_admin/base/_nav.html.erb +3 -0
- data/app/views/rails_detail_admin/items/_form.html.erb +8 -0
- data/app/views/rails_detail_admin/items/edit.html.erb +13 -0
- data/app/views/rails_detail_admin/items/index.html.erb +50 -0
- data/app/views/rails_detail_admin/items/new.html.erb +13 -0
- data/app/views/rails_detail_admin/items/show.html.erb +31 -0
- data/app/views/rails_detail_admin/lists/_form.html.erb +5 -0
- data/app/views/rails_detail_admin/lists/edit.html.erb +12 -0
- data/app/views/rails_detail_admin/lists/index.html.erb +36 -0
- data/app/views/rails_detail_admin/lists/new.html.erb +16 -0
- data/app/views/rails_detail_admin/lists/taxon.html.erb +44 -0
- data/app/views/rails_detail_admin/sections/_form.html.erb +22 -0
- data/app/views/rails_detail_admin/sections/_select.html.erb +38 -0
- data/app/views/rails_detail_admin/sections/_show_section.html.erb +22 -0
- data/app/views/rails_detail_admin/sections/edit.html.erb +17 -0
- data/app/views/rails_detail_admin/sections/index.html.erb +18 -0
- data/app/views/rails_detail_admin/sections/new.html.erb +13 -0
- data/app/views/rails_detail_admin/sources/_form.html.erb +8 -0
- data/app/views/rails_detail_admin/sources/edit.html.erb +6 -0
- data/app/views/rails_detail_admin/sources/index.html.erb +21 -0
- data/app/views/rails_detail_admin/sources/new.html.erb +5 -0
- data/app/views/rails_detail_admin/sources/show.html.erb +5 -0
- data/app/views/rails_detail_admin/wikis/_breadcrumb.html.erb +6 -0
- data/app/views/rails_detail_admin/wikis/_nav.html.erb +16 -0
- data/app/views/rails_detail_admin/wikis/_nav_index.html.erb +5 -0
- data/app/views/rails_detail_admin/wikis/_push.html.erb +10 -0
- data/app/views/rails_detail_admin/wikis/_search.html.erb +21 -0
- data/app/views/rails_detail_admin/wikis/_section.html.erb +72 -0
- data/app/views/rails_detail_admin/wikis/_solo.html.erb +26 -0
- data/app/views/rails_detail_admin/wikis/fade_form.js.erb +9 -0
- data/app/views/rails_detail_admin/wikis/index.html.erb +24 -0
- data/app/views/rails_detail_admin/wikis/show.html.erb +33 -0
- data/app/views/rails_detail_my/answers/_answer.html.erb +14 -0
- data/app/views/rails_detail_my/answers/_form.html.erb +16 -0
- data/app/views/rails_detail_my/answers/edit.html.erb +11 -0
- data/app/views/rails_detail_my/answers/index.html.erb +31 -0
- data/app/views/rails_detail_my/answers/new.html.erb +22 -0
- data/app/views/rails_detail_my/answers/show.html.erb +19 -0
- data/app/views/rails_detail_my/details/_form.html.erb +29 -0
- data/app/views/rails_detail_my/details/_major.html.erb +21 -0
- data/app/views/rails_detail_my/details/_minor.html.erb +25 -0
- data/app/views/rails_detail_my/details/_nav.html/347/232/204/345/211/257/346/234/254.erb +14 -0
- data/app/views/rails_detail_my/details/edit.html.erb +37 -0
- data/app/views/rails_detail_my/details/fade_form.js.erb +9 -0
- data/app/views/rails_detail_my/details/index.html.erb +10 -0
- data/app/views/rails_detail_my/details/search.json.jbuilder +5 -0
- data/app/views/rails_detail_my/details/show.html.erb +52 -0
- data/app/views/rails_detail_my/entity_items/_edit.html.erb +15 -0
- data/app/views/rails_detail_my/entity_items/_new.html.erb +16 -0
- data/app/views/rails_detail_my/entity_items/_taxon_item.html.erb +26 -0
- data/app/views/rails_detail_my/entity_items/create.js.erb +23 -0
- data/app/views/rails_detail_my/entity_items/destroy.js.erb +26 -0
- data/app/views/rails_detail_my/entity_items/edit.js.erb +5 -0
- data/app/views/rails_detail_my/entity_items/index.html.erb +40 -0
- data/app/views/rails_detail_my/entity_items/new.js.erb +7 -0
- data/app/views/rails_detail_my/entity_items/show.html.erb +0 -0
- data/app/views/rails_detail_my/entity_items/update.js.erb +1 -0
- data/app/views/rails_detail_my/knowledges/_form.html.erb +7 -0
- data/app/views/rails_detail_my/knowledges/_sort.html.erb +15 -0
- data/app/views/rails_detail_my/knowledges/_td.html.erb +14 -0
- data/app/views/rails_detail_my/knowledges/edit.html.erb +12 -0
- data/app/views/rails_detail_my/knowledges/index.html.erb +46 -0
- data/app/views/rails_detail_my/knowledges/new.html.erb +13 -0
- data/app/views/rails_detail_my/knowledges/new_belong.html.erb +36 -0
- data/app/views/rails_detail_my/knowledges/show.html.erb +44 -0
- data/app/views/rails_detail_my/majors/_form.html.erb +7 -0
- data/app/views/rails_detail_my/majors/_new.html.erb +5 -0
- data/app/views/rails_detail_my/majors/create.js.erb +4 -0
- data/app/views/rails_detail_my/majors/index.html.erb +39 -0
- data/app/views/rails_detail_my/majors/index2.html.erb +38 -0
- data/app/views/rails_detail_my/majors/new.html.erb +3 -0
- data/app/views/rails_detail_my/majors/new.js.erb +1 -0
- data/app/views/rails_detail_my/majors/show.html.erb +21 -0
- data/app/views/rails_detail_my/minors/_form.html.erb +7 -0
- data/app/views/rails_detail_my/minors/_new.html.erb +7 -0
- data/app/views/rails_detail_my/minors/_part.html.erb +59 -0
- data/app/views/rails_detail_my/minors/create.js.erb +10 -0
- data/app/views/rails_detail_my/minors/index.html.erb +41 -0
- data/app/views/rails_detail_my/minors/new.html.erb +1 -0
- data/app/views/rails_detail_my/minors/new.js.erb +1 -0
- data/app/views/rails_detail_my/minors/show.html.erb +22 -0
- data/app/views/rails_detail_my/notes/_add_link.html.erb +6 -0
- data/app/views/rails_detail_my/notes/_form.html.erb +4 -0
- data/app/views/rails_detail_my/notes/_new.html.erb +2 -0
- data/app/views/rails_detail_my/notes/_note.html.erb +16 -0
- data/app/views/rails_detail_my/notes/_show.html.erb +9 -0
- data/app/views/rails_detail_my/notes/create.js.erb +2 -0
- data/app/views/rails_detail_my/notes/edit.js.erb +1 -0
- data/app/views/rails_detail_my/notes/new.html.erb +2 -0
- data/app/views/rails_detail_my/notes/new.js.erb +24 -0
- data/app/views/rails_detail_my/notes/show.html.erb +2 -0
- data/app/views/rails_detail_my/notes/update.js.erb +1 -0
- data/app/views/rails_detail_my/parts/_new.html.erb +7 -0
- data/app/views/rails_detail_my/parts/_part.html.erb +59 -0
- data/app/views/rails_detail_my/parts/create.js.erb +10 -0
- data/app/views/rails_detail_my/parts/index.html.erb +39 -0
- data/app/views/rails_detail_my/parts/new.html.erb +1 -0
- data/app/views/rails_detail_my/parts/new.js.erb +1 -0
- data/app/views/rails_detail_my/parts/show.html.erb +22 -0
- data/app/views/rails_detail_my/pictures/_add_link.html.erb +6 -0
- data/app/views/rails_detail_my/pictures/_edit.html.erb +8 -0
- data/app/views/rails_detail_my/pictures/_index.html.erb +9 -0
- data/app/views/rails_detail_my/pictures/_new.html.erb +12 -0
- data/app/views/rails_detail_my/pictures/_search_form.html.erb +7 -0
- data/app/views/rails_detail_my/pictures/_show.html.erb +17 -0
- data/app/views/rails_detail_my/pictures/create.js.erb +2 -0
- data/app/views/rails_detail_my/pictures/destroy.js.erb +1 -0
- data/app/views/rails_detail_my/pictures/edit.js.erb +2 -0
- data/app/views/rails_detail_my/pictures/index.html.erb +2 -0
- data/app/views/rails_detail_my/pictures/new.html.erb +2 -0
- data/app/views/rails_detail_my/pictures/new.js.erb +1 -0
- data/app/views/rails_detail_my/pictures/show.html.erb +10 -0
- data/app/views/rails_detail_my/pictures/update.js.erb +1 -0
- data/app/views/rails_detail_my/sections/_form.html.erb +22 -0
- data/app/views/rails_detail_my/sections/_select.html.erb +38 -0
- data/app/views/rails_detail_my/sections/_show_section.html.erb +22 -0
- data/app/views/rails_detail_my/sections/edit.html.erb +17 -0
- data/app/views/rails_detail_my/sections/index.html.erb +18 -0
- data/app/views/rails_detail_my/sections/new.html.erb +13 -0
- data/app/views/rails_detail_my/solos/_new.html.erb +5 -0
- data/app/views/rails_detail_my/solos/create.js.erb +4 -0
- data/app/views/rails_detail_my/solos/edit.js.erb +1 -0
- data/app/views/rails_detail_my/solos/index.html.erb +38 -0
- data/app/views/rails_detail_my/solos/new.html.erb +3 -0
- data/app/views/rails_detail_my/solos/show.html.erb +21 -0
- data/app/views/rails_detail_my/sorts/_form.html.erb +29 -0
- data/app/views/rails_detail_my/sorts/_head.html.erb +24 -0
- data/app/views/rails_detail_my/sorts/_sort.html.erb +49 -0
- data/app/views/rails_detail_my/sorts/_sub.html.erb +16 -0
- data/app/views/rails_detail_my/sorts/edit.html.erb +14 -0
- data/app/views/rails_detail_my/sorts/edit_father.html.erb +17 -0
- data/app/views/rails_detail_my/sorts/pic.html.erb +46 -0
- data/app/views/rails_detail_my/sorts/search.json.jbuilder +6 -0
- data/app/views/rails_detail_my/sorts/show.html.erb +17 -0
- data/app/views/rails_detail_my/sorts/sub.js.erb +5 -0
- data/app/views/rails_detail_my/sources/_form.html.erb +8 -0
- data/app/views/rails_detail_my/sources/edit.html.erb +6 -0
- data/app/views/rails_detail_my/sources/index.html.erb +21 -0
- data/app/views/rails_detail_my/sources/new.html.erb +5 -0
- data/app/views/rails_detail_my/sources/show.html.erb +5 -0
- data/app/views/rails_detail_my/taxon_items/_form.html.erb +4 -0
- data/app/views/rails_detail_my/taxon_items/_new.html.erb +13 -0
- data/app/views/rails_detail_my/taxon_items/_new_list.html.erb +13 -0
- data/app/views/rails_detail_my/taxon_items/_taxon_item.html.erb +5 -0
- data/app/views/rails_detail_my/taxon_items/create.js.erb +1 -0
- data/app/views/rails_detail_my/taxon_items/destroy.js.erb +1 -0
- data/app/views/rails_detail_my/taxon_items/edit.html.erb +14 -0
- data/app/views/rails_detail_my/taxon_items/edit.js.erb +5 -0
- data/app/views/rails_detail_my/taxon_items/index.html.erb +40 -0
- data/app/views/rails_detail_my/taxon_items/new.html.erb +9 -0
- data/app/views/rails_detail_my/taxon_items/new.js.erb +28 -0
- data/app/views/rails_detail_my/taxon_items/update.js.erb +1 -0
- data/app/views/rails_detail_my/wikis/_head.html.erb +24 -0
- data/app/views/rails_detail_my/wikis/_head.html/347/232/204/345/211/257/346/234/254.erb +34 -0
- data/app/views/rails_detail_my/wikis/_sub.html.erb +16 -0
- data/app/views/rails_detail_my/wikis/create.js.erb +3 -0
- data/app/views/rails_detail_my/wikis/edit.html.erb +14 -0
- data/app/views/rails_detail_my/wikis/edit.html/347/232/204/345/211/257/346/234/254.erb +14 -0
- data/app/views/rails_detail_my/wikis/edit_father.html.erb +17 -0
- data/app/views/rails_detail_my/wikis/index.html.erb +41 -0
- data/app/views/rails_detail_my/wikis/new.js.erb +3 -0
- data/app/views/rails_detail_my/wikis/pic.html.erb +46 -0
- data/app/views/rails_detail_my/wikis/search.json.jbuilder +6 -0
- data/app/views/rails_detail_my/wikis/show.html.erb +17 -0
- data/app/views/rails_detail_my/wikis/show.html/347/232/204/345/211/257/346/234/254.erb +25 -0
- data/app/views/rails_detail_my/wikis/sub.js.erb +5 -0
- data/app/views/wikis/_form.html.erb +29 -0
- data/app/views/wikis/_head.html.erb +34 -0
- data/app/views/wikis/_nav.html.erb +2 -0
- data/app/views/wikis/_sort.html.erb +15 -0
- data/app/views/wikis/edit.html.erb +14 -0
- data/app/views/wikis/index.html.erb +20 -0
- data/app/views/wikis/new.html.erb +11 -0
- data/app/views/wikis/show.html.erb +25 -0
- data/config/locales/zh.yml +10 -0
- data/config/routes.rb +31 -0
- data/db/20171115144429_create_lists.rb +39 -0
- data/db/migrate/20150723122558_create_knowledge.rb +16 -0
- data/db/migrate_backup/20150801141208_add_parent_id_to_knowledge.rb +23 -0
- data/db/migrate_backup/20150801154145_add_column_to_wikis.rb +8 -0
- data/db/migrate_backup/20150801154531_add_position_to_knowledges.rb +6 -0
- data/db/migrate_backup/20150801163012_add_wiki_histories_to_wiki.rb +5 -0
- data/db/migrate_backup/20150802015359_change_wiki_histories_count.rb +5 -0
- data/db/migrate_backup/20150802134532_add_active_to_wikis.rb +6 -0
- data/db/migrate_backup/20150802154605_add_type_to_wiki_histroy.rb +8 -0
- data/db/migrate_backup/20150802161426_add_major_records_count_to_know.rb +6 -0
- data/db/migrate_backup/20150905144632_create_konwledage_items.rb +21 -0
- data/db/migrate_backup/20150907124021_remove_photo_id_from_items.rb +8 -0
- data/db/migrate_backup/20150919025025_rename_wiki_to_content.rb +7 -0
- data/db/migrate_backup/20151214033632_create_parts.rb +12 -0
- data/db/migrate_backup/schema.rb +186 -0
- data/lib/rails_detail.rb +26 -0
- data/lib/rails_detail/config.rb +19 -0
- data/lib/rails_detail/engine.rb +28 -0
- data/lib/rails_detail/version.rb +3 -0
- data/lib/tasks/the_detail_tasks.rake +4 -0
- data/test/controllers/knowledges_controller_test.rb +49 -0
- data/test/controllers/the_detail/pictures_controller_test.rb +48 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/system/the_detail/pictures_test.rb +41 -0
- data/test/test_helper.rb +18 -0
- data/test/the_detail_test.rb +7 -0
- 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,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,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
|