mirror of
https://github.com/Paul-Houser/StartTree.git
synced 2025-08-12 09:29:02 +02:00
Compare commits
14 Commits
prettyhtml
...
font-size
Author | SHA1 | Date | |
---|---|---|---|
9a78049525 | |||
a84f0f9e3e | |||
d2b80fd1eb | |||
c1f8bde5e9 | |||
e543ce7b9d | |||
2b90acc3ac | |||
40ba3abed4 | |||
7d4e7c82b2 | |||
3a5db78e88 | |||
6a1067b4cd | |||
224215cd9a | |||
040719487a | |||
4604d29deb | |||
927c607839 |
@ -9,8 +9,10 @@ A terminal-style home page replicating the tree command.
|
|||||||
- [x] Add screenshot to README.md
|
- [x] Add screenshot to README.md
|
||||||
- [x] add install script
|
- [x] add install script
|
||||||
- [ ] Should allow selection of search engine
|
- [ ] Should allow selection of search engine
|
||||||
- [ ] Should allow for multiple columns
|
- [x] Should allow for multiple columns
|
||||||
- [ ] User makes a 'config.yaml' file that is parsed and translated into the HTML
|
- [x] User makes a 'config.yaml' file that is parsed and translated into the HTML
|
||||||
|
- [ ] Allow setting the font size in the config
|
||||||
|
- [ ] Install the update script into a `$PATH` directory
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
Tree_1:
|
Tree_1:
|
||||||
|
@ -1,70 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<link rel="stylesheet" type="text/css" href="./styles/style.css">
|
|
||||||
<title>Home</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="container">
|
|
||||||
<div class="prompt">~<span> λ</span> tree</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="column">
|
|
||||||
<div class="tree">
|
|
||||||
<h1>.</h1>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<h1>general</h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://cloud.paulhouser.xyz">nextcloud</a></li>
|
|
||||||
<li><a href="https://github.com/Paul-Houser">github</a></li>
|
|
||||||
<li><a href="https://gitlab.cs.wwu.edu">wwu-gitlab</a></li>
|
|
||||||
<li><a href="https://mail.google.com">gmail</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<h1>reddit</h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://reddit.com">front page</a></li>
|
|
||||||
<li><a href="https://reddit.com/u/P_swizzles">profile</a></li>
|
|
||||||
<li><a href="https://reddit.com/r/unixporn">unixporn</a></li>
|
|
||||||
<li><a href="https://reddit.com/r/archlinux">archlinux</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="column">
|
|
||||||
<div class="tree">
|
|
||||||
<h1>.</h1>
|
|
||||||
<ul>
|
|
||||||
<li>
|
|
||||||
<h1>school</h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://wwu.instructure.com/">canvas</a></li>
|
|
||||||
<li><a href="https://dw.wwu.edu/Dashboard/dashboard">degreeworks</a></li>
|
|
||||||
<li><a href="https://outlook.office.com">outlook</a></li>
|
|
||||||
<li><a href="https://admin.wwu.edu/pls/wwis/twbkwbis.P_GenMenu?name=bmenu.P_MainMnu">web4u</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<h1>other</h1>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://archlinux.org">arch wiki</a></li>
|
|
||||||
<li><a href="https://hulu.com">hulu</a></li>
|
|
||||||
<li><a href="https://www.netflix.com">netflix</a></li>
|
|
||||||
<li><a href="https://youtube.com">youtube</a></li>
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="prompt">~<span> λ</span> ddg</div>
|
|
||||||
<form action="https://duckduckgo.com/" method="GET">
|
|
||||||
<h1>search: </h1>
|
|
||||||
<input type="text" name="q" autofocus="autofocus">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Binary file not shown.
@ -1,133 +0,0 @@
|
|||||||
@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;
|
|
||||||
}
|
|
16
config.yaml
16
config.yaml
@ -1,22 +1,14 @@
|
|||||||
Tree_1:
|
font_size: 22
|
||||||
|
tree_1:
|
||||||
general:
|
general:
|
||||||
nextcloud: "https://cloud.paulhouser.xyz/"
|
github: "https://www.github.com/"
|
||||||
github: "https://www.github.com/Paul-Houser/"
|
|
||||||
wwu-gitlab: "https://gitlab.cs.wwu.edu/"
|
|
||||||
gmail: "https://mail.google.com/"
|
gmail: "https://mail.google.com/"
|
||||||
reddit:
|
reddit:
|
||||||
frontpage:
|
frontpage:
|
||||||
- "https://www.reddit.com/"
|
- "https://www.reddit.com/"
|
||||||
- "front page"
|
- "front page"
|
||||||
profile: "https://www.reddit.com/u/P_swizzles/"
|
|
||||||
unixporn: "https://www.reddit.com/r/unixporn/"
|
unixporn: "https://www.reddit.com/r/unixporn/"
|
||||||
archlinux: "https://www.reddit.com/r/archlinux/"
|
tree_2:
|
||||||
Tree_2:
|
|
||||||
school:
|
|
||||||
canvas: "https://wwu.instructure.com/"
|
|
||||||
degreeworks: "https://dw.wwu.edu/Dashboard/dashboard"
|
|
||||||
outlook: "https://outlook.office.com"
|
|
||||||
web4u: "https://admin.wwu.edu/pls/wwis/twbkwbis.P_GenMenu?name=bmenu.P_MainMnu"
|
|
||||||
other:
|
other:
|
||||||
archwiki:
|
archwiki:
|
||||||
- "https://archlinux.org/"
|
- "https://archlinux.org/"
|
||||||
|
74
init.py
Executable file
74
init.py
Executable file
@ -0,0 +1,74 @@
|
|||||||
|
#!/bin/python3
|
||||||
|
|
||||||
|
import yaml
|
||||||
|
import os
|
||||||
|
from os.path import expanduser
|
||||||
|
from shutil import copyfile
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
|
# Install dependencies
|
||||||
|
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'bs4'])
|
||||||
|
|
||||||
|
# get home directory
|
||||||
|
home = expanduser("~")
|
||||||
|
|
||||||
|
# get config path
|
||||||
|
config_dir = home + '/.config/StartTree'
|
||||||
|
config_path = home + '/.config/StartTree/config.yaml'
|
||||||
|
|
||||||
|
# get cache path
|
||||||
|
cache_dir = home + '/.cache/StartTree'
|
||||||
|
|
||||||
|
def prettifyHTML(html):
|
||||||
|
soup = BeautifulSoup(html, 'html.parser')
|
||||||
|
prettyHTML = soup.prettify()
|
||||||
|
return prettyHTML
|
||||||
|
|
||||||
|
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'...")
|
||||||
|
os.mkdir(config_dir)
|
||||||
|
print("Copying config.yaml")
|
||||||
|
copyfile("./config.yaml", config_path)
|
||||||
|
print("")
|
||||||
|
|
||||||
|
# check if config.yaml exists
|
||||||
|
if not os.path.exists(config_path):
|
||||||
|
print("No config.yaml found in '~/.config/StartTree'")
|
||||||
|
print("Copy the example config with:")
|
||||||
|
print("\tcp ./config.yaml $HOME/.config/StartTree/config.yaml")
|
||||||
|
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)
|
||||||
|
|
||||||
|
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 main():
|
||||||
|
setup()
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
125
install.py
125
install.py
@ -4,6 +4,7 @@ import yaml
|
|||||||
import os
|
import os
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
|
from bs4 import BeautifulSoup
|
||||||
|
|
||||||
# get home directory
|
# get home directory
|
||||||
home = expanduser("~")
|
home = expanduser("~")
|
||||||
@ -15,51 +16,15 @@ config_path = home + '/.config/StartTree/config.yaml'
|
|||||||
# get cache path
|
# get cache path
|
||||||
cache_dir = home + '/.cache/StartTree'
|
cache_dir = home + '/.cache/StartTree'
|
||||||
|
|
||||||
def setup():
|
def prettifyHTML(html):
|
||||||
# check if .config path exists
|
soup = BeautifulSoup(html, 'html.parser')
|
||||||
if not os.path.isdir(home + '/.config'):
|
prettyHTML = soup.prettify()
|
||||||
print("The directory '~/.config' does not exist, or you do not have permissions to edit it.")
|
return prettyHTML
|
||||||
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'...")
|
|
||||||
os.mkdir(config_dir)
|
|
||||||
print("Copying config.yaml")
|
|
||||||
copyfile("./config.yaml", config_path)
|
|
||||||
print("")
|
|
||||||
|
|
||||||
# check if config.yaml exists
|
|
||||||
if not os.path.exists(config_path):
|
|
||||||
print("No config.yaml found in '~/.config/StartTree'")
|
|
||||||
print("Copy the example config with:")
|
|
||||||
print("\tcp ./config.yaml $HOME/.config/StartTree/config.yaml")
|
|
||||||
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)
|
|
||||||
|
|
||||||
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():
|
def parse_yaml():
|
||||||
with open(config_path, mode='r') as file:
|
with open(config_path, mode='r') as file:
|
||||||
file_dict = yaml.full_load(file)
|
file_dict = yaml.full_load(file)
|
||||||
file.close()
|
file.close()
|
||||||
|
|
||||||
return file_dict
|
return file_dict
|
||||||
|
|
||||||
def print_keys(dictionary):
|
def print_keys(dictionary):
|
||||||
@ -68,31 +33,93 @@ def print_keys(dictionary):
|
|||||||
if isinstance(dictionary[key], dict):
|
if isinstance(dictionary[key], dict):
|
||||||
print_keys(dictionary[key])
|
print_keys(dictionary[key])
|
||||||
|
|
||||||
def gen_columns(html_file):
|
def gen_list_indices(html_file, file_dict):
|
||||||
print("here")
|
for key in file_dict:
|
||||||
|
value = file_dict[key]
|
||||||
|
print(key + "->" + str(value))
|
||||||
|
if not isinstance(value, list):
|
||||||
|
html_file.write("<li><a href=\"" + value + "\">" + key + "</a></li>")
|
||||||
|
else:
|
||||||
|
html_file.write("<li><a href=\"" + value[0] + "\">" + value[1] + "</a></li>")
|
||||||
|
|
||||||
def gen_html():
|
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")
|
||||||
|
|
||||||
|
# generate list indices
|
||||||
|
gen_list_indices(html_file, file_dict[key])
|
||||||
|
|
||||||
|
html_file.write(" </ul>\n")
|
||||||
|
html_file.write("</li>\n")
|
||||||
|
|
||||||
|
def gen_columns(html_file, file_dict):
|
||||||
|
for key in file_dict:
|
||||||
|
if key == "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")
|
||||||
|
|
||||||
|
# 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("</div>\n")
|
||||||
|
|
||||||
|
|
||||||
|
def gen_html(file_dict):
|
||||||
print("Generating index.html...")
|
print("Generating index.html...")
|
||||||
|
|
||||||
# open files
|
# open files
|
||||||
skeleton_html = open('./skeletons/index.html', 'r')
|
skeleton_html = open('./skeletons/index.html', 'r')
|
||||||
cache_html = open(cache_dir + '/index.html', 'w')
|
cache_html = open(cache_dir + '/index.html', 'w+')
|
||||||
|
|
||||||
# copy skeleton_html to cache_html until Column Start comment
|
# copy skeleton_html to cache_html until Column Start comment
|
||||||
lines = skeleton_html.readlines()
|
lines = skeleton_html.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
if line == "<!-- Columns start -->":
|
if line == "<!-- Columns start -->\n":
|
||||||
gen_columns(cache_html)
|
gen_columns(cache_html, file_dict)
|
||||||
else:
|
else:
|
||||||
cache_html.write(line)
|
cache_html.write(line)
|
||||||
|
|
||||||
|
# prettify
|
||||||
|
cache_html.seek(0)
|
||||||
|
pretty_string = cache_html.read()
|
||||||
|
pretty_string = prettifyHTML(pretty_string)
|
||||||
|
cache_html.close()
|
||||||
|
cache_html = open(cache_dir + '/index.html', 'w')
|
||||||
|
cache_html.write(pretty_string)
|
||||||
|
|
||||||
# close files
|
# close files
|
||||||
skeleton_html.close()
|
skeleton_html.close()
|
||||||
cache_html.close()
|
cache_html.close()
|
||||||
|
|
||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def gen_style(file_dict):
|
||||||
setup()
|
skeleton_style = open('./skeletons/style.css', 'r')
|
||||||
|
cache_style = open(cache_dir + '/styles/style.css', 'w')
|
||||||
|
|
||||||
|
font_size = 20
|
||||||
|
for key in file_dict:
|
||||||
|
if key == "font_size":
|
||||||
|
font_size = file_dict[key]
|
||||||
|
break
|
||||||
|
|
||||||
|
lines = skeleton_style.readlines()
|
||||||
|
for line in lines:
|
||||||
|
if line == "/* font-size */\n":
|
||||||
|
cache_style.write("font-size: " + str(font_size) + "px;\n")
|
||||||
|
else:
|
||||||
|
cache_style.write(line)
|
||||||
|
|
||||||
|
def main():
|
||||||
file_dict = parse_yaml()
|
file_dict = parse_yaml()
|
||||||
gen_html()
|
gen_style(file_dict)
|
||||||
|
gen_html(file_dict)
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
font-size: 22px;
|
/* font-size */
|
||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
|
Reference in New Issue
Block a user