diff --git a/custom_syadmin/git_hooks_post-receive.py b/custom_syadmin/git_hooks_post-receive.py
index 50502da..17c0977 100644
--- a/custom_syadmin/git_hooks_post-receive.py
+++ b/custom_syadmin/git_hooks_post-receive.py
@@ -9,7 +9,6 @@ python "D:\dev\websites\sandpoints-dev\custom_syadmin\git_hooks_post-receive.py"
--git_repo "D:\dev\websites\pirate-care-syllabus\gitea\gitea-repositories\gitea\pirate-care-syllabus.git" \
--website "D:\dev\websites\testing-ground\sandpoints" \
--website_preview "D:\dev\websites\testing-ground\sandpoints\_preview" \
---hugo_preview_url http://localhost:8000/_preview/ \
--library "D:\dev\websites\pirate-care-syllabus\_library" \
--tmp_dir "D:\tmp\tmp"
--oldrev $oldrev \
@@ -22,7 +21,7 @@ python "D:\dev\websites\sandpoints-dev\custom_syadmin\git_hooks_post-receive.py"
Just a mental note to read refs from the post-receive hook like this:
-oldrev,newrev,refname = sys.stdin.readline().strip().split(’ ‘)
+oldrev,newrev,refname = sys.stdin.readline().strip().split(' ')
"""
import os
@@ -53,6 +52,7 @@ vars = {
'tmp_dir': '/tmp',
'force': False,
'branch': None,
+ 'preview_branch': None,
}
# logging time
@@ -83,14 +83,20 @@ def cmd(parts, cwd=None, env=None):
return subprocess.check_output(parts, cwd=cwd, env=env, universal_newlines=True).strip()
-def rmrf(path):
+def rmrf(path, keep_dir=False):
""" Use safe-rm for recursive removal """
""" @TODO: make it safer """
def remove_readonly(func, path, excinfo):
os.chmod(path, stat.S_IWRITE)
func(path)
# Try removal
- if os.path.exists(path) and len(os.path.realpath(path)) > 1:
+ if keep_dir and os.path.exists(path) and len(os.path.realpath(path)) > 1:
+ for root, dirs, files in os.walk(path):
+ for f in files:
+ os.unlink(os.path.join(root, f))
+ for d in dirs:
+ shutil.rmtree(os.path.join(root, d), onerror=remove_readonly)
+ elif os.path.exists(path) and len(os.path.realpath(path)) > 1:
shutil.rmtree(path, onerror=remove_readonly)
else:
print("Either the path doesn't exist or you are trying to delete the root directory(?!):", path)
@@ -108,12 +114,19 @@ def build_site(dest, tmp, branch=None, hugo_environment='gitea'):
global GIT_PATH, GIT_REPO, HUGO_PATH
if branch:
print("Cloning branch: ", branch)
- cmd([GIT_PATH, 'clone', '--single-branch', '--branch', branch, '.', tmp], cwd=GIT_REPO)
+ cmd([GIT_PATH, 'clone', '--branch', branch, '.', tmp], cwd=GIT_REPO)
+ #print(' '.join([GIT_PATH, 'archive', '--format', 'tar', branch, '|', 'tar', '-x', '-C', tmp]))
+ #subprocess.call(' '.join([GIT_PATH, 'archive', '--format', 'tar', branch, '|', 'tar', '-x', '-C', tmp]), shell=True, cwd=GIT_REPO)
else:
cmd([GIT_PATH, 'clone', '.', tmp], cwd=GIT_REPO)
- rmrf(dest)
+ rmrf(os.path.join(tmp, '.git'))
+ rmrf(dest, keep_dir=True)
try:
- os.makedirs(dest, exist_ok=True)
+ if not os.path.exists(dest):
+ os.makedirs(dest)
+ print("Build destination created: ", dest)
+ else:
+ print("Build destination exists: ", dest)
except:
print(f"Error creating the directory: {dest}")
lcl = f'{tmp}/last-commit-log.txt'
@@ -129,7 +142,6 @@ def build_site(dest, tmp, branch=None, hugo_environment='gitea'):
now_time = datetime.now().strftime(date_format)
clobber(lcl, f"\n{start_time}\n{now_time}", append=True)
shutil.move(lcl, dest)
- rmrf(tmp)
# Parsing command line arguments
@@ -156,19 +168,23 @@ published = False
refs = cmd([GIT_PATH, 'diff-tree', '--no-commit-id', '--name-only', REF], cwd=GIT_REPO).split("\n")
for r in refs:
if FORCE or r == "PUBLISH.trigger.md":
- build_site(WEBSITE, TMP_WEBSITE)
+ build_site(WEBSITE, TMP_WEBSITE, branch=BRANCH)
published = True
# Check if there is a !publish!
if not published:
refs = cmd([GIT_PATH, 'show', '--format="%s"', '-s'], cwd=GIT_REPO).split(' ')
for r in refs:
if r == "!publish!":
- build_site(WEBSITE, TMP_WEBSITE)
+ build_site(WEBSITE, TMP_WEBSITE, branch=BRANCH)
published = True
# Let the world know if there hasn't been a publish
if not published:
print("The site wasn't build because there was no publish trigger, nor was it forced.")
# create preview version
-build_site(WEBSITE_PREVIEW, TMP_WEBSITE_PREVIEW, branch=BRANCH, hugo_environment='preview')
-
+build_site(WEBSITE_PREVIEW, TMP_WEBSITE_PREVIEW, branch=PREVIEW_BRANCH, hugo_environment='preview')
+
+# Clean up temp directories
+rmrf(TMP_WEBSITE)
+rmrf(TMP_WEBSITE_PREVIEW)
+
# @TODO: link the library
\ No newline at end of file
diff --git a/static/css/site.css b/static/css/site.css
new file mode 100644
index 0000000..e1289eb
--- /dev/null
+++ b/static/css/site.css
@@ -0,0 +1 @@
+stdin 436:3 ⚠ grid-auto-flow works only if grid-template-rows and grid-template-columns are present in the same rule [autoprefixer] html{line-height:1.15;-webkit-text-size-adjust:100%}body{margin:0}main{display:block}h1{font-size:2em;margin:.67em 0}hr{box-sizing:content-box;height:0;overflow:hidden;border-width:0}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}button,[type=button],[type=reset],[type=submit]{-webkit-appearance:button}button::-moz-focus-inner,[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}@font-face{font-family:vollkorn;font-style:italic;font-weight:500;src:url(../fonts/vollkorn-v12-latin-ext_latin-500italic.eot);src:local(''),url(../fonts/vollkorn-v12-latin-ext_latin-500italic.eot?#iefix)format('embedded-opentype'),url(../fonts/vollkorn-v12-latin-ext_latin-500italic.woff2)format('woff2'),url(../fonts/vollkorn-v12-latin-ext_latin-500italic.woff)format('woff'),url(../fonts/vollkorn-v12-latin-ext_latin-500italic.ttf)format('truetype'),url(../fonts/vollkorn-v12-latin-ext_latin-500italic.svg#Vollkorn)format('svg')}@font-face{font-family:vollkorn;font-style:normal;font-weight:400;src:url(../fonts/vollkorn-v12-latin-ext_latin-regular.eot);src:local(''),url(../fonts/vollkorn-v12-latin-ext_latin-regular.eot?#iefix)format('embedded-opentype'),url(../fonts/vollkorn-v12-latin-ext_latin-regular.woff2)format('woff2'),url(../fonts/vollkorn-v12-latin-ext_latin-regular.woff)format('woff'),url(../fonts/vollkorn-v12-latin-ext_latin-regular.ttf)format('truetype'),url(../fonts/vollkorn-v12-latin-ext_latin-regular.svg#Vollkorn)format('svg')}@font-face{font-family:vollkorn;font-style:normal;font-weight:500;src:url(../fonts/vollkorn-v12-latin-ext_latin-500.eot);src:local(''),url(../fonts/vollkorn-v12-latin-ext_latin-500.eot?#iefix)format('embedded-opentype'),url(../fonts/vollkorn-v12-latin-ext_latin-500.woff2)format('woff2'),url(../fonts/vollkorn-v12-latin-ext_latin-500.woff)format('woff'),url(../fonts/vollkorn-v12-latin-ext_latin-500.ttf)format('truetype'),url(../fonts/vollkorn-v12-latin-ext_latin-500.svg#Vollkorn)format('svg')}@font-face{font-family:vollkorn;font-style:italic;font-weight:400;src:url(../fonts/vollkorn-v12-latin-ext_latin-italic.eot);src:local(''),url(../fonts/vollkorn-v12-latin-ext_latin-italic.eot?#iefix)format('embedded-opentype'),url(../fonts/vollkorn-v12-latin-ext_latin-italic.woff2)format('woff2'),url(../fonts/vollkorn-v12-latin-ext_latin-italic.woff)format('woff'),url(../fonts/vollkorn-v12-latin-ext_latin-italic.ttf)format('truetype'),url(../fonts/vollkorn-v12-latin-ext_latin-italic.svg#Vollkorn)format('svg')}@font-face{font-family:great vibes;font-style:normal;font-weight:400;src:url(../fonts/great-vibes-v7-latin-ext_latin-regular.eot);src:local('Great Vibes'),local('GreatVibes-Regular'),url(../fonts/great-vibes-v7-latin-ext_latin-regular.eot?#iefix)format('embedded-opentype'),url(../fonts/great-vibes-v7-latin-ext_latin-regular.woff2)format('woff2'),url(../fonts/great-vibes-v7-latin-ext_latin-regular.woff)format('woff'),url(../fonts/great-vibes-v7-latin-ext_latin-regular.ttf)format('truetype'),url(../fonts/great-vibes-v7-latin-ext_latin-regular.svg#GreatVibes)format('svg')}body{font-family:vollkorn,serif;font-weight:400;max-width:1024px;font-size:1.4rem;padding-left:3rem;padding-top:.5rem;color:#000}.header{display:-ms-grid;display:grid;grid-auto-flow:column;position:-webkit-sticky;position:sticky;top:0;padding-top:.5rem;font-size:1.1rem;background-color:#fff;z-index:10}.topicbar{display:none}.breadcrumbs{-ms-grid-column:1;grid-column:1}.bibliotheke{width:2.4rem;-ms-grid-column:2;grid-column:2;margin-left:auto}.bibliotheke:hover{text-decoration:none;font-size:1rem}.logolink{width:2.4rem;margin-left:auto}.sandpointlogo{border-radius:50%;border:.3em solid red;display:-webkit-inline-box;display:inline-flex;font-family:great vibes,cursive;font-size:1.2rem;font-weight:700;color:#fff;background-color:red;position:relative;padding-left:1em;padding-right:.3em;padding-bottom:1.2em;max-width:0;max-height:0}.sandpointF{position:absolute;font-size:1.2em;margin-top:-.2em;margin-left:-.4em}.sandpointN{position:absolute;font-size:.7em;margin-top:.4em;color:red;margin-left:-.5em}.sandpointC{position:absolute;font-size:1em;margin-left:-.37em}footer{display:-webkit-box;display:flex;margin-bottom:1rem;margin-top:4rem}li{list-style-type:"› "}li[role=doc-endnote]{list-style-type:decimal}img{width:100%}.sup{display:-webkit-inline-box;display:inline-flex;flex-wrap:nowrap;font-family:great vibes,cursive;font-size:.9em;font-style:normal;color:red;vertical-align:baseline;position:relative;top:-.3em}.sup:hover{font-weight:400!important}.syllabustitle,.coretitle{margin-top:4rem;font-style:italic;font-size:4rem;margin-bottom:4rem}.mantletitle,.crusttitle{margin-top:4rem;font-style:italic;font-size:2rem;margin-bottom:4rem}.has,.afterhas{font-style:italic;font-size:1.4rem}.grid{padding-left:3rem;margin-bottom:4rem;display:-ms-grid;display:grid;-ms-grid-columns:1fr 1fr;grid-template-columns:1fr 1fr}.leftcolumn{-ms-grid-column:1;grid-column:1;padding-right:1.2rem;position:relative}#TableOfContents{margin-left:-2rem;margin-top:-1.5rem}#TableOfContents li{list-style:decimal inside;padding-left:.5rem;color:rgba(0,0,0,.4);margin:0;padding:0}#TableOfContents li a{font-family:vollkorn;font-size:1.4rem;font-weight:500;font-style:normal}#TableOfContents>ol:first-child>span>li>a::after{content:"¶";color:rgba(0,0,0,.2);font-size:1.3em;padding-left:.1em}.rightcolumn{-ms-grid-column:2;grid-column:2;display:-ms-grid;display:grid;-ms-grid-columns:auto 1fr;grid-template-columns:auto 1fr;padding-left:.5rem}.has{-ms-grid-column:1;grid-column:1}.content{margin-top:4rem;padding-left:3rem;padding-right:10rem;max-width:720px}a{color:#000;text-decoration:none}a:hover{text-decoration:underline;-webkit-text-decoration-color:red;text-decoration-color:red;font-weight:500;font-size:.97em;cursor:pointer}h1{display:none}h2{font-weight:500;font-size:1.6rem}h3{font-weight:500;font-size:1.4rem}h4{font-weight:500;font-size:1.2rem}h5{font-weight:500;font-size:1.1rem}h6{font-weight:500;font-size:1rem}blockquote{font-style:italic;border-left:1px red solid;padding-left:1rem;padding-right:2rem;padding-top:.1rem;padding-bottom:.1rem;background-color:#fff9f9}h2+p:first-letter{font-family:great vibes,cursive;color:rgba(0,0,0,.8);font-size:1.5em;line-height:0}.hx{position:relative}.hpar{position:absolute;font-size:1.7em;font-style:normal;color:rgba(0,0,0,.1);top:0;margin-top:-.4em}body{counter-reset:h2}h2{counter-reset:h3}h3{counter-reset:h4}h4{counter-reset:h5}h5{counter-reset:h6}h2:before{color:rgba(0,0,0,.4);counter-increment:h2;content:counter(h2)". "}h3:before{color:rgba(0,0,0,.4);counter-increment:h3;content:counter(h2)"." counter(h3)". "}h4:before{color:rgba(0,0,0,.4);counter-increment:h4;content:counter(h2)"." counter(h3)"." counter(h4)". "}h5:before{color:rgba(0,0,0,.4);counter-increment:h5;content:counter(h2)"." counter(h3)"." counter(h4)"." counter(h5)". "}h6:before{color:rgba(0,0,0,.4);counter-increment:h6;content:counter(h2)"." counter(h3)"." counter(h4)"." counter(h5)"." counter(h6)". "}h2.nocount:before,h3.nocount:before,h4.nocount:before,h5.nocount:before,h6.nocount:before{content:"";counter-increment:none}@media(max-width:361px){html{box-sizing:border-box;max-width:360px;margin:0 auto;padding:0}body{font-size:1rem;padding-left:10px;padding-right:10px}.grid{display:inline}.syllabustitle{margin-top:3rem;margin-bottom:2rem;font-size:2.2rem}.leftcolumn{display:none}.has,.afterhas{font-size:1.1rem}.session,.topic{margin-bottom:.2em}.content{padding:0;margin:0 auto;margin-top:4rem}.hpar{display:none}.topicstitle{font-size:1.7rem}.sessiongrid{display:none}}
\ No newline at end of file
diff --git a/themes/sandpoints/layouts/partials/css.html b/themes/sandpoints/layouts/partials/css.html
index e166088..feeb06c 100644
--- a/themes/sandpoints/layouts/partials/css.html
+++ b/themes/sandpoints/layouts/partials/css.html
@@ -1,8 +1,8 @@
-{{ if eq hugo.Environment "gitea" }}
+{{ if (or (eq hugo.Environment "gitea") (eq hugo.Environment "preview") ) }}
{{ else if .Site.IsServer }}
- {{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify | fingerprint }}
-
+ {{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
+
{{ else }}
{{ $flist := newScratch }}
{{ $flist.Set "initial" "nop" }}
@@ -21,7 +21,7 @@
{{ if in $css "css" }}
{{ else }}
- {{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify | fingerprint }}
-
+ {{ $style := resources.Get "css/site.css" | postCSS (dict "config" "./assets/css/postcss.config.js") | minify }}
+
{{ end }}
{{ end }}