diff --git a/starters/markdown-slides/config/_default/params.yaml b/starters/markdown-slides/config/_default/params.yaml index 2fd3b216..35564bf1 100644 --- a/starters/markdown-slides/config/_default/params.yaml +++ b/starters/markdown-slides/config/_default/params.yaml @@ -13,12 +13,19 @@ appearance: # SEO -seo: - site_type: Person - local_business_type: '' - org_name: '' - description: '' - twitter: '' +marketing: + seo: + site_type: Person + local_business_type: '' + org_name: '' + description: '' + twitter: '' + analytics: + google_analytics: '' + baidu_tongji: '' + verification: + google: '' + baidu: '' # Site header @@ -46,13 +53,5 @@ locale: # Site features features: - privacy_pack: false - -require_isotope: false - -marketing: - google_analytics: '' - google_tag_manager: '' - google_site_verification: '' - baidu_site_verification: '' - baidu_tongji: '' + privacy_pack: + enable: false diff --git a/starters/markdown-slides/content/admin/index.md b/starters/markdown-slides/content/admin/index.md index 04c96f80..fda4a485 100644 --- a/starters/markdown-slides/content/admin/index.md +++ b/starters/markdown-slides/content/admin/index.md @@ -2,6 +2,6 @@ # Generate Wowchemy CMS type: wowchemycms outputs: -- wowchemycms_config -- HTML + - wowchemycms_config + - HTML --- diff --git a/starters/markdown-slides/content/home/tags.md b/starters/markdown-slides/content/home/tags.md index 011cd5b0..ed91a319 100644 --- a/starters/markdown-slides/content/home/tags.md +++ b/starters/markdown-slides/content/home/tags.md @@ -13,7 +13,7 @@ title: Mei's Slide Decks 👩🏼🏫 subtitle: An example of writing _open_ slides with Markdown content: -# Choose the taxonomy from `config.yaml` to display (e.g. tags, categories) + # Choose the taxonomy from `config.yaml` to display (e.g. tags, categories) taxonomy: tags # Choose how many tags you would like to display (0 = all tags) count: 20 diff --git a/starters/markdown-slides/content/slides/example/index.md b/starters/markdown-slides/content/slides/example/index.md index 975170c8..6341f49c 100644 --- a/starters/markdown-slides/content/slides/example/index.md +++ b/starters/markdown-slides/content/slides/example/index.md @@ -47,6 +47,7 @@ slides: Inline code: `variable` Code block: + ```python porridge = "blueberry" if porridge == "blueberry": @@ -98,16 +99,20 @@ Add speaker notes to your presentation ```markdown {{%/* speaker_note */%}} + - Only the speaker can read these notes - Press `S` key to view + {{%/* /speaker_note */%}} ``` Press the `S` key to view the speaker notes! {{< speaker_note >}} + - Only the speaker can read these notes - Press `S` key to view + {{< /speaker_note >}} --- diff --git a/starters/markdown-slides/go.mod b/starters/markdown-slides/go.mod index fe55fe31..eb9c21ff 100644 --- a/starters/markdown-slides/go.mod +++ b/starters/markdown-slides/go.mod @@ -3,6 +3,6 @@ module github.com/wowchemy/starter-academic/exampleSite go 1.15 require ( - github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5 v5.0.0-20220109160354-be9e2fde4a4f // indirect - github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5 v5.0.0-20220109160354-be9e2fde4a4f // indirect + github.com/wowchemy/wowchemy-hugo-modules/wowchemy-cms/v5@main + github.com/wowchemy/wowchemy-hugo-modules/wowchemy/v5@main ) diff --git a/wowchemy/assets/js/wowchemy-carousel.js b/wowchemy/assets/js/wowchemy-carousel.js new file mode 100644 index 00000000..741c863e --- /dev/null +++ b/wowchemy/assets/js/wowchemy-carousel.js @@ -0,0 +1,25 @@ +/* --------------------------------------------------------------------------- + * Normalize Bootstrap Carousel Slide Heights. + * --------------------------------------------------------------------------- */ + +function normalizeCarouselSlideHeights() { + let carousels = document.querySelectorAll('.carousel'); + carousels.forEach((carousel) => { + let items = carousel.querySelector('.carousel-item'); + let maxHeight = Math.max.apply( + null, + items + .map(function () { + return this.outerHeight(); + }) + .get(), + ); + items.forEach((item) => { + item.style.minHeight = maxHeight + 'px'; + }); + }); +} + +window.addEventListener('load', normalizeCarouselSlideHeights); +window.addEventListener('resize', normalizeCarouselSlideHeights); +window.addEventListener('orientationchange', normalizeCarouselSlideHeights); diff --git a/wowchemy/assets/js/wowchemy-map.js b/wowchemy/assets/js/wowchemy-map.js new file mode 100644 index 00000000..d4a93d4e --- /dev/null +++ b/wowchemy/assets/js/wowchemy-map.js @@ -0,0 +1,76 @@ +/************************************************* + * Wowchemy + * https://github.com/wowchemy/wowchemy-hugo-themes + * + * Wowchemy Maps + **************************************************/ + +// Initialize Google Maps or OpenStreetMap via Leaflet. +function initMap() { + if ($('#map').length) { + let map_provider = $('#map-provider').val(); + let lat = $('#map-lat').val(); + let lng = $('#map-lng').val(); + let zoom = parseInt($('#map-zoom').val()); + let address = $('#map-dir').val(); + let api_key = $('#map-api-key').val(); + + if (map_provider === 'google') { + let map = new GMaps({ + div: '#map', + lat: lat, + lng: lng, + zoom: zoom, + zoomControl: true, + zoomControlOpt: { + style: 'SMALL', + position: 'TOP_LEFT', + }, + streetViewControl: false, + mapTypeControl: false, + gestureHandling: 'cooperative', + }); + + map.addMarker({ + lat: lat, + lng: lng, + click: function () { + let url = 'https://www.google.com/maps/place/' + encodeURIComponent(address) + '/@' + lat + ',' + lng + '/'; + window.open(url, '_blank'); + }, + title: address, + }); + } else { + let map = new L.map('map').setView([lat, lng], zoom); + if (map_provider === 'mapbox' && api_key.length) { + L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { + attribution: + 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', + tileSize: 512, + maxZoom: 18, + zoomOffset: -1, + id: 'mapbox/streets-v11', + accessToken: api_key, + }).addTo(map); + } else { + L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, + attribution: '© OpenStreetMap', + }).addTo(map); + } + let marker = L.marker([lat, lng]).addTo(map); + let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N'; + marker.bindPopup( + address + + '
', + ); + } + } +} + +document.addEventListener('DOMContentLoaded', function () { + // Initialise street maps if necessary. + initMap(); +}); diff --git a/wowchemy/assets/js/wowchemy-publication.js b/wowchemy/assets/js/wowchemy-publication.js new file mode 100644 index 00000000..69c0018a --- /dev/null +++ b/wowchemy/assets/js/wowchemy-publication.js @@ -0,0 +1,162 @@ +/************************************************* + * Wowchemy + * https://github.com/wowchemy/wowchemy-hugo-themes + * + * Wowchemy Publications + **************************************************/ + +// Active publication filters. +let pubFilters = {}; + +// Search term. +let searchRegex; + +// Filter values (concatenated). +let filterValues; + +// Publication container. +let $grid_pubs = $('#container-publications'); + +// Initialise Isotope publication layout if required. +if ($grid_pubs.length) { + $grid_pubs.isotope({ + itemSelector: '.isotope-item', + percentPosition: true, + masonry: { + // Use Bootstrap compatible grid layout. + columnWidth: '.grid-sizer', + }, + filter: function () { + let $this = $(this); + let searchResults = searchRegex ? $this.text().match(searchRegex) : true; + let filterResults = filterValues ? $this.is(filterValues) : true; + return searchResults && filterResults; + }, + }); + + // Filter by search term. + let $quickSearch = $('.filter-search').keyup( + debounce(function () { + searchRegex = new RegExp($quickSearch.val(), 'gi'); + $grid_pubs.isotope(); + }), + ); + + $('.pub-filters').on('change', function () { + let $this = $(this); + + // Get group key. + let filterGroup = $this[0].getAttribute('data-filter-group'); + + // Set filter for group. + pubFilters[filterGroup] = this.value; + + // Combine filters. + filterValues = concatValues(pubFilters); + + // Activate filters. + $grid_pubs.isotope(); + + // If filtering by publication type, update the URL hash to enable direct linking to results. + if (filterGroup === 'pubtype') { + // Set hash URL to current filter. + let url = $(this).val(); + if (url.substr(0, 9) === '.pubtype-') { + window.location.hash = url.substr(9); + } else { + window.location.hash = ''; + } + } + }); +} + +// Debounce input to prevent spamming filter requests. +function debounce(fn, threshold) { + let timeout; + threshold = threshold || 100; + return function debounced() { + clearTimeout(timeout); + let args = arguments; + let _this = this; + + function delayed() { + fn.apply(_this, args); + } + + timeout = setTimeout(delayed, threshold); + }; +} + +// Flatten object by concatenating values. +function concatValues(obj) { + let value = ''; + for (let prop in obj) { + value += obj[prop]; + } + return value; +} + +// Filter publications according to hash in URL. +function filter_publications() { + // Check for Isotope publication layout. + if (!$grid_pubs.length) return; + + let urlHash = window.location.hash.replace('#', ''); + let filterValue = '*'; + + // Check if hash is numeric. + if (urlHash != '' && !isNaN(urlHash)) { + filterValue = '.pubtype-' + urlHash; + } + + // Set filter. + let filterGroup = 'pubtype'; + pubFilters[filterGroup] = filterValue; + filterValues = concatValues(pubFilters); + + // Activate filters. + $grid_pubs.isotope(); + + // Set selected option. + $('.pubtype-select').val(filterValue); +} + +document.addEventListener('DOMContentLoaded', function () { + // Enable publication filter for publication index page. + if ($('.pub-filters-select')) { + filter_publications(); + // Useful for changing hash manually (e.g. in development): + // window.addEventListener('hashchange', filter_publications, false); + } + + // Load citation modal on 'Cite' click. + $('.js-cite-modal').click(function (e) { + e.preventDefault(); + let filename = $(this).attr('data-filename'); + let modal = $('#modal'); + modal.find('.modal-body code').load(filename, function (response, status, xhr) { + if (status == 'error') { + let msg = 'Error: '; + $('#modal-error').html(msg + xhr.status + ' ' + xhr.statusText); + } else { + $('.js-download-cite').attr('href', filename); + } + }); + modal.modal('show'); + }); + + // Copy citation text on 'Copy' click. + $('.js-copy-cite').click(function (e) { + e.preventDefault(); + // Get text to copy. + let citation = document.querySelector('#modal .modal-body').innerHTML; + navigator.clipboard + .writeText(citation) + .then(function () { + console.debug('Citation copied!'); + }) + .catch(function () { + console.error('Citation copy failed!'); + }); + }); +}); diff --git a/wowchemy/assets/js/wowchemy.js b/wowchemy/assets/js/wowchemy.js index 2c17056a..2994a205 100644 --- a/wowchemy/assets/js/wowchemy.js +++ b/wowchemy/assets/js/wowchemy.js @@ -129,194 +129,6 @@ $(document).on('click', '.navbar-collapse.show', function (e) { } }); -/* --------------------------------------------------------------------------- - * Filter publications. - * --------------------------------------------------------------------------- */ - -// Active publication filters. -let pubFilters = {}; - -// Search term. -let searchRegex; - -// Filter values (concatenated). -let filterValues; - -// Publication container. -let $grid_pubs = $('#container-publications'); - -// Initialise Isotope publication layout if required. -if ($grid_pubs.length) { - $grid_pubs.isotope({ - itemSelector: '.isotope-item', - percentPosition: true, - masonry: { - // Use Bootstrap compatible grid layout. - columnWidth: '.grid-sizer', - }, - filter: function () { - let $this = $(this); - let searchResults = searchRegex ? $this.text().match(searchRegex) : true; - let filterResults = filterValues ? $this.is(filterValues) : true; - return searchResults && filterResults; - }, - }); - - // Filter by search term. - let $quickSearch = $('.filter-search').keyup( - debounce(function () { - searchRegex = new RegExp($quickSearch.val(), 'gi'); - $grid_pubs.isotope(); - }), - ); - - $('.pub-filters').on('change', function () { - let $this = $(this); - - // Get group key. - let filterGroup = $this[0].getAttribute('data-filter-group'); - - // Set filter for group. - pubFilters[filterGroup] = this.value; - - // Combine filters. - filterValues = concatValues(pubFilters); - - // Activate filters. - $grid_pubs.isotope(); - - // If filtering by publication type, update the URL hash to enable direct linking to results. - if (filterGroup === 'pubtype') { - // Set hash URL to current filter. - let url = $(this).val(); - if (url.substr(0, 9) === '.pubtype-') { - window.location.hash = url.substr(9); - } else { - window.location.hash = ''; - } - } - }); -} - -// Debounce input to prevent spamming filter requests. -function debounce(fn, threshold) { - let timeout; - threshold = threshold || 100; - return function debounced() { - clearTimeout(timeout); - let args = arguments; - let _this = this; - - function delayed() { - fn.apply(_this, args); - } - - timeout = setTimeout(delayed, threshold); - }; -} - -// Flatten object by concatenating values. -function concatValues(obj) { - let value = ''; - for (let prop in obj) { - value += obj[prop]; - } - return value; -} - -// Filter publications according to hash in URL. -function filter_publications() { - // Check for Isotope publication layout. - if (!$grid_pubs.length) return; - - let urlHash = window.location.hash.replace('#', ''); - let filterValue = '*'; - - // Check if hash is numeric. - if (urlHash != '' && !isNaN(urlHash)) { - filterValue = '.pubtype-' + urlHash; - } - - // Set filter. - let filterGroup = 'pubtype'; - pubFilters[filterGroup] = filterValue; - filterValues = concatValues(pubFilters); - - // Activate filters. - $grid_pubs.isotope(); - - // Set selected option. - $('.pubtype-select').val(filterValue); -} - -/* --------------------------------------------------------------------------- - * Google Maps or OpenStreetMap via Leaflet. - * --------------------------------------------------------------------------- */ - -function initMap() { - if ($('#map').length) { - let map_provider = $('#map-provider').val(); - let lat = $('#map-lat').val(); - let lng = $('#map-lng').val(); - let zoom = parseInt($('#map-zoom').val()); - let address = $('#map-dir').val(); - let api_key = $('#map-api-key').val(); - - if (map_provider === 'google') { - let map = new GMaps({ - div: '#map', - lat: lat, - lng: lng, - zoom: zoom, - zoomControl: true, - zoomControlOpt: { - style: 'SMALL', - position: 'TOP_LEFT', - }, - streetViewControl: false, - mapTypeControl: false, - gestureHandling: 'cooperative', - }); - - map.addMarker({ - lat: lat, - lng: lng, - click: function () { - let url = 'https://www.google.com/maps/place/' + encodeURIComponent(address) + '/@' + lat + ',' + lng + '/'; - window.open(url, '_blank'); - }, - title: address, - }); - } else { - let map = new L.map('map').setView([lat, lng], zoom); - if (map_provider === 'mapbox' && api_key.length) { - L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}', { - attribution: - 'Map data © OpenStreetMap contributors, CC-BY-SA, Imagery © Mapbox', - tileSize: 512, - maxZoom: 18, - zoomOffset: -1, - id: 'mapbox/streets-v11', - accessToken: api_key, - }).addTo(map); - } else { - L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { - maxZoom: 19, - attribution: '© OpenStreetMap', - }).addTo(map); - } - let marker = L.marker([lat, lng]).addTo(map); - let url = lat + ',' + lng + '#map=' + zoom + '/' + lat + '/' + lng + '&layers=N'; - marker.bindPopup( - address + - '', - ); - } - } -} - /* --------------------------------------------------------------------------- * GitHub API. * --------------------------------------------------------------------------- */ @@ -373,29 +185,6 @@ function toggleSearchDialog() { } } -/* --------------------------------------------------------------------------- - * Normalize Bootstrap Carousel Slide Heights. - * --------------------------------------------------------------------------- */ - -function normalizeCarouselSlideHeights() { - $('.carousel').each(function () { - // Get carousel slides. - let items = $('.carousel-item', this); - // Reset all slide heights. - items.css('min-height', 0); - // Normalize all slide heights. - let maxHeight = Math.max.apply( - null, - items - .map(function () { - return $(this).outerHeight(); - }) - .get(), - ); - items.css('min-height', maxHeight + 'px'); - }); -} - /* --------------------------------------------------------------------------- * Fix Hugo's Goldmark output and Mermaid code blocks. * --------------------------------------------------------------------------- */ @@ -561,50 +350,6 @@ $(window).on('load', function () { } } - // Enable publication filter for publication index page. - if ($('.pub-filters-select')) { - filter_publications(); - // Useful for changing hash manually (e.g. in development): - // window.addEventListener('hashchange', filter_publications, false); - } - - // Load citation modal on 'Cite' click. - $('.js-cite-modal').click(function (e) { - e.preventDefault(); - let filename = $(this).attr('data-filename'); - let modal = $('#modal'); - modal.find('.modal-body code').load(filename, function (response, status, xhr) { - if (status == 'error') { - let msg = 'Error: '; - $('#modal-error').html(msg + xhr.status + ' ' + xhr.statusText); - } else { - $('.js-download-cite').attr('href', filename); - } - }); - modal.modal('show'); - }); - - // Copy citation text on 'Copy' click. - $('.js-copy-cite').click(function (e) { - e.preventDefault(); - // Get selection. - let range = document.createRange(); - let code_node = document.querySelector('#modal .modal-body'); - range.selectNode(code_node); - window.getSelection().addRange(range); - try { - // Execute the copy command. - document.execCommand('copy'); - } catch (e) { - console.log('Error: citation copy failed.'); - } - // Remove selection. - window.getSelection().removeRange(range); - }); - - // Initialise Google Maps if necessary. - initMap(); - // Print latest version of GitHub projects. let githubReleaseSelector = '.js-github-release'; if ($(githubReleaseSelector).length > 0) { @@ -678,11 +423,6 @@ darkModeMediaQuery.addEventListener('change', (event) => { onMediaQueryListEvent(event); }); -// Normalize Bootstrap carousel slide heights for Slider widget instances. -window.addEventListener('load', normalizeCarouselSlideHeights); -window.addEventListener('resize', normalizeCarouselSlideHeights); -window.addEventListener('orientationchange', normalizeCarouselSlideHeights); - // Automatic main menu dropdowns on mouse over. $('body').on('mouseenter mouseleave', '.dropdown', function (e) { var dropdown = $(e.target).closest('.dropdown'); diff --git a/wowchemy/layouts/_default/baseof.html b/wowchemy/layouts/_default/baseof.html index 501ad5bd..50e92494 100644 --- a/wowchemy/layouts/_default/baseof.html +++ b/wowchemy/layouts/_default/baseof.html @@ -57,8 +57,6 @@ {{ end }} - {{ partial "citation" . }} - {{ partial "site_js" . }}