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

[collapsible_headings] link complete font-awesome css from cdn #1179

Merged
merged 1 commit into from
Dec 22, 2017
Merged
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -25,44 +25,29 @@ class ExporterCollapsibleHeadings(ExporterInliner):
def __init__(self, *args, **kwargs):
super(ExporterCollapsibleHeadings, self).__init__(*args, **kwargs)

self.inliner_resources['css'].append("""
/* no local copies of fontawesome fonts in basic templates, so use cdn */
@import url(https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css)
""") # noqa: E501

ch_dir = os.path.join(
os.path.dirname(contrib_init), 'nbextensions',
'collapsible_headings')

with open(os.path.join(ch_dir, 'main.css'), 'r') as f:
self.inliner_resources['css'].append(f.read())

self.inliner_resources['css'].append("""
/* no local copies of fontawesome fonts from basic templates, so get them from cdn */
@font-face {
font-family: 'FontAwesome';
src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/fonts/fontawesome-webfont.eot');
src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/fonts/fontawesome-webfont.eot?#iefix') format('embedded-opentype'),
url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/fonts/fontawesome-webfont.woff') format('woff'),
url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/fonts/fontawesome-webfont.ttf') format('truetype'),
url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/fonts/fontawesome-webfont.svg#fontawesomeregular') format('svg');
font-weight: normal;
font-style: normal;
}
""") # noqa: E501

with open(os.path.join(ch_dir, 'main.js'), 'r') as f:
self.inliner_resources['js'].append(f.read())

cm = ConfigManager()
collapsible_headings_options = cm.get('notebook').get(
'collapsible_headings', {})
self.inliner_resources['js'].append("""
require([
'jquery',
'nbextensions/collapsible_headings/main'
], function (
$,
nbext
) {
nbext.set_collapsible_headings_options(%s);
$(document).ready(function () {
nbext.refresh_all_headings();
$(document).ready(function () {
require(['nbextensions/collapsible_headings/main'], function (ch) {
ch.set_collapsible_headings_options(%s);
ch.refresh_all_headings();
});
});
""" % json.dumps(collapsible_headings_options))