-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from octue/release/0.0.12
Alpha Release/0.0.12
- Loading branch information
Showing
39 changed files
with
2,280 additions
and
499 deletions.
There are no files selected for viewing
This file contains 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 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,29 @@ | ||
from sphinx.errors import ExtensionError | ||
|
||
|
||
def add_ga_javascript(app, pagename, templatename, context, doctree): | ||
if app.config.googleanalytics_enabled: | ||
id = app.config.googleanalytics_id | ||
metatags = context.get('metatags', '') | ||
metatags += "<!-- Global site tag (gtag.js) - Google Analytics -->\n" | ||
metatags += f'<script async src="https://www.googletagmanager.com/gtag/js?id={id}"></script>\n' | ||
metatags += "<script>\n" | ||
metatags += " window.dataLayer = window.dataLayer || [];\n" | ||
metatags += " function gtag(){dataLayer.push(arguments);}\n" | ||
metatags += " gtag('js', new Date());\n" | ||
metatags += f" gtag('config', '{id}');\n" | ||
metatags += "</script>\n" | ||
context['metatags'] = metatags | ||
|
||
|
||
def check_config(app): | ||
if not app.config.googleanalytics_id: | ||
raise ExtensionError("'googleanalytics_id' config value must be set for ga statistics to function properly.") | ||
|
||
|
||
def setup(app): | ||
app.add_config_value('googleanalytics_id', '', 'html') | ||
app.add_config_value('googleanalytics_enabled', True, 'html') | ||
app.connect('html-page-context', add_ga_javascript) | ||
app.connect('builder-inited', check_config) | ||
return {'version': '0.1'} |
This file contains 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,21 @@ | ||
|
||
|
||
``` | ||
extensions = [ | ||
... | ||
'sphinx_accordion.accordion' | ||
... | ||
] | ||
``` | ||
|
||
``` | ||
.. accordion:: | ||
.. accordion-row:: The Title | ||
The Contents | ||
.. accordion-row:: The Second Title | ||
The Contents 2 | ||
``` |
Empty file.
This file contains 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,11 @@ | ||
.sphinx-accordion.accordion { | ||
margin-bottom: 1.75em; | ||
} | ||
|
||
.sphinx-accordion.title p { | ||
display: inline-block; | ||
margin-top: 8px; | ||
margin-right: 0px; | ||
margin-bottom: 8px; | ||
margin-left: 0px; | ||
} |
This file contains 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,46 @@ | ||
// if (!String.prototype.startsWith) { | ||
// Object.defineProperty(String.prototype, 'startsWith', { | ||
// value: function(search, pos) { | ||
// pos = !pos || pos < 0 ? 0 : +pos; | ||
// return this.substring(pos, pos + search.length) === search; | ||
// } | ||
// }); | ||
// } | ||
|
||
$(document).ready(function(){console.log('FFS')}); | ||
|
||
$(function() { | ||
console.log('SOMETHING HAPPENS MAYBE'); | ||
|
||
// We store the data-row values as sphinx-data-<data-row value> | ||
// Add data-row attribute with the extracted value | ||
$('.sphinx-accordion.title').each(function() { | ||
const this1 = $(this); | ||
const prefix = 'sphinx-accordion-title-'; | ||
const classes = this1.attr('class').split(/\s+/); | ||
$.each(classes, function(idx, clazz) { | ||
if (clazz.startsWith(prefix)) { | ||
this1.attr('data-row', clazz.substring(prefix.length)); | ||
} | ||
}); | ||
|
||
const data_row = this1.attr('data-row'); | ||
|
||
this1.on('click', function() { | ||
// Find offset in view | ||
const offset = (this1.offset().top - $(window).scrollTop()); | ||
|
||
// Toggle active class on this subsequent sibling | ||
if (this1.hasClass('active')) { | ||
this1.removeClass('active'); | ||
this1.next().removeClass('active'); | ||
} else { | ||
this1.addClass('active'); | ||
this1.next().addClass('active'); | ||
} | ||
|
||
// Keep tab with the original view offset | ||
$(window).scrollTop(this1.offset().top - offset); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.