-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb4aa1c
commit d1741d3
Showing
14 changed files
with
563 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Simple workflow for deploying static content to GitHub Pages. | ||
name: Deploy static content to Pages | ||
|
||
on: | ||
# Runs on pushes targeting the default branch. | ||
push: | ||
branches: ["main"] | ||
|
||
# Allows you to run this workflow manually from the Actions tab. | ||
workflow_dispatch: | ||
|
||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages. | ||
permissions: | ||
contents: read | ||
pages: write | ||
id-token: write | ||
|
||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. | ||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. | ||
concurrency: | ||
group: "pages" | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Single deploy job since we're just deploying. | ||
deploy: | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: denoland/setup-deno@v1 | ||
with: | ||
deno-version: v1.x | ||
|
||
- name: Build | ||
run: deno task build | ||
|
||
- name: Setup Pages | ||
uses: actions/configure-pages@v4 | ||
|
||
- name: Upload artifact | ||
uses: actions/upload-pages-artifact@v3 | ||
with: | ||
# Upload build directory. | ||
path: 'build' | ||
|
||
- name: Deploy to GitHub Pages | ||
id: deployment | ||
uses: actions/deploy-pages@v4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"deno.enable": true, | ||
"editor.formatOnSave": true, | ||
"editor.defaultFormatter": "denoland.vscode-deno" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,48 @@ | ||
# projects | ||
|
||
List of initiatives owned by the Open Source Software team. | ||
|
||
## Development | ||
|
||
Make sure to install Deno: | ||
<https://deno.land/manual/getting_started/installation>. | ||
|
||
Build the project: | ||
|
||
```sh | ||
deno task build | ||
``` | ||
|
||
Build the project in development mode: | ||
|
||
```sh | ||
deno task dev | ||
``` | ||
|
||
Serve the static site: | ||
|
||
```sh | ||
deno task serve | ||
``` | ||
|
||
Format the project: | ||
|
||
```sh | ||
deno fmt | ||
``` | ||
|
||
Lint the project: | ||
|
||
```sh | ||
deno lint | ||
``` | ||
|
||
Update dependencies: | ||
|
||
```sh | ||
deno task udd | ||
``` | ||
|
||
--- | ||
|
||
Maintained with 💚 by [**@acmcsufoss**](https://github.com/acmcsufoss) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"tasks": { | ||
"lock": "deno cache --lock=deno.lock --lock-write deps.ts", | ||
"udd": "deno run -Ar https://deno.land/x/udd/main.ts deps.ts && deno task lock", | ||
"build": "deno run -A main.ts", | ||
"dev": "deno run -A --watch main.ts", | ||
"serve": "deno run -A https://deno.land/std/http/file_server.ts build" | ||
}, | ||
"compilerOptions": { | ||
"jsx": "react-jsx", | ||
"jsxFactory": "h", | ||
"jsxImportSource": "nano_jsx" | ||
}, | ||
"imports": { | ||
"#/": "./", | ||
"nano_jsx/jsx-runtime": "https://deno.land/x/[email protected]/jsx-runtime/index.ts" | ||
}, | ||
"exclude": ["build"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export { test } from "https://deno.land/[email protected]/front_matter/mod.ts"; | ||
export { copy, expandGlob } from "https://deno.land/[email protected]/fs/mod.ts"; | ||
export { parseArgs } from "https://deno.land/[email protected]/cli/parse_args.ts"; | ||
export { extract } from "https://deno.land/[email protected]/front_matter/any.ts"; | ||
export { CSS, render } from "https://deno.land/x/[email protected]/mod.ts"; | ||
export { | ||
h, | ||
Helmet, | ||
renderSSR, | ||
} from "https://deno.land/x/[email protected]/mod.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from "./projects.ts"; | ||
export * from "./ssr.tsx"; | ||
export * from "./walk.ts"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { extract, test } from "#/deps.ts"; | ||
|
||
export interface ProjectAttrs { | ||
title?: string; | ||
description?: string; | ||
participants?: string[]; | ||
labels?: string[]; | ||
repository?: string; | ||
} | ||
|
||
export interface Project { | ||
id: string; | ||
md: string; | ||
attrs?: ProjectAttrs; | ||
} | ||
|
||
export function parseProject(filename: string, md: string): Project { | ||
const id = filename.replace(/\.md$/, ""); | ||
if (!test(md)) { | ||
return { id, md }; | ||
} | ||
|
||
const extracted = extract<ProjectAttrs>(md); | ||
return { | ||
id, | ||
md: extracted.body, | ||
attrs: extracted.attrs, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import { CSS, h, Helmet, render, renderSSR } from "#/deps.ts"; | ||
import type { Project } from "./projects.ts"; | ||
|
||
/** | ||
* makeRepositoryURL returns a URL for the given repository. | ||
* The given repository string may be a URL or a repository name. | ||
* If the given repository is a URL, it is returned as is. | ||
* If the given repository is a repository name, it is converted to a URL | ||
* by assuming the repository is owned by the acmcsufoss organization. | ||
*/ | ||
function makeRepositoryURL(repository: string) { | ||
if (repository.startsWith("https://")) { | ||
return repository; | ||
} | ||
|
||
return `https://github.com/acmcsufoss/${repository}`; | ||
} | ||
|
||
function ProjectPageComponent(props: { project: Project }) { | ||
const html = render(props.project.md, { baseUrl: "/" }); | ||
return ( | ||
<main> | ||
<Helmet> | ||
<html lang="en" amp /> | ||
<title> | ||
{props.project.attrs?.title} - Open Source Software projects | ||
</title> | ||
<meta | ||
name="description" | ||
content={props.project.attrs?.description} | ||
/> | ||
<style>{CSS}</style> | ||
</Helmet> | ||
|
||
<article | ||
className="markdown-content" | ||
dangerouslySetInnerHTML={{ __html: html }} | ||
/> | ||
</main> | ||
); | ||
} | ||
|
||
function ProjectPreviewComponent(props: { project: Project }) { | ||
return ( | ||
<article> | ||
<h1> | ||
<a href={`/${props.project.id}.html`}>{props.project.attrs?.title}</a> | ||
</h1> | ||
<p>{props.project.attrs?.description}</p> | ||
</article> | ||
); | ||
} | ||
|
||
function ProjectPreviewListComponent(props: { projects: Project[] }) { | ||
return ( | ||
<ul> | ||
{props.projects.map((project) => ( | ||
<li> | ||
<ProjectPreviewComponent project={project} /> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} | ||
|
||
export function ProjectsPageComponent(props: { projects: Project[] }) { | ||
return ( | ||
<main> | ||
<Helmet> | ||
<html lang="en" amp /> | ||
<title>Open Source Software projects</title> | ||
<meta | ||
name="description" | ||
content="List of initiatives owned by the Open Source Software team." | ||
/> | ||
</Helmet> | ||
<ProjectPreviewListComponent projects={props.projects} /> | ||
</main> | ||
); | ||
} | ||
|
||
// deno-lint-ignore no-explicit-any | ||
function renderPageHTML(component: any) { | ||
const html = renderSSR(component); | ||
const { body, head, footer, attributes } = Helmet.SSR(html); | ||
return `<!DOCTYPE html> | ||
<html ${attributes.html.toString()}> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link rel="icon" href="/favicon.ico" type="image/x-icon"> | ||
${head.join("\n")} | ||
</head> | ||
<body ${attributes.body.toString()}>${body}${footer.join("\n")}</body> | ||
</html>`; | ||
} | ||
|
||
export function renderProjectsPageHTML(projects: Project[]) { | ||
return renderPageHTML(<ProjectsPageComponent projects={projects} />); | ||
} | ||
|
||
export function renderProjectPageHTML(project: Project) { | ||
return renderPageHTML(<ProjectPageComponent project={project} />); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { expandGlob } from "#/deps.ts"; | ||
import { parseProject } from "./projects.ts"; | ||
|
||
export async function* walkProjects(glob: string | URL) { | ||
for await (const stat of expandGlob(glob)) { | ||
const md = await Deno.readTextFile(stat.path); | ||
yield parseProject(stat.name, md); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { copy, parseArgs } from "#/deps.ts"; | ||
import type { Project } from "#/lib/projects/mod.ts"; | ||
import { | ||
renderProjectPageHTML, | ||
renderProjectsPageHTML, | ||
walkProjects, | ||
} from "#/lib/projects/mod.ts"; | ||
|
||
// Build script for generating static site from markdown files | ||
// in the projects directory. | ||
async function main(args: string[]) { | ||
const flags = parseArgs(args, { | ||
string: ["indir", "outdir", "staticdir"], | ||
alias: { | ||
indir: ["i"], | ||
outdir: ["o"], | ||
staticdir: ["s"], | ||
}, | ||
default: { | ||
indir: "projects", | ||
outdir: "build", | ||
staticdir: "static", | ||
}, | ||
}); | ||
|
||
// Create outdir if it does not exist. | ||
await Deno.mkdir(flags.outdir, { recursive: true }); | ||
|
||
// Render markdown files to HTML. | ||
const projects: Project[] = []; | ||
for await (const project of walkProjects(`${flags.indir}/*.md`)) { | ||
projects.push(project); | ||
const html = renderProjectPageHTML(project); | ||
await Deno.writeTextFile(`${flags.outdir}/${project.id}.html`, html); | ||
const json = JSON.stringify(project, null, 2); | ||
await Deno.writeTextFile(`${flags.outdir}/${project.id}.json`, json); | ||
} | ||
|
||
// Copy contents of static directory to outdir. | ||
await copy(flags.staticdir, flags.outdir, { overwrite: true }); | ||
|
||
// Render index page. | ||
const html = await renderProjectsPageHTML(projects); | ||
await Deno.writeTextFile(`${flags.outdir}/index.html`, html); | ||
} | ||
|
||
if (import.meta.main) { | ||
await main(Deno.args); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
--- | ||
title: "Crying Counter" | ||
participants: ["Ethan", "Karni", "Jacob", "Justin", "Vamsi"] | ||
labels: ["python"] | ||
--- | ||
|
||
# Crying Counter | ||
|
||
## Description | ||
|
||
Counts instances of “I’m crying” by Discord user ID. | ||
|
||
## References | ||
|
||
- [Design document](https://docs.google.com/document/d/1G3jYfibJuN2NPhCEEtuYVbyL_C04p8puD6ynT8I7Vy8/edit) |
Binary file not shown.