Use Juniper and tidy up

This commit is contained in:
ines 2018-04-30 18:48:35 +02:00
parent 45bb8d75a5
commit 6efb4cdf88
9 changed files with 44 additions and 58 deletions

View File

@ -86,8 +86,8 @@
} }
], ],
"V_CSS": "2.1.2", "V_CSS": "2.1.3",
"V_JS": "2.1.0", "V_JS": "2.1.1",
"DEFAULT_SYNTAX": "python", "DEFAULT_SYNTAX": "python",
"ANALYTICS": "UA-58931649-1", "ANALYTICS": "UA-58931649-1",
"MAILCHIMP": { "MAILCHIMP": {

View File

@ -260,8 +260,8 @@ mixin code(label, language, prompt, height, icon, wrap)
mixin code-exec(label, large) mixin code-exec(label, large)
- label = (label || "Editable code example") + " (experimental)" - label = (label || "Editable code example") + " (experimental)"
+terminal-wrapper(label, !large) +terminal-wrapper(label, !large)
figure.thebelab-wrapper figure.juniper-wrapper
span.thebelab-wrapper__text.u-text-tiny v#{BINDER_VERSION} · Python 3 · via #[+a("https://mybinder.org/").u-hide-link Binder] span.juniper-wrapper__text.u-text-tiny v#{BINDER_VERSION} · Python 3 · via #[+a("https://mybinder.org/").u-hide-link Binder]
+code(data-executable="true")&attributes(attributes) +code(data-executable="true")&attributes(attributes)
block block

View File

@ -1,15 +1,10 @@
//- 💫 INCLUDES > SCRIPTS //- 💫 INCLUDES > SCRIPTS
if IS_PAGE || SECTION == "index"
script(type="text/x-thebe-config")
| { bootstrap: true, binderOptions: { repo: "#{KERNEL_BINDER}"},
| kernelOptions: { name: "#{KERNEL_PYTHON}" }}
- scripts = ["vendor/prism.min", "vendor/vue.min"] - scripts = ["vendor/prism.min", "vendor/vue.min"]
- if (SECTION == "universe") scripts.push("vendor/vue-markdown.min") - if (SECTION == "universe") scripts.push("vendor/vue-markdown.min")
- if (quickstart) scripts.push("vendor/quickstart.min") - if (quickstart) scripts.push("vendor/quickstart.min")
- if (IS_PAGE) scripts.push("vendor/in-view.min") - if (IS_PAGE) scripts.push("vendor/in-view.min")
- if (IS_PAGE || SECTION == "index") scripts.push("vendor/thebelab.custom.min") - if (IS_PAGE || SECTION == "index") scripts.push("vendor/juniper.min")
for script in scripts for script in scripts
script(src="/assets/js/" + script + ".js") script(src="/assets/js/" + script + ".js")

View File

@ -3,7 +3,7 @@
//- Code block //- Code block
.c-code-block, .c-code-block,
.thebelab-cell .juniper-cell
background: $color-front background: $color-front
color: darken($color-back, 20) color: darken($color-back, 20)
padding: 0.75em 0 padding: 0.75em 0
@ -32,7 +32,7 @@
//- Code block content //- Code block content
.c-code-block__content, .c-code-block__content,
.thebelab-input, .juniper-input,
.jp-OutputArea .jp-OutputArea
display: block display: block
font: normal normal 1.1rem/#{1.9} $font-code font: normal normal 1.1rem/#{1.9} $font-code
@ -45,13 +45,21 @@
vertical-align: middle vertical-align: middle
opacity: 0.5 opacity: 0.5
//- Thebelab //- Juniper
[data-executable] [data-executable]
margin-bottom: 0 margin-bottom: 0
.thebelab-input.thebelab-input .juniper-cell
padding: 3em 2em 1em border: 0
.juniper-input
padding: 0
.juniper-output
color: inherit
background: inherit
padding: 0
.jp-OutputArea .jp-OutputArea
&:not(:empty) &:not(:empty)
@ -75,13 +83,14 @@
font-family: inherit font-family: inherit
font-weight: bold font-weight: bold
.thebelab-run-button .juniper-button
@extend .u-text-label, .u-text-label--dark @extend .u-text-label, .u-text-label--dark
position: static
.thebelab-wrapper .juniper-wrapper
position: relative position: relative
.thebelab-wrapper__text .juniper-wrapper__text
@include position(absolute, top, right, 1.25rem, 1.25rem) @include position(absolute, top, right, 1.25rem, 1.25rem)
color: $color-subtle-dark color: $color-subtle-dark
z-index: 10 z-index: 10

View File

@ -36,21 +36,19 @@ import initUniverse from './universe.vue.js';
/** /**
* Initialise Quickstart * Initialise Quickstart
*/ */
if (document.querySelector('#qs') && window.Quickstart) { {
new Quickstart('#qs'); if (document.querySelector('#qs') && window.Quickstart) {
new Quickstart('#qs');
}
} }
/** /**
* Thebelabs * Initialise Juniper
*/ */
if (window.thebelab) { {
window.thebelab.on('status', (ev, data) => { if (window.Juniper) {
if (data.status == 'failed') { new Juniper({ repo: 'ines/spacy-binder' });
const msg = "Failed to connect to kernel :( This can happen if too many users are active at the same time. Please reload the page and try again!"; }
const wrapper = `<span style="white-space: pre-wrap">${msg}</span>`;
document.querySelector('.jp-OutputArea-output pre').innerHTML = wrapper;
}
});
} }
/** /**

View File

@ -116,7 +116,8 @@ export default function(selector, dataPath) {
$_updateUrl(params) { $_updateUrl(params) {
const loc = Object.keys(params) const loc = Object.keys(params)
.map(param => `${param}=${encodeURIComponent(params[param])}`); .map(param => `${param}=${encodeURIComponent(params[param])}`);
const url = loc.length ? '?' + loc.join('&') : window.location.origin + window.location.pathname; const url = loc.length ? '?' + loc.join('&')
: window.location.origin + window.location.pathname;
window.history.pushState(params, null, url); window.history.pushState(params, null, url);
} }
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -276,7 +276,7 @@ p
nlp = spacy.load('en_core_web_sm') nlp = spacy.load('en_core_web_sm')
matcher = Matcher(nlp.vocab) matcher = Matcher(nlp.vocab)
# register a new token extension to flag bad HTML # register a new token extension to flag bad HTML
Token.set_extension('bad_html', default=False, force=True) Token.set_extension('bad_html', default=False)
def merge_and_flag(matcher, doc, i, matches): def merge_and_flag(matcher, doc, i, matches):
match_id, start, end = matches[i] match_id, start, end = matches[i]
@ -650,7 +650,7 @@ p
matcher.add('HASHTAG', None, [{'ORTH': '#'}, {'IS_ASCII': True}]) matcher.add('HASHTAG', None, [{'ORTH': '#'}, {'IS_ASCII': True}])
# register token extension # register token extension
Token.set_extension('is_hashtag', default=False, force=True) Token.set_extension('is_hashtag', default=False)
doc = nlp(u"Hello world 😀 #MondayMotivation") doc = nlp(u"Hello world 😀 #MondayMotivation")
matches = matcher(doc) matches = matcher(doc)