mirror of
https://github.com/Paul-Houser/StartTree.git
synced 2024-11-21 15:03:08 +01:00
install now adds starttree.py to path, which can be run from any directory
This commit is contained in:
parent
8ef7375fac
commit
666cb6d933
24
generate.py
24
generate.py
@ -9,6 +9,10 @@ from bs4 import BeautifulSoup
|
||||
# get home directory
|
||||
home = expanduser("~")
|
||||
|
||||
# install script will fill this in
|
||||
# replace line
|
||||
repo_dir = "/home/paul/Documents/GitHub/StartTree"
|
||||
|
||||
# get config path
|
||||
config_dir = home + '/.config/StartTree'
|
||||
config_path = home + '/.config/StartTree/config.yaml'
|
||||
@ -45,28 +49,28 @@ def gen_list_indices(html_file, file_dict):
|
||||
def gen_col_headers(html_file, file_dict):
|
||||
for key in file_dict:
|
||||
html_file.write("<li>\n")
|
||||
html_file.write(" <h1>" + key + "</h1>\n")
|
||||
html_file.write(" <ul>\n")
|
||||
html_file.write("<h1>" + key + "</h1>\n")
|
||||
html_file.write("<ul>\n")
|
||||
|
||||
# generate list indices
|
||||
gen_list_indices(html_file, file_dict[key])
|
||||
|
||||
html_file.write(" </ul>\n")
|
||||
html_file.write("</ul>\n")
|
||||
html_file.write("</li>\n")
|
||||
|
||||
def gen_columns(html_file, file_dict):
|
||||
for key in file_dict:
|
||||
if key.split("_")[0] == "tree":
|
||||
html_file.write("<div class=\"column\">\n")
|
||||
html_file.write(" <div class=\"tree\">\n")
|
||||
html_file.write(" <h1>.</h1>\n")
|
||||
html_file.write(" <ul>\n")
|
||||
html_file.write("<div class=\"tree\">\n")
|
||||
html_file.write("<h1>.</h1>\n")
|
||||
html_file.write("<ul>\n")
|
||||
|
||||
# generate the column headers
|
||||
gen_col_headers(html_file, file_dict[key])
|
||||
|
||||
html_file.write(" </ul>\n")
|
||||
html_file.write(" </div>\n")
|
||||
html_file.write("</ul>\n")
|
||||
html_file.write("</div>\n")
|
||||
html_file.write("</div>\n")
|
||||
|
||||
|
||||
@ -74,7 +78,7 @@ def gen_html(file_dict):
|
||||
print("Generating index.html...")
|
||||
|
||||
# open files
|
||||
skeleton_html = open('./skeletons/index.html', 'r')
|
||||
skeleton_html = open(repo_dir + '/skeletons/index.html', 'r')
|
||||
cache_html = open(cache_dir + '/index.html', 'w+')
|
||||
|
||||
# copy skeleton_html to cache_html until Column Start comment
|
||||
@ -100,7 +104,7 @@ def gen_html(file_dict):
|
||||
print("Done!")
|
||||
|
||||
def gen_style(file_dict):
|
||||
skeleton_style = open('./skeletons/style.css', 'r')
|
||||
skeleton_style = open(repo_dir + '/skeletons/style.css', 'r')
|
||||
cache_style = open(cache_dir + '/styles/style.css', 'w')
|
||||
|
||||
# find style attributes in file_dict
|
||||
|
10
init.sh
10
init.sh
@ -4,6 +4,8 @@ config_dir=$HOME/.config/StartTree
|
||||
config_path=$HOME/.config/StartTree/config.yaml
|
||||
cache_dir=$HOME/.cache/StartTree
|
||||
|
||||
# install pip reqs
|
||||
echo "Downloading pip dependencies..."
|
||||
pip install --user bs4
|
||||
|
||||
# check if .config path exists
|
||||
@ -53,3 +55,11 @@ cp "./skeletons/style.css" "$cache_dir/styles/style.css"
|
||||
|
||||
echo "Creating Hack.ttf..."
|
||||
cp "./skeletons/Hack.ttf" "$cache_dir/styles/Hack.ttf"
|
||||
|
||||
# add to path
|
||||
FILEPATH=$(readlink -f "generate.py")
|
||||
ln -s $FILEPATH $HOME/.local/bin/starttree.py
|
||||
echo "generate.py has been linked to $HOME/.local/bin/"
|
||||
echo "Make sure this directory is in your \$PATH"
|
||||
|
||||
sed -i "/# replace line/{n;s@.*@repo_dir = \"$(pwd)\"@}" generate.py
|
||||
|
Loading…
Reference in New Issue
Block a user