Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
DoneXBlock
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
DoneXBlock
Commits
7a517a8f
Commit
7a517a8f
authored
May 28, 2014
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First prototype
parent
89a2ddf7
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
87 additions
and
27 deletions
+87
-27
README.md
+6
-5
audio/__init__.py
+0
-2
config.yaml
+18
-0
setup.py
+7
-6
template/__init__.py
+2
-0
template/static/css/template.css
+4
-3
template/static/html/template.html
+1
-1
template/static/js/src/template.js
+0
-0
template/template.py
+10
-10
xmaker.py
+39
-0
No files found.
README.md
View file @
7a517a8f
Audio
XBlock
Template
XBlock
===========
===========
===
This is a simple XBlock which will play audio files as an HTML5 audio
This is a simple template for an XBlock. It will play audio files as
element. If unavailable, it will fall back to an embed element.
an HTML5 audio element. If unavailable, it will fall back to an embed
element.
Usage:
Usage:
<
audio
src="http://server.tld/static/song.mp3" />
<
template
src="http://server.tld/static/song.mp3" />
audio/__init__.py
deleted
100644 → 0
View file @
89a2ddf7
from
.audio
import
AudioXBlock
\ No newline at end of file
config.yaml
0 → 100644
View file @
7a517a8f
# Welcome!
#
# Step 1: Come up with a short name for your XBlock. For example, if
# your XBlock plays audio files, 'audio' is a good name.
short-name
:
audio
# Step 2: Create a repository on github for your XBlock. In the above
# case, I strongly recommend the short name, followed by 'XBlock,' in
# camelcase. Do not initialize this repo. We'll do it for you
github
:
git@github.com:pmitros/AudioXBlock.git
# Step 3: Give a short description of this XBlock
description
:
Plays an audio file as an embed element
# Step 4: Give a multiline description. Keep the 2 line indent, please.
overview
:
|
This XBlock plays an audio file as an HTML5 audio element. If
the audio element is not present, it will fall back to an
embed element.
# Once you're done, hit save, and watch the magic happen!
\ No newline at end of file
setup.py
View file @
7a517a8f
"""Setup for
audio
XBlock."""
"""Setup for
template
XBlock."""
import
os
import
os
from
setuptools
import
setup
from
setuptools
import
setup
...
@@ -15,19 +15,19 @@ def package_data(pkg, root):
...
@@ -15,19 +15,19 @@ def package_data(pkg, root):
setup
(
setup
(
name
=
'
audio
-xblock'
,
name
=
'
template
-xblock'
,
version
=
'0.1'
,
version
=
'0.1'
,
description
=
'
audio
XBlock'
,
# TODO: write a better description.
description
=
'
template
XBlock'
,
# TODO: write a better description.
packages
=
[
packages
=
[
'
audio
'
,
'
template
'
,
],
],
install_requires
=
[
install_requires
=
[
'XBlock'
,
'XBlock'
,
],
],
entry_points
=
{
entry_points
=
{
'xblock.v1'
:
[
'xblock.v1'
:
[
'
audio = audio:Audio
XBlock'
,
'
template = template:Template
XBlock'
,
]
]
},
},
package_data
=
package_data
(
"
audio
"
,
"static"
),
package_data
=
package_data
(
"
template
"
,
"static"
),
)
)
\ No newline at end of file
template/__init__.py
0 → 100644
View file @
7a517a8f
from
.template
import
TemplateXBlock
\ No newline at end of file
audio/static/css/audio
.css
→
template/static/css/template
.css
View file @
7a517a8f
/* CSS for
Audio
XBlock */
/* CSS for
Template
XBlock */
.
audio
_block
.count
{
.
template
_block
.count
{
font-weight
:
bold
;
font-weight
:
bold
;
}
}
.
audio
_block
p
{
.
template
_block
p
{
cursor
:
pointer
;
cursor
:
pointer
;
}
}
\ No newline at end of file
audio/static/html/audio
.html
→
template/static/html/template
.html
View file @
7a517a8f
<div
class=
"
audio
_block"
>
<div
class=
"
template
_block"
>
<audio
controls
preload
>
<audio
controls
preload
>
<source
src=
"{src}"
>
<source
src=
"{src}"
>
<embed
height=
"50"
width=
"100"
src=
"{src}"
>
<embed
height=
"50"
width=
"100"
src=
"{src}"
>
...
...
audio/static/js/src/audio
.js
→
template/static/js/src/template
.js
View file @
7a517a8f
File moved
audio/audio
.py
→
template/template
.py
View file @
7a517a8f
...
@@ -7,7 +7,7 @@ from xblock.fields import Scope, Integer, String
...
@@ -7,7 +7,7 @@ from xblock.fields import Scope, Integer, String
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
class
Audio
XBlock
(
XBlock
):
class
Template
XBlock
(
XBlock
):
"""
"""
This XBlock will play an MP3 file as an HTML5 audio element.
This XBlock will play an MP3 file as an HTML5 audio element.
"""
"""
...
@@ -27,16 +27,16 @@ class AudioXBlock(XBlock):
...
@@ -27,16 +27,16 @@ class AudioXBlock(XBlock):
# TO-DO: change this view to display your data your own way.
# TO-DO: change this view to display your data your own way.
def
student_view
(
self
,
context
=
None
):
def
student_view
(
self
,
context
=
None
):
"""
"""
The primary view of the
Audio
XBlock, shown to students
The primary view of the
Template
XBlock, shown to students
when viewing courses.
when viewing courses.
"""
"""
html
=
self
.
resource_string
(
"static/html/
audio
.html"
)
html
=
self
.
resource_string
(
"static/html/
template
.html"
)
print
self
.
src
print
self
.
src
print
html
.
format
print
html
.
format
frag
=
Fragment
(
html
.
format
(
src
=
self
.
src
))
frag
=
Fragment
(
html
.
format
(
src
=
self
.
src
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/
audio
.css"
))
frag
.
add_css
(
self
.
resource_string
(
"static/css/
template
.css"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/
audio
.js"
))
frag
.
add_javascript
(
self
.
resource_string
(
"static/js/src/
template
.js"
))
frag
.
initialize_js
(
'
Audio
XBlock'
)
frag
.
initialize_js
(
'
Template
XBlock'
)
print
self
.
xml_text_content
()
print
self
.
xml_text_content
()
return
frag
return
frag
...
@@ -46,11 +46,11 @@ class AudioXBlock(XBlock):
...
@@ -46,11 +46,11 @@ class AudioXBlock(XBlock):
def
workbench_scenarios
():
def
workbench_scenarios
():
"""A canned scenario for display in the workbench."""
"""A canned scenario for display in the workbench."""
return
[
return
[
(
"
Audio
XBlock"
,
(
"
Template
XBlock"
,
"""<vertical_demo>
"""<vertical_demo>
<
audio src="http://localhost/Ikea.mp3"> </audio
>
<
template src="http://localhost/Ikea.mp3"> </template
>
<
audio src="http://localhost/skull.mp3"> </audio
>
<
template src="http://localhost/skull.mp3"> </template
>
<
audio src="http://localhost/monkey.mp3"> </audio
>
<
template src="http://localhost/monkey.mp3"> </template
>
</vertical_demo>
</vertical_demo>
"""
),
"""
),
]
]
xmaker.py
0 → 100644
View file @
7a517a8f
import
yaml
commands
=
'''
git mv ./template/template.py ./template/{shortname}.py
git mv ./template/static/html/template.html ./template/static/html/{shortname}.html
git mv ./template/static/css/template.css ./template/static/css/{shortname}.css
git mv ./template/static/js/src/template.js ./template/static/js/src/{shortname}.js
git mv template {shortname}
find . -type f | grep -v git | xargs sed -i 's/template/{shortname}/g'
find . -type f | grep -v git | xargs sed -i 's/Template/{Shortname}/g'
git remote rm origin
git remote add origin {github}
git commit -a -m "Initializing repo"
git push --set-upstream origin master
'''
os
.
system
(
"editor config.yaml"
)
settings
=
yaml
.
load
(
open
(
"config.yaml"
,
'r'
))
commands
=
commands
.
format
(
shortname
=
settings
[
"short-name"
],
Shortname
=
settings
[
"short-name"
]
.
capitalize
(),
github
=
settings
[
"github"
])
readme
=
open
(
"README.md"
,
"w"
)
readme
.
writelines
([
"{Shortname}XBlock"
.
format
(
Shortname
=
settings
[
"short-name"
]
.
capitalize
()),
"=============="
,
""
,
settings
[
"description"
],
""
settings
[
"overview"
]])
for
command
in
commands
:
if
len
(
command
>
0
):
print
command
os
.
system
(
command
)
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