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

Moving baselines to public/baselines

parent 5090c8ac
Loading
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -91,10 +91,10 @@ pages:
        TAG_NAME: "upgrade"
        TAG_NAME: "upgrade"
  before_script:
  before_script:
    - |
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=master" >> publish_on_pages.sh
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/publish_on_pages%2Esh/raw?ref=addDiffCR" >> publish_on_pages.sh
    - chmod +x publish_on_pages.sh
    - chmod +x publish_on_pages.sh
    - |
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/updateIndex%2Epy/raw?ref=master" >> updateIndex.py
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/updateIndex%2Epy/raw?ref=addDiffCR" >> updateIndex.py
    - |
    - |
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/index%2Ehtml/raw?ref=master" >> index.html
     curl "${CI_API_V4_URL}/projects/$TOOLS_SCRIPTS_PROJECT_ID/repository/files/index%2Ehtml/raw?ref=master" >> index.html
    - |
    - |
+22 −7
Original line number Original line Diff line number Diff line
@@ -23,26 +23,41 @@ fi
set -e
set -e


echo "------ Get the previous GitLab Pages content --------"
echo "------ Get the previous GitLab Pages content --------"
# Move all folders except the "baselines" folder if baselines folder exists
if [ -d "public/baselines" ]; then
    echo "Baselines already moved to baselines/";
else
    mkdir -p "public/baselines"
    for folder in public/*; do
        if [ -d "$folder" ] && [ "$(basename "$folder")" != "baselines" ]; then
            mv "$folder" "public/baselines/"
            echo "Moved $(basename "$folder") to public/baselines"
        fi
    done
    # Move index.html with new location
    mv "public/index.html" "public/baselines/"

fi


echo "------ Add/update content --------"
echo "------ Add/update content --------"
if [ $4 == 'upgrade' ]; then
if [ $4 == 'upgrade' ]; then
    echo 'Upgrading index.html...'
    echo 'Upgrading index.html...'
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -u "$7_$4" "$4/$7_$4.docx" "$5"
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -u "$7_$4" "$4/$7_$4.docx" "$5"
elif [ $6 == 'true' ]; then
elif [ $6 == 'true' ]; then
    echo 'Removing all web pages content...'
    echo 'Removing all baselines ...'
	rm -r public/*;
	rm -r public/baselines/*;
	mkdir -p "public/$4"
	mkdir -p "public/baselines/$4"
    ls public/
    ls public/
	cp -r -f "$7_$4.docx" public/$4
	cp -r -f "$7_$4.docx" public/baselines/$4
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5"
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5"
elif [ $6 == 'false' ]; then
elif [ $6 == 'false' ]; then
	mkdir -p "public/$4"
	mkdir -p "public/baselines/$4"
    ls public/
    ls public/
	cp -r -f "$7_$4.docx" public/$4
	cp -r -f "$7_$4.docx" public/baselines/$4
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5"
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 "$7_$4" "$4/$7_$4.docx" "$5"
else
else
    echo 'Removing entry for ' $6
    echo 'Removing entry for ' $6
    rm -r -f public/$6
    rm -r -f public/baselines/$6
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -re "$7_$4" "$4/$7_$4.docx" "$5"
    docker run --rm -v $(pwd):/tmp -w /tmp "$DOCKER_IMAGE" python3 $1 -re "$7_$4" "$4/$7_$4.docx" "$5"
fi
fi


+6 −10
Original line number Original line Diff line number Diff line
@@ -12,12 +12,12 @@ import argparse, os


def upgradeIndex(args: argparse.Namespace) -> None:
def upgradeIndex(args: argparse.Namespace) -> None:
    # Check if index.htm exists
    # Check if index.htm exists
    if not os.path.exists('public/index.html'):
    if not os.path.exists('public/baselines/index.html'):
        print("'index.html' does not exist yet, Upgrade is not needed")
        print("'index.html' does not exist yet, Upgrade is not needed")
        exit()
        exit()
    else:
    else:
        # Read the source HTML file
        # Read the source HTML file
        with open('public/index.html', 'r', encoding='utf-8') as source_file:
        with open('public/baselines/index.html', 'r', encoding='utf-8') as source_file:
            source_html = source_file.read()
            source_html = source_file.read()


        # Read the destination HTML file
        # Read the destination HTML file
@@ -46,26 +46,22 @@ def upgradeIndex(args: argparse.Namespace) -> None:
            exit(1)
            exit(1)


        # Save the updated destination HTML
        # Save the updated destination HTML
        with open('public/index.html', 'w', encoding='utf-8') as dest_updated_file:
        with open('public/baselines/index.html', 'w', encoding='utf-8') as dest_updated_file:
            dest_updated_file.write(str(dest_soup))
            dest_updated_file.write(str(dest_soup))



        # Read index HTML
        with open('public/index.html', 'r', encoding='utf-8') as file:
            html_content = file.read()
        print("Index.html upgraded")
        print("Index.html upgraded")




def updateIndex(args:argparse.Namespace) -> None:
def updateIndex(args:argparse.Namespace) -> None:
    
    
    # Check if index.htm exists
    # Check if index.htm exists
    if not os.path.exists('public/index.html'):
    if not os.path.exists('public/baselines/index.html'):
        print("'index.html' does not exist yet, using template")
        print("'index.html' does not exist yet, using template")
        with open(args.indexTemplate, 'r', encoding='utf-8') as file:
        with open(args.indexTemplate, 'r', encoding='utf-8') as file:
            html_content = file.read()
            html_content = file.read()
    else:
    else:
        # Read index HTML
        # Read index HTML
        with open('public/index.html', 'r', encoding='utf-8') as file:
        with open('public/baselines/index.html', 'r', encoding='utf-8') as file:
            html_content = file.read()
            html_content = file.read()


    # Analyze index content with BeautifulSoup
    # Analyze index content with BeautifulSoup
@@ -97,7 +93,7 @@ def updateIndex(args:argparse.Namespace) -> None:
            document_list.append(li)
            document_list.append(li)


    # Save the updated index.html file
    # Save the updated index.html file
    with open('public/index.html', 'w', encoding='utf-8') as file:
    with open('public/baselines/index.html', 'w', encoding='utf-8') as file:
        file.write(str(soup))
        file.write(str(soup))


    print("Index.html updated")
    print("Index.html updated")