Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in / Register
  • O ogs
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 71
    • Issues 71
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 24
    • Merge requests 24
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • ogs
  • ogs
  • Merge requests
  • !4067

[web] Restructuring to page bundles

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Lars Bilke requested to merge bilke/ogs:web-page-bundles into master Mar 29, 2022
  • Overview 7
  • Commits 17
  • Pipelines 7
  • Changes 408

Preview is here: https://ogs.ogs.xyz/-/ogs/-/jobs/179420/artifacts/web/public/index.html

Restructures the /docs-section to use page bundles.

This will enable correct images in MR web site previews. Still not working are other linked files, e.g. PDFs or supplementary scripts and also images in Jupyter notebooks.

The following script (adapted from https://www.virtuallypotato.com/script-to-convert-posts-to-hugo-page-bundles/) was used:

# Usage: ./convert-to-pagebundle.sh vpotato/content/posts/hello-hugo.md

inputPost="$1"                              # vpotato/content/posts/hello-hugo.md
postPath=$(dirname $inputPost)              # vpotato/content/posts
postTitle=$(basename $inputPost .md)        # hello-hugo
newPath="$postPath/$postTitle"              # vpotato/content/posts/hello-hugo
newPost="$newPath/index.md"                 # vpotato/content/posts/hello-hugo/index.md

siteBase=$(echo "$inputPost" | awk -F/ '{ print $1 }')  # vpotato

imageLinks=($(ggrep -o -P '\.\./\S*.(png|jpg|pdf|mp4|svg)' $inputPost))
# Ex: '/images/posts/image-name.png'
echo $imageLinks
imageFiles=($(for file in ${imageLinks[@]}; do basename $file; done))
# Ex: 'image-name.png'
imagePaths=($(for file in ${imageLinks[@]}; do echo "$file"; done))
# Ex: 'vpotato/static/images/posts/image-name.png'

mkdir -p "$newPath"                         # make 'hello-hugo' dir
mv "$inputPost" "$newPost"                  # move 'hello-hugo.md' to 'hello-hugo/index.md'

for index in ${!imagePaths[@]}; do
    mv ${imagePaths[index]} $newPath
    # vpotato/static/images/posts/image-name.png --> vpotato/content/posts/hello-hugo/image-name.png
    echo "$postPath/${imageFiles[index]} -> $newPath/${imageFiles[index]}"
    mv $postPath/${imageFiles[index]} $newPath
    echo "s^${imagePaths[index]}^${imageFiles[index]}^"
    sed -i '' "s^${imagePaths[index]}^${imageFiles[index]}^" $newPost
done
find content/docs/benchmarks -name '*.md' -not -name '*index.md' -exec ./convert-to-pagebundle.sh {} \;
...
find content/docs/userguide -name '*.md' -not -name '*index.md' -exec ./convert-to-pagebundle.sh {} \;
  1. Feature description was added to the changelog
  2. Tests covering your feature were added?
Edited Mar 30, 2022 by Lars Bilke
Assignee
Assign to
Reviewer
Request review from
Time tracking
Source branch: web-page-bundles