added cactus theme files

This commit is contained in:
2022-07-31 17:32:45 -07:00
parent 1c054014c6
commit b32268d438
142 changed files with 17322 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
(() => {
function createCopyButton(codeNode) {
const copyBtn = document.createElement('button')
copyBtn.className = 'code-copy-btn'
copyBtn.type = 'button'
copyBtn.innerText = 'copy'
let resetTimer
copyBtn.addEventListener('click', () => {
navigator.clipboard.writeText(codeNode.innerText).then(() => {
copyBtn.innerText = 'copied!'
}).then(() => {
clearTimeout(resetTimer)
resetTimer = setTimeout(() => {
copyBtn.innerText = 'copy'
}, 1000)
})
})
return copyBtn
}
document.querySelectorAll('pre > code')
.forEach((codeNode) => {
const copyBtn = createCopyButton(codeNode);
const preNode = codeNode.parentNode
codeNode.parentNode.insertBefore(copyBtn, codeNode)
})
document.querySelectorAll('.highlight table > tbody > tr > td:first-child .code-copy-btn')
.forEach((btn) => {
btn.remove()
})
})()

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,113 @@
/**
* Sets up Justified Gallery.
*/
if (!!$.prototype.justifiedGallery) {
var options = {
rowHeight: 140,
margins: 4,
lastRow: "justify"
};
$(".article-gallery").justifiedGallery(options);
}
$(document).ready(function() {
/**
* Shows the responsive navigation menu on mobile.
*/
$("#header > #nav > ul > .icon").click(function() {
$("#header > #nav > ul").toggleClass("responsive");
});
/**
* Controls the different versions of the menu in blog post articles
* for Desktop, tablet and mobile.
*/
if ($(".post").length) {
var menu = $("#menu");
var nav = $("#menu > #nav");
var menuIcon = $("#menu-icon, #menu-icon-tablet");
/**
* Display the menu on hi-res laptops and desktops.
*/
if ($(document).width() >= 1440) {
menu.css("visibility", "visible");
menuIcon.addClass("active");
}
/**
* Display the menu if the menu icon is clicked.
*/
menuIcon.click(function() {
if (menu.css("visibility") === "hidden") {
menu.css("visibility", "visible");
menuIcon.addClass("active");
} else {
menu.css("visibility", "hidden");
menuIcon.removeClass("active");
}
return false;
});
/**
* Add a scroll listener to the menu to hide/show the navigation links.
*/
if (menu.length) {
$(window).on("scroll", function() {
var topDistance = menu.offset().top;
// hide only the navigation links on desktop
if (!nav.is(":visible") && topDistance < 50) {
nav.show();
} else if (nav.is(":visible") && topDistance > 100) {
nav.hide();
}
// on tablet, hide the navigation icon as well and show a "scroll to top
// icon" instead
if ( ! $( "#menu-icon" ).is(":visible") && topDistance < 50 ) {
$("#menu-icon-tablet").show();
$("#top-icon-tablet").hide();
} else if (! $( "#menu-icon" ).is(":visible") && topDistance > 100) {
$("#menu-icon-tablet").hide();
$("#top-icon-tablet").show();
}
});
}
/**
* Show mobile navigation menu after scrolling upwards,
* hide it again after scrolling downwards.
*/
if ($( "#footer-post").length) {
var lastScrollTop = 0;
$(window).on("scroll", function() {
var topDistance = $(window).scrollTop();
if (topDistance > lastScrollTop){
// downscroll -> show menu
$("#footer-post").hide();
} else {
// upscroll -> hide menu
$("#footer-post").show();
}
lastScrollTop = topDistance;
// close all submenu"s on scroll
$("#nav-footer").hide();
$("#toc-footer").hide();
$("#share-footer").hide();
// show a "navigation" icon when close to the top of the page,
// otherwise show a "scroll to the top" icon
if (topDistance < 50) {
$("#actions-footer > #top").hide();
} else if (topDistance > 100) {
$("#actions-footer > #top").show();
}
});
}
}
});

View File

@@ -0,0 +1,154 @@
// A local search script with the help of
// [hexo-generator-search](https://github.com/PaicHyperionDev/hexo-generator-search)
// Copyright (C) 2015
// Joseph Pan <http://github.com/wzpan>
// Shuhao Mao <http://github.com/maoshuhao>
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as
// published by the Free Software Foundation; either version 2.1 of the
// License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
// 02110-1301 USA
//
// Modified by:
// Pieter Robberechts <http://github.com/probberechts>
/*exported searchFunc*/
var searchFunc = function(path, searchId, contentId) {
function stripHtml(html) {
html = html.replace(/<style([\s\S]*?)<\/style>/gi, "");
html = html.replace(/<script([\s\S]*?)<\/script>/gi, "");
html = html.replace(/<figure([\s\S]*?)<\/figure>/gi, "");
html = html.replace(/<\/div>/ig, "\n");
html = html.replace(/<\/li>/ig, "\n");
html = html.replace(/<li>/ig, " * ");
html = html.replace(/<\/ul>/ig, "\n");
html = html.replace(/<\/p>/ig, "\n");
html = html.replace(/<br\s*[\/]?>/gi, "\n");
html = html.replace(/<[^>]+>/ig, "");
return html;
}
function getAllCombinations(keywords) {
var i, j, result = [];
for (i = 0; i < keywords.length; i++) {
for (j = i + 1; j < keywords.length + 1; j++) {
result.push(keywords.slice(i, j).join(" "));
}
}
return result;
}
$.ajax({
url: path,
dataType: "xml",
success: function(xmlResponse) {
// get the contents from search data
var datas = $("entry", xmlResponse).map(function() {
return {
title: $("title", this).text(),
content: $("content", this).text(),
url: $("link", this).attr("href")
};
}).get();
var $input = document.getElementById(searchId);
if (!$input) { return; }
var $resultContent = document.getElementById(contentId);
$input.addEventListener("input", function(){
var resultList = [];
var keywords = getAllCombinations(this.value.trim().toLowerCase().split(" "))
.sort(function(a,b) { return b.split(" ").length - a.split(" ").length; });
$resultContent.innerHTML = "";
if (this.value.trim().length <= 0) {
return;
}
// perform local searching
datas.forEach(function(data) {
var matches = 0;
if (!data.title || data.title.trim() === "") {
data.title = "Untitled";
}
var dataTitle = data.title.trim().toLowerCase();
var dataContent = stripHtml(data.content.trim());
var dataUrl = data.url;
var indexTitle = -1;
var indexContent = -1;
var firstOccur = -1;
// only match artiles with not empty contents
if (dataContent !== "") {
keywords.forEach(function(keyword) {
indexTitle = dataTitle.indexOf(keyword);
indexContent = dataContent.indexOf(keyword);
if( indexTitle >= 0 || indexContent >= 0 ){
matches += 1;
if (indexContent < 0) {
indexContent = 0;
}
if (firstOccur < 0) {
firstOccur = indexContent;
}
}
});
}
// show search results
if (matches > 0) {
var searchResult = {};
searchResult.rank = matches;
searchResult.str = "<li><a href='"+ dataUrl +"' class='search-result-title'>"+ dataTitle +"</a>";
if (firstOccur >= 0) {
// cut out 100 characters
var start = firstOccur - 20;
var end = firstOccur + 80;
if(start < 0){
start = 0;
}
if(start == 0){
end = 100;
}
if(end > dataContent.length){
end = dataContent.length;
}
var matchContent = dataContent.substr(start, end);
// highlight all keywords
var regS = new RegExp(keywords.join("|"), "gi");
matchContent = matchContent.replace(regS, function(keyword) {
return "<em class=\"search-keyword\">"+keyword+"</em>";
});
searchResult.str += "<p class=\"search-result\">" + matchContent +"...</p>";
}
searchResult.str += "</li>";
resultList.push(searchResult);
}
});
resultList.sort(function(a, b) {
return b.rank - a.rank;
});
var result ="<ul class=\"search-result-list\">";
for (var i = 0; i < resultList.length; i++) {
result += resultList[i].str;
}
result += "</ul>";
$resultContent.innerHTML = result;
});
}
});
};