Skip to content

Commit

Permalink
Refactor; add subdir example
Browse files Browse the repository at this point in the history
  • Loading branch information
psychemedia committed Jun 17, 2021
1 parent 07c4afa commit e2887fb
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 12 deletions.
15 changes: 5 additions & 10 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,19 @@ jobs:
uses: actions/checkout@v2
- name: Fetch the release
run: |
curl -L https://github.com/jtpio/jupyterlite/releases/download/v0.1.0a0/jupyterlite-app-0.1.0-alpha.0.tgz | tar -xz
mv package dist
chmod u+x ./jupyterlite-install.sh
./jupyterlite-install.sh
- name: Copy the federated extensions
run: |
# TODO
- name: setup python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Create all.json
- name: Create manifest and stage
run: |
pip install jupyter_server
python all_generator.py
- name: Copy the content
run: |
mkdir -p dist/api/contents/ dist/files
cp all.json dist/api/contents/
cp -r content/* dist/files/
chmod u+x ./deploy.sh
./deploy.sh
- name: List the content of the app
run: |
tree dist
Expand Down
19 changes: 17 additions & 2 deletions all_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def default(self, o):


path = '.'
outdir = Path(path)

outdir = Path(path) / 'file_manifests'
outdir.mkdir(exist_ok=True)

files_dir = Path(path) / 'content'

Expand All @@ -30,5 +32,18 @@ def default(self, o):
json.dumps(
fm.get(''), indent=2, sort_keys=True, cls=DateTimeEncoder
),
encoding="utf-8",
encoding="utf-8"
)

# We then need to do this for every directory in the contents dir
for p in files_dir.iterdir():
if p.is_dir():
rel_p = p.relative_to(str(files_dir))

all_json = (outdir / rel_p / "all.json")
all_json.parent.mkdir(parents=True, exist_ok=True)

all_json.write_text(
json.dumps(fm.get(str(rel_p)), indent=2, sort_keys=True, cls=DateTimeEncoder),
encoding="utf-8"
)
File renamed without changes.
28 changes: 28 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash
# Ensure this file is executable: chmod u+x deploy.sh

# Ensure that jupyterlite is installed: ./jupyterlite-install.sh

# Create all.json manifest
pip3 install jupyter_server
python3 all_generator.py

# Ensure distrribtiuon file directory available
mkdir -p dist/api/contents/ dist/files

# Copy manifest
#cp all.json dist/api/contents/
cp -R file_manifests/* dist/api/contents/

cp jupyter-lite.json dist/
cp config-utils.js dist/
cp -R custom/* dist/

# Copy content
rm -rf dist/files/*
cp -r content/* dist/files/



# Local webserver
# python3 -m http.server 8111 -d dist/
9 changes: 9 additions & 0 deletions jupyterlite-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
# Ensure this file is executable: chmod u+x jupyterlite-install.sh

# Install jupyterlite
curl -L https://github.com/jtpio/jupyterlite/releases/download/v0.1.0a0/jupyterlite-app-0.1.0-alpha.0.tgz | tar -xz
mv package dist

# Install packages
#cp -R packages/* dist/

0 comments on commit e2887fb

Please sign in to comment.