caddy-website/new/download.html
2023-11-19 01:43:45 -05:00

111 lines
No EOL
3.7 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<title>Download Caddy</title>
{{include "/includes/head.html"}}
<link rel="stylesheet" href="/resources/css/download.css">
<link rel="stylesheet" href="/resources/css/docs.css">
<script src="/resources/js/download.js"></script>
</head>
<body>
{{include "/includes/header.html" "light-header"}}
<main>
<article>
<h1>Download</h1>
</article>
<div class="wrapper filters">
<input id="search-package" placeholder="Search package: e.g. cloudflare" class="shadow" />
<select id="sort-package" class="shadow">
<option value="download">Sort by most popular</option>
<option value="alphabetically">Sort alphabetically</option>
<option value="type">Group by module namespace</option>
</select>
</div>
<div class="wrapper list">
<div id="side-panel-packages">
</div>
<div id="packages">
</div>
</div>
<div id="download" class="wrapper">
<div class="shadow-lg">
<div>
<span>Download generated caddy binary with 3 extra modules or run the command below</span>
</div>
<div id="command">
<pre>
<span id="command-builder">xcaddy build</span>
</pre>
<svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-copy" width="24" height="24"
viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round"
stroke-linejoin="round">
<path stroke="none" d="M0 0h24v24H0z" fill="none"></path>
<path d="M8 8m0 2a2 2 0 0 1 2 -2h8a2 2 0 0 1 2 2v8a2 2 0 0 1 -2 2h-8a2 2 0 0 1 -2 -2z"></path>
<path d="M16 8v-2a2 2 0 0 0 -2 -2h-8a2 2 0 0 0 -2 2v8a2 2 0 0 0 2 2h2"></path>
</svg>
</div>
</div>
</div>
</main>
{{include "/includes/footer.html"}}
<script type="text/javascript">
let groupBy = 'download';
let packages = [];
const getCardTemplate = item => `{{ include "/includes/card.html" }}`;
function renderList(list) {
if (groupBy === 'type') {
const groupedData = Object.entries(packageManager.group(groupBy)).filter(([_, items]) => !!items.length)
document.getElementById('side-panel-packages').innerHTML = `
<div>
<h2 class="blue">Namespaces</h2>
${groupedData.map(([k]) => `<a href="#${k}"> ${ k }</a>`).join('')}
</div>`;
document.getElementById('packages').innerHTML = groupedData.map(([category, items]) => `
<section id="${category}">
<h2 class="blue">${category}</h2>
<div class="card-list">${items.map(getCardTemplate).join('')}</div>
</section>`).join('')
return;
}
document.getElementById('side-panel-packages').innerHTML = '';
document.getElementById('packages').innerHTML = `
<div class="card-list">
${list.map(getCardTemplate).join('')}
</div>`;
};
function togglePackage({ target: { dataset: { module } } }) {
const element = document.getElementById('packages').querySelector(`button[data-module="${module}"]`);
if (packages.includes(module)) {
packages = packages.filter(p => p !== module)
element.innerHTML = "Add this module";
} else {
packages.push(module);
element.innerHTML = "Remove this module";
}
document.getElementById('command-builder').innerText = `xcaddy build${packages.map(p => ` --with ${p}`).join('')}`
}
packageManager.getPackages().then(() => {
renderList(packageManager.group(groupBy))
})
document.getElementById('search-package').addEventListener('input', ({ target: { value } }) => {
packageManager.setFilterValue(value.toLowerCase());
renderList(packageManager.group(groupBy))
})
document.getElementById('sort-package').addEventListener('change', ({ target: { value } }) => {
groupBy = value;
renderList(packageManager.group(value))
})
</script>
</body>
</html>