-
Notifications
You must be signed in to change notification settings - Fork 21
Adding tutorial content videos #147
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
Merged
Merged
Changes from 44 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
cbcde6c
Add tutorial recordings to resource gallery
jukent dc346b0
Add thumbnails from youtube videos
jukent 2d78ea7
Update thumbnails
jukent 19e4e44
Add thumbnails to correct path
jukent 68155de
Delete ptss-cartopy.jpeg
jukent 768fd65
Delete ptss-dask1.jpeg
jukent 9c68afb
Delete ptss-oop.jpeg
jukent cb54023
Delete ptss-geocatviz.jpeg
jukent 692ab06
Delete ptss-firstpackage.jpeg
jukent 652121f
Delete ptss-git.png
jukent 82a40f1
Delete ptss-txtfile.jpeg
jukent 9e33ff0
Delete ptss-xarray1.jpeg
jukent 3cecda2
Delete ptss-writingfx.jpeg
jukent f635165
Delete ptss-dask2.jpeg
jukent d0b9122
Delete ptss-datadict.jpeg
jukent 675fda2
Delete ptss-pandas.jpeg
jukent 2b9b7e6
Delete ptss-matplotlib.jpeg
jukent 2141fc3
Delete ptss-numpy.jpeg
jukent a117b77
Delete ptss-xarray2.jpeg
jukent 29a0458
Delete ptss-geocatplot.jpeg
jukent bb6d846
Delete ptss-jupyter.jpeg
jukent 0c96231
Fix indent
jukent 6fe7a85
update blackdoc v0.3.4
jukent 1c9386d
Merge branch 'ProjectPythia:main' into jukent-videos
jukent c449f0f
Merge branch 'main' into jukent-videos
jukent 7f7552b
Add videos
jukent b0299b4
Add data viz domain tag
jukent db2d89d
Add thumbnails
jukent c2f8fe0
Add thumbnails for git
jukent c4d2d45
delete images in wrong directory
jukent d450c3b
revert changes
jukent f6b2e7b
Merge branch 'main' into jukent-videos
jukent 744cc81
add links to github repos in description
jukent 8da191a
Merge branch 'main' into jukent-videos
jukent 985c30b
fix links with href
jukent 4ba1045
fix remaining links
jukent 28ad8e5
use truncate to fix html
jukent dad0f5a
add truncatehtml to setup.cfg
jukent 5e0b1f8
Merge branch 'main' into jukent-videos
jukent a211048
update pre-commit
jukent d8b3cd3
Merge branch 'jukent-videos' of github.com:jukent/projectpythia.githu…
jukent b762d13
pre-commit
jukent 6788da8
rm raw_input
jukent db7247c
del sys
jukent 6266f0c
Update portal/_extensions/truncatehtml.py
jukent 5af0f5f
Merge branch 'main' into jukent-videos
jukent 5a9cb45
content sp
jukent 09a032c
Merge branch 'main' into jukent-videos
jukent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not length < target_len: | ||
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
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.
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.
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.
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.
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.
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.
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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.