added skeletons, more work done on install.py

This commit is contained in:
Paul Houser 2020-08-23 23:38:15 -07:00
parent 4375bed7e1
commit da735327cb
4 changed files with 212 additions and 29 deletions

View File

@ -12,11 +12,19 @@ home = expanduser("~")
config_dir = home + '/.config/StartTree'
config_path = home + '/.config/StartTree/config.yaml'
# get cache path
cache_dir = home + '/.cache/StartTree'
def setup():
# check if .config path exists
if not os.path.isdir(home + '/.config'):
print("The directory '~/.config' does not exist, or you do not have permissions to edit it.")
exit()
if not os.path.isdir(home + '/.cache'):
print("The directory '~/.cache' does not exist, or you do not have permissions to edit it.")
exit()
# check if .config/StartTree exists, create it and config if not
if not os.path.isdir(config_dir):
print("Creating '~/.config/StartTree'...")
@ -33,13 +41,58 @@ if not os.path.exists(config_path):
print("or create your own in that directory.")
exit()
# create directory structure in .cache
if not os.path.isdir(cache_dir):
print("Creating '" + cache_dir + "'...")
os.mkdir(cache_dir)
file_dict = {}
num_columns = 0
print("Creating '" + cache_dir + "/styles'")
os.mkdir(cache_dir + '/styles')
print("Creating style.css")
copyfile("./skeletons/style.css", cache_dir + '/styles/style.css')
print("Creating Hack.ttf")
copyfile("./skeletons/Hack.ttf", cache_dir + '/styles/Hack.ttf')
def parse_yaml():
with open(config_path, mode='r') as file:
file_dict = yaml.full_load(file)
file.close()
num_columns = len(file_dict)
return file_dict
def print_keys(dictionary):
for key in dictionary:
print(key)
if isinstance(dictionary[key], dict):
print_keys(dictionary[key])
def gen_columns(html_file):
print("here")
def gen_html():
print("Generating index.html...")
# open files
skeleton_html = open('./skeletons/index.html', 'r')
cache_html = open(cache_dir + '/index.html', 'w')
# copy skeleton_html to cache_html until Column Start comment
lines = skeleton_html.readlines()
for line in lines:
if line == "<!-- Columns start -->":
gen_columns(cache_html)
else:
cache_html.write(line)
# close files
skeleton_html.close()
cache_html.close()
print("Done!")
if __name__ == '__main__':
setup()
file_dict = parse_yaml()
gen_html()

BIN
skeletons/Hack.ttf Normal file

Binary file not shown.

View File

@ -9,13 +9,10 @@
<div class="container">
<div class="prompt">~<span> λ</span> tree</div>
<div class="row">
<!-- Columns here -->
<!-- Columns start -->
</div>
<div class="prompt">~<span> λ</span> ddg</div>
<!-- form for search engine -->
</div>
<form action="https://duckduckgo.com/" method="GET">
<h1>search: </h1>
<input type="text" name="q" autofocus="autofocus">
</form>

133
skeletons/style.css Normal file
View File

@ -0,0 +1,133 @@
@import url('/home/paul/.cache/wal/colors.css');
@font-face {
font-family: "Roboto Mono";
src: url("./Hack.ttf");
}
:root {
--font: "Roboto Mono";
/* --background: var(--background) !important; */
/* --foreground: #fffffe; */
/* --pink: #e53170; */
/* --red: #f25f4c; */
/* --orange: #ff8906; */
/* --branch: 1px solid #a7a9be; */
--branch: 1px solid var(--color12);
}
html {
font-size: 22px;
}
body {
background: var(--background);
}
.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.prompt {
font-family: var(--font);
color: var(--color5);
}
.prompt~.prompt {
padding: 1.5rem 0 0.3125rem;
}
span {
color: var(--color10);
}
h1 {
display: inline;
font-family: var(--font);
font-size: 1rem;
font-weight: normal;
color: var(--color9);
}
.tree > ul {
margin: 0;
padding-left: 1rem;
padding-right: 1rem;
}
ul {
list-style: none;
padding-left: 2.5rem;
}
li {
position: relative;
}
li::before, li::after {
content: "";
position: absolute;
left: -0.75rem;
}
li::before {
border-top: var(--branch);
top: 0.75rem;
width: 0.5rem;
}
li::after {
border-left: var(--branch);
height: 100%;
top: 0.25rem;
}
li:last-child::after {
height: 0.5rem;
}
a {
font-family: var(--font);
font-size: 1rem;
color: var(--color6);
text-decoration: none;
outline: none;
}
a:hover {
color: var(--color12);
background: var(--background);
}
form h1 {
padding-left: 0.125rem;
}
input {
font-family: var(--font);
font-size: 1rem;
color: var(--color6);
background-color: var(--background);
border-width: 1px;
border-color: var(--color12);
border-style: solid;
padding-top: 4px;
padding-bottom: 4px;
}
.column {
flex: 50%;
padding: 5px;
}
.row {
display: flex;
}
.row:after {
content: "";
display: table;
clear: both;
}