mirror of
https://github.com/caddyserver/website.git
synced 2025-04-20 04:15:04 -04:00

* Initial commit; starting new design Dropdown menu * Begin docs layout of new design * Get themes under control; button hover splash * Some basic responsiveness * Finish responsive layout; several bug fixes * Avoid flash during color scheme change * Begin building top of homepage * docs: Start building quick-assist feature * Work on homepage a little more * Keep working on homepage * More homepage progress * Some sponsor SVGs * Add sponsor features * Implement basic Sponsor Experience box * Reorganize some styles * WIP sponsors page * Start features page WIP * Minor improvements * Fix headings; work on features page * WIP features page * Continue work on marketing pages * Continue work on features page * More features WIP * Continue features page... * More work on features page * Keeping going :) * Continue home and features pages * More homepage/features content, screenshots, tweaks * Minor fixes to features page * Minor tweaks * Work on testimonials * Work on homepage more * More homepage work * Continue work on homepage * Add some sponsor logos * Some citation screenshots * Add citations * Start making homepage responsive * Re-add cache busting Fix docs * Use markdown syntax highlighting on frontpage * Rework AJQuery to $_ to not interfere with jQuery * Rewrite quick assist with AlpineJS, use markdown for contents * More work on marketing pages * Rebase and fix code displays * Syntax highlight on-demand example, fix rollover * Adjust on-demand demo * Work on responsiveness * Keep working on responsiveness * Mainly finish making design responsive * Thiccer favicon * More work on marketing pages * Keep on going * Fix link * Move new site into src folder * Add open graph image * Add recorded demo for homepage * Tweak caption * Fix Poppins font for now * Minor tweaks * Trim demo ending * Remove unfinished pages Also update Framer logo --------- Co-authored-by: Francis Lavoie <lavofr@gmail.com>
81 lines
2.1 KiB
JavaScript
81 lines
2.1 KiB
JavaScript
document.addEventListener('DOMContentLoaded', function() {
|
|
// Algolia search
|
|
docsearch({
|
|
appId: "BH4D9OD16A",
|
|
apiKey: '14275a785f6ebd31d162f9d2d8fc0125',
|
|
indexName: 'caddyserver',
|
|
container: '#search',
|
|
});
|
|
});
|
|
|
|
const caddyImportPath = 'github.com/caddyserver/caddy/v2';
|
|
|
|
function isStandard(packagePath) {
|
|
return packagePath.startsWith(caddyImportPath);
|
|
}
|
|
|
|
function truncate(str, maxLen) {
|
|
if (!str) return "";
|
|
str = str.trim();
|
|
let firstPeriod = str.match(/\.(\s|$)/); // first dot not in the middle of a word, or at end of string
|
|
let terminate = firstPeriod ? firstPeriod.index+1 : str.length;
|
|
str = str.substring(0, terminate);
|
|
if (str.length <= maxLen) {
|
|
return str;
|
|
}
|
|
return str+"...";
|
|
}
|
|
|
|
function moduleDocsPreview(mod, maxLen) {
|
|
if (!mod || !mod.docs) return "";
|
|
let short = truncate(mod.docs, maxLen);
|
|
if (short.indexOf(mod.name) === 0) {
|
|
short = short.substr(mod.name.length).trim();
|
|
}
|
|
return short;
|
|
}
|
|
|
|
function detectPlatform() {
|
|
// assume 32-bit linux, then change OS and architecture if justified
|
|
var os = "linux", arch = "amd64";
|
|
|
|
// change os
|
|
if (/Macintosh/i.test(navigator.userAgent)) {
|
|
os = "darwin";
|
|
} else if (/Windows/i.test(navigator.userAgent)) {
|
|
os = "windows";
|
|
} else if (/FreeBSD/i.test(navigator.userAgent)) {
|
|
os = "freebsd";
|
|
} else if (/OpenBSD/i.test(navigator.userAgent)) {
|
|
os = "openbsd";
|
|
}
|
|
|
|
// change architecture
|
|
if (os == "darwin" || /amd64|x64|x86_64|Win64|WOW64|i686|64-bit/i.test(navigator.userAgent)) {
|
|
arch = "amd64";
|
|
} else if (/arm64/.test(navigator.userAgent)) {
|
|
arch = "arm64";
|
|
} else if (/ ARM| armv/.test(navigator.userAgent)) {
|
|
arch = "arm";
|
|
}
|
|
|
|
// change arm version
|
|
if (arch == "arm") {
|
|
var arm = "7"; // assume version 7 by default
|
|
if (/armv6/.test(navigator.userAgent)) {
|
|
arm = "6";
|
|
} else if (/armv5/.test(navigator.userAgent)) {
|
|
arm = "5";
|
|
}
|
|
arch += arm;
|
|
}
|
|
|
|
return [os, arch];
|
|
}
|
|
|
|
// Detect the platform OS, but with an allow-list of values
|
|
// and if the value is not allowed, return the default.
|
|
function defaultOS(allowed, def) {
|
|
var [os] = detectPlatform();
|
|
return allowed.includes(os) ? os : def;
|
|
}
|