Merge branch '87-add-ci-job-for-pages' into 'master'
Added simple shell script for generating HTML overviews of the overlay contents Closes #87 See merge request !156
This commit is contained in:
		
						commit
						d5178b1dea
					
				
					 3 changed files with 107 additions and 2 deletions
				
			
		
							
								
								
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
										
									
									
										vendored
									
									
								
							|  | @ -1 +1,2 @@ | ||||||
| *~ | *~ | ||||||
|  | .public/ | ||||||
|  |  | ||||||
|  | @ -12,8 +12,8 @@ pages: | ||||||
|   only: |   only: | ||||||
|     - master |     - master | ||||||
|   script: |   script: | ||||||
|     - mkdir .public |     - chmod +x .gitlab-pages-generator.sh | ||||||
|     - mv * .public |     - ./gitlab-pages-generator.sh . .public | ||||||
|     - mv .public public |     - mv .public public | ||||||
|   artifacts: |   artifacts: | ||||||
|     paths: |     paths: | ||||||
|  |  | ||||||
							
								
								
									
										104
									
								
								.gitlab-pages-generator.sh
									
										
									
									
									
										Executable file
									
								
							
							
						
						
									
										104
									
								
								.gitlab-pages-generator.sh
									
										
									
									
									
										Executable file
									
								
							|  | @ -0,0 +1,104 @@ | ||||||
|  | #!/bin/sh | ||||||
|  | 
 | ||||||
|  | ROOT=$(realpath "${1:-.}") | ||||||
|  | TARGET=$(realpath "${2:-.public}") | ||||||
|  | declare -a PARTS=() | ||||||
|  | 
 | ||||||
|  | function createDir() { | ||||||
|  | 	mkdir -p "${1}" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function createDirInTarget() { | ||||||
|  | 	local dirpart="${1}" | ||||||
|  | 	local destinationdirectory=${dirpart/${ROOT}/${TARGET}} | ||||||
|  | 	echo $destinationdirectory | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function writeHTMLHeader() { | ||||||
|  | 	local targetfile="${1}" | ||||||
|  | 	local currentdir="${2}" | ||||||
|  | 
 | ||||||
|  | 	cat <<EOHEAD > "${targetfile}" | ||||||
|  | <!DOCTYPE html> | ||||||
|  | <html> | ||||||
|  | <head> | ||||||
|  | 	<meta charset="UTF-8"> | ||||||
|  | 	<title>gentoo-overlay/${currentdir}</title> | ||||||
|  | </head> | ||||||
|  | <body> | ||||||
|  | 	<h1>gentoo-overlay/${currentdir}</h1> | ||||||
|  | 	<ul> | ||||||
|  | EOHEAD | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function writeHTMLFooter() { | ||||||
|  | 	local targetfile="${1}" | ||||||
|  | 	cat <<EOFOOT >> "${targetfile}" | ||||||
|  | 	</ul> | ||||||
|  | </body> | ||||||
|  | </html> | ||||||
|  | EOFOOT | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function writeHTMLFileentry() { | ||||||
|  | 	local targetfile="${1}" | ||||||
|  | 	local filename="${2}" | ||||||
|  | 	cat <<EOFILE >> "${targetfile}" | ||||||
|  | 		<li><a href="${filename}">${filename}</a></li> | ||||||
|  | EOFILE | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function pushPart() { | ||||||
|  | 	local part="${1}" | ||||||
|  | 	PARTS=("${PARTS[@]}" "${part}")	 | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function popPart() { | ||||||
|  | 	local index=$(expr ${#PARTS[@]} - 1) | ||||||
|  | 	unset PARTS[${index}] | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function renderParts() { | ||||||
|  | 	local IFS="/" | ||||||
|  | 	echo "${PARTS[*]}" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function renderTargetPath() { | ||||||
|  | 	local parts=$(renderParts) | ||||||
|  | 	echo "${TARGET}${parts:+/}${parts}" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function renderTargetFilename() { | ||||||
|  | 	local targetPath=$(renderTargetPath) | ||||||
|  | 	echo "${targetPath}/index.html" | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function processDir() { | ||||||
|  | 	local dir="${1}" | ||||||
|  | 	cd "${dir}" | ||||||
|  | 	local realpath=$(realpath .) | ||||||
|  | 	local files=$(ls) | ||||||
|  | 	local parts=$(renderParts) | ||||||
|  | 	local targetPath=$(renderTargetPath) | ||||||
|  | 	local targetFilename=$(renderTargetFilename) | ||||||
|  | 	mkdir -p "${targetPath}" | ||||||
|  | 	writeHTMLHeader "${targetFilename}" "${parts}" | ||||||
|  | 	writeHTMLFileentry "${targetFilename}" ".." | ||||||
|  | 	for f in ${files} ; do | ||||||
|  | 		if [ -f "${f}" ] ;then | ||||||
|  | 			cp "${f}" "${targetPath}" | ||||||
|  | 			writeHTMLFileentry "${targetFilename}" "${f}" | ||||||
|  | 		elif [ -d "${f}" ] ; then | ||||||
|  | 			writeHTMLFileentry "${targetFilename}" "${f}/" | ||||||
|  | 			pushPart "${f}" | ||||||
|  | 			processDir "${f}" | ||||||
|  | 			popPart | ||||||
|  | 		else | ||||||
|  | 			echo "Unknown: ${f}" | ||||||
|  | 		fi | ||||||
|  | 	done | ||||||
|  | 	writeHTMLFooter "${targetFilename}" | ||||||
|  | 	cd .. | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | processDir "${ROOT}" | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue