Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding tutorial content videos #147

Merged
merged 48 commits into from
Sep 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
cbcde6c
Add tutorial recordings to resource gallery
jukent Sep 9, 2021
dc346b0
Add thumbnails from youtube videos
jukent Sep 9, 2021
2d78ea7
Update thumbnails
jukent Sep 9, 2021
19e4e44
Add thumbnails to correct path
jukent Sep 9, 2021
68155de
Delete ptss-cartopy.jpeg
jukent Sep 9, 2021
768fd65
Delete ptss-dask1.jpeg
jukent Sep 9, 2021
9c68afb
Delete ptss-oop.jpeg
jukent Sep 9, 2021
cb54023
Delete ptss-geocatviz.jpeg
jukent Sep 9, 2021
692ab06
Delete ptss-firstpackage.jpeg
jukent Sep 9, 2021
652121f
Delete ptss-git.png
jukent Sep 9, 2021
82a40f1
Delete ptss-txtfile.jpeg
jukent Sep 9, 2021
9e33ff0
Delete ptss-xarray1.jpeg
jukent Sep 9, 2021
3cecda2
Delete ptss-writingfx.jpeg
jukent Sep 9, 2021
f635165
Delete ptss-dask2.jpeg
jukent Sep 9, 2021
d0b9122
Delete ptss-datadict.jpeg
jukent Sep 9, 2021
675fda2
Delete ptss-pandas.jpeg
jukent Sep 9, 2021
2b9b7e6
Delete ptss-matplotlib.jpeg
jukent Sep 9, 2021
2141fc3
Delete ptss-numpy.jpeg
jukent Sep 9, 2021
a117b77
Delete ptss-xarray2.jpeg
jukent Sep 9, 2021
29a0458
Delete ptss-geocatplot.jpeg
jukent Sep 9, 2021
bb6d846
Delete ptss-jupyter.jpeg
jukent Sep 9, 2021
0c96231
Fix indent
jukent Sep 9, 2021
6fe7a85
update blackdoc v0.3.4
jukent Sep 14, 2021
1c9386d
Merge branch 'ProjectPythia:main' into jukent-videos
jukent Sep 16, 2021
c449f0f
Merge branch 'main' into jukent-videos
jukent Sep 16, 2021
7f7552b
Add videos
jukent Sep 16, 2021
b0299b4
Add data viz domain tag
jukent Sep 16, 2021
db2d89d
Add thumbnails
jukent Sep 16, 2021
c2f8fe0
Add thumbnails for git
jukent Sep 16, 2021
c4d2d45
delete images in wrong directory
jukent Sep 16, 2021
d450c3b
revert changes
jukent Sep 16, 2021
f6b2e7b
Merge branch 'main' into jukent-videos
jukent Sep 17, 2021
744cc81
add links to github repos in description
jukent Sep 17, 2021
8da191a
Merge branch 'main' into jukent-videos
jukent Sep 17, 2021
985c30b
fix links with href
jukent Sep 17, 2021
4ba1045
fix remaining links
jukent Sep 17, 2021
28ad8e5
use truncate to fix html
jukent Sep 23, 2021
dad0f5a
add truncatehtml to setup.cfg
jukent Sep 23, 2021
5e0b1f8
Merge branch 'main' into jukent-videos
jukent Sep 23, 2021
a211048
update pre-commit
jukent Sep 23, 2021
d8b3cd3
Merge branch 'jukent-videos' of github.com:jukent/projectpythia.githu…
jukent Sep 23, 2021
b762d13
pre-commit
jukent Sep 23, 2021
6788da8
rm raw_input
jukent Sep 23, 2021
db7247c
del sys
jukent Sep 23, 2021
6266f0c
Update portal/_extensions/truncatehtml.py
jukent Sep 27, 2021
5af0f5f
Merge branch 'main' into jukent-videos
jukent Sep 27, 2021
5a9cb45
content sp
jukent Sep 29, 2021
09a032c
Merge branch 'main' into jukent-videos
jukent Sep 29, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repos:
- id: double-quote-string-fixer

- repo: https://github.com/ambv/black
rev: 21.6b0
rev: 21.9b0
hooks:
- id: black

Expand All @@ -29,7 +29,7 @@ repos:
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v5.8.0
rev: v5.9.3
hooks:
- id: isort

Expand All @@ -39,7 +39,7 @@ repos:
# - id: prettier

- repo: https://github.com/nbQA-dev/nbQA
rev: 0.13.0
rev: 1.1.1
hooks:
- id: nbqa-black
additional_dependencies: [black==20.8b1]
Expand Down
179 changes: 179 additions & 0 deletions portal/_extensions/truncatehtml.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
#!/usr/bin/env python

# Copyright (c) 2015 Eric Entzel

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

from __future__ import print_function

END = -1

# HTML5 void-elements that do not require a closing tag
# https://html.spec.whatwg.org/multipage/syntax.html#void-elements
VOID_ELEMENTS = (
'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'link',
'meta',
'param',
'source',
'track',
'wbr',
)


class UnbalancedError(Exception):
pass


class OpenTag:
def __init__(self, tag, rest=''):
self.tag = tag
self.rest = rest

def as_string(self):
return '<' + self.tag + self.rest + '>'


class CloseTag(OpenTag):
def as_string(self):
return '</' + self.tag + '>'


class SelfClosingTag(OpenTag):
pass


class Tokenizer:
def __init__(self, input):
self.input = input
self.counter = 0 # points at the next unconsumed character of the input

def __next_char(self):
self.counter += 1
return self.input[self.counter]

def next_token(self):
try:
char = self.input[self.counter]
self.counter += 1
if char == '&':
return self.__entity()
elif char != '<':
return char
elif self.input[self.counter] == '/':
self.counter += 1
return self.__close_tag()
else:
return self.__open_tag()
except IndexError:
return END

def __entity(self):
"""Return a token representing an HTML character entity.
Precondition: self.counter points at the charcter after the &
Postcondition: self.counter points at the character after the ;
"""
char = self.input[self.counter]
entity = ['&']
while char != ';':
entity.append(char)
char = self.__next_char()
entity.append(';')
self.counter += 1
return ''.join(entity)

def __open_tag(self):
"""Return an open/close tag token.
Precondition: self.counter points at the first character of the tag name
Postcondition: self.counter points at the character after the <tag>
"""
char = self.input[self.counter]
tag = []
rest = []
while char != '>' and char != ' ':
tag.append(char)
char = self.__next_char()
while char != '>':
rest.append(char)
char = self.__next_char()
if self.input[self.counter - 1] == '/':
self.counter += 1
return SelfClosingTag(''.join(tag), ''.join(rest))
elif ''.join(tag) in VOID_ELEMENTS:
self.counter += 1
return SelfClosingTag(''.join(tag), ''.join(rest))
else:
self.counter += 1
return OpenTag(''.join(tag), ''.join(rest))

def __close_tag(self):
"""Return an open/close tag token.
Precondition: self.counter points at the first character of the tag name
Postcondition: self.counter points at the character after the <tag>
"""
char = self.input[self.counter]
tag = []
while char != '>':
tag.append(char)
char = self.__next_char()
self.counter += 1
return CloseTag(''.join(tag))


def truncate(str, target_len, ellipsis=''):
"""Returns a copy of str truncated to target_len characters,
preserving HTML markup (which does not count towards the length).
Any tags that would be left open by truncation will be closed at
the end of the returned string. Optionally append ellipsis if
the string was truncated."""
stack = [] # open tags are pushed on here, then popped when the matching close tag is found
retval = [] # string to be returned
length = 0 # number of characters (not counting markup) placed in retval so far
tokens = Tokenizer(str)
tok = tokens.next_token()
while tok != END:
if length >= target_len and tok == ' ':
retval.append(ellipsis)
break
if tok.__class__.__name__ == 'OpenTag':
stack.append(tok)
retval.append(tok.as_string())
elif tok.__class__.__name__ == 'CloseTag':
if stack[-1].tag == tok.tag:
stack.pop()
retval.append(tok.as_string())
else:
raise UnbalancedError(tok.as_string())
elif tok.__class__.__name__ == 'SelfClosingTag':
retval.append(tok.as_string())
else:
retval.append(tok)
length += 1
tok = tokens.next_token()
while len(stack) > 0:
tok = CloseTag(stack.pop().tag)
retval.append(tok.as_string())
return ''.join(retval)
5 changes: 4 additions & 1 deletion portal/_extensions/yaml_gallery_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from textwrap import dedent

import yaml
from truncatehtml import truncate


def _tag_in_item(item, tag_str=None):
Expand Down Expand Up @@ -117,7 +118,9 @@ def build_from_items(items, filename, title='Gallery', subtitle=None, menu_html=
short_description = item['description']
modal_str = ''
else:
short_description = item['description'][:max_descr_len] + ' <a class="modal-btn">...more</a>'
short_description = truncate(
item['description'], max_descr_len, ellipsis='<a class="modal-btn"> ...more</a>'
)
modal_str = f"""
<div class="modal">
<div class="content">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-cartopy.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-dask1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-dask2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-datadict.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-geocatcomp.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-geocatplot.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-git.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-jupyter.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-matplotlib.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-numpy.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-oop.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-pandas.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-txtfile.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-writingfx.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-xarray1.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added portal/_static/thumbnails/ptss-xarray2.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading