Skip to content

Commit

Permalink
Setup oranda page
Browse files Browse the repository at this point in the history
  • Loading branch information
elkowar committed Nov 23, 2024
1 parent f1503a8 commit 2711210
Show file tree
Hide file tree
Showing 16 changed files with 2,071 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github: [elkowar]
ko_fi: elkowar
99 changes: 99 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Workflow to build your docs with oranda (and mdbook)
# and deploy them to Github Pages
name: Web

# We're going to push to the gh-pages branch, so we need that permission
permissions:
contents: write

# What situations do we want to build docs in?
# All of these work independently and can be removed / commented out
# if you don't want oranda/mdbook running in that situation
on:
# Check that a PR didn't break docs!
#
# Note that the "Deploy to Github Pages" step won't run in this mode,
# so this won't have any side-effects. But it will tell you if a PR
# completely broke oranda/mdbook. Sadly we don't provide previews (yet)!
pull_request:

# Whenever something gets pushed to main, update the docs!
# This is great for getting docs changes live without cutting a full release.
#
# Note that if you're using cargo-dist, this will "race" the Release workflow
# that actually builds the Github Release that oranda tries to read (and
# this will almost certainly complete first). As a result you will publish
# docs for the latest commit but the oranda landing page won't know about
# the latest release. The workflow_run trigger below will properly wait for
# cargo-dist, and so this half-published state will only last for ~10 minutes.
#
# If you only want docs to update with releases, disable this, or change it to
# a "release" branch. You can, of course, also manually trigger a workflow run
# when you want the docs to update.
push:
branches:
- main

# Whenever a workflow called "Release" completes, update the docs!
#
# If you're using cargo-dist, this is recommended, as it will ensure that
# oranda always sees the latest release right when it's available. Note
# however that Github's UI is wonky when you use workflow_run, and won't
# show this workflow as part of any commit. You have to go to the "actions"
# tab for your repo to see this one running (the gh-pages deploy will also
# only show up there).
workflow_run:
workflows: [ "Release" ]
types:
- completed

# Alright, let's do it!
jobs:
web:
name: Build and deploy site and docs
runs-on: ubuntu-latest
steps:
# Setup
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
- uses: swatinem/rust-cache@v2

# If you use any mdbook plugins, here's the place to install them!

# Install and run oranda (and mdbook)!
#
# This will write all output to ./public/ (including copying mdbook's output to there).
- name: Install and run oranda
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/axodotdev/oranda/releases/latest/download/oranda-installer.sh | sh
oranda build
- name: Prepare HTML for link checking
# untitaker/hyperlink supports no site prefixes, move entire site into
# a subfolder
run: mkdir /tmp/public/ && cp -R public /tmp/public/oranda

- name: Check HTML for broken internal links
uses: untitaker/[email protected]
with:
args: /tmp/public/

# Deploy to our gh-pages branch (creating it if it doesn't exist).
# The "public" dir that oranda made above will become the root dir
# of this branch.
#
# Note that once the gh-pages branch exists, you must
# go into repo's settings > pages and set "deploy from branch: gh-pages".
# The other defaults work fine.
- name: Deploy to Github Pages
uses: JamesIves/[email protected]
# ONLY if we're on main (so no PRs or feature branches allowed!)
if: ${{ github.ref == 'refs/heads/main' }}
with:
branch: gh-pages
# Gotta tell the action where to find oranda's output
folder: public
token: ${{ secrets.GITHUB_TOKEN }}
single-commit: true
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@

/tmp
/test_home

# Generated by `oranda generate ci`
public/
4 changes: 4 additions & 0 deletions Readme.md → README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<div class="oranda-hide">

# Yolk – Painfree Templated Dotfile Management

</div>

Yolk is a dotfile management tool with a unique spin,
sitting somewhere in between [GNU Stow](https://www.gnu.org/software/stow/) and [chezmoi](https://www.chezmoi.io/).

Expand Down
5 changes: 5 additions & 0 deletions oranda.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"build": {
"path_prefix": "yolk"
}
}
245 changes: 245 additions & 0 deletions public/artifacts.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,245 @@
/* Code modified from the blender website
* https://www.blender.org/wp-content/themes/bthree/assets/js/get_os.js?x82196
*/

let options = {
windows64: "x86_64-pc-windows",
windows32: "i686-pc-windows",
windowsArm: "aarch64-pc-windows",

mac64: "x86_64-apple",
mac32: "i686-apple",
macSilicon: "aarch64-apple",

linux64: "x86_64-unknown-linux",
linux32: "i686-unknown-linux",
linuxArm: "aarch64-unknown-linux",

// ios: "ios",
// android: "linux-android",
// freebsd: "freebsd",
};

function isAppleSilicon() {
try {
var glcontext = document.createElement("canvas").getContext("webgl");
var debugrenderer = glcontext
? glcontext.getExtension("WEBGL_debug_renderer_info")
: null;
var renderername =
(debugrenderer &&
glcontext.getParameter(debugrenderer.UNMASKED_RENDERER_WEBGL)) ||
"";
if (renderername.match(/Apple M/) || renderername.match(/Apple GPU/)) {
return true;
}

return false;
} catch (e) {}
}

function getOS() {
var OS = options.windows64.default;
var userAgent = navigator.userAgent;
var platform = navigator.platform;

if (navigator.appVersion.includes("Win")) {
if (
!userAgent.includes("Windows NT 5.0") &&
!userAgent.includes("Windows NT 5.1") &&
(userAgent.indexOf("Win64") > -1 ||
platform == "Win64" ||
userAgent.indexOf("x86_64") > -1 ||
userAgent.indexOf("x86_64") > -1 ||
userAgent.indexOf("amd64") > -1 ||
userAgent.indexOf("AMD64") > -1 ||
userAgent.indexOf("WOW64") > -1)
) {
OS = options.windows64;
} else {
if (
window.external &&
window.external.getHostEnvironmentValue &&
window.external
.getHostEnvironmentValue("os-architecture")
.includes("ARM64")
) {
OS = options.windowsArm;
} else {
try {
var canvas = document.createElement("canvas");
var gl = canvas.getContext("webgl");

var debugInfo = gl.getExtension("WEBGL_debug_renderer_info");
var renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
if (renderer.includes("Qualcomm")) OS = options.windowsArm;
} catch (e) {}
}
}
}

//MacOS, MacOS X, macOS
if (navigator.appVersion.includes("Mac")) {
if (
navigator.userAgent.includes("OS X 10.5") ||
navigator.userAgent.includes("OS X 10.6")
) {
OS = options.mac32;
} else {
OS = options.mac64;

const isSilicon = isAppleSilicon();
if (isSilicon) {
OS = options.macSilicon;
}
}
}

// linux
if (platform.includes("Linux")) {
OS = options.linux64;
// FIXME: Can we find out whether linux 32-bit or ARM are used?
}

// if (
// userAgent.includes("iPad") ||
// userAgent.includes("iPhone") ||
// userAgent.includes("iPod")
// ) {
// OS = options.ios;
// }
// if (platform.toLocaleLowerCase().includes("freebsd")) {
// OS = options.freebsd;
// }

return OS;
}

let os = getOS();
window.os = os;

// Unhide and hydrate selector with events
const archSelect = document.querySelector(".arch-select");
if (archSelect) {
archSelect.classList.remove("hidden");
const selector = document.querySelector("#install-arch-select");
if (selector) {
selector.addEventListener("change", onArchChange);
}
}

// Hydrate tab buttons with events
Array.from(document.querySelectorAll(".install-tab[data-id]")).forEach((tab) => {
tab.addEventListener("click", onTabClick);
});

function onArchChange(evt) {
// Get target
const target = evt.currentTarget.value;
// Find corresponding installer lists
const newContentEl = document.querySelector(`.arch[data-arch=${target}]`);
const oldContentEl = document.querySelector(`.arch[data-arch]:not(.hidden)`);
// Hide old content element (if applicable)
if (oldContentEl) {
oldContentEl.classList.add("hidden");
}
// Show new content element
newContentEl.classList.remove("hidden");
// Show the first tab's content if nothing was selected before
if (newContentEl.querySelectorAll(".install-tab.selected").length === 0) {
const firstContentChild = newContentEl.querySelector(".install-content:first-of-type");
const firstTabChild = newContentEl.querySelector(".install-tab:first-of-type");
firstContentChild.classList.remove("hidden");
if (firstTabChild) {
firstTabChild.classList.add("selected");
}
}
// Hide "no OS detected" message
const noDetectEl = document.querySelector(".no-autodetect");
noDetectEl.classList.add("hidden");
// Hide Mac hint
document.querySelector(".mac-switch").classList.add("hidden");
}

function onTabClick(evt) {
// Get target and ID
const {triple, id} = evt.currentTarget.dataset;
if (triple) {
// Find corresponding content elements
const newContentEl = document.querySelector(`.install-content[data-id="${String(id)}"][data-triple=${triple}]`);
const oldContentEl = document.querySelector(`.install-content[data-triple=${triple}][data-id]:not(.hidden)`);
// Find old tab to unselect
const oldTabEl = document.querySelector(`.install-tab[data-triple=${triple}].selected`);
// Hide old content element
if (oldContentEl && oldTabEl) {
oldContentEl.classList.add("hidden");
oldTabEl.classList.remove("selected");
}

// Unhide new content element
newContentEl.classList.remove("hidden");
// Select new tab element
evt.currentTarget.classList.add("selected");
}
}

const allPlatforms = Array.from(document.querySelectorAll(`.arch[data-arch]`));
let hit = allPlatforms.find(
(a) => {
// Show Intel Mac downloads if no M1 Mac downloads are available
if (
a.attributes["data-arch"].value.includes(options.mac64) &&
os.includes(options.macSilicon) &&
!allPlatforms.find(p => p.attributes["data-arch"].value.includes(options.macSilicon))) {
// Unhide hint
document.querySelector(".mac-switch").classList.remove("hidden");
return true;
}
return a.attributes["data-arch"].value.includes(os);
}
);

if (hit) {
hit.classList.remove("hidden");
const selectEl = document.querySelector("#install-arch-select");
selectEl.value = hit.dataset.arch;
const firstContentChild = hit.querySelector(".install-content:first-of-type");
const firstTabChild = hit.querySelector(".install-tab:first-of-type");
firstContentChild.classList.remove("hidden");
if (firstTabChild) {
firstTabChild.classList.add("selected");
}
} else {
const noDetectEl = document.querySelector(".no-autodetect");
if (noDetectEl) {
const noDetectElDetails = document.querySelector(".no-autodetect-details");
if (noDetectElDetails) {
noDetectElDetails.innerHTML = `We detected you're on ${os} but there don't seem to be installers for that. `
}
noDetectEl.classList.remove("hidden");
}
}

let copyButtons = Array.from(document.querySelectorAll("[data-copy]"));
if (copyButtons.length) {
copyButtons.forEach(function (element) {
element.addEventListener("click", () => {
navigator.clipboard.writeText(element.attributes["data-copy"].value);
});
});
}

// Toggle for pre releases
const checkbox = document.getElementById("show-prereleases");

if (checkbox) {
checkbox.addEventListener("click", () => {
const all = document.getElementsByClassName("pre-release");

if (all) {
for (var item of all) {
item.classList.toggle("hidden");
}
}
});
}
1 change: 1 addition & 0 deletions public/artifacts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"format_version":"0.6.5","tag":"v0.0.1","formatted_date":"Nov 23 2024 at 19:12 UTC","platforms_with_downloads":[{"target":["aarch64-apple-darwin"],"display_name":"macOS Apple Silicon","installers":[2]},{"target":["x86_64-apple-darwin"],"display_name":"macOS Intel","installers":[2]},{"target":["x86_64-pc-windows-msvc"],"display_name":"Windows x64","installers":[0]},{"target":["x86_64-unknown-linux-gnu"],"display_name":"Linux x64","installers":[2]},{"target":["x86_64-unknown-linux-musl"],"display_name":"musl Linux x64","installers":[2,1]}],"downloadable_files":[[4,{"name":"yolk-x86_64-pc-windows-msvc.zip","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-pc-windows-msvc.zip","view_path":null,"checksum_file":5},["Windows x64"]],[6,{"name":"yolk-x86_64-unknown-linux-musl.tar.xz","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-unknown-linux-musl.tar.xz","view_path":null,"checksum_file":7},["musl Linux x64"]]],"release":{"artifacts":{"files":[{"name":"dist-manifest.json","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/dist-manifest.json","view_path":null,"checksum_file":null},{"name":"source.tar.gz","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/source.tar.gz","view_path":null,"checksum_file":2},{"name":"source.tar.gz.sha256","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/source.tar.gz.sha256","view_path":null,"checksum_file":null},{"name":"yolk-installer.sh","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-installer.sh","view_path":"yolk-installer.sh.txt","checksum_file":null},{"name":"yolk-x86_64-pc-windows-msvc.zip","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-pc-windows-msvc.zip","view_path":null,"checksum_file":5},{"name":"yolk-x86_64-pc-windows-msvc.zip.sha256","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-pc-windows-msvc.zip.sha256","view_path":null,"checksum_file":null},{"name":"yolk-x86_64-unknown-linux-musl.tar.xz","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-unknown-linux-musl.tar.xz","view_path":null,"checksum_file":7},{"name":"yolk-x86_64-unknown-linux-musl.tar.xz.sha256","download_url":"https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-x86_64-unknown-linux-musl.tar.xz.sha256","view_path":null,"checksum_file":null}],"installers":[{"label":"zip","description":"","app_name":null,"method":{"type":"Download","file":4}},{"label":"tarball","description":"","app_name":null,"method":{"type":"Download","file":6}},{"label":"shell","description":"","app_name":null,"method":{"type":"Run","file":3,"run_hint":"curl --proto '=https' --tlsv1.2 -LsSf https://github.com/elkowar/Yolk/releases/download/v0.0.1/yolk-installer.sh | sh"}}],"targets":{"aarch64-apple-darwin":[2],"aarch64-unknown-linux-gnu":[2],"aarch64-unknown-linux-musl":[2],"i686-apple-darwin":[2],"i686-unknown-linux-gnu":[2],"i686-unknown-linux-musl":[2],"x86_64-apple-darwin":[2],"x86_64-pc-windows-msvc":[0],"x86_64-unknown-linux-gnu":[2],"x86_64-unknown-linux-musl":[2,1]}}},"os_script":"/yolk/artifacts.js","has_checksum_files":true}
Loading

0 comments on commit 2711210

Please sign in to comment.