2020-04-16 00:55:28 +02:00
|
|
|
<p>
|
|
|
|
{{
|
|
|
|
_('Built with %(pelican_url)s using %(flex_url)s theme',
|
|
|
|
pelican_url='<a href="http://getpelican.com" target="_blank">Pelican</a>',
|
|
|
|
flex_url='<a href="http://bit.ly/flex-pelican" target="_blank">Flex</a>'|safe)
|
|
|
|
}}
|
|
|
|
{% if THEME_COLOR_ENABLE_USER_OVERRIDE %}
|
2020-04-15 05:58:04 +02:00
|
|
|
<span class="footer-separator">|</span>
|
2020-04-07 08:22:07 +02:00
|
|
|
Switch to the
|
|
|
|
<a href="javascript:void(0)" onclick="switchTheme('dark')">
|
|
|
|
dark
|
|
|
|
</a>|<a href="javascript:void(0)" onclick="switchTheme('light')">
|
|
|
|
light
|
|
|
|
</a>
|
2020-04-16 00:55:28 +02:00
|
|
|
{% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %}
|
|
|
|
|<a href="javascript:void(0)" onclick="switchTheme('browser')">
|
|
|
|
browser
|
|
|
|
</a>
|
|
|
|
{% endif %}
|
2020-04-07 08:22:07 +02:00
|
|
|
theme
|
2020-04-16 00:55:28 +02:00
|
|
|
{% endif %}
|
2020-04-07 08:22:07 +02:00
|
|
|
</p>
|
2020-04-16 00:55:28 +02:00
|
|
|
{% if THEME_COLOR_ENABLE_USER_OVERRIDE %}
|
|
|
|
<script>
|
|
|
|
{% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %}
|
2020-04-16 02:33:28 +02:00
|
|
|
{% if THEME_COLOR|default("light") == "dark" %}
|
|
|
|
const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark), (prefers-color-scheme: no-preference)');
|
|
|
|
{% else %}
|
|
|
|
const darkSchemeWatch = window.matchMedia('(prefers-color-scheme: dark)');
|
|
|
|
{% endif %}
|
2020-04-16 00:55:28 +02:00
|
|
|
{% endif %}
|
2020-04-07 08:22:07 +02:00
|
|
|
|
2020-04-16 00:55:28 +02:00
|
|
|
function detectThemeAndSwitchStyle() {
|
|
|
|
let theme = localStorage.getItem('themeOverride');
|
|
|
|
if (theme !== 'light' && theme !== 'dark') {
|
|
|
|
{% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %}
|
|
|
|
theme = darkSchemeWatch.matches ? 'dark' : 'light';
|
|
|
|
{% else %}
|
|
|
|
theme = '{{ THEME_COLOR|default("light") }}';
|
|
|
|
{% endif %}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Find the pygments CSS files (there are two, one for each theme) and
|
|
|
|
// change them both to the theme specified by the user.
|
|
|
|
const pygmentsTheme = theme === 'light'
|
|
|
|
? '{{ PYGMENTS_STYLE|default('github') }}'
|
|
|
|
: '{{ PYGMENTS_STYLE_DARK or PYGMENTS_STYLE or 'monokai' }}';
|
|
|
|
Array.from(document.head.getElementsByTagName('link')).forEach(linkEl => {
|
|
|
|
if (linkEl.href.match(/\/theme\/pygments\/.*\.min\.css/)) {
|
|
|
|
linkEl.href = `/theme/pygments/${pygmentsTheme}.min.css`;
|
|
|
|
}
|
|
|
|
});
|
2020-04-08 06:16:41 +02:00
|
|
|
|
2020-04-16 00:55:28 +02:00
|
|
|
const htmlElement = document.getElementsByTagName('html')[0];
|
|
|
|
if (theme === 'dark') {
|
|
|
|
htmlElement.classList.add('dark-theme');
|
|
|
|
htmlElement.classList.remove('light-theme');
|
|
|
|
} else {
|
|
|
|
htmlElement.classList.add('light-theme');
|
|
|
|
htmlElement.classList.remove('dark-theme');
|
2020-04-08 05:36:38 +02:00
|
|
|
}
|
2020-04-16 00:55:28 +02:00
|
|
|
}
|
2020-04-08 05:36:38 +02:00
|
|
|
|
2020-04-16 00:55:28 +02:00
|
|
|
function switchTheme(themeOverride) {
|
|
|
|
localStorage.setItem('themeOverride', themeOverride);
|
|
|
|
detectThemeAndSwitchStyle();
|
2020-04-07 08:22:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
detectThemeAndSwitchStyle();
|
2020-04-16 00:55:28 +02:00
|
|
|
{% if THEME_COLOR_AUTO_DETECT_BROWSER_PREFERENCE %}
|
|
|
|
darkSchemeWatch.addListener(detectThemeAndSwitchStyle);
|
|
|
|
{% endif %}
|
|
|
|
</script>
|
|
|
|
{% endif %}
|