Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6d5fbc0b
Commit
6d5fbc0b
authored
Dec 04, 2012
by
Chris Dodge
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
work in progress
parent
c52c61ff
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
138 additions
and
11 deletions
+138
-11
cms/djangoapps/contentstore/views.py
+7
-4
cms/static/coffee/src/views/asset_library_widget.coffee
+9
-1
cms/static/coffee/src/views/module_edit.coffee
+2
-1
cms/static/coffee/src/views/module_speed_edit.coffee
+87
-0
cms/static/coffee/src/views/unit.coffee
+14
-3
cms/static/js/speed-editor.js
+9
-2
common/lib/xmodule/xmodule/templates/html/empty.yaml
+5
-0
common/lib/xmodule/xmodule/templates/problem/empty.yaml
+5
-0
No files found.
cms/djangoapps/contentstore/views.py
View file @
6d5fbc0b
...
@@ -679,6 +679,9 @@ def clone_item(request):
...
@@ -679,6 +679,9 @@ def clone_item(request):
parent_location
=
Location
(
request
.
POST
[
'parent_location'
])
parent_location
=
Location
(
request
.
POST
[
'parent_location'
])
template
=
Location
(
request
.
POST
[
'template'
])
template
=
Location
(
request
.
POST
[
'template'
])
data
=
request
.
POST
.
get
(
'data'
)
data
=
request
.
POST
.
get
(
'data'
)
metadata
=
None
if
'metadata'
in
request
.
POST
and
len
(
request
.
POST
[
'metadata'
])
>
0
:
metadata
=
json
.
loads
(
request
.
POST
.
get
(
'metadata'
))
display_name
=
request
.
POST
.
get
(
'display_name'
)
display_name
=
request
.
POST
.
get
(
'display_name'
)
...
@@ -693,6 +696,9 @@ def clone_item(request):
...
@@ -693,6 +696,9 @@ def clone_item(request):
# TODO: This needs to be deleted when we have proper storage for static content
# TODO: This needs to be deleted when we have proper storage for static content
new_item
.
metadata
[
'data_dir'
]
=
parent
.
metadata
[
'data_dir'
]
new_item
.
metadata
[
'data_dir'
]
=
parent
.
metadata
[
'data_dir'
]
if
metadata
is
not
None
:
new_item
.
metadata
.
update
(
metadata
)
# replace the display name with an optional parameter passed in from the caller
# replace the display name with an optional parameter passed in from the caller
if
display_name
is
not
None
:
if
display_name
is
not
None
:
new_item
.
metadata
[
'display_name'
]
=
display_name
new_item
.
metadata
[
'display_name'
]
=
display_name
...
@@ -700,7 +706,6 @@ def clone_item(request):
...
@@ -700,7 +706,6 @@ def clone_item(request):
_modulestore
(
template
)
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
_modulestore
(
template
)
.
update_metadata
(
new_item
.
location
.
url
(),
new_item
.
own_metadata
)
# seed any initial content, if passed by caller
# seed any initial content, if passed by caller
logging
.
debug
(
'data = {0}'
.
format
(
data
))
if
data
is
not
None
:
if
data
is
not
None
:
_modulestore
(
template
)
.
update_item
(
new_item
.
location
.
url
(),
data
)
_modulestore
(
template
)
.
update_item
(
new_item
.
location
.
url
(),
data
)
...
@@ -950,9 +955,7 @@ def assets(request, location):
...
@@ -950,9 +955,7 @@ def assets(request, location):
display_info
[
'thumb_url'
]
=
StaticContent
.
get_url_path_from_location
(
thumbnail_location
)
if
thumbnail_location
is
not
None
else
None
display_info
[
'thumb_url'
]
=
StaticContent
.
get_url_path_from_location
(
thumbnail_location
)
if
thumbnail_location
is
not
None
else
None
display_info
[
'markup'
]
=
"<img src='{0}' />"
.
format
(
display_info
[
'url'
])
display_info
[
'markup'
]
=
"<img src='{0}' />"
.
format
(
display_info
[
'url'
])
asset_display
.
append
(
display_info
)
asset_display
.
append
(
display_info
)
logging
.
debug
(
"assets = {0}"
.
format
(
asset_display
))
return
HttpResponse
(
json
.
dumps
(
asset_display
))
return
HttpResponse
(
json
.
dumps
(
asset_display
))
...
...
cms/static/coffee/src/views/asset_library_widget.coffee
View file @
6d5fbc0b
class
LibraryEntry
extends
Backbone
.
Model
class
LibraryEntry
extends
Backbone
.
Model
# declare the basic schema of this model
defaults
:
defaults
:
id
:
null
id
:
null
thumb_url
:
null
thumb_url
:
null
...
@@ -8,24 +9,31 @@ class LibraryEntry extends Backbone.Model
...
@@ -8,24 +9,31 @@ class LibraryEntry extends Backbone.Model
markup
:
null
markup
:
null
mime_type
:
null
mime_type
:
null
# this is the collection of assets
class
LibraryCollection
extends
Backbone
.
Collection
class
LibraryCollection
extends
Backbone
.
Collection
url
:
'/assets/'
url
:
'/assets/'
model
:
LibraryEntry
model
:
LibraryEntry
initialize
:
(
course_location
)
->
initialize
:
(
course_location
)
->
# the collection fetch url is /assets/<location
@
url
=
@
url
+
course_location
@
url
=
@
url
+
course_location
# this is the main Backbone View which encompasses the entire
# asset window
class
CMS
.
Views
.
AssetWidget
extends
Backbone
.
View
class
CMS
.
Views
.
AssetWidget
extends
Backbone
.
View
initialize
:
->
initialize
:
->
# the editor is passed in by the caller, we need this so we can inject content into it
# when we pick the asset to insert
@
editor
=
@
options
.
editor
@
editor
=
@
options
.
editor
# This subview covers the list of assets
@
library
=
new
CMS
.
Views
.
AssetWidget
.
Library
(
@
library
=
new
CMS
.
Views
.
AssetWidget
.
Library
(
el
:
@
$
(
'.library'
)
el
:
@
$
(
'.library'
)
model
:
@
model
model
:
@
model
assetWidget
:
@
assetWidget
:
@
)
)
# this subview covers the upload form
@
uploadForm
=
new
CMS
.
Views
.
AssetWidget
.
UploadForm
(
@
uploadForm
=
new
CMS
.
Views
.
AssetWidget
.
UploadForm
(
el
:
@
$
(
'.upload-form'
)
el
:
@
$
(
'.upload-form'
)
model
:
@
model
model
:
@
model
...
...
cms/static/coffee/src/views/module_edit.coffee
View file @
6d5fbc0b
...
@@ -35,11 +35,12 @@ class CMS.Views.ModuleEdit extends Backbone.View
...
@@ -35,11 +35,12 @@ class CMS.Views.ModuleEdit extends Backbone.View
return
_metadata
return
_metadata
cloneTemplate
:
(
parent
,
template
,
content
)
->
cloneTemplate
:
(
parent
,
template
,
content
,
_metadata
)
->
$
.
post
(
"/clone_item"
,
{
$
.
post
(
"/clone_item"
,
{
parent_location
:
parent
parent_location
:
parent
template
:
template
template
:
template
data
:
content
data
:
content
metadata
:
JSON
.
stringify
(
_metadata
)
},
(
data
)
=>
},
(
data
)
=>
@
model
.
set
(
id
:
data
.
id
)
@
model
.
set
(
id
:
data
.
id
)
@
$el
.
data
(
'id'
,
data
.
id
)
@
$el
.
data
(
'id'
,
data
.
id
)
...
...
cms/static/coffee/src/views/module_speed_edit.coffee
0 → 100644
View file @
6d5fbc0b
class
CMS
.
Views
.
ModuleSpeedEdit
extends
CMS
.
Views
.
ModuleEdit
events
:
"click .component-actions .edit-button"
:
'clickEditButton'
"click .component-actions .delete-button"
:
'onDelete'
initialize
:
->
@
onDelete
=
@
options
.
onDelete
@
parent
=
@
options
.
parent
super
(
@
options
)
clickEditButton
:
->
@
enterEditMode
()
enterEditMode
:
->
@
$editorEl
=
$
(
$
(
'#problem-editor'
).
html
())
# Toggle our class
@
$el
.
addClass
(
'editing'
)
# We put the editor dialog in a separate Backbone view
@
$editor
=
new
CMS
.
Views
.
SpeedEditor
(
el
:
@
$editorEl
widget
:
@
# pass along a callback
parent
:
@
parent
model
:
@
model
)
$componentActions
=
$
(
$
(
'#component-actions'
).
html
())
@
$el
.
append
(
@
$editorEl
)
@
$el
.
append
(
$componentActions
)
@
$el
.
show
()
# $modalCover is defined in base.js
$modalCover
.
fadeIn
(
200
)
onCloseEditor
:
->
@
exitEditMode
()
@
$el
.
remove
()
onSaveEditor
:
->
# note, we need to nest the whole XML inside a <problem></problem>
xml
=
'<problem>
\n
'
+
getXMLContent
()
+
'</problem>'
metadata
=
{
'markdown_source'
:
getMarkdownContent
()}
if
not
@
model
.
id
@
cloneTemplate
(
@
options
.
parent
,
'i4x://edx/templates/problem/Empty'
,
xml
,
metadata
)
@
exitEditMode
()
else
data
=
data
:
xml
@
model
.
save
(
data
).
done
(
->
@
exitEditMode
()
).
fail
(
=>
showToastMessage
(
"There was an error saving your changes. Please try again."
,
null
,
3
)
)
exitEditMode
:
->
$modalCover
.
fadeOut
(
150
)
@
$editorEl
.
remove
()
@
$el
.
removeClass
(
'editing'
)
class
CMS
.
Views
.
SpeedEditor
extends
Backbone
.
View
events
:
"click .cancel-button"
:
'closeEditor'
"click .save-button"
:
'saveEditor'
initialize
:
->
@
$preview
=
$
(
$
(
'#problem-preview'
).
html
())
initProblemEditors
(
@
$el
,
@
$preview
)
@
$el
.
append
(
@
$preview
)
closeEditor
:
(
event
)
->
@
$el
.
slideUp
(
150
)
if
@
options
.
widget
@
options
.
widget
.
onCloseEditor
()
saveEditor
:
(
event
)
->
if
@
options
.
widget
@
options
.
widget
.
onSaveEditor
()
cms/static/coffee/src/views/unit.coffee
View file @
6d5fbc0b
...
@@ -92,9 +92,20 @@ class CMS.Views.UnitEdit extends Backbone.View
...
@@ -92,9 +92,20 @@ class CMS.Views.UnitEdit extends Backbone.View
@
$editor
=
$
(
$
(
'#video-editor'
).
html
())
@
$editor
=
$
(
$
(
'#video-editor'
).
html
())
$preview
=
$
(
$
(
'#video-preview'
).
html
())
$preview
=
$
(
$
(
'#video-preview'
).
html
())
when
'problem'
when
'problem'
@
$editor
=
$
(
$
(
'#problem-editor'
).
html
())
parent
=
@
$el
.
data
(
'id'
)
$preview
=
$
(
$
(
'#problem-preview'
).
html
())
$editView
=
$
(
'<li>'
).
addClass
(
'component'
)
initProblemEditors
(
@
$editor
,
$preview
)
@
$newComponentItem
.
before
(
$editView
)
@
speedEditor
=
new
CMS
.
Views
.
ModuleSpeedEdit
(
el
:
$editView
onDelete
:
@
deleteComponent
parent
:
parent
model
:
new
CMS
.
Models
.
Module
(
course_location
:
@
model
.
get
(
'course_location'
)
)
)
@
speedEditor
.
enterEditMode
()
return
when
'html'
when
'html'
$editView
=
$
(
'<li>'
).
addClass
(
'component'
)
$editView
=
$
(
'<li>'
).
addClass
(
'component'
)
@
$newComponentItem
.
before
(
$editView
)
@
$newComponentItem
.
before
(
$editView
)
...
...
cms/static/js/speed-editor.js
View file @
6d5fbc0b
...
@@ -428,4 +428,12 @@ function onKeyboard(e) {
...
@@ -428,4 +428,12 @@ function onKeyboard(e) {
}
}
break
;
break
;
}
}
}
}
\ No newline at end of file
function
getXMLContent
()
{
return
xmlEditor
.
getValue
();
}
function
getMarkdownContent
()
{
return
simpleEditor
.
getValue
();
}
common/lib/xmodule/xmodule/templates/html/empty.yaml
0 → 100644
View file @
6d5fbc0b
---
metadata
:
display_name
:
Empty
data
:
"
"
children
:
[]
common/lib/xmodule/xmodule/templates/problem/empty.yaml
0 → 100644
View file @
6d5fbc0b
---
metadata
:
display_name
:
Empty
data
:
"
"
children
:
[]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment