GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — shell-scripts/code-for-web.sh at master · Janis-Rullis-IT/shell-scripts Expand file tree/ Copy pathcode-for-web.shMore file actions executable file ·114 lines (96 loc) · 3.11 KB / Copy pathcode-for-web.shFile metadata and controlsexecutable file ·114 lines (96 loc) · 3.11 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 #!/bin/bash # sudo ln -s ~/Desktop/www/shell-scripts/code-for-web.sh /usr/local/bin/code-for-web # sudo chmod a+x /usr/local/bin/code-for-web echo "== Generarte HTML, XML, JSON for static pages == Example code-for-web 20190820-Kurzeme-Klaipeda-0002-Pavilosta-by-Janis-Rullis Pavilosta 2019:08:20 1 0 "; if [[ ! -n $1 ]]; then echo "Filename?"; exit; fi if [[ ! -n $2 ]]; then echo "Description?"; exit; fi if [[ ! -n $3 ]]; then echo "Date?"; exit; fi if [[ ! -n $4 ]]; then echo "Image count?"; exit; fi if [[ ! -n $5 ]]; then echo "Image INDEX?"; exit; fi # #2 https://clubmate.fi/replace-strings-in-files-with-the-sed-bash-command/#Replace_an_array_of_values # Associative array where key represents a search string, # and the value itself represents the replace string. declare -A confs DATE=$3; DATE_SHORT=${DATE//:/}; DESCRIPTION=$2 IMG_CNT=$4; IMG_INDEX=$5; DATE_W_DOTS=`tr ':' '.' <<< ${DATE}`.; confs=( [DATE_W_HYPENS]=`tr ':' '-' <<< ${DATE}` [DATE_W_DOTS]=$DATE_W_DOTS [DATE_SHORT]=$DATE_SHORT [HTML_FILENAME]="${DATE_SHORT}-${DESCRIPTION}.html" [XML_FILENAME]="${DATE_SHORT}-${DESCRIPTION}.xml" [HTML_SHORT_TITLE]="${DATE_W_DOTS} ${DESCRIPTION}" [HTML_TITLE]="Analog Photography | ${DATE_W_DOTS} ${DESCRIPTION} | ruu.lv" [IMG_FILENAME]=$1 [DESCRIPTION]=$DESCRIPTION ) setVariables(){ if [[ ! -n $1 ]]; then echo "Filename?"; exit; fi target=$1 for i in "${!confs[@]}" do search=$i replace=${confs[$i]} sed -i -e "s/${search}/${replace}/g" $target; done } # #2 tpl.html can be found in https://github.com/ruu-lv/content_gen # #7 TODO: Replace tpl vars and actions with an array and a for-loop. # #3 Create a fresh HTML, Sitemap XML if this is the first image. if [[ $IMG_INDEX == 0 ]]; then cat /usr/local/bin/news.header.tpl.html > ${confs[HTML_FILENAME]}; setVariables ${confs[HTML_FILENAME]}; cat /usr/local/bin/news.header.tpl.xml > ${confs[XML_FILENAME]}; setVariables ${confs[XML_FILENAME]}; # #7 Vidoe pages. cat /usr/local/bin/video.tpl.html > video-${confs[HTML_FILENAME]}; setVariables video-${confs[HTML_FILENAME]}; cat /usr/local/bin/video.tpl.xml > video-${confs[XML_FILENAME]}; setVariables video-${confs[XML_FILENAME]}; cat /usr/local/bin/video.amp.tpl.html > video-amp-${confs[HTML_FILENAME]}; setVariables video-amp-${confs[HTML_FILENAME]}; echo "" > img.html; echo "" > img.xml; fi # #2 Append the image template block to the target HTML. cat /usr/local/bin/img.tpl.html >> img.html setVariables img.html # #5 Append the image template block to the target Sitemap XML. cat /usr/local/bin/img.tpl.xml >> img.xml setVariables img.xml # #3 Merge HTML and Sitemap XML parts if this is the last image. if [[ $IMG_INDEX == $((IMG_CNT-1)) ]]; then cat img.html >> ${confs[HTML_FILENAME]}; cat /usr/local/bin/news.footer.tpl.html >> ${confs[HTML_FILENAME]}; rm img.html echo ${confs[HTML_FILENAME]}; cat img.xml >> ${confs[XML_FILENAME]}; cat /usr/local/bin/news.footer.tpl.xml >> ${confs[XML_FILENAME]}; rm img.xml echo ${confs[XML_FILENAME]}; fi |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |