Browse Source

Ability to include local files

Volodymyr Tkach 1 year ago
parent
commit
961815e4a8
2 changed files with 12 additions and 2 deletions
  1. 11 1
      assets.sh
  2. 1 1
      test/test.css

+ 11 - 1
assets.sh

@@ -50,7 +50,17 @@ while read -r line; do
 
 
 				DATA_TO_IMPORT=""
 				DATA_TO_IMPORT=""
 				if [[ ! -f "${CACHE_FILE}" ]]; then
 				if [[ ! -f "${CACHE_FILE}" ]]; then
-					DATA_TO_IMPORT=$(curl -s "${FILE_TO_IMPORT}")
+					# Local import
+					if [[ ${FILE_TO_IMPORT} == "./"* ]]; then
+						FILE_TO_IMPORT="$(dirname "${SOURCE_FILE}")$(echo "${FILE_TO_IMPORT}" | sed 's/^\.//')"
+						if [[ -f "${FILE_TO_IMPORT}" ]]; then
+							DATA_TO_IMPORT=$(cat "${FILE_TO_IMPORT}")
+						fi
+					fi
+					# Remote import
+					if [[ ${FILE_TO_IMPORT} == "http"* ]]; then
+						DATA_TO_IMPORT=$(curl -s "${FILE_TO_IMPORT}")
+					fi
 					echo "${DATA_TO_IMPORT}" > ${CACHE_FILE}
 					echo "${DATA_TO_IMPORT}" > ${CACHE_FILE}
 				else
 				else
 					DATA_TO_IMPORT=$(cat ${CACHE_FILE})
 					DATA_TO_IMPORT=$(cat ${CACHE_FILE})

+ 1 - 1
test/test.css

@@ -1 +1 @@
-*,::after,::before{box-sizing:border-box}html{height:100%;line-height:1.5}body{color:#212529;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;margin:0;padding:0}.clear::after{clear:both;content:'';display:block;height:0;line-height:0;margin:0;padding:0}.checkbox-ios{display:inline-block;height:20px;vertical-align:middle;width:35px}.checkbox-ios input[type=checkbox]{max-height:0;max-width:0;opacity:0;position:absolute}.checkbox-ios input[type=checkbox]+label{border-radius:24px;border:2px solid #212529;cursor:pointer;display:block;height:20px;margin-bottom:0;margin-top:0;position:relative;text-indent:-5000px;width:35px}.checkbox-ios input[type=checkbox]+label:before{background:#212529;border-radius:24px;content:"";display:block;height:12px;left:2px;position:absolute;top:2px;transition:.1s ease-in-out;width:12px}.checkbox-ios input[type=checkbox]:checked+label{border-color:#212529}.checkbox-ios input[type=checkbox]:focus+label{box-shadow:0 0 0 .25rem rgb(13 110 253 / 25%);outline:0}.checkbox-ios input[type=checkbox]:checked+label:before{background:#212529;left:17px}.checkbox-ios input[type=checkbox]+label:after{border-color:#212529;border-style:solid;border-width:0 0 2px 2px;content:"";display:block;height:5px;left:6px;opacity:0;position:absolute;top:7px;transform:translate3d(-50%,-50%,0) rotate(-45deg);transition:.1s ease-in-out;width:7px}.checkbox-ios input[type=checkbox]:checked+label:after{border-color:#212529;opacity:1}.example{background-color:red}
+*,::after,::before{box-sizing:border-box}html{height:100%;line-height:1.5}body{color:#212529;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:16px;font-weight:400;margin:0;padding:0}.clear::after{clear:both;content:'';display:block;height:0;line-height:0;margin:0;padding:0}.checkbox-ios{display:inline-block;height:20px;vertical-align:middle;width:35px}.checkbox-ios input[type=checkbox]{max-height:0;max-width:0;opacity:0;position:absolute}.checkbox-ios input[type=checkbox]+label{border-radius:24px;border:2px solid #212529;cursor:pointer;display:block;height:20px;margin-bottom:0;margin-top:0;position:relative;text-indent:-5000px;width:35px}.checkbox-ios input[type=checkbox]+label:before{background:#212529;border-radius:24px;content:"";display:block;height:12px;left:2px;position:absolute;top:2px;transition:.1s ease-in-out;width:12px}.checkbox-ios input[type=checkbox]:checked+label{border-color:#212529}.checkbox-ios input[type=checkbox]:focus+label{box-shadow:0 0 0 .25rem rgb(13 110 253 / 25%);outline:0}.checkbox-ios input[type=checkbox]:checked+label:before{background:#212529;left:17px}.checkbox-ios input[type=checkbox]+label:after{border-color:#212529;border-style:solid;border-width:0 0 2px 2px;content:"";display:block;height:5px;left:6px;opacity:0;position:absolute;top:7px;transform:translate3d(-50%,-50%,0) rotate(-45deg);transition:.1s ease-in-out;width:7px}.checkbox-ios input[type=checkbox]:checked+label:after{border-color:#212529;opacity:1}.example{background-color:red}.local{background-color:green}.subdir{background-color:purple}.example2{background-color:yellow}