Skip to content
Snippets Groups Projects
html_md.sh 13.6 KiB
Newer Older
  • Learn to ignore specific revisions
  • Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    #!/bin/bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ### DOWNLOAD AND CONVERT DOCUMENTATION
    # autor: kru0052
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    # version: 0.89
    # change: formatting, ALFA TESTS
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    # bugs: bad internal links
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ###
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    if [ "$1" = "-t" ]; then
    	test="pdfunite"
     	while read a ; do 
    			test+=" $a"
    	done < seznam.txt
    	test+=" test.pdf"
    	$test
    
    	while read a ; do 
    			rm "$i"
    	done < seznam.txt
    		
    fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    if [ "$1" = "-d" ]; then
    	# remove pdf, md and epub files
       STARTTIME=$(date +%s)
    	if [ "$2" = "pdf" ]; then
    		echo "$(tput setaf 9)*.pdf deleted$(tput setaf 15)"
    		if [ -d ./pdf ]; then
    			rm -rf ./pdf
    		fi
    	elif [ "$2" = "epub" ]; then
    		echo "$(tput setaf 9)*.epub deleted$(tput setaf 15)"
    		if [ -d ./epub ]; then
    			rm -rf ./epub
    		fi
    	elif [ "$2" = "md" ]; then
    		echo "$(tput setaf 9)*.md deleted$(tput setaf 15)"
    		if [ -d ./converted ]; then
    			rm -rf ./converted
    		fi
    	elif [ "$2" = "all" ]; then
    		echo "$(tput setaf 9)all files deleted$(tput setaf 15)"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		if [ -d ./docs.it4i ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			rm -rf ./converted
    		fi
    		if [ -d ./epub ]; then
    			rm -rf ./epub
    		fi
    		if [ -d ./pdf ]; then
    			rm -rf ./pdf
    		fi
    		if [ -d ./info ]; then
    			rm -rf ./info
    		fi
    		if [ -d ./docs.it4i.cz ]; then
    			rm -rf ./docs.it4i.cz
    		fi
    	fi
       ENDTIME=$(date +%s)
    	echo "It takes $(($ENDTIME - $STARTTIME)) seconds to complete this task..."
    fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    if [ "$1" = "-e" ]; then
    	# export to pdf/epub
       STARTTIME=$(date +%s)
    	counter=1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	count=$(find ./docs.it4i -name "*.md" -type f | wc -l)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	if [ "$2" = "epub" ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		if [ -d ./epub ]; then
    			rm -rf ./epub
    		fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		find ./docs.it4i -name -name "*.md" | 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read i; 
    		do 
    			a=$(basename "$i")
    			b=$(dirname "$i")
    			c=$(pwd)
    		
    			echo "$(tput setaf 12)($counter/$count)$(tput setaf 11)$a => $(tput setaf 13)${a%.*}.epub$(tput setaf 15)"
    			counter=$((counter+1))
    			cd "$b"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				# export to epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				pandoc ${a%.*}.md -o ${a%.*}.epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			cd "$c"
    		done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# new folder for epub files
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		mkdir epub;
    		(while read i; 
    		do		
    			mkdir "./epub/$i";
    		done) < ./source/list_folder
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# move epub files to folder epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		echo "$(tput setaf 11)moved epub files$(tput setaf 15)"; 
    		while read a ; do 
    			mv "./converted/${a%.*}.epub" "./epub/${a%.*}.epub";
    		done < ./source/list_md_mv
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	fi
    	if [ "$2" = "pdf" ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		if [ -d ./pdf ]; then
    			rm -rf ./pdf
    		fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		find ./docs.it4i -name "*.md" | 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read i; 
    		do 
    			a=$(basename "$i")
    			b=$(dirname "$i")
    			c=$(pwd)
    		
    			echo "$(tput setaf 12)($counter/$count)$(tput setaf 11)$a => $(tput setaf 13)${a%.*}.pdf$(tput setaf 15)"
    			#echo "$b"
    			counter=$((counter+1))
    			cd "$b"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				#!double subscripts problem !!!!!!
    				#ansys-fluent.md
    				#capacity-computing.md
    				#job-submission-and-execution.md
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				if [ $a = "job-submission-and-execution.md" ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					pandoc ${a%.*}.md -o ${a%.*}.epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					pandoc ${a%.*}.epub -V "geometry:paperwidth=8.26387in" -V "geometry:paperheight=29.7cm" -V "geometry:vmargin=1.4cm" -V "geometry:hmargin=1.6cm" -V "fontsize:12pt" -t latex --latex-engine=xelatex --mathml -o ${a%.*}.pdf
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					rm "${a%.*}.epub"
    				elif [ $a = "ansys-fluent.md" ]; then
    					pandoc ${a%.*}.md -o ${a%.*}.epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					pandoc ${a%.*}.epub -V "geometry:paperwidth=8.26387in" -V "geometry:paperheight=29.7cm" -V "geometry:vmargin=1.4cm" -V "geometry:hmargin=1.6cm" -V "fontsize:12pt" -t latex --latex-engine=xelatex --mathml -o ${a%.*}.pdf
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					rm "${a%.*}.epub"
    				elif [ $a = "capacity-computing.md" ]; then
    					pandoc ${a%.*}.md -o ${a%.*}.epub
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					pandoc ${a%.*}.epub -V "geometry:paperwidth=8.26387in" -V "geometry:paperheight=29.7cm" -V "geometry:vmargin=1.4cm" -V "geometry:hmargin=1.6cm" -V "fontsize:12pt" -t latex --latex-engine=xelatex --mathml -o ${a%.*}.pdf
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					rm "${a%.*}.epub"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				elif [ $a = "list_of_modules.md" ]; then
    					echo "big files..."
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				else
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    					#pandoc ${a%.*}.md  -t latex --latex-engine=xelatex --mathml -o ${a%.*}.pdf
    					pandoc -V "geometry:paperwidth=8.26387in" -V "geometry:paperheight=29.7cm" -V "geometry:vmargin=1.4cm" -V "geometry:hmargin=1.6cm" -V "fontsize:12pt" -t latex --latex-engine=xelatex --mathml -o ${a%.*}.pdf ${a%.*}.md
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    				fi
    			cd "$c"
    		done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		find ./docs.it4i -name "*.pdf" | 
    		while read i; 
    		do 
    			echo "$i" >> seznam.txt
    			rm "$i"
    		done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	fi
       ENDTIME=$(date +%s)
    	echo "It takes $(($ENDTIME - $STARTTIME)) seconds to complete this task..."
    fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    if [ "$1" = "-w" ]; then
    	# download html pages 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
       STARTTIME=$(date +%s)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	rm -rf docs.it4i.cz
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	wget -X pbspro-documentation,changelog,whats-new,portal_css,portal_javascripts,++resource++jquery-ui-themes,anselm-cluster-documentation/icon.jpg -R favicon.ico,pdf.png,logo.png,background.png,application.png,search_icon.png,png.png,sh.png,touch_icon.png,anselm-cluster-documentation/icon.jpg,*js,robots.txt,*xml,RSS,download_icon.png,pdf,*zip,*rar,@@*,anselm-cluster-documentation/icon.jpg.1 --mirror --convert-links --adjust-extension --page-requisites  --no-parent https://docs.it4i.cz;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	# download images
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	wget --directory-prefix=./docs.it4i.cz/ http://verif.cs.vsb.cz/aislinn/doc/report.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/virtualization/virtualization-job-workflow
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig1.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig2.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig3.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig4.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig5.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig6.png
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig7.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig7x.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig8.png
    	wget --directory-prefix=./docs.it4i.cz/ https://docs.it4i.cz/anselm-cluster-documentation/software/omics-master-1/images/fig9.png
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
       ENDTIME=$(date +%s)
    	echo "It takes $(($ENDTIME - $STARTTIME)) seconds to complete this task..."	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    fi
    if [ "$1" = "-c" ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	### convert html to md
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
       STARTTIME=$(date +%s)
       if [ -d ./docs.it4i.cz ]; then
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	# erasing the previous transfer
    
    	if [ -d ./docs.it4i ]; then
    			rm -rf ./docs.it4i
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	fi
    	if [ -d ./info ]; then
    			rm -rf ./info;
    	fi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	# erasing duplicate files and unwanted files
    	(while read i; 
    	do		
    		if [ -f "$i" ];
    		then
    			echo "$(tput setaf 9)$i deleted";
    		  	rm "$i";
    		fi
    	done) < ./source/list_rm
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    	# counter for html and md files	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	counter=1
    	count=$(find . -name "*.html" -type f | wc -l)
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	find . -name "*.ht*" | 
    	while read i; 
    	do 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# filtering html files
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		echo "$(tput setaf 12)($counter/$count)$(tput setaf 11)$i"; 
    		counter=$((counter+1))
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "$(tput setaf 15)\t\tFiltering html files...\n";
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		HEAD=$(grep -n -m1 '<h1' "$i" |cut -f1 -d: | tr --delete '\n')
    		END=$(grep -n -m1 '<!-- <div tal:content=' "$i" |cut -f1 -d: | tr --delete '\n')
    		LAST=$(wc -l "$i" | cut -f1 -d' ')
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		DOWN=$((LAST-END+2))
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		sed '1,'"$((HEAD-1))"'d' "$i" | sed -n -e :a -e '1,'"$DOWN"'!{P;N;D;};N;ba' > "${i%.*}TMP.html"	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# converted .html to .md
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\t.html => $(tput setaf 13).md\n$(tput setaf 15)"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		pandoc -f html -t markdown+pipe_tables-grid_tables "${i%.*}TMP.html" -o "${i%.*}.md"; 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		rm "${i%.*}TMP.html";
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# filtering html and css elements...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tFiltering html and css elements in md files...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		sed -e 's/``` /```/' "${i%.*}.md"  | sed -e 's/<\/div>//g' | sed '/^<div/d' | sed -e 's/<\/span>//' | sed -e 's/^\*\*//' | sed -e 's/\\//g' | sed -e 's/^: //g' | sed -e 's/^Obsah//g' > "${i%.*}TMP.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" > "${i%.*}TMP.TEST.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			cat -s "${i%.*}TMP.TEST.md" > "${i%.*}TMP.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done < ./source/replace 
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# repair formatting...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tFix formatting text...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" | sed -e 's/^``//g' > "${i%.*}TMP.TEST.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			cat -s "${i%.*}TMP.TEST.md" > "${i%.*}TMP.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done < ./source/formatting 
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# repair image...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tFix of links pictures...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" > "${i%.*}.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			cat -s "${i%.*}.md" > "${i%.*}TMP.md";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done < ./source/repairIMG
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# repair tables
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tFix formatting tables...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" > "${i%.*}.md";		
    			sed -e :a -e '/\\$/N; s/\\\n//; ta' "${i%.*}.md" > "${i%.*}TMP.md";
    		done < ./source/tab
    		
    		# replace tables
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tReplacement table...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" | sed -e 's/^>//' > "${i%.*}.md";		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    			cat -s "${i%.*}.md" > "${i%.*}TMP.md";
    		done < ./source/tabREPLACE
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# last repair formatting...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		printf "\t\tLatest fix formatting text...\n"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read x ; do 
    			arg1=`echo "$x" | cut -d"&" -f1 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;	
    			arg2=`echo "$x" | cut -d"&" -f2 | sed 's:[]\[\^\$\.\*\/\"]:\\\\&:g'`;
    	
    			sed -e 's/'"$arg1"'/'"$arg2"'/' "${i%.*}TMP.md" > "${i%.*}TMP.TEST.md";
    			cat -s "${i%.*}TMP.TEST.md" > "${i%.*}TMP.md";
    		done < ./source/lastFilter
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		cat "${i%.*}TMP.md" > "${i%.*}.md";
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# delete temporary files
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		rm "${i%.*}TMP.md";
    		rm "${i%.*}TMP.TEST.md";		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	# delete empty files
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	find -type f -size -10c | 
    	while read i; 
    	do
    		rm "$i"; 	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		echo "$(tput setaf 9)$i deleted"; 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    	### create new folder and move converted files
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	# create folder info and list all files and folders
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	mkdir info;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	echo "$(tput setaf 11)Create folder info and lists od files..."; 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	find ./docs.it4i.cz -name "*.png" -type f > ./info/list_image;
    	find ./docs.it4i.cz -name "*.jpg" -type f >> ./info/list_image;
    	find ./docs.it4i.cz -name "*.jpeg" -type f >> ./info/list_image;
    	find ./docs.it4i.cz -name "*.md" -type f> ./info/list_md; 
    	find ./docs.it4i.cz -type d | sort > ./info/list_folder;
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	count=$(find ./docs.it4i.cz -name "*.md" -type f | wc -l)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	if [ $count -eq 150 ]; then
    
    		mkdir docs.it4i;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		(while read i; 
    		do		
    
    			mkdir "./docs.it4i/$i";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done) < ./source/list_folder
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# move md files to folder converted
    		echo "$(tput setaf 11)Moved md files..."; 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read a b ; do 
    
    			mv "$a" "./docs.it4i/$b";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done < <(paste ./info/list_md ./source/list_md_mv)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# copy jpg, jpeg and png to folder converted
    
    		echo "$(tput setaf 11)Copy image files...";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		while read a b ; do 
    
    			cp "$a" "./docs.it4i/$b";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		done < <(paste ./info/list_image ./source/list_image_mv)
    
    		cp ./docs.it4i.cz/salomon/salomon ./docs.it4i/salomon/salomon
    		cp ./docs.it4i.cz/salomon/salomon-2 ./docs.it4i/salomon/salomon-2
    		cp ./docs.it4i/salomon/resource-allocation-and-job-execution/fairshare_formula.png ./docs.it4i/anselm-cluster-documentation/resource-allocation-and-job-execution/fairshare_formula.png
    		cp ./docs.it4i/salomon/resource-allocation-and-job-execution/job_sort_formula.png ./docs.it4i/anselm-cluster-documentation/resource-allocation-and-job-execution/job_sort_formula.png
    		cp ./docs.it4i/salomon/software/debuggers/vtune-amplifier.png ./docs.it4i/anselm-cluster-documentation/software/debuggers/vtune-amplifier.png
    		cp ./docs.it4i/salomon/software/debuggers/Snmekobrazovky20160708v12.33.35.png ./docs.it4i/anselm-cluster-documentation/software/debuggers/Snmekobrazovky20160708v12.33.35.png
    		cp ./docs.it4i.cz/virtualization-job-workflow ./docs.it4i/anselm-cluster-documentation/software/ 
    		cp ./docs.it4i.cz/anselm-cluster-documentation/anyconnecticon.jpg ./docs.it4i/salomon/accessing-the-cluster/anyconnecticon.jpg
    		cp ./docs.it4i.cz/anselm-cluster-documentation/anyconnectcontextmenu.jpg ./docs.it4i/salomon/accessing-the-cluster/anyconnectcontextmenu.jpg
    		cp ./docs.it4i.cz/get-started-with-it4innovations/accessing-the-clusters/graphical-user-interface/vnc/TightVNC_login.png ./docs.it4i/salomon/software/debuggers/TightVNC_login.png
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		# list all files and folder converted
    
    		find ./docs.it4i -name "*.png" -type f > ./info/list_image_converted;
    		find ./docs.it4i -name "*.jpg" -type f >> ./info/list_image_converted;
    		find ./docs.it4i -name "*.jpeg" -type f >> ./info/list_image_converted;
    		find ./docs.it4i -name "*.md" -type f> ./info/list_md_converted; 
    		find ./docs.it4i -type d | sort > ./info/list_folder_converted;	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    		echo "$(tput setaf 13)COMPLETED...$(tput setaf 15)"; 
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	else
    
    		printf "\n\n$(tput setaf 9)Can not create a folder docs.it4i, because the number of MD files disagrees. The converted files remain in the folder docs.it4i.cz !!!!...$(tput setaf 15)\n\n";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    	fi
       else
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
       	printf "\n\n$(tput setaf 9)Folder docs.it4i.cz not exists!!!!...$(tput setaf 15)\n\nRun html_md.sh -w\n\n";
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
       fi
       ENDTIME=$(date +%s)
       echo "It takes $(($ENDTIME - $STARTTIME)) seconds to complete this task..."
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    fi