Commit 2dc6781f authored by Miguel Angel Reina Ortega's avatar Miguel Angel Reina Ortega
Browse files

Implementing backup + different nav format

parent 78eb9a7f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -102,16 +102,16 @@ pages:
    - |
     sed -i 's/PROJECT/'${CI_PROJECT_NAME^^}'/g' index.html
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs/images/favicon%2Eico/raw?ref=toMkdocs" >> favicon.html
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs%2Fimages%2Ffavicon%2Eico/raw?ref=toMkdocs" >> favicon.html
    - mkdir -p docs/images && mv favicon.html docs/images/
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/images/onem2m%2Epng/raw?ref=toMkdocs" >> onem2m.png
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs%2Fimages%2Fonem2m%2Epng/raw?ref=toMkdocs" >> onem2m.png
    - mv onem2m.png docs/images/
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/images/onem2m_sq%2Epng/raw?ref=toMkdocs" >> onem2m_sq.png
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs%2Fimages%2Fonem2m_sq%2Epng/raw?ref=toMkdocs" >> onem2m_sq.png
    - mv onem2m_sq.png docs/images/
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/stylesheets/extra%2Ecss/raw?ref=toMkdocs" >> extra.css
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs%2Fstylesheets%2Fextra%2Ecss/raw?ref=toMkdocs" >> extra.css
    - mkdir -p docs/stylesheets && mv extra.css docs/stylesheets/
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/toMkdocs%2Fmkdocs%2Eyml/raw?ref=toMkdocs" >> mkdocs.yml
+21 −7
Original line number Diff line number Diff line
@@ -2,6 +2,11 @@

DOCKER_IMAGE=logiqx/python-bs4:3.9-slim
MIKE_DOCKER_IMAGE=mike:master
#BACKUP=false
PAGES_BRANCH=gl-pages
#HTTPS_REMOTE=https://gitlab-ci-token:${ACCESS_TOKEN}@${CI_SERVER_HOST}/rep/${CI_PROJECT_PATH}.git
HTTPS_REMOTE=https://gitlab-ci-token:mytoken@git.onem2m.org/specifications/${3}.git


echo "\n------ Checking for docker image --------"
docker pull "$DOCKER_IMAGE"
@@ -12,7 +17,13 @@ echo "TAG NAME:" $4
echo "------ Get the previous GitLab Pages content --------"
set +e
curl --fail "$2/content.zip" -o "content.zip"
if [ -e "content.zip" ]; then
echo $BACKUP
if [ $BACKUP == "true" ]; then
    echo "Retrieving content.zip from backup"
    curl "https://git.onem2m.org/specifications/ts-0019/-/jobs/1082/artifacts/download?file_type=archive" >> content.zip
    unzip "content.zip";
    rm "content.zip"
elif [ -e "content.zip" ]; then
    unzip "content.zip";
    rm "content.zip";
else
@@ -63,21 +74,24 @@ else
fi

####### GENERATE NAV SPEC #######
## Temporary trial
#rm public/index.html
echo "------ Generate input for mkdocs --------"
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" python3 $8 --title $3 "./$7.md"
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" python3 $8 --title ${3^^} "./$7.md"

echo "------ Move to docs folder --------"
ls
mv $3/ docs/
mv ${3^^}/ docs/
cat _nav.yml >> mkdocs.yml

echo "------ Generating site --------"
#docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" /bin/sh -c 'git config user.name ci-bot && git config user.email ci-bot@example.com && mike deploy -u $4 latest'
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" /bin/sh -c 'git config user.name ci-bot && git config user.email ci-bot@example.com && mike deploy --deploy-prefix site -r $HTTPS_REMOTE -b $PAGES_BRANCH -u $4 latest && mike set-default --deploy-prefix site -r $HTTPS_REMOTE -b $PAGES_BRANCH latest'
#docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" /bin/sh -c 'git config user.name ci-bot && git config user.email ci-bot@example.com && mike set-default latest'
docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" mkdocs build -d public
#docker run --rm -u $(id -u):$(id -g) -v $(pwd):/tmp -w /tmp "$MIKE_DOCKER_IMAGE" mkdocs build -d site

echo "------ Move to output to public folder --------"
#mv site/* public/
echo "------ Move output to public folder --------"
cp -r site/* public/
rm -r site/

###########################

+12 −11
Original line number Diff line number Diff line
@@ -4,8 +4,9 @@ copyright: "Copyright © 2024 oneM2M Partnership Project"

# Required for RSS feed
site_description: oneM2M Specifications navigator
site_name: oneM2M Specifications
site_url: https://specifications.onem2m.org
site_url: https://specifications.onem2m.org/ts-0019/

docs_dir: docs

extra_css:
  - stylesheets/extra.css
@@ -21,12 +22,12 @@ theme:
    - content.code.copy
    #- navigation.footer
    - content.footnote.tooltips
    - navigation.indexes
    - navigation.instant.progress
    - navigation.prune
    - navigation.sections
    - navigation.tabs
    - navigation.tabs.sticky
    #- navigation.indexes
    #- navigation.instant.progress
    #- navigation.prune
    #- navigation.sections
    #- navigation.tabs
    #- navigation.tabs.sticky
    - search.suggest
    - search.highlight
    - search.share
@@ -82,9 +83,9 @@ extra:
    - icon: fontawesome/brands/linkedin
      link: https://www.linkedin.com/company/onem2m/
      name: oneM2M @ LinkedIn
  version:
    provider: mike

nav:



  - 'index.md'
+2 −0
Original line number Diff line number Diff line
@@ -181,10 +181,12 @@ def writeClauses(outLines:list[Clause], filename:str, navTitle:str) -> None:
		for i, f in enumerate(outLines):
			if f.onlyNav:
				file.write(f"  {'  '*f.level}- '{f.title}':\n")
				#file.write(f"{'  '*f.level}- '{f.title}':\n")
			else:
				if len(f.lines) == 0:
					continue
				file.write(f"  {'  '*f.level}- '{f.title}': '{navTitle}/{i:0{fnLength}}.md'\n")
				#file.write(f"{'  '*f.level}- '{f.title}': '{navTitle}/{i:0{fnLength}}.md'\n")


def updateLinks(clauses:list[Clause]) -> list[Clause]: