fassets_core 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +21 -0
- data/README.md +22 -0
- data/Rakefile +39 -0
- data/app/assets/images/fassets_core/add.png +0 -0
- data/app/assets/images/fassets_core/archive.png +0 -0
- data/app/assets/images/fassets_core/classify.png +0 -0
- data/app/assets/images/fassets_core/clipboard.png +0 -0
- data/app/assets/images/fassets_core/collapse.png +0 -0
- data/app/assets/images/fassets_core/collapsed.png +0 -0
- data/app/assets/images/fassets_core/delete.png +0 -0
- data/app/assets/images/fassets_core/drag.png +0 -0
- data/app/assets/images/fassets_core/edit.png +0 -0
- data/app/assets/images/fassets_core/link.png +0 -0
- data/app/assets/images/fassets_core/markup_preview.png +0 -0
- data/app/assets/images/fassets_core/remove.png +0 -0
- data/app/assets/images/fassets_core/sort.png +0 -0
- data/app/assets/images/fassets_core/warning.png +0 -0
- data/app/assets/javascripts/fassets_core/add_asset_box.js +102 -0
- data/app/assets/javascripts/fassets_core/application.js.erb +14 -0
- data/app/assets/javascripts/fassets_core/assets.js +31 -0
- data/app/assets/javascripts/fassets_core/catalog_box.js +73 -0
- data/app/assets/javascripts/fassets_core/catalogs.js +46 -0
- data/app/assets/javascripts/fassets_core/classification.js +37 -0
- data/app/assets/javascripts/fassets_core/edit_box.js +63 -0
- data/app/assets/javascripts/fassets_core/facets.js.erb +32 -0
- data/app/assets/javascripts/fassets_core/tray.js +30 -0
- data/app/assets/stylesheets/fassets_core/add_asset_box.css.scss +77 -0
- data/app/assets/stylesheets/fassets_core/application.css +16 -0
- data/app/assets/stylesheets/fassets_core/assets.css.scss +74 -0
- data/app/assets/stylesheets/fassets_core/catalog_box.css.scss +45 -0
- data/app/assets/stylesheets/fassets_core/collapsible.css.scss +54 -0
- data/app/assets/stylesheets/fassets_core/edit_box.css.scss +58 -0
- data/app/assets/stylesheets/fassets_core/facet.css.scss +56 -0
- data/app/assets/stylesheets/fassets_core/filter.css.scss +20 -0
- data/app/assets/stylesheets/fassets_core/forms.css.scss +12 -0
- data/app/assets/stylesheets/fassets_core/labels.css.scss +13 -0
- data/app/assets/stylesheets/fassets_core/master.css.scss +127 -0
- data/app/assets/stylesheets/fassets_core/sidebar.css.scss +84 -0
- data/app/assets/stylesheets/fassets_core/tray.css.scss +106 -0
- data/app/controllers/assets_controller.rb +115 -0
- data/app/controllers/catalogs_controller.rb +99 -0
- data/app/controllers/classifications_controller.rb +56 -0
- data/app/controllers/facets_controller.rb +57 -0
- data/app/controllers/fassets_core/application_controller.rb +5 -0
- data/app/controllers/labels_controller.rb +54 -0
- data/app/controllers/tray_positions_controller.rb +81 -0
- data/app/helpers/assets_helper.rb +20 -0
- data/app/helpers/catalogs_helper.rb +3 -0
- data/app/helpers/classifications_helper.rb +8 -0
- data/app/helpers/fassets_core/application_helper.rb +48 -0
- data/app/helpers/labels_helper.rb +3 -0
- data/app/helpers/tray_positions_helper.rb +3 -0
- data/app/models/asset.rb +52 -0
- data/app/models/catalog.rb +16 -0
- data/app/models/classification.rb +8 -0
- data/app/models/facet.rb +19 -0
- data/app/models/label.rb +11 -0
- data/app/models/label_filter.rb +16 -0
- data/app/models/labeling.rb +5 -0
- data/app/models/tray_position.rb +9 -0
- data/app/views/assets/_add_asset_sidebar.html.haml +8 -0
- data/app/views/assets/_classification.html.haml +33 -0
- data/app/views/assets/_form.html.haml +30 -0
- data/app/views/assets/_put_on_tray.html.haml +7 -0
- data/app/views/assets/edit.html.haml +15 -0
- data/app/views/assets/new.html.haml +25 -0
- data/app/views/assets/show.html.haml +13 -0
- data/app/views/catalogs/_box_catalog_list.html.haml +6 -0
- data/app/views/catalogs/_box_content.html.haml +13 -0
- data/app/views/catalogs/_catalog.html.haml +2 -0
- data/app/views/catalogs/_facet.html.haml +13 -0
- data/app/views/catalogs/_filter_item.html.haml +3 -0
- data/app/views/catalogs/_form.html.haml +6 -0
- data/app/views/catalogs/box.html.haml +6 -0
- data/app/views/catalogs/edit.html.haml +8 -0
- data/app/views/catalogs/index.html.haml +17 -0
- data/app/views/catalogs/new.html.haml +8 -0
- data/app/views/catalogs/show.html.haml +30 -0
- data/app/views/classifications/update.js.erb +4 -0
- data/app/views/facets/_form.html.haml +9 -0
- data/app/views/facets/edit.html.haml +15 -0
- data/app/views/labels/_form.haml +3 -0
- data/app/views/labels/_sidebar.html.haml +22 -0
- data/app/views/labels/destroy.js.erb +13 -0
- data/app/views/layouts/fassets_core/application.html.haml +16 -0
- data/app/views/shared/_asset.html.haml +22 -0
- data/app/views/shared/_asset_form.html.haml +7 -0
- data/app/views/shared/_classification.html.haml +23 -0
- data/app/views/shared/_clipboard.html.haml +10 -0
- data/app/views/shared/_error.html.haml +6 -0
- data/app/views/shared/_tray.html.haml +13 -0
- data/app/views/shared/_tray_position.html.haml +8 -0
- data/app/views/tray_positions/create.js.rjs +10 -0
- data/app/views/tray_positions/destroy.js.rjs +1 -0
- data/app/views/tray_positions/sort.js.rjs +15 -0
- data/config/initializers/mime_types.rb +2 -0
- data/config/initializers/uploader.rb +2 -0
- data/config/initializers/users.rb +7 -0
- data/config/routes.rb +34 -0
- data/db/migrate/001_create_catalogs.rb +13 -0
- data/db/migrate/002_create_facets.rb +14 -0
- data/db/migrate/003_create_labels.rb +12 -0
- data/db/migrate/005_create_classifications.rb +12 -0
- data/db/migrate/006_create_labelings.rb +12 -0
- data/db/migrate/007_create_tray_positions.rb +13 -0
- data/db/migrate/008_create_assets.rb +16 -0
- data/db/migrate/010_add_label_ordering.rb +10 -0
- data/db/migrate/017_add_clipboard.rb +11 -0
- data/db/migrate/20120803150826_add_position_to_facet.rb +5 -0
- data/db/schema.rb +141 -0
- data/db/seeds.rb +7 -0
- data/lib/acts_as_asset.rb +36 -0
- data/lib/authenticated_system.rb +187 -0
- data/lib/authenticated_test_helper.rb +20 -0
- data/lib/fassets_core.rb +6 -0
- data/lib/fassets_core/engine.rb +7 -0
- data/lib/fassets_core/plugins.rb +13 -0
- data/lib/fassets_core/test_helper.rb +3 -0
- data/lib/fassets_core/test_helper/every_assets_controller.rb +161 -0
- data/lib/fassets_core/test_helper/every_authenticated_controller.rb +10 -0
- data/lib/fassets_core/version.rb +3 -0
- data/lib/tasks/cucumber.rake +57 -0
- data/lib/tasks/fassets-core_tasks.rake +4 -0
- data/lib/template_manager.rb +27 -0
- data/test/fassets-core_test.rb +7 -0
- data/test/fixtures/asset_contents.yml +7 -0
- data/test/fixtures/assets.yml +7 -0
- data/test/fixtures/catalogs.yml +9 -0
- data/test/fixtures/classifications.yml +7 -0
- data/test/fixtures/facets.yml +9 -0
- data/test/fixtures/frames.yml +11 -0
- data/test/fixtures/image_assets.yml +7 -0
- data/test/fixtures/labellings.yml +7 -0
- data/test/fixtures/labels.yml +9 -0
- data/test/fixtures/presentations.yml +7 -0
- data/test/fixtures/slides.yml +11 -0
- data/test/fixtures/slots.yml +0 -0
- data/test/fixtures/topics.yml +11 -0
- data/test/fixtures/tray_positions.yml +7 -0
- data/test/fixtures/users.yml +31 -0
- data/test/functional/assets_controller_test.rb +8 -0
- data/test/functional/catalogs_controller_test.rb +8 -0
- data/test/functional/classifications_controller_test.rb +8 -0
- data/test/functional/content_controller_test.rb +8 -0
- data/test/functional/facets_controller_test.rb +8 -0
- data/test/functional/file_assets_controller_test.rb +8 -0
- data/test/functional/files_controller_test.rb +8 -0
- data/test/functional/labellings_controller_test.rb +8 -0
- data/test/functional/labels_controller_test.rb +8 -0
- data/test/functional/presentations_controller_test.rb +8 -0
- data/test/functional/sessions_controller_test.rb +82 -0
- data/test/functional/slides_controller_test.rb +8 -0
- data/test/functional/slots_controller_test.rb +8 -0
- data/test/functional/tray_positions_controller_test.rb +8 -0
- data/test/functional/urls_controller_test.rb +8 -0
- data/test/functional/users_controller_test.rb +58 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/performance/browsing_test.rb +9 -0
- data/test/test_helper.rb +10 -0
- data/test/unit/asset_content_test.rb +8 -0
- data/test/unit/asset_test.rb +8 -0
- data/test/unit/catalog_test.rb +8 -0
- data/test/unit/classification_test.rb +8 -0
- data/test/unit/facet_test.rb +8 -0
- data/test/unit/frame_test.rb +8 -0
- data/test/unit/image_asset_test.rb +8 -0
- data/test/unit/label_test.rb +8 -0
- data/test/unit/labelling_test.rb +8 -0
- data/test/unit/presentation_test.rb +8 -0
- data/test/unit/slide_test.rb +8 -0
- data/test/unit/slot_test.rb +8 -0
- data/test/unit/topic_test.rb +8 -0
- data/test/unit/tray_position_test.rb +8 -0
- data/test/unit/user_test.rb +103 -0
- metadata +453 -0
@@ -0,0 +1,127 @@
|
|
1
|
+
.fassets_core {
|
2
|
+
text-align: left;
|
3
|
+
|
4
|
+
li {
|
5
|
+
list-style: none;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
a.icon {
|
10
|
+
padding-left: 18px;
|
11
|
+
background-repeat: no-repeat;
|
12
|
+
}
|
13
|
+
a.icon.remove {
|
14
|
+
background-image: image-url("fassets_core/remove.png");
|
15
|
+
}
|
16
|
+
a.icon.edit {
|
17
|
+
background-image: image-url("fassets_core/edit.png");
|
18
|
+
}
|
19
|
+
a.icon.link {
|
20
|
+
background-image: image-url("fassets_core/link.png");
|
21
|
+
}
|
22
|
+
a.icon.file {
|
23
|
+
background-image: image-url("fassets_core/image.png");
|
24
|
+
}
|
25
|
+
|
26
|
+
.action {
|
27
|
+
font-size: 10pt;
|
28
|
+
}
|
29
|
+
.action input{
|
30
|
+
float: left;
|
31
|
+
}
|
32
|
+
.center {
|
33
|
+
text-align: center;
|
34
|
+
}
|
35
|
+
|
36
|
+
.clear {
|
37
|
+
clear: both;
|
38
|
+
}
|
39
|
+
|
40
|
+
/* @group Container */
|
41
|
+
|
42
|
+
#container {
|
43
|
+
padding: 15px;
|
44
|
+
margin-bottom: 10px;
|
45
|
+
background-color: white;
|
46
|
+
}
|
47
|
+
|
48
|
+
.active {
|
49
|
+
background-color: #dce9ff;
|
50
|
+
border: 1px dotted #0060ff;
|
51
|
+
}
|
52
|
+
.hover {
|
53
|
+
border: 1px solid #0060ff;
|
54
|
+
background-color: #dce9ff;
|
55
|
+
}
|
56
|
+
|
57
|
+
/* @end */
|
58
|
+
|
59
|
+
#parent {
|
60
|
+
color: #6e6e6e;
|
61
|
+
font-weight: bold;
|
62
|
+
}
|
63
|
+
|
64
|
+
/* @group FacetColors */
|
65
|
+
|
66
|
+
span.color {
|
67
|
+
font-weight: bold;
|
68
|
+
color: white;
|
69
|
+
padding: .1em .5em;
|
70
|
+
}
|
71
|
+
.red {background-color: #d10818;}
|
72
|
+
.red_lite {background-color: #f9c0c4;}
|
73
|
+
.red_lite a {color: #d10818;}
|
74
|
+
|
75
|
+
.orange {background-color: #ff6300;}
|
76
|
+
.orange_lite {background-color: #ffd2a7;}
|
77
|
+
.orange_lite a {color: #d43d00;}
|
78
|
+
|
79
|
+
.yellow {background-color: #f4cb00;}
|
80
|
+
.yellow_lite {background-color: #f3e8b6;}
|
81
|
+
.yellow_lite a {color: #f4cb00;}
|
82
|
+
|
83
|
+
.green {background-color: #55b100;}
|
84
|
+
.green_lite {background-color: #c1f294;}
|
85
|
+
.green_lite a {color: #55b100;}
|
86
|
+
|
87
|
+
.blue {background-color: #478adb;}
|
88
|
+
.blue_lite {background-color: #bfd8f7;}
|
89
|
+
.blue_lite a {color: #478adb;}
|
90
|
+
|
91
|
+
.violet {background-color: #8600ab;}
|
92
|
+
.violet_lite {background-color: #cf9ddc;}
|
93
|
+
.violet_lite a {color: #8600ab;}
|
94
|
+
|
95
|
+
.gray {background-color: #3a3a3a;}
|
96
|
+
.gray_lite {background-color: #c5c5c5;}
|
97
|
+
.gray_lite {color: #3a3a3a;}
|
98
|
+
|
99
|
+
/* @end */
|
100
|
+
|
101
|
+
#drop_asset {
|
102
|
+
cursor: 'pointer';
|
103
|
+
}
|
104
|
+
#name_warning {
|
105
|
+
color: red;
|
106
|
+
font-weight: bold;
|
107
|
+
}
|
108
|
+
#title_warning {
|
109
|
+
color: red;
|
110
|
+
font-weight: bold;
|
111
|
+
}
|
112
|
+
#file_warning {
|
113
|
+
color: red;
|
114
|
+
font-weight: bold;
|
115
|
+
}
|
116
|
+
#url_warning {
|
117
|
+
color: red;
|
118
|
+
font-weight: bold;
|
119
|
+
}
|
120
|
+
.asset_form {
|
121
|
+
float: left;
|
122
|
+
margin-top: 50px;
|
123
|
+
margin-left: 30px;
|
124
|
+
}
|
125
|
+
#asset_preview {
|
126
|
+
float: left;
|
127
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
#sidebar {
|
2
|
+
float: right;
|
3
|
+
right: 0%;
|
4
|
+
width: 25%;
|
5
|
+
height: 100%;
|
6
|
+
|
7
|
+
.classification_form {
|
8
|
+
margin-bottom: 1em;
|
9
|
+
margin-right: .5em;
|
10
|
+
height: 95px;
|
11
|
+
background-color: #888888;
|
12
|
+
border: 2px solid #777777;
|
13
|
+
border-radius: 5px;
|
14
|
+
label {
|
15
|
+
margin-left: 7px;
|
16
|
+
margin-top: 5px;
|
17
|
+
margin-bottom: 3px;
|
18
|
+
font-size: 16px;
|
19
|
+
color: white;
|
20
|
+
text-shadow: 1px 1px #777777;
|
21
|
+
}
|
22
|
+
#classification_catalog_id {
|
23
|
+
margin-left: 0.5em;
|
24
|
+
}
|
25
|
+
.classification_create {
|
26
|
+
margin-left: 0.5em;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
.classification_sidebar {
|
30
|
+
background-color: #888888;
|
31
|
+
border: 2px solid #777777;
|
32
|
+
border-radius: 5px;
|
33
|
+
margin-right: .5em;
|
34
|
+
.title {
|
35
|
+
margin-left: 7px;
|
36
|
+
margin-top: 5px;
|
37
|
+
margin-bottom: 3px;
|
38
|
+
font-size: 16px;
|
39
|
+
color: white;
|
40
|
+
text-shadow: 1px 1px #777777;
|
41
|
+
}
|
42
|
+
.collection {
|
43
|
+
margin-bottom: .5em;
|
44
|
+
padding: 0;
|
45
|
+
margin-right: .5em;
|
46
|
+
|
47
|
+
.classification_header {
|
48
|
+
margin-bottom: 10px;
|
49
|
+
height: 30px;
|
50
|
+
margin-left: 0;
|
51
|
+
.classification_title {
|
52
|
+
font-size: 16px;
|
53
|
+
font-weight: bold;
|
54
|
+
float: left;
|
55
|
+
margin-top: 5px;
|
56
|
+
padding: 3px;
|
57
|
+
padding-left: 6px;
|
58
|
+
padding-right: 6px;
|
59
|
+
position: relative;
|
60
|
+
top: 0px;
|
61
|
+
color: white;
|
62
|
+
text-shadow: 1px 1px #777777;
|
63
|
+
}
|
64
|
+
.classification_drop {
|
65
|
+
float: left;
|
66
|
+
position: relative;
|
67
|
+
top: 5px;
|
68
|
+
left: 15px;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
li.classification {
|
72
|
+
margin-left: .5em;
|
73
|
+
margin-bottom: .5em;
|
74
|
+
//background-color: #666666;
|
75
|
+
//border: 2px solid #555555;
|
76
|
+
border-radius: 5px;
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
form input[type=text] {
|
82
|
+
width: 90%;
|
83
|
+
}
|
84
|
+
}
|
@@ -0,0 +1,106 @@
|
|
1
|
+
#tray {
|
2
|
+
padding: .5em;
|
3
|
+
border-top: 1px solid #bbb;
|
4
|
+
position: fixed;
|
5
|
+
bottom: 0;
|
6
|
+
width: 100%;
|
7
|
+
height: 124px;
|
8
|
+
//background-color: #f5f5f5;
|
9
|
+
//background-color: #363636;
|
10
|
+
background: #DDD;
|
11
|
+
background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, rgb(198,198,198)), color-stop(1, rgb(226,225,226)));
|
12
|
+
background-image: -moz-linear-gradient(center bottom, rgb(198,198,198) 0%, rgb(226,225,226) 100%);
|
13
|
+
background-repeat: repeat;
|
14
|
+
border-top: 1px solid #727272;
|
15
|
+
ul#create_links {
|
16
|
+
//text-align: right;
|
17
|
+
margin-right: 3.5em;
|
18
|
+
width: 4em;
|
19
|
+
float: right;
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
#tray_placeholder {
|
24
|
+
height: 92px;
|
25
|
+
}
|
26
|
+
|
27
|
+
#tray ul {
|
28
|
+
padding: .3em;
|
29
|
+
}
|
30
|
+
|
31
|
+
#tray ul li {
|
32
|
+
padding-left: .5em;
|
33
|
+
display: inline;
|
34
|
+
}
|
35
|
+
|
36
|
+
#tray ol {
|
37
|
+
min-height: 120px;
|
38
|
+
}
|
39
|
+
|
40
|
+
#tray ol li.asset_placeholder {
|
41
|
+
float: left;
|
42
|
+
height: 102px;
|
43
|
+
width: 80px;
|
44
|
+
margin: 0 1em 1em 0;
|
45
|
+
background-color: #bfd8f7;
|
46
|
+
}
|
47
|
+
|
48
|
+
#tray ol.active {
|
49
|
+
background-color: #dce9ff;
|
50
|
+
border: 1px dotted #0060ff;
|
51
|
+
}
|
52
|
+
#tray ol.hover {
|
53
|
+
border: 1px solid #0060ff;
|
54
|
+
background-color: #dce9ff;
|
55
|
+
}
|
56
|
+
|
57
|
+
#tray ol li.clipboard {
|
58
|
+
position: relative;
|
59
|
+
float: left;
|
60
|
+
width: 250px;
|
61
|
+
height: 48px;
|
62
|
+
margin: 0 1em 1em 0;
|
63
|
+
}
|
64
|
+
|
65
|
+
#tray ol li.clipboard .icon {
|
66
|
+
float: left;
|
67
|
+
width: 52px;
|
68
|
+
height: 48px;
|
69
|
+
}
|
70
|
+
|
71
|
+
#tray ol li.clipboard .caption {
|
72
|
+
display: block;
|
73
|
+
line-height: 48px;
|
74
|
+
height: 48px;
|
75
|
+
overflow: hidden;
|
76
|
+
}
|
77
|
+
|
78
|
+
#tray ol li.clipboard .type{
|
79
|
+
position: absolute;
|
80
|
+
top: 2px;
|
81
|
+
left: 52px;
|
82
|
+
color: #999;
|
83
|
+
font-size: .8em;
|
84
|
+
}
|
85
|
+
|
86
|
+
#tray ol li.clipboard .action{
|
87
|
+
position: absolute;
|
88
|
+
top: 2px;
|
89
|
+
right: 2px;
|
90
|
+
}
|
91
|
+
|
92
|
+
#tray ol li.clipboard input {
|
93
|
+
position: absolute;
|
94
|
+
bottom: 0px;
|
95
|
+
left: 52px;
|
96
|
+
}
|
97
|
+
|
98
|
+
#new_tray_position {
|
99
|
+
float: left;
|
100
|
+
position: relative;
|
101
|
+
margin-bottom: 2px;
|
102
|
+
}
|
103
|
+
|
104
|
+
//.button_to {
|
105
|
+
// float: left;
|
106
|
+
//}
|
@@ -0,0 +1,115 @@
|
|
1
|
+
class AssetsController < FassetsCore::ApplicationController
|
2
|
+
include AssetsHelper
|
3
|
+
before_filter :authenticate_user!, :except => [:show]
|
4
|
+
before_filter :find_content, :except => [:new, :create, :classifications]
|
5
|
+
|
6
|
+
def new
|
7
|
+
if self.respond_to?(:content_model)
|
8
|
+
@content = self.content_model.new
|
9
|
+
else
|
10
|
+
@asset_types = FassetsCore::Plugins::all
|
11
|
+
type = @asset_types.select{ |t| t[:name] == params[:type]}.first
|
12
|
+
type ||= @asset_types.first if params[:type].nil?
|
13
|
+
unless type.nil?
|
14
|
+
@selected_type = type[:name]
|
15
|
+
@content = type[:class].new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
respond_to do |format|
|
19
|
+
format.html { render :template => 'assets/new', :layout => !(params["content_only"]) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
def create
|
23
|
+
@content = self.content_model.new(content_params)
|
24
|
+
@content.asset = Asset.create(:user => current_user, :name => params["asset"]["name"])
|
25
|
+
respond_to do |format|
|
26
|
+
if @content.save
|
27
|
+
@classification = Classification.new(:catalog_id => params["classification"]["catalog_id"],:asset_id => @content.asset.id)
|
28
|
+
@classification.save
|
29
|
+
create_content_labeling(@content.asset.id, params["classification"]["catalog_id"])
|
30
|
+
flash[:notice] = "Created new asset!"
|
31
|
+
format.js { render :json => @content.to_jq_upload.merge({:status => :ok}).to_json }
|
32
|
+
format.html { redirect_to edit_asset_content_path(@content) }
|
33
|
+
else
|
34
|
+
flash[:error] = "Could not create asset!"
|
35
|
+
format.js { render :json => {:errors => @content.errors.messages}.to_json }
|
36
|
+
format.html do
|
37
|
+
render :template => 'assets/new'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
def show
|
43
|
+
render :template => 'assets/show'
|
44
|
+
end
|
45
|
+
def edit
|
46
|
+
render :template => 'assets/edit', :locals => {:in_fancybox => false}, :layout => false
|
47
|
+
end
|
48
|
+
def update
|
49
|
+
if @content.update_attributes(content_params) and @content.asset.update_attributes(params["asset"])
|
50
|
+
flash[:notice] = "Succesfully updated asset!"
|
51
|
+
render :nothing => true
|
52
|
+
else
|
53
|
+
flash[:error] = "Could not update asset!"
|
54
|
+
render :template => 'assets/edit'
|
55
|
+
end
|
56
|
+
end
|
57
|
+
def destroy
|
58
|
+
flash[:notice] = "Asset has been deleted!"
|
59
|
+
@content.destroy
|
60
|
+
redirect_to main_app.root_url
|
61
|
+
end
|
62
|
+
def preview
|
63
|
+
render :partial => content_model.to_s.underscore.pluralize + "/" + @content.media_type.to_s.underscore + "_preview"
|
64
|
+
end
|
65
|
+
def classifications
|
66
|
+
@content = Asset.find(params[:id]).content
|
67
|
+
render :partial => "assets/classification"
|
68
|
+
end
|
69
|
+
protected
|
70
|
+
def content_params
|
71
|
+
field_name = self.content_model.to_s.underscore.gsub("/","_")
|
72
|
+
logger.debug field_name
|
73
|
+
params[field_name]
|
74
|
+
end
|
75
|
+
def find_content
|
76
|
+
if params[:asset_id]
|
77
|
+
content_id = Asset.find(params[:id]).content_id
|
78
|
+
else
|
79
|
+
content_id = params[:id]
|
80
|
+
end
|
81
|
+
content_id = Asset.find(params[:id]).content_id
|
82
|
+
@content = self.content_model.find(content_id)
|
83
|
+
rescue ActiveRecord::RecordNotFound => e
|
84
|
+
flash[:error] = "#{self.content_model.to_s} with id #{params[:id]} not found"
|
85
|
+
redirect_to main_app.root_url
|
86
|
+
end
|
87
|
+
def create_content_labeling(asset_id,catalog_id)
|
88
|
+
asset = Asset.find(asset_id)
|
89
|
+
content_facet = Facet.where(:catalog_id => catalog_id, :caption => "Content Type").first
|
90
|
+
return if content_facet.nil?
|
91
|
+
content_facet.labels.each do |label|
|
92
|
+
if asset.content_type == "FileAsset"
|
93
|
+
if label.caption.downcase == asset.content.media_type
|
94
|
+
labeling = Labeling.new(:classification_id => @classification.id, :label_id => label.id)
|
95
|
+
labeling.save
|
96
|
+
end
|
97
|
+
elsif asset.content_type == "Url"
|
98
|
+
if label.caption == "Url"
|
99
|
+
labeling = Labeling.new(:classification_id => @classification.id, :label_id => label.id)
|
100
|
+
labeling.save
|
101
|
+
end
|
102
|
+
elsif asset.content_type == "Code"
|
103
|
+
if label.caption == "Code"
|
104
|
+
labeling = Labeling.new(:classification_id => @classification.id, :label_id => label.id)
|
105
|
+
labeling.save
|
106
|
+
end
|
107
|
+
elsif asset.content_type == "FassetsPresentations::Presentation"
|
108
|
+
if label.caption == "Presentation"
|
109
|
+
labeling = Labeling.new(:classification_id => @classification.id, :label_id => label.id)
|
110
|
+
labeling.save
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|