Compare commits
2 Commits
31a5a00c82
...
b7465c516d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b7465c516d | ||
|
|
880799c06c |
15
balloon.py
15
balloon.py
@@ -104,30 +104,27 @@ def main() -> None:
|
|||||||
# Incorrect number of arguments
|
# Incorrect number of arguments
|
||||||
# Long help flag
|
# Long help flag
|
||||||
# Short help flag
|
# Short help flag
|
||||||
if len(sys.argv) != 2 or (
|
if len(sys.argv) != 3 or (
|
||||||
sys.argv[0] == '--help'
|
sys.argv[0] == '--help'
|
||||||
or sys.argv[0] == '-h'
|
or sys.argv[0] == '-h'
|
||||||
):
|
):
|
||||||
help()
|
help()
|
||||||
return
|
return
|
||||||
|
|
||||||
file_name = sys.argv[1].removeprefix('src/')
|
with open(str(WORK_DIR) + sys.argv[1], 'rt') as f:
|
||||||
|
|
||||||
with open(str(WORK_DIR) + 'src/' + file_name, 'rt') as f:
|
|
||||||
html_src = HTML(f.read())
|
html_src = HTML(f.read())
|
||||||
|
|
||||||
|
# Patch to make sure that target paths are available.
|
||||||
try:
|
try:
|
||||||
os.makedirs(str(WORK_DIR) + 'target/' + os.path.dirname(file_name))
|
os.makedirs(str(WORK_DIR) + os.path.dirname(sys.argv[2]))
|
||||||
except FileExistsError:
|
except FileExistsError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
with open(str(WORK_DIR) + 'target/' + file_name, 'w') as f:
|
with open(str(WORK_DIR) + sys.argv[2], 'w') as f:
|
||||||
f.write(html_src.write())
|
f.write(html_src.write())
|
||||||
|
|
||||||
def help() -> None:
|
def help() -> None:
|
||||||
print('Usage: python balloon.py [OPTIONS] <SOURCE>')
|
print('Usage: python balloon.py [OPTIONS] <SOURCE> <DESTINATION>')
|
||||||
print()
|
|
||||||
print('Note: balloon implicitly assumes that <SOURCE> is in src/, and should inflate into target/')
|
|
||||||
print()
|
print()
|
||||||
print()
|
print()
|
||||||
print('Options:')
|
print('Options:')
|
||||||
|
|||||||
73
build.sh
73
build.sh
@@ -1,12 +1,13 @@
|
|||||||
#! /usr/bin/bash
|
#!/usr/bin/bash
|
||||||
#
|
#
|
||||||
# I'm new to bash scripting, so give me a break.
|
# I'm new to bash scripting, so give me a break.
|
||||||
# I know that this is probably crap, but it's cheap, dirty, and does the job.
|
# I know that this is probably crap, but it's cheap, dirty, and does the job.
|
||||||
|
|
||||||
python=~/.pyenv/versions/3.12.9/bin/python
|
|
||||||
green='\e[32m'
|
green='\e[32m'
|
||||||
cyan='\e[36m'
|
cyan='\e[36m'
|
||||||
|
|
||||||
|
src_prefix='src/'
|
||||||
|
|
||||||
# The "a" is just to make this work if no characters are present in $@
|
# The "a" is just to make this work if no characters are present in $@
|
||||||
args=$@
|
args=$@
|
||||||
args+=('a')
|
args+=('a')
|
||||||
@@ -18,57 +19,54 @@ else
|
|||||||
args='inflate style copy'
|
args='inflate style copy'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Cheap patch for copying in case the paths aren't present.
|
||||||
mkdir -p target/.well-known
|
mkdir -p target/.well-known
|
||||||
|
|
||||||
for x in $args
|
for x in $args
|
||||||
do
|
do
|
||||||
|
cmd=''
|
||||||
|
|
||||||
|
files=''
|
||||||
|
|
||||||
|
src_ext=''
|
||||||
|
target_ext=''
|
||||||
|
|
||||||
if [ "$x" == 'inflate' ]
|
if [ "$x" == 'inflate' ]
|
||||||
then
|
then
|
||||||
echo -e "$green"Inflating...
|
cmd='~/.pyenv/versions/3.12.9/bin/python balloon.py'
|
||||||
|
|
||||||
files=(`ls src/*.html`)
|
files=(`ls src/*.html`)
|
||||||
|
# Because bash won't let **/ find files without another nested dir.
|
||||||
|
files+=(`ls src/blog/*.html`) # This wouldn't be needed under zsh.
|
||||||
|
files+=(`ls src/blog/**/*.html`)
|
||||||
files+=(`ls src/errors/*.html`)
|
files+=(`ls src/errors/*.html`)
|
||||||
files+=(`ls src/blog/*.html`)
|
|
||||||
|
|
||||||
for html in "${files[@]}"
|
action=Inflating...
|
||||||
do
|
|
||||||
echo -e " $cyan$html"
|
|
||||||
|
|
||||||
eval $python 'balloon.py' $html
|
|
||||||
done
|
|
||||||
|
|
||||||
elif [ "$x" == 'style' ]
|
elif [ "$x" == 'style' ]
|
||||||
then
|
then
|
||||||
echo -e "$green"Styling...
|
cmd='sass'
|
||||||
|
|
||||||
files=(
|
files=(`ls src/**/style.scss`)
|
||||||
'style'
|
|
||||||
'errors/style'
|
|
||||||
'blog/style'
|
|
||||||
)
|
|
||||||
|
|
||||||
for stylesheet in "${files[@]}"
|
src_ext='.scss'
|
||||||
do
|
target_ext='.css'
|
||||||
echo -e "$cyan src/$stylesheet.scss -> target/$stylesheet.css"
|
|
||||||
sass src/$stylesheet.scss target/$stylesheet.css
|
action=Styling...
|
||||||
done
|
|
||||||
|
|
||||||
elif [ "$x" == 'copy' ]
|
elif [ "$x" == 'copy' ]
|
||||||
then
|
then
|
||||||
echo -e "$green"Copying...
|
cmd='cp -Ru'
|
||||||
|
|
||||||
files=(
|
files=(
|
||||||
'.well-known/security.txt'
|
'src/.well-known/'
|
||||||
'img'
|
'src/feed/'
|
||||||
'robots.txt'
|
'src/img/'
|
||||||
|
'src/robots.txt'
|
||||||
)
|
)
|
||||||
|
|
||||||
for item in "${files[@]}"
|
action=Copying...
|
||||||
do
|
|
||||||
echo -e "$cyan src/$item"
|
|
||||||
|
|
||||||
cp -Ru src/$item target/$item
|
|
||||||
done
|
|
||||||
else
|
else
|
||||||
echo -e "$green"Usage:"$cyan" build.sh [OPTIONS] [COMMAND]
|
echo -e "$green"Usage:"$cyan" build.sh [OPTIONS] [COMMAND]
|
||||||
echo
|
echo
|
||||||
@@ -79,5 +77,20 @@ do
|
|||||||
echo ' inflate Inflate the HTML source'
|
echo ' inflate Inflate the HTML source'
|
||||||
echo ' style Compile SCSS to CSS'
|
echo ' style Compile SCSS to CSS'
|
||||||
echo ' copy Copy assets to target'
|
echo ' copy Copy assets to target'
|
||||||
|
|
||||||
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo -e "$green$action"
|
||||||
|
|
||||||
|
for src in "${files[@]}"
|
||||||
|
do
|
||||||
|
target="${src//$src_prefix}"
|
||||||
|
target="${target//$src_ext}"
|
||||||
|
target="target/$target$target_ext"
|
||||||
|
|
||||||
|
echo -e "$cyan $src -> $target"
|
||||||
|
|
||||||
|
eval "$cmd $src $target"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
|
|||||||
3
src/blog/posts/style.scss
Normal file
3
src/blog/posts/style.scss
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
@use "../../partials/a_common";
|
||||||
|
|
||||||
|
@use "../../partials/pane_blog";
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
@use "../partials/a_common";
|
@use "../partials/a_common";
|
||||||
|
|
||||||
@use "../partials/pane_blog";
|
@use "../partials/pane_main";
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
@use "a_quick_links";
|
@use "a_quick_links";
|
||||||
@use "a_pages";
|
@use "a_pages";
|
||||||
|
|
||||||
@use "pane_main";
|
|
||||||
@use "pane_nav";
|
@use "pane_nav";
|
||||||
@use "pane_spacer";
|
@use "pane_spacer";
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,3 @@
|
|||||||
@use "partials/a_common";
|
@use "partials/a_common";
|
||||||
|
|
||||||
|
@use "partials/pane_main";
|
||||||
|
|||||||
Reference in New Issue
Block a user