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

refactor!: cdn system #789

Merged
merged 18 commits into from
Aug 16, 2022
407 changes: 407 additions & 0 deletions _cdn.yml

Large diffs are not rendered by default.

160 changes: 76 additions & 84 deletions _config.yml

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<%_ if (config.favicon) { _%>
<link rel="shortcut icon" type='image/x-icon' href="<%- url_for(config.favicon) %>">
<%_ } _%>
<link rel="preload" href="<%- theme.cdn.map.css.style %>" as="style">
<link rel="preload" href="<%- theme.cdn.volantis_style %>" as="style">
<%- generate_preload_fontfamily(theme) %>
<!-- feed -->
<%_ if (config.feed && config.feed.path){ _%>
Expand All @@ -58,8 +58,8 @@
/* 首屏样式 */
<%- FirstCSS() %>
</style>
<link rel="stylesheet" href="<%- theme.cdn.map.css.style %>" media="print" onload="this.media='all';this.onload=null">
<noscript><link rel="stylesheet" href="<%- theme.cdn.map.css.style %>"></noscript>
<link rel="stylesheet" href="<%- theme.cdn.volantis_style %>" media="print" onload="this.media='all';this.onload=null">
<noscript><link rel="stylesheet" href="<%- theme.cdn.volantis_style %>"></noscript>
<%_ if (theme.plugins.darkmode.enable) { _%>
<script>
let userColorScheme=localStorage.getItem("color-scheme")
Expand Down
1 change: 0 additions & 1 deletion layout/_partial/scripts/_ctrl.ejs
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<%- partial('_partial/scripts/_ctrl/cdnCtrl') _%>
<%- partial('_partial/scripts/_ctrl/coverCtrl') _%>
127 changes: 0 additions & 127 deletions layout/_partial/scripts/_ctrl/cdnCtrl.ejs

This file was deleted.

5 changes: 2 additions & 3 deletions layout/_partial/scripts/global.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

volantis.GLOBAL_CONFIG ={
debug: <%- JSON.stringify(theme.debug) %>,
cdn: <%- JSON.stringify(theme.cdn.map) %>,
default: <%- JSON.stringify(theme.default) %>,
lastupdate: new Date(<%- theme.getStartTime %>),
cdn: <%- JSON.stringify(theme.cdn) %>,
sidebar: {
for_page: <%- JSON.stringify(theme.sidebar.for_page) %>,
for_post: <%- JSON.stringify(theme.sidebar.for_post) %>,
Expand All @@ -25,7 +25,6 @@
},
plugins: {
message: <%- JSON.stringify(theme.plugins.message) %>,
fancybox: <%- JSON.stringify(theme.plugins.fancybox) %>,
<% if(theme.plugins.aplayer.enable) { %>
aplayer: {
id: <%- JSON.stringify(theme.plugins.aplayer.id) %>,
Expand Down Expand Up @@ -280,7 +279,7 @@
volantis.import = {
jQuery: () => {
if (typeof jQuery == "undefined") {
return volantis.js("<%- theme.plugins.jquery %>")
return volantis.js("<%- theme.cdn.jquery %>")
} else {
return new Promise(resolve => {
resolve()
Expand Down
14 changes: 7 additions & 7 deletions layout/_partial/scripts/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@

<script>
<% if (theme.plugins.fontawesome) { %>
volantis.css("<%- theme.plugins.fontawesome %>");
volantis.css("<%- theme.cdn.fontawesome %>");
<% } %>
<% if (theme.plugins.fontawesome_animation.enable) { %>
volantis.css("<%- theme.plugins.fontawesome_animation.css %>");
volantis.css("<%- theme.cdn['font-awesome-animation'] %>");
<% } %>
<% if (theme.plugins.nodewaves.enable) { %>
volantis.css("<%- theme.plugins.nodewaves.css %>");
volantis.css("<%- theme.cdn.nodewaves_css %>");
<% } %>
</script>

<!-- required -->
<% if (theme.plugins.globalJquery) { %>
<%- js(theme.plugins.jquery) %>
<%- js(theme.cdn.jquery) %>
<% } %>

<!-- internal -->
<%- js(theme.cdn.map.js.app) %>
<%- js(theme.cdn.volantis_app) %>

<% if (theme.rightmenu.enable) { %>
<%- partial('../../_plugins/rightmenu/layout') %>
Expand Down Expand Up @@ -87,7 +87,7 @@


<% if (theme.analytics.busuanzi) { %>
<script defer src="<%- theme.analytics.busuanzi %>" data-pjax></script>
<script defer src="<%- theme.cdn.busuanzi %>" data-pjax></script>
<% } %>

<!-- optional -->
Expand All @@ -100,7 +100,7 @@
<% } %>

<% if (theme.plugins.comment_typing.enable) { %>
<%- js(theme.plugins.comment_typing.js) %>
<%- js(theme.cdn.comment_typing) %>
<% } %>

<% if (theme.plugins.code_highlight) { %>
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/_page_plugins/artitalk/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>
<script>
volantis.import.jQuery().then(()=>{
volantis.js("<%= theme.plugins.artitalk.js %>").then(()=>{
volantis.js("<%= theme.cdn.artitalk %>").then(()=>{
new Artitalk(Object.assign(<%- JSON.stringify(theme.plugins.artitalk) %>, {}))
})
})
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/_page_plugins/bbtalk/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</script>
<script>
volantis.import.jQuery().then(()=>{
volantis.js("<%= theme.plugins.bbtalk.js %>").then(()=>{
volantis.js("<%= theme.cdn.bbtalk %>").then(()=>{
bbtalk.init(Object.assign(<%- JSON.stringify(theme.plugins.bbtalk) %>, {}))
})
})
Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/_page_plugins/fcircle/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
apiurl: '<%- theme.plugins.fcircle.api %>'
}
</script>
<link rel="stylesheet" href="<%- theme.plugins.fcircle.css %>">
<link rel="stylesheet" href="<%- theme.cdn.fcircle_css %>">
<script type="text/javascript"
src="<%- theme.plugins.fcircle.js %>">
src="<%- theme.cdn.fcircle_js %>">
</script>
6 changes: 3 additions & 3 deletions layout/_plugins/_page_plugins/katex/index.ejs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script>
// https://www.micdz.cn/article/katex-on-volantis/
if (typeof renderMathInElement == "undefined") {
volantis.css("<%= theme.plugins.katex.css %>")
volantis.css("<%= theme.cdn.katex_css %>")
function pjax_katex() {
volantis.js("<%= theme.plugins.katex.render %>").then(()=>{
volantis.js("<%= theme.cdn.katex_render %>").then(()=>{
renderMathInElement(document.body);
})
}
volantis.js("<%= theme.plugins.katex.js %>").then(pjax_katex)
volantis.js("<%= theme.cdn.katex_js %>").then(pjax_katex)
volantis.pjax.push(pjax_katex)
}
</script>
2 changes: 1 addition & 1 deletion layout/_plugins/_page_plugins/mathjax/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
};
(function () {
var script = document.createElement('script');
script.src = "<%= theme.plugins.mathjax %>";
script.src = "<%= theme.cdn.mathjax %>";
script.defer = true;
document.head.appendChild(script);
})();
Expand Down
8 changes: 4 additions & 4 deletions layout/_plugins/aplayer/script.ejs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<script>
volantis.css("<%- theme.plugins.aplayer.css %>");
volantis.css("<%- theme.cdn.aplayer_css %>");
(async () => {
// APlayer 需要在 MetingJS 之前加载
await volantis.js("<%- theme.plugins.aplayer.js.aplayer %>")
await volantis.js("<%- theme.plugins.aplayer.js.meting %>")
await volantis.js("<%- theme.cdn.aplayer_js %>")
await volantis.js("<%- theme.cdn.meting %>")
<% if ((theme.rightmenu.enable || theme.rightmenus.enable) && theme.rightmenu.layout.includes('music')) { %>
// 右键 music 需要在 APlayer MetingJS 之后加载
await volantis.js('<%- theme.cdn.addJS("plugins/aplayer") %>')
await volantis.js('<%- theme.cdn.volantis_aplayer %>')
<% } %>
})();

Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/comments/artalk/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
volantis.layoutHelper("comments",`<div id="artalk_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`);
function load_artalk() {
if(!document.querySelectorAll("#artalk_container")[0])return;
volantis.css("<%- theme.comments.artalk.css %>");
volantis.js("<%- theme.comments.artalk.js %>").then(pjax_artalk);
volantis.css("<%- theme.cdn.artalk_css %>");
volantis.js("<%- theme.cdn.artalk_js %>").then(pjax_artalk);
}

function pjax_artalk() {
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/comments/discuss/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
volantis.layoutHelper("comments",`<div id="discuss_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
function load_discuss() {
if(!document.querySelectorAll("#discuss_container")[0])return;
volantis.js("<%- theme.comments.discuss.js %>", pjax_discuss)
volantis.js("<%- theme.cdn.discuss %>", pjax_discuss)
}
function pjax_discuss() {
if(!document.querySelectorAll("#discuss_container")[0])return;
Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/comments/disqusjs/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
volantis.layoutHelper("comments",`<div id="disqus_thread"></div>`)
// from: https://github.com/ChrAlpha/hexo-theme-cards/blob/master/layout/_plugins/comments/disqusjs/source.ejs
function loadDisqusJS() {
volantis.js('<%= theme.comments.disqusjs.js %>', pjax_DisqusJS)
volantis.css('<%= theme.comments.disqusjs.css %>')
volantis.js('<%= theme.cdn.disqusjs_js %>', pjax_DisqusJS)
volantis.css('<%= theme.cdn.disqusjs_css %>')
}
let path = pdata.commentPath;
if (path.length == 0) {
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/comments/gitalk/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
gitalk.render('gitalk-container');
}
}
volantis.js('<%= theme.comments.gitalk.js %>').then(pjax_gitalk)
volantis.js('<%= theme.cdn.gitalk %>').then(pjax_gitalk)
volantis.pjax.push(pjax_gitalk);
</script>
2 changes: 1 addition & 1 deletion layout/_plugins/comments/twikoo/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
volantis.layoutHelper("comments",`<div id="twikoo_container"><i class="fa-solid fa-cog fa-spin fa-fw fa-2x"></i></div>`)
function load_twikoo() {
if(!document.querySelectorAll("#twikoo_container")[0])return;
volantis.js("<%- theme.comments.twikoo.js %>", pjax_twikoo)
volantis.js("<%- theme.cdn.twikoo %>", pjax_twikoo)
}
function pjax_twikoo() {
if(!document.querySelectorAll("#twikoo_container")[0])return;
Expand Down
6 changes: 3 additions & 3 deletions layout/_plugins/comments/vssue/script.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

<script src="<%- theme.comments.vssue.vue %>"></script>
<script src="<%- theme.comments.vssue.js %>"></script>
<script src="<%- theme.cdn.vssue_vue %>"></script>
<script src="<%- theme.cdn.vssue_js %>"></script>
<script>
volantis.css("<%- theme.comments.vssue.css %>");
volantis.css("<%- theme.cdn.vssue_css %>");
function fancybox_vssue() {
if(typeof VolantisFancyBox === "undefined") {
const checkFancyBox = setInterval(() => {
Expand Down
4 changes: 2 additions & 2 deletions layout/_plugins/comments/waline/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
}
}

volantis.css('<%= theme.comments.waline.css %>')
volantis.js('<%- theme.comments.waline.js %>').then(pjax_waline)
volantis.css('<%= theme.cdn.waline_css %>')
volantis.js('<%- theme.cdn.waline_js %>').then(pjax_waline)
volantis.pjax.push(pjax_waline);
</script>
6 changes: 3 additions & 3 deletions layout/_plugins/github-api/script.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<% if (theme.plugins.sitesjs.enable) { %>
const sites_api = document.getElementById('sites-api');
if (sites_api != undefined && typeof SitesJS === 'undefined') {
volantis.js("<%- theme.cdn.map.js.sites %>")
volantis.js("<%- theme.cdn.volantis_tags_sites %>")
}
<% } %>
<% if (theme.plugins.friendsjs.enable) { %>
const friends_api = document.getElementById('friends-api');
if (friends_api != undefined && typeof FriendsJS === 'undefined') {
volantis.js("<%- theme.cdn.map.js.friends %>")
volantis.js("<%- theme.cdn.volantis_tags_friends %>")
}
<% } %>
<% if (theme.plugins.contributorsjs.enable) { %>
const contributors_api = document.getElementById('contributors-api');
if (contributors_api != undefined && typeof ContributorsJS === 'undefined') {
volantis.js("<%- theme.cdn.map.js.contributors %>")
volantis.js("<%- theme.cdn.volantis_tags_contributors %>")
}
<% } %>
};
Expand Down
2 changes: 1 addition & 1 deletion layout/_plugins/lazyload/script.ejs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<script defer src="<%- theme.plugins.lazyload.js %>"></script>
<script defer src="<%- theme.cdn['vanilla-lazyload'] %>"></script>
<script>
// https://www.npmjs.com/package/vanilla-lazyload
// Set the options globally
Expand Down
Loading