From 351d6728d0f7d5ec1fb01aaa1139bce4bac1bcc2 Mon Sep 17 00:00:00 2001 From: elkan1788 Date: Sun, 5 Jan 2025 16:40:58 +0800 Subject: [PATCH] :art: :bug: Rename file & path & remove unused file. --- .../{third-party => 3rd}/disqusjs.scss | 0 .../{third-party => 3rd}/gitalk.scss | 0 .../{third-party => 3rd}/gitter.scss | 0 .../{third-party => 3rd}/index.scss | 0 .../{third-party => 3rd}/livere.scss | 0 .../{third-party => 3rd}/mermaid.scss | 0 .../{third-party => 3rd}/related-posts.scss | 0 .../{third-party => 3rd}/search.scss | 0 .../{third-party => 3rd}/utterances.scss | 0 .../{third-party => 3rd}/waline.scss | 0 assets/css/_common/components/index.scss | 2 +- .../{third-party => 3rd}/comments/artalk.js | 0 .../{third-party => 3rd}/comments/giscus.js | 0 .../{third-party => 3rd}/comments/livere.js | 0 .../comments/utterances.js | 0 .../{third-party => 3rd}/comments/waline.js | 0 .../{third-party => 3rd}/comments/waline3.js | 0 .../js/{third-party => 3rd}/others/counter.js | 0 .../{third-party => 3rd}/others/lawidget.js | 0 assets/js/{third-party => 3rd}/others/math.js | 0 .../js/{third-party => 3rd}/others/mermaid.js | 0 .../{third-party => 3rd}/others/translate.js | 2 +- .../js/{third-party => 3rd}/search/algolia.js | 0 .../js/{third-party => 3rd}/search/local.js | 0 .../js/{third-party => 3rd}/share/addtoany.js | 0 .../{third-party => 3rd}/share/sharethis.js | 0 exampleSite/content/post/image-viewer.md | 16 +-- .../_funs/{get_res.html => get_cdn_res.html} | 0 layouts/partials/_funs/get_plugin.html | 2 +- layouts/partials/head/style.html | 2 +- layouts/partials/scripts/global.html | 30 +++--- .../third-party/analytics/baidu-analytics.js | 7 -- .../third-party/analytics/google-analytics.js | 35 ------ static/js/third-party/analytics/growingio.js | 10 -- static/js/third-party/chat/chatra.js | 19 ---- static/js/third-party/chat/gitter.js | 5 - static/js/third-party/chat/tidio.js | 10 -- static/js/third-party/fancybox.js | 38 ------- static/js/third-party/google-translate.min.js | 1 - static/js/third-party/math/katex.js | 7 -- static/js/third-party/math/mathjax.js | 36 ------- static/js/third-party/pace.js | 7 -- static/js/third-party/quicklink.js | 37 ------- static/js/third-party/rating.js | 22 ---- static/js/third-party/statistics/firestore.js | 64 ----------- .../third-party/statistics/lean-analytics.js | 102 ------------------ static/js/third-party/tags/mermaid.js | 32 ------ static/js/third-party/tags/pdf.js | 23 ---- 48 files changed, 27 insertions(+), 482 deletions(-) rename assets/css/_common/components/{third-party => 3rd}/disqusjs.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/gitalk.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/gitter.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/index.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/livere.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/mermaid.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/related-posts.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/search.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/utterances.scss (100%) rename assets/css/_common/components/{third-party => 3rd}/waline.scss (100%) rename assets/js/{third-party => 3rd}/comments/artalk.js (100%) rename assets/js/{third-party => 3rd}/comments/giscus.js (100%) rename assets/js/{third-party => 3rd}/comments/livere.js (100%) rename assets/js/{third-party => 3rd}/comments/utterances.js (100%) rename assets/js/{third-party => 3rd}/comments/waline.js (100%) rename assets/js/{third-party => 3rd}/comments/waline3.js (100%) rename assets/js/{third-party => 3rd}/others/counter.js (100%) rename assets/js/{third-party => 3rd}/others/lawidget.js (100%) rename assets/js/{third-party => 3rd}/others/math.js (100%) rename assets/js/{third-party => 3rd}/others/mermaid.js (100%) rename assets/js/{third-party => 3rd}/others/translate.js (80%) rename assets/js/{third-party => 3rd}/search/algolia.js (100%) rename assets/js/{third-party => 3rd}/search/local.js (100%) rename assets/js/{third-party => 3rd}/share/addtoany.js (100%) rename assets/js/{third-party => 3rd}/share/sharethis.js (100%) rename layouts/partials/_funs/{get_res.html => get_cdn_res.html} (100%) delete mode 100644 static/js/third-party/analytics/baidu-analytics.js delete mode 100644 static/js/third-party/analytics/google-analytics.js delete mode 100644 static/js/third-party/analytics/growingio.js delete mode 100644 static/js/third-party/chat/chatra.js delete mode 100644 static/js/third-party/chat/gitter.js delete mode 100644 static/js/third-party/chat/tidio.js delete mode 100644 static/js/third-party/fancybox.js delete mode 100644 static/js/third-party/google-translate.min.js delete mode 100644 static/js/third-party/math/katex.js delete mode 100644 static/js/third-party/math/mathjax.js delete mode 100644 static/js/third-party/pace.js delete mode 100644 static/js/third-party/quicklink.js delete mode 100644 static/js/third-party/rating.js delete mode 100644 static/js/third-party/statistics/firestore.js delete mode 100644 static/js/third-party/statistics/lean-analytics.js delete mode 100644 static/js/third-party/tags/mermaid.js delete mode 100644 static/js/third-party/tags/pdf.js diff --git a/assets/css/_common/components/third-party/disqusjs.scss b/assets/css/_common/components/3rd/disqusjs.scss similarity index 100% rename from assets/css/_common/components/third-party/disqusjs.scss rename to assets/css/_common/components/3rd/disqusjs.scss diff --git a/assets/css/_common/components/third-party/gitalk.scss b/assets/css/_common/components/3rd/gitalk.scss similarity index 100% rename from assets/css/_common/components/third-party/gitalk.scss rename to assets/css/_common/components/3rd/gitalk.scss diff --git a/assets/css/_common/components/third-party/gitter.scss b/assets/css/_common/components/3rd/gitter.scss similarity index 100% rename from assets/css/_common/components/third-party/gitter.scss rename to assets/css/_common/components/3rd/gitter.scss diff --git a/assets/css/_common/components/third-party/index.scss b/assets/css/_common/components/3rd/index.scss similarity index 100% rename from assets/css/_common/components/third-party/index.scss rename to assets/css/_common/components/3rd/index.scss diff --git a/assets/css/_common/components/third-party/livere.scss b/assets/css/_common/components/3rd/livere.scss similarity index 100% rename from assets/css/_common/components/third-party/livere.scss rename to assets/css/_common/components/3rd/livere.scss diff --git a/assets/css/_common/components/third-party/mermaid.scss b/assets/css/_common/components/3rd/mermaid.scss similarity index 100% rename from assets/css/_common/components/third-party/mermaid.scss rename to assets/css/_common/components/3rd/mermaid.scss diff --git a/assets/css/_common/components/third-party/related-posts.scss b/assets/css/_common/components/3rd/related-posts.scss similarity index 100% rename from assets/css/_common/components/third-party/related-posts.scss rename to assets/css/_common/components/3rd/related-posts.scss diff --git a/assets/css/_common/components/third-party/search.scss b/assets/css/_common/components/3rd/search.scss similarity index 100% rename from assets/css/_common/components/third-party/search.scss rename to assets/css/_common/components/3rd/search.scss diff --git a/assets/css/_common/components/third-party/utterances.scss b/assets/css/_common/components/3rd/utterances.scss similarity index 100% rename from assets/css/_common/components/third-party/utterances.scss rename to assets/css/_common/components/3rd/utterances.scss diff --git a/assets/css/_common/components/third-party/waline.scss b/assets/css/_common/components/3rd/waline.scss similarity index 100% rename from assets/css/_common/components/third-party/waline.scss rename to assets/css/_common/components/3rd/waline.scss diff --git a/assets/css/_common/components/index.scss b/assets/css/_common/components/index.scss index 191a6cb..15bb2f2 100644 --- a/assets/css/_common/components/index.scss +++ b/assets/css/_common/components/index.scss @@ -25,4 +25,4 @@ @import 'post'; @import 'pages'; -@import 'third-party'; +@import '3rd'; diff --git a/assets/js/third-party/comments/artalk.js b/assets/js/3rd/comments/artalk.js similarity index 100% rename from assets/js/third-party/comments/artalk.js rename to assets/js/3rd/comments/artalk.js diff --git a/assets/js/third-party/comments/giscus.js b/assets/js/3rd/comments/giscus.js similarity index 100% rename from assets/js/third-party/comments/giscus.js rename to assets/js/3rd/comments/giscus.js diff --git a/assets/js/third-party/comments/livere.js b/assets/js/3rd/comments/livere.js similarity index 100% rename from assets/js/third-party/comments/livere.js rename to assets/js/3rd/comments/livere.js diff --git a/assets/js/third-party/comments/utterances.js b/assets/js/3rd/comments/utterances.js similarity index 100% rename from assets/js/third-party/comments/utterances.js rename to assets/js/3rd/comments/utterances.js diff --git a/assets/js/third-party/comments/waline.js b/assets/js/3rd/comments/waline.js similarity index 100% rename from assets/js/third-party/comments/waline.js rename to assets/js/3rd/comments/waline.js diff --git a/assets/js/third-party/comments/waline3.js b/assets/js/3rd/comments/waline3.js similarity index 100% rename from assets/js/third-party/comments/waline3.js rename to assets/js/3rd/comments/waline3.js diff --git a/assets/js/third-party/others/counter.js b/assets/js/3rd/others/counter.js similarity index 100% rename from assets/js/third-party/others/counter.js rename to assets/js/3rd/others/counter.js diff --git a/assets/js/third-party/others/lawidget.js b/assets/js/3rd/others/lawidget.js similarity index 100% rename from assets/js/third-party/others/lawidget.js rename to assets/js/3rd/others/lawidget.js diff --git a/assets/js/third-party/others/math.js b/assets/js/3rd/others/math.js similarity index 100% rename from assets/js/third-party/others/math.js rename to assets/js/3rd/others/math.js diff --git a/assets/js/third-party/others/mermaid.js b/assets/js/3rd/others/mermaid.js similarity index 100% rename from assets/js/third-party/others/mermaid.js rename to assets/js/3rd/others/mermaid.js diff --git a/assets/js/third-party/others/translate.js b/assets/js/3rd/others/translate.js similarity index 80% rename from assets/js/third-party/others/translate.js rename to assets/js/3rd/others/translate.js index 6dee18e..c386ede 100644 --- a/assets/js/third-party/others/translate.js +++ b/assets/js/3rd/others/translate.js @@ -4,6 +4,6 @@ NexT.plugins.others.translate = function() { if (!NexT.utils.checkDOMExist(element)) return; NexT.utils.lazyLoadComponent(element, function() { window.translateelement_styles='/css/google-translate.min.css'; - NexT.utils.getScript('/js/third-party/google-translate.min.js'); + NexT.utils.getScript('/js/3rd/google-translate.min.js'); }); } \ No newline at end of file diff --git a/assets/js/third-party/search/algolia.js b/assets/js/3rd/search/algolia.js similarity index 100% rename from assets/js/third-party/search/algolia.js rename to assets/js/3rd/search/algolia.js diff --git a/assets/js/third-party/search/local.js b/assets/js/3rd/search/local.js similarity index 100% rename from assets/js/third-party/search/local.js rename to assets/js/3rd/search/local.js diff --git a/assets/js/third-party/share/addtoany.js b/assets/js/3rd/share/addtoany.js similarity index 100% rename from assets/js/third-party/share/addtoany.js rename to assets/js/3rd/share/addtoany.js diff --git a/assets/js/third-party/share/sharethis.js b/assets/js/3rd/share/sharethis.js similarity index 100% rename from assets/js/third-party/share/sharethis.js rename to assets/js/3rd/share/sharethis.js diff --git a/exampleSite/content/post/image-viewer.md b/exampleSite/content/post/image-viewer.md index 7cb64be..f40a0f5 100644 --- a/exampleSite/content/post/image-viewer.md +++ b/exampleSite/content/post/image-viewer.md @@ -27,15 +27,15 @@ expired: true ## 动物 -![cute-scottish-fold-cat](/post/image-viewer/preview_cute-scottish-fold-cat.jpg) -![scottish-fold-kitten](/post/image-viewer/preview_scottish-fold-kitten.jpg) -![hourses](/post/image-viewer/preview_horses.jpg) -![owl-family-background](/post/image-viewer/preview_owl-family-background.jpg) +![cute-scottish-fold-cat](/demo/image-viewer/preview_cute-scottish-fold-cat.jpg) +![scottish-fold-kitten](/demo/image-viewer/preview_scottish-fold-kitten.jpg) +![hourses](/demo/image-viewer/preview_horses.jpg) +![owl-family-background](/demo/image-viewer/preview_owl-family-background.jpg) ## 风景 -![luxury-resort-in-maldives](/post/image-viewer/preview_luxury-resort-in-maldives.jpg) -![sea-shell](/post/image-viewer/preview_sea-shell.jpg) -![the-arch-sunset](/post/image-viewer/preview_the-arch-sunset.jpg) -![norway-autumn-landscape](/post/image-viewer/preview_norway-autumn-landscape.jpg) +![luxury-resort-in-maldives](/demo/image-viewer/preview_luxury-resort-in-maldives.jpg) +![sea-shell](/demo/image-viewer/preview_sea-shell.jpg) +![the-arch-sunset](/demo/image-viewer/preview_the-arch-sunset.jpg) +![norway-autumn-landscape](/demo/image-viewer/preview_norway-autumn-landscape.jpg) diff --git a/layouts/partials/_funs/get_res.html b/layouts/partials/_funs/get_cdn_res.html similarity index 100% rename from layouts/partials/_funs/get_res.html rename to layouts/partials/_funs/get_cdn_res.html diff --git a/layouts/partials/_funs/get_plugin.html b/layouts/partials/_funs/get_plugin.html index 4b50486..70d6a00 100644 --- a/layouts/partials/_funs/get_plugin.html +++ b/layouts/partials/_funs/get_plugin.html @@ -1,6 +1,6 @@ {{/* Get third party js plugins resource */}} -{{ $pluginPath := printf "%s/%s/%s" "js/third-party" .class .plugin }} +{{ $pluginPath := printf "%s/%s/%s" "js/3rd" .class .plugin }} {{ $targetPath := printf "js/%s" .plugin }} {{ $plugin := resources.Get $pluginPath | resources.ExecuteAsTemplate $targetPath .ctx }} diff --git a/layouts/partials/head/style.html b/layouts/partials/head/style.html index 0a34bfe..cb96efc 100644 --- a/layouts/partials/head/style.html +++ b/layouts/partials/head/style.html @@ -4,7 +4,7 @@ {{ $router := .Scratch.Get "router" }} {{ range $css := $cssRes }} - {{ $pluginCss := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }} + {{ $pluginCss := partial "_funs/get_cdn_res.html" (dict "res" . "vendor" $vendor "router" $router) }} {{ end }} diff --git a/layouts/partials/scripts/global.html b/layouts/partials/scripts/global.html index 085c253..419a625 100644 --- a/layouts/partials/scripts/global.html +++ b/layouts/partials/scripts/global.html @@ -3,7 +3,7 @@ {{ $vendor := .Site.Params.vendors.plugins }} {{ $router := .Scratch.Get "router" }} {{ range $jsRes }} - {{ $pluginJS := partial "_funs/get_res.html" (dict "res" . "vendor" $vendor "router" $router) }} + {{ $pluginJS := partial "_funs/get_cdn_res.html" (dict "res" . "vendor" $vendor "router" $router) }} {{ end }} @@ -41,18 +41,18 @@ {{/* Share scripts */}} {{/** if and .Site.Params.share.enable (isset .Site.Params "sharethisid") }} -{{ $sharethisjs := resources.Get "js/third-party/share/sharethis.js" }} +{{ $sharethisjs := resources.Get "js/3rd/share/sharethis.js" }} {{ $nextjs = $nextjs | append $sharethisjs }} {{ end **/}} {{ with .Site.Params.share }} {{ if or .enable .Params.share }} {{ if isset . "sharethis" }} - {{ $sharethisjs := resources.Get "js/third-party/share/sharethis.js" }} + {{ $sharethisjs := resources.Get "js/3rd/share/sharethis.js" }} {{ $nextjs = $nextjs | append $sharethisjs }} {{ end }} {{ if isset . "addtoany" }} - {{ $addtoanyjs := resources.Get "js/third-party/share/addtoany.js" }} + {{ $addtoanyjs := resources.Get "js/3rd/share/addtoany.js" }} {{ $nextjs = $nextjs | append $addtoanyjs }} {{ end }} {{ end }} @@ -60,53 +60,53 @@ {{/* Comments scripts */}} {{ if isset .Site.Params "waline" }} - {{ $walinejs := resources.Get "js/third-party/comments/waline.js" }} + {{ $walinejs := resources.Get "js/3rd/comments/waline.js" }} {{ $nextjs = $nextjs | append $walinejs }} {{ end }} {{ if isset .Site.Params "waline3" }} - {{ $walinejs3 := resources.Get "js/third-party/comments/waline3.js" }} + {{ $walinejs3 := resources.Get "js/3rd/comments/waline3.js" }} {{ $nextjs = $nextjs | append $walinejs3 }} {{ end }} {{ if or .Site.Params.postMeta.views.enable .Site.Params.postMeta.comments.enable }} - {{ $counterjs := resources.Get "js/third-party/others/counter.js" }} + {{ $counterjs := resources.Get "js/3rd/others/counter.js" }} {{ $nextjs = $nextjs | append $counterjs }} {{ end }} {{ if isset .Site.Params "giscus" }} -{{ $giscusjs := resources.Get "js/third-party/comments/giscus.js" }} +{{ $giscusjs := resources.Get "js/3rd/comments/giscus.js" }} {{ $nextjs = $nextjs | append $giscusjs }} {{ end}} {{ if isset .Site.Params "livere" }} -{{ $liverejs := resources.Get "js/third-party/comments/livere.js" }} +{{ $liverejs := resources.Get "js/3rd/comments/livere.js" }} {{ $nextjs = $nextjs | append $liverejs }} {{ end }} {{ if isset .Site.Params "artalk" }} -{{ $artalkjs := resources.Get "js/third-party/comments/artalk.js" }} +{{ $artalkjs := resources.Get "js/3rd/comments/artalk.js" }} {{ $nextjs = $nextjs | append $artalkjs }} {{ end }} {{ if isset .Site.Params "utterances" }} -{{ $utterancesjs := resources.Get "js/third-party/comments/utterances.js" }} +{{ $utterancesjs := resources.Get "js/3rd/comments/utterances.js" }} {{ $nextjs = $nextjs | append $utterancesjs }} {{ end }} {{/* Search engin scripts */}} {{ if .Site.Params.localSearch.enable }} -{{ $search := resources.Get "js/third-party/search/local.js" }} +{{ $search := resources.Get "js/3rd/search/local.js" }} {{ $nextjs = $nextjs | append $search }} {{ end }} {{ if .Site.Params.algoliaSearch.enable }} -{{ $search := resources.Get "js/third-party/search/algolia.js" }} +{{ $search := resources.Get "js/3rd/search/algolia.js" }} {{ $nextjs = $nextjs | append $search }} {{ end }} {{/* Other not useful scripts, eg: 51la widget, translate */}} {{ with .Site.Params.siteState.views }} {{ if and .enable (eq .plugin "51la") }} - {{ $lawt := resources.Get "js/third-party/others/lawidget.js" }} + {{ $lawt := resources.Get "js/3rd/others/lawidget.js" }} {{ $nextjs = $nextjs | append $lawt }} {{ end }} {{ end }} {{ if .Site.Params.footer.translate }} -{{ $translate := resources.Get "js/third-party/others/translate.js" }} +{{ $translate := resources.Get "js/3rd/others/translate.js" }} {{ $nextjs = $nextjs | append $translate }} {{ end }} diff --git a/static/js/third-party/analytics/baidu-analytics.js b/static/js/third-party/analytics/baidu-analytics.js deleted file mode 100644 index c10e7d0..0000000 --- a/static/js/third-party/analytics/baidu-analytics.js +++ /dev/null @@ -1,7 +0,0 @@ -/* global _hmt */ - -if (!window._hmt) window._hmt = []; - -document.addEventListener('pjax:success', () => { - _hmt.push(['_trackPageview', location.pathname]); -}); diff --git a/static/js/third-party/analytics/google-analytics.js b/static/js/third-party/analytics/google-analytics.js deleted file mode 100644 index 2cd128f..0000000 --- a/static/js/third-party/analytics/google-analytics.js +++ /dev/null @@ -1,35 +0,0 @@ -/* global CONFIG, dataLayer, gtag */ - -if (!CONFIG.google_analytics.only_pageview) { - if (CONFIG.hostname === location.hostname) { - window.dataLayer = window.dataLayer || []; - window.gtag = function() { - dataLayer.push(arguments); - }; - gtag('js', new Date()); - gtag('config', CONFIG.google_analytics.tracking_id); - - document.addEventListener('pjax:success', () => { - gtag('event', 'page_view', { - page_location: location.href, - page_path : location.pathname, - page_title : document.title - }); - }); - } -} else { - const sendPageView = () => { - if (CONFIG.hostname !== location.hostname) return; - const uid = localStorage.getItem('uid') || (Math.random() + '.' + Math.random()); - localStorage.setItem('uid', uid); - navigator.sendBeacon('https://www.google-analytics.com/collect', new URLSearchParams({ - v : 1, - tid: CONFIG.google_analytics.tracking_id, - cid: uid, - t : 'pageview', - dp : encodeURIComponent(location.pathname) - })); - }; - document.addEventListener('pjax:complete', sendPageView); - sendPageView(); -} diff --git a/static/js/third-party/analytics/growingio.js b/static/js/third-party/analytics/growingio.js deleted file mode 100644 index 0460833..0000000 --- a/static/js/third-party/analytics/growingio.js +++ /dev/null @@ -1,10 +0,0 @@ -/* global CONFIG, gio */ - -if (!window.gio) { - window.gio = function() { - (window.gio.q = window.gio.q || []).push(arguments); - }; -} - -gio('init', `${CONFIG.growingio_analytics}`, {}); -gio('send'); diff --git a/static/js/third-party/chat/chatra.js b/static/js/third-party/chat/chatra.js deleted file mode 100644 index e495b8e..0000000 --- a/static/js/third-party/chat/chatra.js +++ /dev/null @@ -1,19 +0,0 @@ -/* global CONFIG, Chatra */ - -(function() { - if (CONFIG.chatra.embed) { - window.ChatraSetup = { - mode : 'frame', - injectTo: CONFIG.chatra.embed - }; - } - - window.ChatraID = CONFIG.chatra.id; - - const chatButton = document.querySelector('.sidebar-button button'); - if (chatButton) { - chatButton.addEventListener('click', () => { - Chatra('openChat', true); - }); - } -})(); diff --git a/static/js/third-party/chat/gitter.js b/static/js/third-party/chat/gitter.js deleted file mode 100644 index 2b26d05..0000000 --- a/static/js/third-party/chat/gitter.js +++ /dev/null @@ -1,5 +0,0 @@ -/* global CONFIG */ - -((window.gitter = {}).chat = {}).options = { - room: CONFIG.gitter.room -}; diff --git a/static/js/third-party/chat/tidio.js b/static/js/third-party/chat/tidio.js deleted file mode 100644 index bffb918..0000000 --- a/static/js/third-party/chat/tidio.js +++ /dev/null @@ -1,10 +0,0 @@ -/* global tidioChatApi */ - -(function() { - const chatButton = document.querySelector('.sidebar-button button'); - if (chatButton) { - chatButton.addEventListener('click', () => { - tidioChatApi.open(); - }); - } -})(); diff --git a/static/js/third-party/fancybox.js b/static/js/third-party/fancybox.js deleted file mode 100644 index bb436ab..0000000 --- a/static/js/third-party/fancybox.js +++ /dev/null @@ -1,38 +0,0 @@ -document.addEventListener('page:loaded', () => { - - /** - * Wrap images with fancybox. - */ - document.querySelectorAll('.post-body :not(a) > img, .post-body > img').forEach(element => { - const $image = $(element); - const imageLink = $image.attr('data-src') || $image.attr('src'); - const $imageWrapLink = $image.wrap(``).parent('a'); - if ($image.is('.post-gallery img')) { - $imageWrapLink.attr('data-fancybox', 'gallery').attr('rel', 'gallery'); - } else if ($image.is('.group-picture img')) { - $imageWrapLink.attr('data-fancybox', 'group').attr('rel', 'group'); - } else { - $imageWrapLink.attr('data-fancybox', 'default').attr('rel', 'default'); - } - - const imageTitle = $image.attr('title') || $image.attr('alt'); - if (imageTitle) { - // Do not append image-caption if pandoc has already created a figcaption - if (!$imageWrapLink.next('figcaption').length) { - $imageWrapLink.append(`

${imageTitle}

`); - } - // Make sure img title tag will show correctly in fancybox - $imageWrapLink.attr('title', imageTitle).attr('data-caption', imageTitle); - } - }); - - $.fancybox.defaults.hash = false; - $('.fancybox').fancybox({ - loop : true, - helpers: { - overlay: { - locked: false - } - } - }); -}); diff --git a/static/js/third-party/google-translate.min.js b/static/js/third-party/google-translate.min.js deleted file mode 100644 index fd80e1b..0000000 --- a/static/js/third-party/google-translate.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(){var gtConstEvalStartTime=new Date();var h=this||self,l=/^[\w+/_-]+[=]{0,2}$/,m=null;function n(a){return(a=a.querySelector&&a.querySelector("script[nonce]"))&&(a=a.nonce||a.getAttribute("nonce"))&&l.test(a)?a:""}function p(a,b){function c(){}c.prototype=b.prototype;a.i=b.prototype;a.prototype=new c;a.prototype.constructor=a;a.h=function(g,f,k){for(var e=Array(arguments.length-2),d=2;d"}else d=void 0===c?"undefined":null===c?"null":typeof c;v("Argument is not a %s (or a non-Element, non-Location mock); got: %s","HTMLScriptElement",d)}a instanceof x&&a.constructor===x?d=a.g:(d=typeof a,v("expected object of type TrustedResourceUrl, got '"+a+"' of type "+("object"!=d?d:a?Array.isArray(a)?"array":d:"null")),d="type_error:TrustedResourceUrl");c.src=d;(d=c.ownerDocument&&c.ownerDocument.defaultView)&&d!=h?d=n(d.document):(null===m&&(m=n(h.document)),d=m);d&&c.setAttribute("nonce",d);z(c)}function _loadCss(a){var b=document.createElement("link");b.type="text/css";b.rel="stylesheet";b.charset="UTF-8";b.href=a;z(b)}function _isNS(a){a=a.split(".");for(var b=window,c=0;c { - if (!CONFIG.enableMath) return; - - NexT.utils.getScript(CONFIG.katex.copy_tex_js).catch(() => {}); -}); diff --git a/static/js/third-party/math/mathjax.js b/static/js/third-party/math/mathjax.js deleted file mode 100644 index fe4d448..0000000 --- a/static/js/third-party/math/mathjax.js +++ /dev/null @@ -1,36 +0,0 @@ -/* global NexT, CONFIG, MathJax */ - -document.addEventListener('page:loaded', () => { - if (!CONFIG.enableMath) return; - - if (typeof MathJax === 'undefined') { - window.MathJax = { - tex: { - inlineMath: { '[+]': [['$', '$']] }, - tags : CONFIG.mathjax.tags - }, - options: { - renderActions: { - insertedScript: [200, () => { - document.querySelectorAll('mjx-container').forEach(node => { - const target = node.parentNode; - if (target.nodeName.toLowerCase() === 'li') { - target.parentNode.classList.add('has-jax'); - } - }); - }, '', false] - } - } - }; - NexT.utils.getScript(CONFIG.mathjax.js, { - attributes: { - defer: true - } - }); - } else { - MathJax.startup.document.state(0); - MathJax.typesetClear(); - MathJax.texReset(); - MathJax.typesetPromise(); - } -}); diff --git a/static/js/third-party/pace.js b/static/js/third-party/pace.js deleted file mode 100644 index c22d59f..0000000 --- a/static/js/third-party/pace.js +++ /dev/null @@ -1,7 +0,0 @@ -/* global Pace */ - -Pace.options.restartOnPushState = false; - -document.addEventListener('pjax:send', () => { - Pace.restart(); -}); diff --git a/static/js/third-party/quicklink.js b/static/js/third-party/quicklink.js deleted file mode 100644 index 2543ad1..0000000 --- a/static/js/third-party/quicklink.js +++ /dev/null @@ -1,37 +0,0 @@ -/* global CONFIG, quicklink */ - -(function() { - if (typeof CONFIG.quicklink.ignores === 'string') { - const ignoresStr = `[${CONFIG.quicklink.ignores}]`; - CONFIG.quicklink.ignores = JSON.parse(ignoresStr); - } - - let resetFn = null; - - const onRefresh = () => { - if (resetFn) resetFn(); - if (!CONFIG.quicklink.enable) return; - - let ignoresArr = CONFIG.quicklink.ignores || []; - if (!Array.isArray(ignoresArr)) { - ignoresArr = [ignoresArr]; - } - - resetFn = quicklink.listen({ - timeout : CONFIG.quicklink.timeout, - priority: CONFIG.quicklink.priority, - ignores : [ - uri => uri.includes('#'), - uri => uri === CONFIG.quicklink.url, - ...ignoresArr - ] - }); - }; - - if (CONFIG.quicklink.delay) { - window.addEventListener('load', onRefresh); - document.addEventListener('pjax:success', onRefresh); - } else { - document.addEventListener('page:loaded', onRefresh); - } -})(); diff --git a/static/js/third-party/rating.js b/static/js/third-party/rating.js deleted file mode 100644 index fc61a3a..0000000 --- a/static/js/third-party/rating.js +++ /dev/null @@ -1,22 +0,0 @@ -/* global CONFIG, WPac */ - -(function() { - const widgets = [{ - widget: 'Rating', - id : CONFIG.rating.id, - el : 'wpac-rating', - color : CONFIG.rating.color - }]; - - document.addEventListener('page:loaded', () => { - if (!CONFIG.page.isPost) return; - - const newWidgets = widgets.map(widget => ({ ...widget })); - - if (window.WPac) { - WPac.init(newWidgets); - } else { - window.wpac_init = newWidgets; - } - }); -})(); diff --git a/static/js/third-party/statistics/firestore.js b/static/js/third-party/statistics/firestore.js deleted file mode 100644 index b06dbb1..0000000 --- a/static/js/third-party/statistics/firestore.js +++ /dev/null @@ -1,64 +0,0 @@ -/* global CONFIG, firebase */ - -firebase.initializeApp({ - apiKey : CONFIG.firestore.apiKey, - projectId: CONFIG.firestore.projectId -}); - -(function() { - const getCount = (doc, increaseCount) => { - // IncreaseCount will be false when not in article page - return doc.get().then(d => { - // Has no data, initialize count - let count = d.exists ? d.data().count : 0; - // If first view this article - if (increaseCount) { - // Increase count - count++; - doc.set({ - count - }); - } - return count; - }); - }; - - const appendCountTo = el => { - return count => { - el.innerText = count; - }; - }; - - const db = firebase.firestore(); - const articles = db.collection(CONFIG.firestore.collection); - - document.addEventListener('page:loaded', () => { - - if (CONFIG.page.isPost) { - // Fix issue #118 - // https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent - const title = document.querySelector('.post-title').textContent.trim(); - const doc = articles.doc(title); - let increaseCount = CONFIG.hostname === location.hostname; - if (localStorage.getItem(title)) { - increaseCount = false; - } else { - // Mark as visited - localStorage.setItem(title, true); - } - getCount(doc, increaseCount).then(appendCountTo(document.querySelector('.firestore-visitors-count'))); - } else if (CONFIG.page.isHome) { - const promises = [...document.querySelectorAll('.post-title')].map(element => { - const title = element.textContent.trim(); - const doc = articles.doc(title); - return getCount(doc); - }); - Promise.all(promises).then(counts => { - const metas = document.querySelectorAll('.firestore-visitors-count'); - counts.forEach((val, idx) => { - appendCountTo(metas[idx])(val); - }); - }); - } - }); -})(); diff --git a/static/js/third-party/statistics/lean-analytics.js b/static/js/third-party/statistics/lean-analytics.js deleted file mode 100644 index b5d4205..0000000 --- a/static/js/third-party/statistics/lean-analytics.js +++ /dev/null @@ -1,102 +0,0 @@ -/* global CONFIG */ -/* eslint-disable no-console */ - -(function() { - const leancloudSelector = url => { - url = encodeURI(url); - return document.getElementById(url).querySelector('.leancloud-visitors-count'); - }; - - const addCount = Counter => { - const visitors = document.querySelector('.leancloud_visitors'); - const url = decodeURI(visitors.id); - const title = visitors.dataset.flagTitle; - - Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url }))}`) - .then(response => response.json()) - .then(({ results }) => { - if (results.length > 0) { - const counter = results[0]; - leancloudSelector(url).innerText = counter.time + 1; - Counter('put', '/classes/Counter/' + counter.objectId, { - time: { - '__op' : 'Increment', - 'amount': 1 - } - }) - .catch(error => { - console.error('Failed to save visitor count', error); - }); - } else if (CONFIG.leancloud_visitors.security) { - leancloudSelector(url).innerText = 'Counter not initialized! More info at console err msg.'; - console.error('ATTENTION! LeanCloud counter has security bug, see how to solve it here: https://github.com/theme-next/hexo-leancloud-counter-security. \n However, you can still use LeanCloud without security, by setting `security` option to `false`.'); - } else { - Counter('post', '/classes/Counter', { title, url, time: 1 }) - .then(response => response.json()) - .then(() => { - leancloudSelector(url).innerText = 1; - }) - .catch(error => { - console.error('Failed to create', error); - }); - } - }) - .catch(error => { - console.error('LeanCloud Counter Error', error); - }); - }; - - const showTime = Counter => { - const visitors = document.querySelectorAll('.leancloud_visitors'); - const entries = [...visitors].map(element => { - return decodeURI(element.id); - }); - - Counter('get', `/classes/Counter?where=${encodeURIComponent(JSON.stringify({ url: { '$in': entries } }))}`) - .then(response => response.json()) - .then(({ results }) => { - for (const url of entries) { - const target = results.find(item => item.url === url); - leancloudSelector(url).innerText = target ? target.time : 0; - } - }) - .catch(error => { - console.error('LeanCloud Counter Error', error); - }); - }; - - const { app_id, app_key, server_url } = CONFIG.leancloud_visitors; - const fetchData = api_server => { - const Counter = (method, url, data) => { - return fetch(`${api_server}/1.1${url}`, { - method, - headers: { - 'X-LC-Id' : app_id, - 'X-LC-Key' : app_key, - 'Content-Type': 'application/json' - }, - body: JSON.stringify(data) - }); - }; - if (CONFIG.page.isPost) { - if (CONFIG.hostname !== location.hostname) return; - addCount(Counter); - } else if (document.querySelectorAll('.post-title-link').length >= 1) { - showTime(Counter); - } - }; - - const api_server = app_id.slice(-9) === '-MdYXbMMI' ? `https://${app_id.slice(0, 8).toLowerCase()}.api.lncldglobal.com` : server_url; - - document.addEventListener('page:loaded', () => { - if (api_server) { - fetchData(api_server); - } else { - fetch(`https://app-router.leancloud.cn/2/route?appId=${app_id}`) - .then(response => response.json()) - .then(({ api_server }) => { - fetchData(`https://${api_server}`); - }); - } - }); -})(); diff --git a/static/js/third-party/tags/mermaid.js b/static/js/third-party/tags/mermaid.js deleted file mode 100644 index 9623dc5..0000000 --- a/static/js/third-party/tags/mermaid.js +++ /dev/null @@ -1,32 +0,0 @@ -/* global NexT, CONFIG, mermaid */ - -document.addEventListener('page:loaded', () => { - const mermaidElements = document.querySelectorAll('.mermaid'); - if (mermaidElements.length) { - NexT.utils.getScript(CONFIG.mermaid.js, { - condition: window.mermaid - }).then(() => { - mermaidElements.forEach(element => { - const newElement = document.createElement('div'); - newElement.innerHTML = element.innerHTML; - newElement.className = element.className; - const parent = element.parentNode; - // Fix issue #347 - // Support mermaid inside backtick code block - if (parent.matches('pre')) { - parent.parentNode.replaceChild(newElement, parent); - } else { - parent.replaceChild(newElement, element); - } - }); - mermaid.initialize({ - theme : CONFIG.darkmode && window.matchMedia('(prefers-color-scheme: dark)').matches ? CONFIG.mermaid.theme.dark : CONFIG.mermaid.theme.light, - logLevel : 4, - flowchart: { curve: 'linear' }, - gantt : { axisFormat: '%m/%d/%Y' }, - sequence : { actorMargin: 50 } - }); - mermaid.init(); - }); - } -}); diff --git a/static/js/third-party/tags/pdf.js b/static/js/third-party/tags/pdf.js deleted file mode 100644 index 7e82891..0000000 --- a/static/js/third-party/tags/pdf.js +++ /dev/null @@ -1,23 +0,0 @@ -/* global NexT, CONFIG, PDFObject */ - -document.addEventListener('page:loaded', () => { - if (document.querySelectorAll('.pdf-container').length) { - NexT.utils.getScript(CONFIG.pdf.object_url, { - condition: window.PDFObject - }).then(() => { - document.querySelectorAll('.pdf-container').forEach(element => { - PDFObject.embed(element.dataset.target, element, { - pdfOpenParams: { - navpanes : 0, - toolbar : 0, - statusbar: 0, - pagemode : 'thumbs', - view : 'FitH' - }, - PDFJS_URL: CONFIG.pdf.url, - height : element.dataset.height - }); - }); - }); - } -});