source

table of contents

this page contains the Pyra0 code that's used to generate this website . the full source repository is on SourceHut .

design philosophy

generator.nv

- include file: ../pyra0/libraries/ruby.nv
- include file: ../pyra0/libraries/nokogiri.nv

- get html for each page
- collect backlinks
- render backlinks
- insert table of contents
- insert source code
- wrap each page
- output the website
- copy the static assets
- create tar archive


* get html for each page
  - get files in pages folder

* got files: File
  - get base name of File -> name
  - read html fragment from File -> html

* name: Name * html: Html
  - pages: Name Html


| collect backlinks for: Page Html
* found elements: Link
  - get content of Link -> title
  - get attribute href of Link -> destination
  - switch tag of Link to a
  - append .html to Link href
  - set id to content of Link

| collect backlinks for: Page Html
* title: Title * destination: Destination
  - backlink to Destination: from Page with Title
  
| collect backlinks * pages: Page Html
  - collect backlinks for: Page Html
  - find elements with tag ba in Html

* collect backlinks

* collect backlinks for: Page Html
  - pages: Page Html


| render backlinks for: Page Html
* backlink to Page: from Source with Title
| list: List
  - found backlink for: Page
  - append element Item to List
  ^ item = "
      <li>#{source.gsub '-', ' '}:
        <a href='/#{source}.html##{title.gsub ' ', '-'}'>
          #{title}
        </a>
      </li>"

| render backlinks for: Page Html
| found backlink for: Page
* list: List
  - append element Result to Html
  ^ result = "
      <div class='backlinks'>
        <h2>backlinks</h2>
        #{list}
      </div>"

| render backlinks for: Page Html
* list: List

| render backlinks * pages: Page Html
  - render backlinks for: Page Html
  - create element ul in Html -> list

* render backlinks

* render backlinks for: Page Html
  - pages: Page Html


* update level | heading: Heading
  - get level of heading Heading -> level

* level: Level * last level: Last
  - last level: Level
  - Last minus Level -> change and times

* change: Change - compare Change and 0 -> direction

* direction: less
  - move: down

* direction: greater * times: Times
  - put up on move Times times

* direction: equal

* move: down * list: List * position: Position
  - append element List to Position
  - position: List

| move: down | html: Html
  - create element ul in Html -> list

* move: up * parent: Parent * position: Position
  - position: Parent

| move: up | position: Position
  - get parent of Position -> parent

* add heading: to list
* heading: Heading | position: Position
  - set id to content of Heading
  - append element Element to Position
  ^ element = "
      <li><a href='##{heading.content.gsub ' ', '-'}'>
        #{heading.content}
      </a></li>"

| insert table of contents
* found elements: Heading
  - heading: Heading
  - update level
  - add heading: to list

* insert: toc | toc: List
  - get amount of children of List -> count

* count: Count - compare Count and 2 -> enough

* enough: greater * html: Html * toc: List
  - insert Table before children of Html
  ^ table = "
      <details class='toc'>
        <summary>table of contents</summary>
        #{list}
      </details>"

- no toc: index
- no toc: wiki
- no toc: projects
- no toc: about

| insert table of contents
| no toc; Page
* pages: Page Html
  - inserted toc: Page Html

| insert table of contents * pages: Page Html
  - last level: 2 - html: Html
  - create element ul in Html -> toc and position
  - find elements with tag h2,h3,h4,h5,h6 in Html
  - insert: toc
  - inserted toc: Page Html

* insert table of contents

* inserted toc: Page Html - pages: Page Html


* insert source code | pages; source Html
  - find element with id #generator in Html -> container
  - get file content of generator.nv -> content

* container: Container * content: Content
  - set content of Container to Content


* find elements in wrapper | wrapper: Wrapper
  - find element with tag main in Wrapper -> main
  - find element with tag title in Wrapper -> title
  - create heading
  - set wrapper title

* create heading | page: index

* create heading | page: Page | main: Main
  - append element Header to Main
  ^ header = "<h1>#{page.gsub '-', ' '}</h1>"

* set wrapper title * page: Page * title: Title
  - set content of Title to Text
  ^ text = "eevie nebulæ: #{page.gsub '-', ' '}"

* wrap Page Html * main: Main * wrapper: Wrapper
  - append element Html to Main
  - wrapped: Page Wrapper

| wrap each page * pages: Page Html
  - page: Page
  - read html from wrapper.html -> wrapper
  - find elements in wrapper
  - wrap Page Html

* wrap each page

* wrapped: Page Html - pages: Page Html


* output the website
  - ensure site directory exists
  - output each page

| output each page
* pages: Page Html
  - write file Path with content Html
  ^ path = "site/#{page}.html"

* output each page


* copy the static assets
  - copy files static/. to site
  - copy files /home/eevie/files/srht/yarnstar/dist/. to site/yarnstar
  - copy files /home/eevie/files/srht/miraquad/artifact/web/. to site/miraquad
  - copy files /home/eevie/files/srht/pyra0/examples/axowotw/. to site/axowotw

* create tar archive
  ^ `cd site && tar -czvf eevie.dev.tar.gz *`