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,76 @@
|
|
1
|
+
class RailsDetailMy::PicturesController < RailsDetailMy::BaseController
|
2
|
+
before_action :set_pictures, only: [:index]
|
3
|
+
before_action :set_picture, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
@pictures = @pictures.page(params[:page])
|
7
|
+
end
|
8
|
+
|
9
|
+
def new
|
10
|
+
@picture = Picture.new
|
11
|
+
@picture.detail_type = params[:detail_type]
|
12
|
+
@picture.detail_id = params[:detail_id]
|
13
|
+
end
|
14
|
+
|
15
|
+
def create
|
16
|
+
@picture = Picture.new(picture_params)
|
17
|
+
@picture.detail_type = params[:detail_type]
|
18
|
+
@picture.detail_id = params[:detail_id]
|
19
|
+
|
20
|
+
respond_to do |format|
|
21
|
+
if @picture.save
|
22
|
+
format.html { redirect_to detail_pictures_url(params[:detail_type], params[:detail_id]), notice: 'Picture was successfully created.' }
|
23
|
+
format.js
|
24
|
+
format.json { render json: { picture: @picture.as_json, filename: url_for(@picture.file) } }
|
25
|
+
else
|
26
|
+
format.html { render :new }
|
27
|
+
format.js
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def show
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit
|
36
|
+
end
|
37
|
+
|
38
|
+
def update
|
39
|
+
respond_to do |format|
|
40
|
+
if @picture.update(picture_params)
|
41
|
+
format.html { redirect_to detail_pictures_url(params[:detail_type], ), notice: 'Picture was successfully updated.' }
|
42
|
+
format.json { render json: { filename: url_for(@picture.file) } }
|
43
|
+
else
|
44
|
+
format.html { render :edit }
|
45
|
+
format.json { }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def destroy
|
51
|
+
@picture.destroy
|
52
|
+
|
53
|
+
respond_to do |format|
|
54
|
+
format.js
|
55
|
+
format.html { redirect_to detail_pictures_url, notice: 'Picture was successfully destroyed.' }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
def set_pictures
|
61
|
+
@pictures = Picture.where(detail_type: params[:detail_type], detail_id: params[:detail_id])
|
62
|
+
end
|
63
|
+
|
64
|
+
def set_picture
|
65
|
+
@picture = Picture.find(params[:id])
|
66
|
+
end
|
67
|
+
|
68
|
+
def picture_params
|
69
|
+
params.fetch(:picture, {}).permit(
|
70
|
+
:title,
|
71
|
+
:file,
|
72
|
+
:body
|
73
|
+
)
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
class RailsDetailMy::SectionsController < RailsDetailMy::BaseController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@sort = Sort.find(params[:sort_id])
|
5
|
+
@sections = Section.find_all_by_sort_id(params[:sort_id])
|
6
|
+
end
|
7
|
+
|
8
|
+
def new
|
9
|
+
@section = Section.new
|
10
|
+
@sort = Sort.find(params[:sort_id])
|
11
|
+
end
|
12
|
+
|
13
|
+
def create
|
14
|
+
@section = Section.new(params[:section])
|
15
|
+
@section.sort_id = params[:sort_id]
|
16
|
+
|
17
|
+
@baike = Sort.find(params[:sort_id])
|
18
|
+
@baike.have_section = 1
|
19
|
+
@baike.save
|
20
|
+
|
21
|
+
|
22
|
+
respond_to do |format|
|
23
|
+
if @section.save
|
24
|
+
format.html { redirect_to sort_sections_url(params[:sort_id]), :notice => '添加成功' }
|
25
|
+
else
|
26
|
+
format.html { render action: "new" }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit
|
32
|
+
@section = Section.find(params[:id])
|
33
|
+
@sort = Sort.find @section.sort_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def update
|
37
|
+
@section = Section.find(params[:id])
|
38
|
+
@sort = Sort.find @section.sort_id
|
39
|
+
|
40
|
+
respond_to do |format|
|
41
|
+
if @section.update_attributes(params[:section])
|
42
|
+
format.html { redirect_to sort_sections_url(@sort), notice: "修改成功" }
|
43
|
+
format.json { head :no_content }
|
44
|
+
else
|
45
|
+
format.html { render action: "edit" }
|
46
|
+
format.json { render json: @section.errors, status: :unprocessable_entity }
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def destroy
|
52
|
+
@section = Section.find(params[:id])
|
53
|
+
@sort = Sort.find @section.sort_id
|
54
|
+
@section.destroy
|
55
|
+
|
56
|
+
respond_to do |format|
|
57
|
+
format.html { redirect_to sort_sections_url(@sort) }
|
58
|
+
format.json { head :no_content }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
@@ -0,0 +1,96 @@
|
|
1
|
+
class RailsDetailMy::SolosController < RailsDetailMy::BaseController
|
2
|
+
before_action :set_solo, only: [:edit, :update]
|
3
|
+
|
4
|
+
def index
|
5
|
+
@sort = Sort.find params[:sort_id]
|
6
|
+
@solos = @sort.solos.order("id DESC")
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.html
|
10
|
+
format.json { render json: @solos }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def new
|
15
|
+
@sort = Sort.find params[:sort_id]
|
16
|
+
if @sort.solos == []
|
17
|
+
@solo = Solo.new
|
18
|
+
else
|
19
|
+
@solo = Solo.new(:content => @sort.solos.last.content||'',
|
20
|
+
:picture => @sort.solos.last.picture)
|
21
|
+
end
|
22
|
+
|
23
|
+
respond_to do |format|
|
24
|
+
format.html
|
25
|
+
format.js
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def create
|
30
|
+
@sort = Sort.find params[:sort_id]
|
31
|
+
@solo = @sort.solos.build solo_params
|
32
|
+
|
33
|
+
respond_to do |format|
|
34
|
+
if @solo.save
|
35
|
+
format.html { redirect_to @solo, notice: 'Solo was successfully created.' }
|
36
|
+
format.js
|
37
|
+
format.json { render json: @solo, status: :created, location: @solo }
|
38
|
+
else
|
39
|
+
format.html { render action: "new" }
|
40
|
+
format.js
|
41
|
+
format.json { render json: @solo.errors, status: :unprocessable_entity }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def show
|
47
|
+
@sort = Sort.find params[:sort_id]
|
48
|
+
@solo = Solo.find(params[:id])
|
49
|
+
|
50
|
+
respond_to do |format|
|
51
|
+
format.html
|
52
|
+
format.js
|
53
|
+
format.json { render json: @solo }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def edit
|
58
|
+
respond_to do |format|
|
59
|
+
format.js
|
60
|
+
format.html { render :layout => false }
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def update
|
65
|
+
respond_to do |format|
|
66
|
+
if @sort.update(sort_params)
|
67
|
+
format.html { redirect_to :back, :notice => '更新成功' }
|
68
|
+
format.json { head :no_content }
|
69
|
+
else
|
70
|
+
format.html { render action: "edit" }
|
71
|
+
format.json { render json: @sort.errors, status: :unprocessable_entity }
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def destroy
|
77
|
+
@sort = Sort.find params[:sort_id]
|
78
|
+
@solo = Solo.find(params[:id])
|
79
|
+
@solo.destroy
|
80
|
+
|
81
|
+
respond_to do |format|
|
82
|
+
format.html { redirect_to solos_url }
|
83
|
+
format.json { head :no_content }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def set_solo
|
89
|
+
@solo = Solo.find params[:id]
|
90
|
+
end
|
91
|
+
|
92
|
+
def solo_params
|
93
|
+
params[:solo].permit(:name, :subname, :content, :reason).merge(:user_id => current_user.id)
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
class RailsDetailMy::SourcesController < RailsDetailMy::BaseController
|
2
|
+
|
3
|
+
def index
|
4
|
+
@sources = Source.all
|
5
|
+
|
6
|
+
respond_to do |format|
|
7
|
+
format.html
|
8
|
+
format.json { render json: @sources }
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def show
|
13
|
+
@source = Source.find(params[:id])
|
14
|
+
|
15
|
+
respond_to do |format|
|
16
|
+
format.html
|
17
|
+
format.json { render json: @source }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
def new
|
23
|
+
@source = Source.new
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
format.html # new.html.erb
|
27
|
+
format.json { render json: @source }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# GET /sources/1/edit
|
32
|
+
def edit
|
33
|
+
@source = Source.find(params[:id])
|
34
|
+
end
|
35
|
+
|
36
|
+
# POST /sources
|
37
|
+
# POST /sources.json
|
38
|
+
def create
|
39
|
+
@source = Source.new(params[:source])
|
40
|
+
|
41
|
+
respond_to do |format|
|
42
|
+
if @source.save
|
43
|
+
format.html { redirect_to @source, notice: 'Source was successfully created.' }
|
44
|
+
format.json { render json: @source, status: :created, location: @source }
|
45
|
+
else
|
46
|
+
format.html { render action: "new" }
|
47
|
+
format.json { render json: @source.errors, status: :unprocessable_entity }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# PUT /sources/1
|
53
|
+
# PUT /sources/1.json
|
54
|
+
def update
|
55
|
+
@source = Source.find(params[:id])
|
56
|
+
|
57
|
+
respond_to do |format|
|
58
|
+
if @source.update_attributes(params[:source])
|
59
|
+
format.html { redirect_to @source, notice: 'Source was successfully updated.' }
|
60
|
+
format.json { head :no_content }
|
61
|
+
else
|
62
|
+
format.html { render action: "edit" }
|
63
|
+
format.json { render json: @source.errors, status: :unprocessable_entity }
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# DELETE /sources/1
|
69
|
+
# DELETE /sources/1.json
|
70
|
+
def destroy
|
71
|
+
@source = Source.find(params[:id])
|
72
|
+
@source.destroy
|
73
|
+
|
74
|
+
respond_to do |format|
|
75
|
+
format.html { redirect_to sources_url }
|
76
|
+
format.json { head :no_content }
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
class RailsDetailMy::TaxonItemsController < RailsDetailMy::BaseController
|
2
|
+
before_action :set_taxon_item, only: [:show, :edit, :update, :destroy]
|
3
|
+
|
4
|
+
def index
|
5
|
+
taxon_items = TaxonItem.includes(:list).where(taxon_type: params[:taxon_type], taxon_id: params[:taxon_id])
|
6
|
+
@items_hash = taxon_items.group_by { |i| i.list }
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
end
|
11
|
+
|
12
|
+
def new
|
13
|
+
@taxon = params[:taxon_type].safe_constantize.find params[:taxon_id]
|
14
|
+
if params[:list_id]
|
15
|
+
@list = List.find params[:list_id]
|
16
|
+
else
|
17
|
+
@lists = List.all.map { |list| [list.name, list.id] }
|
18
|
+
end
|
19
|
+
|
20
|
+
@taxon_item = TaxonItem.new(taxon_type: params[:taxon_type], taxon_id: params[:taxon_id], list_id: params[:list_id])
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit
|
24
|
+
end
|
25
|
+
|
26
|
+
def create
|
27
|
+
@taxon_item = TaxonItem.new(taxon_item_params)
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
if @taxon_item.save
|
31
|
+
format.js
|
32
|
+
format.html { redirect_to @taxon_item, notice: 'Taxon item was successfully created.' }
|
33
|
+
else
|
34
|
+
format.js
|
35
|
+
format.html { render :new }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
def update
|
42
|
+
respond_to do |format|
|
43
|
+
if @taxon_item.update(taxon_item_params)
|
44
|
+
format.js
|
45
|
+
format.html { redirect_to @taxon_item, notice: 'Taxon item was successfully created.' }
|
46
|
+
else
|
47
|
+
format.js
|
48
|
+
format.html { render :edit }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def destroy
|
54
|
+
@taxon_item.destroy
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def set_taxon_item
|
59
|
+
@taxon_item = TaxonItem.find(params[:id])
|
60
|
+
end
|
61
|
+
|
62
|
+
def taxon_item_params
|
63
|
+
params.fetch(:taxon_item, {}).permit(:list_id, :item_id).merge(taxon_type: params[:taxon_type], taxon_id: params[:taxon_id])
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
class RailsDetailMy::WikisController < RailsDetailMy::BaseController
|
2
|
+
|
3
|
+
|
4
|
+
def search
|
5
|
+
@sorts = Sort.find [params[:id],1]
|
6
|
+
#if params[:ids]
|
7
|
+
# @sorts = Sort.where(:id => params[:ids].split('-'))
|
8
|
+
#else
|
9
|
+
# @sorts = Sort.limit(20).search(:name_cont => params[:q]).result
|
10
|
+
#end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def index
|
15
|
+
@sorts = Sort.roots
|
16
|
+
end
|
17
|
+
|
18
|
+
def new
|
19
|
+
@sort = Sort.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def create
|
23
|
+
@sort = Sort.new sort_params
|
24
|
+
|
25
|
+
respond_to do |format|
|
26
|
+
if @sort.save
|
27
|
+
format.html { redirect_to admin_sorts_url, notice: '添加成功' }
|
28
|
+
else
|
29
|
+
format.html { render action: "new" }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def edit
|
35
|
+
respond_to do |format|
|
36
|
+
format.html
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def update
|
41
|
+
respond_to do |format|
|
42
|
+
if @sort.update(sort_params)
|
43
|
+
format.html { redirect_to :back, :notice => '更新成功' }
|
44
|
+
format.json { head :no_content }
|
45
|
+
else
|
46
|
+
format.html { render action: "edit" }
|
47
|
+
format.json { render json: @sort.errors, status: :unprocessable_entity }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def sub
|
53
|
+
if params[:sup]
|
54
|
+
@sup = Sort.find params[:sup]
|
55
|
+
@sort = Sort.new(:position => @sup.position.to_i+1)
|
56
|
+
else
|
57
|
+
@parent = Sort.find params[:id]
|
58
|
+
@sort = Sort.new(:position => params[:position])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def create_sub
|
63
|
+
@parent = Sort.find params[:id]
|
64
|
+
@sort = @parent.children.new sort_params
|
65
|
+
@sort.insert_at(params[:sort][:position].to_i)
|
66
|
+
|
67
|
+
respond_to do |format|
|
68
|
+
if @sort.save
|
69
|
+
format.html { redirect_to :back, :notice => "添加成功" }
|
70
|
+
format.json { render json: @sort, status: :created, location: @sort }
|
71
|
+
else
|
72
|
+
format.html { render :action => 'sub' }
|
73
|
+
format.json { render json: @sort.errors, status: :unprocessable_entity }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def destroy
|
79
|
+
@sort.destroy
|
80
|
+
|
81
|
+
respond_to do |format|
|
82
|
+
format.html { redirect_to admin_sorts_url }
|
83
|
+
format.json { head :no_content }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
private
|
88
|
+
def set_wiki
|
89
|
+
@wiki = Wiki.find params[:id]
|
90
|
+
end
|
91
|
+
|
92
|
+
def wiki_params
|
93
|
+
params[:wiki].permit(:name, :subname, :position)
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
def show
|
98
|
+
@solo = Wiki.includes(:children).find params[:id]
|
99
|
+
end
|
100
|
+
|
101
|
+
def fade_form
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|