Daniel Chapman

Daniel Chapman

<img width="987" alt="Screen Shot 2022-03-25 at 10 22 11 AM" src="https://user-images.githubusercontent.com/36767987/160138999-fdc14c88-f90a-45c4-8e27-65e0f9e959f9.png">
// Menu: Get Current Weather
// Description: Forecast provided by weather.gov
// Author: Daniel Chapman
// Twitter: @ds_chapman
import "@johnlindquist/kit"
let input = await arg("Get the Weather", ["For My Current Location", "For a Different Location"])
var location;
if (input == "For My Current Location") {
// Requires LocateMe installed on the path
// '$ brew install locateme'
// Also make sure to allow locateme in privacy/security
location = await $`locateme -f "lat={LAT}&lon={LON}"`;
div(
`<iframe src="https://forecast.weather.gov/MapClick.php?${location}" height=1280px width=100% />`,
);
} else if (input == "For a Different Location") {
location = await arg("City, State or Zip")
div(`<iframe src="https://forecast.weather.gov/zipcity.php?inputstring=${location}" height=1280px width=100% />`)
}
<img width="880" alt="Screen Shot 2022-03-25 at 9 54 41 AM" src="https://user-images.githubusercontent.com/36767987/160134094-4bf70455-6727-407a-a0d3-ab528283fa45.png"> <img width="880" alt="Screen Shot 2022-03-25 at 9 55 21 AM" src="https://user-images.githubusercontent.com/36767987/160134204-177e87e1-0b5c-4e16-a05a-dc1fb2a7017d.png">
// Name: Website Tools
// Description: Tools for maintaining my website (dschapman.com)
// Author: Daniel Chapman
// Twitter: @ds_chapman
import "@johnlindquist/kit"
let website_content = "/Users/danielchapman/Library/Mobile Documents/iCloud~md~obsidian/Documents/dschapman-com-content"
let website_notes = "/Users/danielchapman/Library/Mobile Documents/iCloud~md~obsidian/Documents/My notes"
let website_dir = "/Users/danielchapman/github/dschapman/dschapman-com"
let today = Date()
let output = []
let input = await arg("Select an Option", [{ name: "Publish", description: "Update the git repositories necessary to publish an update to my website", value: "Publish" }, { name: "Open Website in VSCode", description: "Open a vscode environment for dschapman-com", value: "VSCode" }, { name: "Edit Website Content", description: "Open the website's content in Obsidian", value: "Edit Website Content" }, { name: "Open Website", description: "Open https://dschapman.com in the browser", value: "Open Website" }, { name: "View on Github", description: "View website code on Github", value: "Github" }].sort((a, b) => { return (a.name > b.name ? 1 : -1) }))
switch (input) {
case "Publish":
input = await arg("Publish", [{ name: "Website Content", description: "Publish any changes to poems, articles or blog posts", "value": "Website Content" }, { name: "Website Notes", description: "Publish any changes to public notes", value: "Website Notes" }, { name: "All Content", description: "Publish it all", value: "All Content" }])
// -C allows git to be run from any directory
switch (input) {
case "Website Content":
output.push(await exec(`git -C "${website_content}" add -A`))
output.push(await exec(`git -C "${website_content}" commit -m "Publish content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_content}" push`))
output.push(await exec(`git -C "${website_dir}" submodule update --remote`))
output.push(await exec(`git -C "${website_dir}" add dschapman-com-content`))
output.push(await exec(`git -C "${website_dir}" commit -m "Publish content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_dir}" push`))
break;
case "Website Notes":
output.push(await exec(`git -C "${website_notes}" add -A`))
output.push(await exec(`git -C "${website_notes}" commit -m "Publish content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_notes}" push`))
output.push(await exec(`git -C "${website_dir}" submodule update --remote`))
output.push(await exec(`git -C "${website_dir}" add My-notes`))
output.push(await exec(`git -C "${website_dir}" commit -m "Publish notes: ${today.toString()}"`))
output.push(await exec(`git -C "${website_dir}" push`))
break;
case "All":
output.push(await exec(`git -C "${website_content}" add -A`))
output.push(await exec(`git -C "${website_content}" commit -m "Publish content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_content}" push`))
output.push(await exec(`git -C "${website_notes}" add -A`))
output.push(await exec(`git -C "${website_notes}" commit -m "Publish content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_notes}" push`))
output.push(await exec(`git -C "${website_dir}" submodule update --remote`))
output.push(await exec(`git -C "${website_dir}" add My-notes dschapman-com-content`))
output.push(await exec(`git -C "${website_dir}" commit -m "Publish all content: ${today.toString()}"`))
output.push(await exec(`git -C "${website_dir}" push`))
break;
default:
break;
}
break;
case "VSCode":
exec(`code "${website_dir}"`);
break;
case "Edit Website Content":
input = await arg("Open", [{ name: "Articles, Poems, and Blog Posts", value: "content" }, { name: "Digital Notes", value: "notes" }])
switch (input) {
case "content":
console.log("Content")
browse(`"obsidian://open?vault=dschapman-com-content"`)
break;
case "notes":
console.log("Notes")
browse(`"obsidian://open?vault=My%20notes"`)
break;
default:
break;
}
break;
case "Open Website":
browse("https://dschapman.com")
break;
case "Github":
browse("https://github.com/dschapman/dschapman-com")
break;
default:
break;
}
output.forEach(item => {
if (item.stdout)
console.log(item.stdout)
})