Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeee committed Jun 20, 2024
2 parents 2c9828e + 0a8c94d commit dc475da
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 6 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Publish example site

name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 20.x
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Setup Pages
uses: actions/configure-pages@v4

- name: Rename json file
run: cp polycule.json.example polycule.json

- name: Rename base URI file
run: cp _data/URIs.json.example _data/URIs.json

- name: Build
run: npm run buildit

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "./_site"

deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v3
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash
npm run buildit
chown -R www-data:www-data _site
chown -R $(whoami):www-data _site
18 changes: 15 additions & 3 deletions edit.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,19 @@ param[dcedge2]=$(echo "${sorteddcs}" | tail -n1)

json=$(cat $SCRIPT_DIR/polycule.json)
echo "current json:" >> $log
echo "${json}" >> $log
echo "${json}" | jq -c >> $log

# add node
if [ ! -z "${param[addnode]}" ]; then
echo "add node!: ${param[addnode]}" >> $log
json=$(echo "${json}" | jq '.nodes |= .+ ["'"${param[addnode]}"'"]')
innodes=$(echo "${json}" | jq -r '.nodes | .[]' | grep "^${param[addnode]}$" | wc -l)
if [ $innodes -lt 1 ]; then
json=$(echo "${json}" | jq '.nodes |= .+ ["'"${param[addnode]}"'"]')
else
echo "node already in nodes, doing nothing. \$innodes was $innodes" >> $log
fi
fi
# remove node
if [ ! -z "${param[removenode]}" ]; then
echo "remove node!: ${param[removenode]}" >> $log
appearsinedges=$(echo "${json}" | jq -r '.edges | .[] | .[]' | grep "${param[removenode]}" | wc -l)
Expand All @@ -55,25 +62,30 @@ if [ ! -z "${param[removenode]}" ]; then
echo "refusing to remove node with edges" >> $log
fi
fi
# add edge
if [ ! -z "${param[addedge1]}" ] && [ ! -z "${param[addedge2]}" ]; then
echo "add edge from ${param[addedge1]} to ${param[addedge2]}" >> $log
edge1innodes=$(echo "${json}" | jq -r '.nodes | .[]' | grep "^${param[addedge1]}$" | wc -l)
edge2innodes=$(echo "${json}" | jq -r '.nodes | .[]' | grep "^${param[addedge2]}$" | wc -l)
edgeinedges=$(echo "${json}" | jq -rc '.edges | .[]' | grep -F '["'"${param[addedge1]}"'","'"${param[addedge2]}"'"]' | wc -l)
if [ $edge1innodes != 1 ] || [ $edge2innodes != 1 ]; then
echo "desired edge not found in edges" >> $log
elif [ "${param[addedge1]}" == "${param[addedge2]}" ]; then
echo "desired edges are the same, doing nothing" >> $log
elif [ $edgeinedges -ge 1 ]; then
echo "edge already in edges, doing nothing..." >> $log
else
json=$(echo "${json}" | jq '.edges |= .+ [["'"${param[addedge1]}"'","'"${param[addedge2]}"'"]]')
fi
fi
# remove edge
if [ ! -z "${param[dcedge1]}" ] && [ ! -z "${param[dcedge2]}" ]; then
echo "disconnect edge from ${param[dcedge1]} to ${param[dcedge2]}" >> $log
json=$(echo "${json}" | jq '.edges |= .- [["'"${param[dcedge1]}"'","'"${param[dcedge2]}"'"]]')
fi

echo "json after:" >> $log
echo "${json}" >> $log
echo "${json}" | jq -c >> $log
echo "${json}" > $SCRIPT_DIR/polycule.json
echo "rebuilding site..." >> $log
echo "cannot rebuild site... not able to use npm... copying json manually" >> $log
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@

@font-face {
font-family: "Hockey is Life";
src: url("/hockey.ttf");
src: url("hockey.ttf");
}

body {
Expand Down Expand Up @@ -238,7 +238,7 @@
id="svg"
width="500"
height="500"
viewBox="-20 -20 120 120"
viewBox="0 0 100 100"
xmlns="http://www.w3.org/2000/svg"
>
<g id="edges"></g>
Expand Down

0 comments on commit dc475da

Please sign in to comment.