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
0d3b566d
Commit
0d3b566d
authored
Feb 14, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish piping URL through to pdf.js
parent
f0258b8d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
11 deletions
+27
-11
common/static/js/vendor/pdf.js.REMOVED.git-id
+2
-0
lms/djangoapps/staticbook/views.py
+17
-2
lms/templates/static_pdfbook.html
+3
-5
lms/urls.py
+5
-4
No files found.
common/static/js/vendor/pdf.js.REMOVED.git-id
0 → 100644
View file @
0d3b566d
14bab45163f93a24ad55d82faafc3e56bce0a222
\ No newline at end of file
lms/djangoapps/staticbook/views.py
View file @
0d3b566d
from
django.conf
import
settings
from
lxml
import
etree
# from django.conf import settings
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.decorators
import
login_required
from
mitxmako.shortcuts
import
render_to_response
from
mitxmako.shortcuts
import
render_to_response
from
courseware.access
import
has_access
from
courseware.access
import
has_access
from
courseware.courses
import
get_course_with_access
from
courseware.courses
import
get_course_with_access
from
lxml
import
etree
from
static_replace
import
replace_static_urls
@login_required
@login_required
...
@@ -40,6 +42,19 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
...
@@ -40,6 +42,19 @@ def pdf_index(request, course_id, book_index, chapter=None, page=None):
book_index
=
int
(
book_index
)
book_index
=
int
(
book_index
)
textbook
=
course
.
pdf_textbooks
[
book_index
]
textbook
=
course
.
pdf_textbooks
[
book_index
]
def
remap_static_url
(
original_url
,
course
):
input_url
=
"'"
+
original_url
+
"'"
output_url
=
replace_static_urls
(
input_url
,
course
.
metadata
[
'data_dir'
],
course_namespace
=
course
.
location
)
# strip off the quotes again...
return
output_url
[
1
:
-
1
]
textbook
[
'url'
]
=
remap_static_url
(
textbook
[
'url'
],
course
)
# then remap all the chapter URLs as well, if they are provided.
# if page is None:
# if page is None:
# page = textbook.start_page
# page = textbook.start_page
...
...
lms/templates/static_pdfbook.html
View file @
0d3b566d
...
@@ -9,8 +9,7 @@
...
@@ -9,8 +9,7 @@
<
%
block
name=
"js_extra"
>
<
%
block
name=
"js_extra"
>
<!-- Use latest PDF.js build from Github -->
<script
type=
"text/javascript"
src=
"/static/js/vendor/pdf.js"
></script>
<script
type=
"text/javascript"
src=
"https://raw.github.com/mozilla/pdf.js/gh-pages/build/pdf.js"
></script>
<script
type=
"text/javascript"
>
<script
type=
"text/javascript"
>
//
//
...
@@ -28,7 +27,7 @@
...
@@ -28,7 +27,7 @@
PDFJS
.
disableWorker
=
true
;
PDFJS
.
disableWorker
=
true
;
var
pdfDoc
=
null
,
var
pdfDoc
=
null
,
pageNum
=
1
,
pageNum
=
$
{
int
(
page
)
if
page
is
not
None
else
1
}
,
scale
=
0.8
,
scale
=
0.8
,
canvas
=
document
.
getElementById
(
'the-canvas'
),
canvas
=
document
.
getElementById
(
'the-canvas'
),
ctx
=
canvas
.
getContext
(
'2d'
);
ctx
=
canvas
.
getContext
(
'2d'
);
...
@@ -86,8 +85,7 @@
...
@@ -86,8 +85,7 @@
</script>
</script>
</
%
block>
</
%
block>
<!-- TODO: what should active_page be set to here???? textbook/0 or pdftextbook/0? -->
<
%
include
file=
"/courseware/course_navigation.html"
args=
"active_page='pdftextbook/{0}'.format(book_index)"
/>
<
%
include
file=
"/courseware/course_navigation.html"
args=
"active_page='textbook/{0}'.format(book_index)"
/>
<section
class=
"container"
>
<section
class=
"container"
>
<div
class=
"book-wrapper"
>
<div
class=
"book-wrapper"
>
...
...
lms/urls.py
View file @
0d3b566d
...
@@ -239,10 +239,11 @@ if settings.COURSEWARE_ENABLED:
...
@@ -239,10 +239,11 @@ if settings.COURSEWARE_ENABLED:
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/(?P<page>[^/]*)$'
,
'staticbook.views.pdf_index'
),
'staticbook.views.pdf_index'
),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$'
,
# Doesn't yet support loading individual chapters...
'staticbook.views.pdf_index'
),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/$',
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$'
,
# 'staticbook.views.pdf_index'),
'staticbook.views.pdf_index'
),
# url(r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/pdfbook/(?P<book_index>[^/]*)/chapter/(?P<chapter>[^/]*)/(?P<page>[^/]*)$',
# 'staticbook.views.pdf_index'),
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
url
(
r'^courses/(?P<course_id>[^/]+/[^/]+/[^/]+)/courseware/?$'
,
'courseware.views.index'
,
name
=
"courseware"
),
'courseware.views.index'
,
name
=
"courseware"
),
...
...
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