diff --git a/.github/workflows/static.yaml b/.github/workflows/static.yaml new file mode 100644 index 0000000..b1a9847 --- /dev/null +++ b/.github/workflows/static.yaml @@ -0,0 +1,52 @@ +# 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: true + +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 + - name: Set up node + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: 'npm' + - name: Install dependencies + run: npm ci + - name: Build + run: npm run build + - name: Setup Pages + uses: actions/configure-pages@v5 + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: './dist' + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/index.html b/index.html index 46a816c..b63185e 100644 --- a/index.html +++ b/index.html @@ -8,6 +8,14 @@
+ +

Galaxy

+
+
+ +

Ideas

+
+
diff --git a/src/base_types/idea_base.ts b/src/base_types/idea_base.ts new file mode 100644 index 0000000..66cce00 --- /dev/null +++ b/src/base_types/idea_base.ts @@ -0,0 +1,40 @@ +export abstract class IdeaBase { + title: string; + note: string; + tags: string[]; + references: string[]; + derivedFrom: IdeaBase[]; + + constructor() { + this.title = ""; + this.note = ""; + this.tags = []; + this.references = []; + this.derivedFrom = []; + } + + describe(indent: string = "") { + const descriptions: string[] = []; + const thisTypeName = this.constructor.name; + descriptions.push(`${indent}- ${this.title}`); + descriptions.push(`${indent} - ${this.note}`); + if (this.tags.length > 0) { + descriptions.push(`${indent} - Tags: ${this.tags.join(", ")}`); + } + if (this.references.length > 0) { + descriptions.push(`${indent} - References:`); + for (const reference of this.references) { + descriptions.push(`${indent} - ${reference}`); + } + } + if (this.derivedFrom.length > 0) { + descriptions.push(`${indent} - Derived from:`); + for (const idea of this.derivedFrom) { + const typeName = idea.constructor.name; + descriptions.push(`${indent} - ${typeName}`); + } + } + return descriptions.join("\n"); + } +} + diff --git a/src/base_types/star_system_base.ts b/src/base_types/star_system_base.ts new file mode 100644 index 0000000..f48058c --- /dev/null +++ b/src/base_types/star_system_base.ts @@ -0,0 +1,20 @@ +export abstract class StarSystemBase { + name: string; + index: number; + coordinates: number[]; + + constructor() { + this.name = ""; + this.index = 0; + this.coordinates = []; + } + + describe(indent: string = "") { + const descriptions: string[] = []; + const thisTypeName = this.constructor.name; + descriptions.push(`${indent}- ${this.name}`); + descriptions.push(`${indent} - Index: ${this.index}`); + descriptions.push(`${indent} - Coordinates: (${this.coordinates.join(", ")})`); + return descriptions.join("\n"); + } +} \ No newline at end of file diff --git a/src/galaxy.ts b/src/galaxy.ts new file mode 100644 index 0000000..e142daa --- /dev/null +++ b/src/galaxy.ts @@ -0,0 +1,33 @@ +import { marked } from "marked"; +import { Star1 } from "./stars/star_1"; + +class Galaxy { + stars: Star1[]; + + constructor() { + this.stars = []; + } + + add_star(star: Star1) { + this.stars.push(star); + } + + get_stars() { + return this.stars; + } +} + +export function drawGalaxy(galaxy_e: HTMLDivElement) { + const galaxy = new Galaxy(); + galaxy.add_star(new Star1()); + + for (const star of galaxy.get_stars()) { + const starDescription = star.describe(); + + const star_e = document.createElement('div'); + star_e.className = 'star'; + star_e.innerHTML = marked(starDescription) as string; + galaxy_e.appendChild(star_e); + } +} + diff --git a/src/idea_bank.ts b/src/idea_bank.ts new file mode 100644 index 0000000..fe316f1 --- /dev/null +++ b/src/idea_bank.ts @@ -0,0 +1,37 @@ +import { IdeaBase } from './base_types/idea_base'; +import { marked } from 'marked'; +import { StarHasMind } from './ideas/star_has_mind'; +import { PlantShip } from './ideas/plant_ship'; +import { SpaceTravelUsingStarMind } from './ideas/space_travel_using_star_mind'; + +class IdeaBank { + ideas: IdeaBase[]; + + constructor() { + this.ideas = []; + } + + add_idea(idea: IdeaBase) { + this.ideas.push(idea); + } + + get_ideas() { + return this.ideas; + } +} + +export function drawAllIdea(ideas_e: HTMLDivElement) { + const ideaBank = new IdeaBank(); + ideaBank.add_idea(new StarHasMind()); + ideaBank.add_idea(new PlantShip()); + ideaBank.add_idea(new SpaceTravelUsingStarMind()); + + for (const idea of ideaBank.get_ideas()) { + const ideaDescription = idea.describe(); + + const idea_e = document.createElement('div'); + idea_e.className = 'idea'; + idea_e.innerHTML = marked(ideaDescription) as string; + ideas_e.appendChild(idea_e); + } +} \ No newline at end of file diff --git a/src/ideas/plant_ship.ts b/src/ideas/plant_ship.ts new file mode 100644 index 0000000..ea1eb32 --- /dev/null +++ b/src/ideas/plant_ship.ts @@ -0,0 +1,15 @@ +import { IdeaBase } from "../base_types/idea_base"; + +export class PlantShip extends IdeaBase { + + constructor() { + super(); + + this.title = "Plant Ship"; + this.note = "A spaceship that is a living plant."; + this.tags = ["space_travel", "spaceship", "plant"]; + this.references = [ + "https://en.wikipedia.org/wiki/Bio-inspired_robotics", + ]; + } +} \ No newline at end of file diff --git a/src/ideas/space_travel_using_star_mind.ts b/src/ideas/space_travel_using_star_mind.ts new file mode 100644 index 0000000..c806baf --- /dev/null +++ b/src/ideas/space_travel_using_star_mind.ts @@ -0,0 +1,19 @@ +import { IdeaBase } from "../base_types/idea_base"; +import { StarHasMind } from "./star_has_mind"; +import { PlantShip } from "./plant_ship"; + +export class SpaceTravelUsingStarMind extends IdeaBase { + constructor() { + super(); + + this.title = "Space Travel Using Star Mind"; + this.note = "Traveling through space using the mind of a star."; + this.tags = ["star", "universe", "space_travel"]; + this.references = [ + ]; + this.derivedFrom = [ + new StarHasMind(), + new PlantShip(), + ]; + } +} \ No newline at end of file diff --git a/src/ideas/star_has_mind.ts b/src/ideas/star_has_mind.ts new file mode 100644 index 0000000..86afb6a --- /dev/null +++ b/src/ideas/star_has_mind.ts @@ -0,0 +1,14 @@ +import { IdeaBase } from "../base_types/idea_base"; + +export class StarHasMind extends IdeaBase { + constructor() { + super(); + + this.title = "Star Has Mind"; + this.note = "A star is a conscious entity."; + this.tags = ["star", "universe", "space_travel"]; + this.references = [ + "https://www.sheldrake.org/files/pdfs/papers/Is_the_Sun_Conscious.pdf", + ]; + } +} diff --git a/src/main.ts b/src/main.ts index d353da5..51db8aa 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,12 @@ import './style.css'; +import { drawAllIdea } from './idea_bank'; +import { drawGalaxy } from './galaxy'; function startApp() { console.log('App started'); + + drawGalaxy(document.getElementById('galaxy') as HTMLDivElement); + drawAllIdea(document.getElementById('ideas') as HTMLDivElement); } // when the page is loaded, the script will be executed diff --git a/src/stars/star_1.ts b/src/stars/star_1.ts new file mode 100644 index 0000000..bd3b313 --- /dev/null +++ b/src/stars/star_1.ts @@ -0,0 +1,12 @@ +import { StarSystemBase } from "../base_types/star_system_base"; + +export class Star1 extends StarSystemBase { + constructor() { + super(); + + this.name = "Star 1"; + this.index = 1; + this.coordinates = [0.76, 0.43, 0.01]; + } +} + diff --git a/vite.config.js b/vite.config.js index 019e49d..d86a918 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,7 +4,7 @@ import { defineConfig, loadEnv } from 'vite' export default defineConfig(({ command, mode }) => { const env = loadEnv(mode, process.cwd(), '') return { - base: '/', + base: '/NatriumStory/', plugins: [], define: { }