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
71209989
Commit
71209989
authored
Mar 21, 2013
by
Arthur Barrett
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring notes js
parent
76e338d8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
82 additions
and
19 deletions
+82
-19
lms/djangoapps/courseware/tabs.py
+1
-1
lms/djangoapps/notes/views.py
+12
-13
lms/djangoapps/staticbook/views.py
+5
-2
lms/envs/common.py
+7
-2
lms/static/coffee/src/notes.coffee
+49
-0
lms/templates/static_htmlbook.html
+8
-1
No files found.
lms/djangoapps/courseware/tabs.py
View file @
71209989
...
...
@@ -326,7 +326,7 @@ def get_default_tabs(user, course, active_page):
tabs
.
extend
(
_wiki
({
'name'
:
'Wiki'
,
'type'
:
'wiki'
},
user
,
course
,
active_page
))
tabs
.
extend
(
_student_notes
({
'name'
:
'
My
Notes'
,
'type'
:
'notes'
},
user
,
course
,
active_page
))
tabs
.
extend
(
_student_notes
({
'name'
:
'Notes'
,
'type'
:
'notes'
},
user
,
course
,
active_page
))
if
user
.
is_authenticated
()
and
not
course
.
hide_progress_tab
:
tabs
.
extend
(
_progress
({
'name'
:
'Progress'
},
user
,
course
,
active_page
))
...
...
lms/djangoapps/notes/views.py
View file @
71209989
...
...
@@ -6,20 +6,19 @@ import logging
log
=
logging
.
getLogger
(
__name__
)
#----------------------------------------------------------------------#
# HTML views.
#
# Example for enabling annotator.js (snippet):
#
# $('body').annotator()
# .annotator('addPlugin', 'Tags')
# .annotator('addPlugin', 'Store', { 'prefix': '/courses/HarvardX/CB22x/2013_Spring/notes/api' });
#
# See annotator.js docs:
#
# https://github.com/okfn/annotator/wiki
def
notes
(
request
,
course_id
):
''' Displays a student's notes in a course.
$('body').annotator()
.annotator('addPlugin', 'Tags')
.annotator('addPlugin', 'Store', {
'prefix': /^(
\
/courses
\
/[^/]+
\
/[^/]+
\
/[^/]+)/.exec(window.location.href.toString().split(window.location.host)[1]
'annotationData': {
'uri': window.location.href.toString().split(window.location.host)[1]
}
});
'''
course
=
get_course_with_access
(
request
.
user
,
course_id
,
'load'
)
notes
=
Note
.
objects
.
filter
(
user_id
=
request
.
user
.
id
)
...
...
lms/djangoapps/staticbook/views.py
View file @
71209989
...
...
@@ -2,6 +2,7 @@ from lxml import etree
from
django.contrib.auth.decorators
import
login_required
from
django.http
import
Http404
from
django.core.urlresolvers
import
reverse
from
mitxmako.shortcuts
import
render_to_response
from
courseware.access
import
has_access
...
...
@@ -25,7 +26,9 @@ def index(request, course_id, book_index, page=None):
return
render_to_response
(
'staticbook.html'
,
{
'book_index'
:
book_index
,
'page'
:
int
(
page
),
'course'
:
course
,
'book_url'
:
textbook
.
book_url
,
'course'
:
course
,
'book_url'
:
textbook
.
book_url
,
'notes_api_url'
:
reverse
(
'notes_api_root'
,
{
'course_id'
:
course_id
}),
'table_of_contents'
:
table_of_contents
,
'start_page'
:
textbook
.
start_page
,
'end_page'
:
textbook
.
end_page
,
...
...
@@ -99,10 +102,10 @@ def html_index(request, course_id, book_index, chapter=None, anchor_id=None):
for
entry
in
textbook
[
'chapters'
]:
entry
[
'url'
]
=
remap_static_url
(
entry
[
'url'
],
course
)
return
render_to_response
(
'static_htmlbook.html'
,
{
'book_index'
:
book_index
,
'course'
:
course
,
'notes_api_url'
:
reverse
(
'notes_api_root'
,
kwargs
=
{
'course_id'
:
course_id
}),
'textbook'
:
textbook
,
'chapter'
:
chapter
,
'anchor_id'
:
anchor_id
,
...
...
lms/envs/common.py
View file @
71209989
...
...
@@ -427,6 +427,7 @@ main_vendor_js = [
discussion_js
=
sorted
(
rooted_glob
(
PROJECT_ROOT
/
'static'
,
'coffee/src/discussion/**/*.coffee'
))
staff_grading_js
=
sorted
(
rooted_glob
(
PROJECT_ROOT
/
'static'
,
'coffee/src/staff_grading/**/*.coffee'
))
open_ended_js
=
sorted
(
rooted_glob
(
PROJECT_ROOT
/
'static'
,
'coffee/src/open_ended/**/*.coffee'
))
notes_js
=
sorted
(
rooted_glob
(
PROJECT_ROOT
/
'static'
,
'coffee/src/notes/**/*.coffee'
))
PIPELINE_CSS
=
{
'application'
:
{
...
...
@@ -458,7 +459,7 @@ PIPELINE_JS = {
'source_filenames'
:
sorted
(
set
(
rooted_glob
(
COMMON_ROOT
/
'static'
,
'coffee/src/**/*.coffee'
)
+
rooted_glob
(
PROJECT_ROOT
/
'static'
,
'coffee/src/**/*.coffee'
))
-
set
(
courseware_js
+
discussion_js
+
staff_grading_js
+
open_ended_js
)
set
(
courseware_js
+
discussion_js
+
staff_grading_js
+
open_ended_js
+
notes_js
)
)
+
[
'js/form.ext.js'
,
'js/my_courses_dropdown.js'
,
...
...
@@ -491,7 +492,11 @@ PIPELINE_JS = {
'open_ended'
:
{
'source_filenames'
:
open_ended_js
,
'output_filename'
:
'js/open_ended.js'
}
},
'notes'
:
{
'source_filenames'
:
notes_js
,
'output_filename'
:
'js/notes.js'
},
}
PIPELINE_DISABLE_WRAPPER
=
True
...
...
lms/static/coffee/src/notes.coffee
0 → 100644
View file @
71209989
class
@
StudentNotes
targets
:
[]
storeConfig
:
prefix
:
''
annotationData
:
uri
:
''
constructor
:
()
->
@
storeConfig
=
prefix
:
@
getPrefix
()
annotationData
:
uri
:
@
getURIPath
()
$
(
document
).
ready
(
@
init
)
init
:
(
$
)
=>
if
not
StudentNotes
.
ready
$
(
document
).
delegate
(
'*'
,
{
'notes:init'
:
@
onInitNotes
,
'notes:load'
:
@
onLoadNotes
})
StudentNotes
.
ready
=
true
onInitNotes
:
(
event
,
annotationData
=
null
)
=>
found
=
(
target
for
target
in
@
targets
when
target
is
event
.
target
)
storeConfig
=
$
.
extend
{},
@
storeConfig
$
.
extend
(
storeConfig
.
annotationData
,
annotationData
)
if
annotationData
if
found
.
length
is
0
$
(
event
.
target
).
annotator
()
.
annotator
(
'addPlugin'
,
'Tags'
)
.
annotator
(
'addPlugin'
,
'Store'
,
storeConfig
)
@
targets
.
push
(
event
.
target
)
onLoadNotes
:
(
event
)
=>
if
event
.
target
in
@
targets
$
(
event
.
target
).
annotator
().
annotator
(
'loadAnnotations'
)
getPrefix
:
()
->
re
=
/^(\/courses\/[^/]+\/[^/]+\/[^/]+)/
match
=
re
.
exec
(
@
getURIPath
())
prefix
=
(
if
match
then
match
[
1
]
else
''
)
return
"
#{
prefix
}
/notes/api"
getURIPath
:
()
->
window
.
location
.
href
.
toString
().
split
(
window
.
location
.
host
)[
1
]
lms/templates/static_htmlbook.html
View file @
71209989
...
...
@@ -31,13 +31,20 @@
anchorToLoad
=
options
.
anchor_id
;
}
var
onComplete
=
function
(
url
)
{
return
function
()
{
annotationData
=
{
'uri'
:
url
}
$
(
this
).
trigger
(
'notes:init'
,
[
annotationData
]);
}
};
loadUrl
=
function
htmlViewLoadUrl
(
url
,
anchorId
)
{
// clear out previous load, if any:
parentElement
=
document
.
getElementById
(
'bookpage'
);
while
(
parentElement
.
hasChildNodes
())
parentElement
.
removeChild
(
parentElement
.
lastChild
);
// load new URL in:
$
(
'#bookpage'
).
load
(
url
);
$
(
'#bookpage'
).
load
(
url
,
null
,
onComplete
(
url
)
);
// if there is an anchor set, then go to that location:
if
(
anchorId
!=
null
)
{
...
...
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