Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
osp
tools.ethertoff
Commits
33db392b
Commit
33db392b
authored
Jul 03, 2019
by
gijs
Browse files
Start of timecodes in pads
parent
31ca689d
Changes
6
Hide whitespace changes
Inline
Side-by-side
generator/management/commands/generate.py
View file @
33db392b
...
...
@@ -63,18 +63,17 @@ def generate ():
shutil
.
rmtree
(
outputdir
)
os
.
mkdir
(
outputdir
)
print
(
'Copying static files'
)
shutil
.
copytree
(
staticdir
,
os
.
path
.
join
(
outputdir
,
'static'
))
print
(
'Parsing pads'
)
os
.
mkdir
(
os
.
path
.
join
(
outputdir
,
'produsers'
))
os
.
mkdir
(
os
.
path
.
join
(
outputdir
,
'activities'
))
os
.
mkdir
(
os
.
path
.
join
(
outputdir
,
'pages'
))
os
.
mkdir
(
os
.
path
.
join
(
outputdir
,
'tags'
))
os
.
mkdir
(
os
.
path
.
join
(
outputdir
,
'notes'
))
print
(
'Copying static files'
)
shutil
.
copytree
(
staticdir
,
os
.
path
.
join
(
outputdir
,
'static'
))
print
(
'Parsing pads'
)
parse_pads
()
print
(
'Read pads'
)
...
...
generator/models.py
View file @
33db392b
...
...
@@ -189,13 +189,72 @@ def parseReference(match, source=None):
# switch between reference type and inclusion types
def
formatTimecode
(
hours
=
None
,
minutes
=
None
,
seconds
=
None
):
out
=
'{1:0>2d}:{0:0>2d}'
.
format
(
int
(
seconds
)
if
seconds
else
0
,
int
(
minutes
)
if
minutes
else
0
)
if
hours
:
out
=
'{:d}:{}'
.
format
(
int
(
hours
),
out
)
return
out
# Formats
# 7 → 7 seconds
# 7:00 → 7 minutes
# 1:07:00 → 1 hour, 7 minutes
# 1h7 → 1 hour, 7 minutes
def
parseTimecodeString
(
content
):
if
'h'
in
content
:
hours
,
tail
=
content
.
split
(
'h'
)
if
':'
in
tail
:
minutes
,
seconds
=
tail
.
split
(
':'
,
2
)
else
:
minutes
=
tail
seconds
=
0
else
:
parts
=
content
.
split
(
':'
,
3
)
if
parts
:
if
len
(
parts
)
==
3
:
hours
,
minutes
,
seconds
=
parts
elif
len
(
parts
)
==
2
:
hours
=
0
minutes
,
seconds
=
parts
else
:
hours
=
0
minutes
=
0
seconds
=
parts
[
0
]
else
:
hours
=
0
minutes
=
0
seconds
=
0
return
(
int
(
hours
),
int
(
minutes
),
int
(
seconds
))
def
inSeconds
(
hours
=
0
,
minutes
=
0
,
seconds
=
0
):
return
max
(
0
,
seconds
)
+
max
(
0
,
minutes
*
60
)
+
max
(
0
,
hours
*
3600
)
def
insertTimecode
(
matches
):
hours
,
minutes
,
seconds
=
parseTimecodeString
(
matches
.
group
(
1
))
return
'<span class="timecode" data-time="{0}">{1}</span>'
.
format
(
inSeconds
(
hours
,
minutes
,
seconds
),
formatTimecode
(
hours
,
minutes
,
seconds
))
def
parseTimecodes
(
content
):
return
re
.
sub
(
r
'\[\[t(?:imecode)?\s*:\s*([\d:]+)\]\]'
,
insertTimecode
,
content
)
def
parseShortTimecodes
(
content
):
return
re
.
sub
(
r
'\[((?:\d+(?:h|:))?(?:\d+:)?\d+)\]'
,
insertTimecode
,
content
)
def
expandTags
(
content
):
return
re
.
sub
(
r
'\[\[([^:\]]+)\]\]'
,
'[[tag:
\\
1]]'
,
content
)
return
re
.
sub
(
r
'\[\[
\s*
([^:\]]+)\
s*\
]\]'
,
'[[tag:
\\
1]]'
,
content
)
def
resolveReferences
(
content
,
source
=
None
):
# return content
if
content
:
return
mark_safe
(
re
.
sub
(
r
'\[\[([\w\._\-]+):([^\|\]]+)(?:\|(.[^\]+]+))?\]\]'
,
partial
(
parseReference
,
source
=
source
),
expandTags
(
content
)))
content
=
expandTags
(
content
)
content
=
parseShortTimecodes
(
content
)
content
=
parseTimecodes
(
content
)
return
mark_safe
(
re
.
sub
(
r
'\[\[([\w\._\-]+):([^\|\]]+)(?:\|(.[^\]+]+))?\]\]'
,
partial
(
parseReference
,
source
=
source
),
content
))
# return mark_safe(re.sub(r"\[\[(\w+):(.[^\]]+)\]\]", insertReference, content))
else
:
return
content
...
...
generator/templates/note.html
View file @
33db392b
...
...
@@ -9,4 +9,7 @@
</nav>
<h1>
{{ note.title }}
</h1>
{{ note.content }}
{% endblock %}
{% block footerresources %}
<script
src=
"{{ SITE_URL }}static/js/timejumper.js"
></script>
{% endblock %}
\ No newline at end of file
generator/templates/page_structure.html
View file @
33db392b
...
...
@@ -51,5 +51,6 @@
}
})();
</script>
{% block footerresources %}{% endblock %}
</body>
</html>
\ No newline at end of file
generator/templates/static/js/timejumper.js
0 → 100644
View file @
33db392b
(
function
()
{
var
timecodes
=
document
.
querySelectorAll
(
'
.timecode
'
),
player
=
document
.
querySelector
(
'
main audio
'
);
if
(
player
)
{
for
(
var
i
=
0
;
i
<
timecodes
.
length
;
i
++
)
{
timecodes
[
i
].
addEventListener
(
'
click
'
,
function
()
{
console
.
log
(
'
Jumping to
'
,
parseInt
(
this
.
dataset
.
time
));
player
.
currentTime
=
parseInt
(
this
.
dataset
.
time
);
});
}
}
})();
\ No newline at end of file
generator/templates/static/styles.simple.css
View file @
33db392b
...
...
@@ -409,4 +409,19 @@ a.tag {
.programme-item-list
li
{
border-bottom
:
2px
solid
black
;
padding
:
1em
;
}
.timecode
{
font-size
:
75%
;
border
:
1px
solid
;
padding
:
.1em
.25em
;
/* margin-right: .5em; */
/* margin-left: -.5em; */
letter-spacing
:
1px
;
vertical-align
:
baseline
;
cursor
:
pointer
;
}
.timecode
:hover
{
color
:
var
(
--red-question
);
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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