forked from extern/StartTree
Compare commits
1 Commits
master
...
prettyhtml
Author | SHA1 | Date | |
---|---|---|---|
|
ebdd91f526 |
96
README.md
96
README.md
@ -1,89 +1,23 @@
|
||||
# StartTree
|
||||
A terminal-style home page replicating the tree command, modified from [this](https://notabug.org/nytly/home) start page, which no longer exists.
|
||||
A terminal-style home page replicating the tree command.
|
||||
|
||||
<p align="center">
|
||||
<img src="/images/StartTree.png", title="StartTree"/>
|
||||
<img src="/StartTree.png", title="StartTree"/>
|
||||
</p>
|
||||
|
||||
<div align="center">
|
||||
<h1>
|
||||
<a href="https://gideonwolfe.com/">
|
||||
<img style="vertical-align:middle" src="/images/forest.png", width="400", />
|
||||
</a>
|
||||
<span style="">
|
||||
<img style="vertical-align:middle" src="/images/void.png", width="400", />
|
||||
</a>
|
||||
</span>
|
||||
</h1>
|
||||
</div>
|
||||
## TODO
|
||||
- [x] Add screenshot to README.md
|
||||
- [x] add install script
|
||||
- [ ] Should allow selection of search engine
|
||||
- [ ] Should allow for multiple columns
|
||||
- [ ] User makes a 'config.yaml' file that is parsed and translated into the HTML
|
||||
|
||||
# Usage
|
||||
## Installation
|
||||
To install StartTree for the first time, run the following commands:
|
||||
(Note: If the `~/.config/StartTree` directory already exists, `init.sh` will not copy the example config to prevent accidentally overwriting a custom config. )
|
||||
```
|
||||
git clone https://github.com/Paul-Houser/StartTree.git
|
||||
cd StartTree
|
||||
chmod +x init.sh
|
||||
chmod +x generate.py
|
||||
./init.sh
|
||||
./generate.py
|
||||
```
|
||||
This will create the directory `~/.config/StartTree` containing the default `config.yaml`, install `starttree.py` to your `$PATH`, as well as generate the html/css, which you can view by pointing your browser at `$HOME/.cache/StartTree/index.html`.
|
||||
|
||||
## Config
|
||||
The config should be placed in `~/.config/StartTree/config.yaml`
|
||||
|
||||
## Updating the HTML
|
||||
To re-generate the html/css after editing the config, execute `starttree.py` from any directory.
|
||||
|
||||
# Example Config
|
||||
```yaml
|
||||
font_size: 22 # specify font size
|
||||
theme: void # specify the name of a theme in the themes/ directory, or use 'pywal'
|
||||
tree_1: # each column should be named 'tree_X' where X is unique for each tree.
|
||||
general: # Header name
|
||||
github: "https://www.github.com/" # Link-text: url
|
||||
gmail: "https://mail.google.com/"
|
||||
reddit:
|
||||
# the following is an example of naming a link something with a space,
|
||||
# or containing characters that cannot be in a yaml variable name.
|
||||
frontpage:
|
||||
- "https://www.reddit.com/"
|
||||
- "front page" #
|
||||
unixporn: "https://www.reddit.com/r/unixporn/"
|
||||
tree_2:
|
||||
other:
|
||||
archwiki:
|
||||
- "https://archlinux.org/"
|
||||
- "arch wiki"
|
||||
hulu: "https://www.hulu.com/"
|
||||
netflix: "https://www.netflix.com/"
|
||||
youtube: "https://www.youtube.com/"
|
||||
Tree_1:
|
||||
General:
|
||||
Google: "https://www.google.com/"
|
||||
Youtube: "https://www.youtube.com/"
|
||||
Reddit:
|
||||
Homepage: "https://www.reddit.com/"
|
||||
Unixporn: "https://www.reddit.com/r/unixporn/"
|
||||
```
|
||||
|
||||
# Themes
|
||||
|
||||
A variety of themes can be found in the `themes` directory.
|
||||
|
||||
If one wishes to dynamically theme from `pywal`, they may select `pywal` as their chosen theme in `config.yaml`.
|
||||
|
||||
# Docker
|
||||
|
||||
In order to circumvent some restrictions on browsers for what is allowed as a "Home" and "New Tab" page, you can host StartTree as a lightweight `NGINX` server through `docker-compose`.
|
||||
|
||||
To set this up, one must have `docker` and `docker-compose` installed and configured. Then, go into the directory where you cloned `StartTree`, and run
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
vim docker-compose.yaml # edit specifics to your liking
|
||||
docker-compose -f docker-compose.yaml up -d
|
||||
```
|
||||
|
||||
This will make the `NGINX` server persist across reboots. You can point your browser's new tab and home page to `localhost:p<port#>` and you should see your startpage!
|
||||
|
||||
### NOTE:
|
||||
|
||||
Currently, docker is unaware if a file changes on the fly (like generating a new colorscheme or adding new shortcuts), so you have to restart the container with
|
||||
|
||||
`docker-compose -f docker-compose.yaml restart <servicename>`
|
||||
|
BIN
StartTree.png
Normal file
BIN
StartTree.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 730 KiB |
70
WebExample/index.html
Normal file
70
WebExample/index.html
Normal file
@ -0,0 +1,70 @@
|
||||
<!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>
|
BIN
WebExample/styles/Hack.ttf
Normal file
BIN
WebExample/styles/Hack.ttf
Normal file
Binary file not shown.
133
WebExample/styles/style.css
Normal file
133
WebExample/styles/style.css
Normal 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;
|
||||
}
|
17
config.yaml
17
config.yaml
@ -1,15 +1,22 @@
|
||||
font_size: 22
|
||||
theme: void
|
||||
tree_1:
|
||||
Tree_1:
|
||||
general:
|
||||
github: "https://www.github.com/"
|
||||
nextcloud: "https://cloud.paulhouser.xyz/"
|
||||
github: "https://www.github.com/Paul-Houser/"
|
||||
wwu-gitlab: "https://gitlab.cs.wwu.edu/"
|
||||
gmail: "https://mail.google.com/"
|
||||
reddit:
|
||||
frontpage:
|
||||
- "https://www.reddit.com/"
|
||||
- "front page"
|
||||
profile: "https://www.reddit.com/u/P_swizzles/"
|
||||
unixporn: "https://www.reddit.com/r/unixporn/"
|
||||
tree_2:
|
||||
archlinux: "https://www.reddit.com/r/archlinux/"
|
||||
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:
|
||||
archwiki:
|
||||
- "https://archlinux.org/"
|
||||
|
Binary file not shown.
@ -1,46 +0,0 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
#charset koi8-r;
|
||||
#access_log /var/log/nginx/host.access.log main;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
expires -1;
|
||||
}
|
||||
|
||||
#error_page 404 /404.html;
|
||||
|
||||
# redirect server error pages to the static page /50x.html
|
||||
#
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /usr/share/nginx/html;
|
||||
}
|
||||
|
||||
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# proxy_pass http://127.0.0.1;
|
||||
#}
|
||||
|
||||
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
|
||||
#
|
||||
#location ~ \.php$ {
|
||||
# root html;
|
||||
# fastcgi_pass 127.0.0.1:9000;
|
||||
# fastcgi_index index.php;
|
||||
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
|
||||
# include fastcgi_params;
|
||||
#}
|
||||
|
||||
# deny access to .htaccess files, if Apache's document root
|
||||
# concurs with nginx's one
|
||||
#
|
||||
#location ~ /\.ht {
|
||||
# deny all;
|
||||
#}
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
version: '3'
|
||||
services:
|
||||
|
||||
StartTree:
|
||||
image: nginx
|
||||
volumes:
|
||||
- $HOME/.cache/StartTree/styles/colors.css:/usr/share/nginx/html/styles/colors.css # This needs to be changed depending on theme
|
||||
- $HOME/.cache/StartTree/index.html:/usr/share/nginx/html/index.html
|
||||
- $HOME/.cache/StartTree/styles/style.css:/usr/share/nginx/html/styles/style.css
|
||||
- $HOME/.cache/StartTree/styles/Hack.ttf:/usr/share/nginx/html/styles/Hack.ttf
|
||||
- $HOME/.cache/StartTree/default.conf:/etc/nginx/conf.d/default.conf # modified conf to disable page caching :)
|
||||
ports:
|
||||
- "9876:80"
|
||||
environment:
|
||||
- NGINX_PORT=80
|
||||
restart: unless-stopped
|
141
generate.py
141
generate.py
@ -1,141 +0,0 @@
|
||||
#!/bin/python3
|
||||
|
||||
import yaml
|
||||
import os
|
||||
from os.path import expanduser
|
||||
from shutil import copyfile
|
||||
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'
|
||||
|
||||
# get cache path
|
||||
cache_dir = home + '/.cache/StartTree'
|
||||
|
||||
def prettifyHTML(html):
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
prettyHTML = soup.prettify()
|
||||
return prettyHTML
|
||||
|
||||
def parse_yaml():
|
||||
with open(config_path, mode='r') as file:
|
||||
file_dict = yaml.full_load(file)
|
||||
file.close()
|
||||
return file_dict
|
||||
|
||||
def print_keys(dictionary):
|
||||
for key in dictionary:
|
||||
print(key)
|
||||
if isinstance(dictionary[key], dict):
|
||||
print_keys(dictionary[key])
|
||||
|
||||
def gen_list_indices(html_file, file_dict):
|
||||
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_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.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")
|
||||
|
||||
# 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...")
|
||||
|
||||
# open files
|
||||
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
|
||||
lines = skeleton_html.readlines()
|
||||
for line in lines:
|
||||
if line == "<!-- Columns start -->\n":
|
||||
gen_columns(cache_html, file_dict)
|
||||
else:
|
||||
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
|
||||
skeleton_html.close()
|
||||
cache_html.close()
|
||||
|
||||
print("Done!")
|
||||
|
||||
def gen_style(file_dict):
|
||||
skeleton_style = open(repo_dir + '/skeletons/style.css', 'r')
|
||||
cache_style = open(cache_dir + '/styles/style.css', 'w')
|
||||
|
||||
# find style attributes in file_dict
|
||||
font_size = 20
|
||||
theme = "void"
|
||||
for key in file_dict:
|
||||
if key == "font_size":
|
||||
font_size = file_dict[key]
|
||||
if key == "theme":
|
||||
theme = file_dict[key]
|
||||
|
||||
if theme == "pywal":
|
||||
theme = home + '/.cache/wal/colors.css'
|
||||
else:
|
||||
theme = repo_dir + '/themes/' + theme + '.css'
|
||||
|
||||
copyfile(theme, home + '/.cache/StartTree/styles/colors.css')
|
||||
|
||||
cache_style.write("@import url('./colors.css');\n")
|
||||
|
||||
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()
|
||||
gen_style(file_dict)
|
||||
gen_html(file_dict)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
Binary file not shown.
Before Width: | Height: | Size: 647 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.9 MiB |
BIN
images/void.png
BIN
images/void.png
Binary file not shown.
Before Width: | Height: | Size: 2.6 MiB |
68
init.sh
68
init.sh
@ -1,68 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
if [ ! -d "$HOME/.config" ]; then
|
||||
echo "The directory '~/.config' does not exist, or you do not have permissions to edit it."
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if .cache path exists
|
||||
if [ ! -d "$HOME/.cache" ]; then
|
||||
echo "The directory '~/.cache' does not exist, or you do not have permissions to edit it."
|
||||
exit
|
||||
fi
|
||||
|
||||
# check if .config/StartTree exists, create it and config if not
|
||||
if [ ! -d "$config_dir" ]; then
|
||||
echo "Creating '~/.config/StartTree'..."
|
||||
mkdir $config_dir
|
||||
echo "Copying config.yaml..."
|
||||
cp ./config.yaml $config_path
|
||||
echo
|
||||
fi
|
||||
|
||||
# check if config.yaml exists
|
||||
if [ ! -f "$config_path" ]; then
|
||||
echo "No config.yaml found in '~/.config/StartTree'"
|
||||
echo "Copy the example config with:"
|
||||
echo "\tcp ./config.yaml $HOME/.config/StartTree/config.yaml"
|
||||
echo "or create your own in that directory."
|
||||
exit
|
||||
fi
|
||||
|
||||
# create directory structure in .cache
|
||||
if [ ! -d "$cache_dir" ]; then
|
||||
echo "Creating '$cache_dir'..."
|
||||
mkdir $cache_dir
|
||||
|
||||
echo "Symlinking themes..."
|
||||
ln -s $(pwd)/themes $HOME/.cache/StartTree/themes
|
||||
|
||||
echo "Creating '$cache_dir/styles'..."
|
||||
mkdir "$cache_dir/styles"
|
||||
fi
|
||||
|
||||
echo "Creating style.css..."
|
||||
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"
|
||||
|
||||
FILEPATH=$(readlink -f "docker/data/default.conf")
|
||||
ln -s $FILEPATH $HOME/.cache/StartTree/default.conf
|
||||
|
||||
sed -i "/# replace line/{n;s@.*@repo_dir = \"$(pwd)\"@}" generate.py
|
109
install.py
Executable file
109
install.py
Executable file
@ -0,0 +1,109 @@
|
||||
#!/bin/python3
|
||||
|
||||
import yaml
|
||||
import os
|
||||
from os.path import expanduser
|
||||
from shutil import copyfile
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
# 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 = "<div><h1>Hello</h1></div>"
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
prettyHTML = print(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 parse_yaml():
|
||||
with open(config_path, mode='r') as file:
|
||||
file_dict = yaml.full_load(file)
|
||||
file.close()
|
||||
|
||||
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)
|
||||
|
||||
prettifyHTML()
|
||||
|
||||
# close files
|
||||
skeleton_html.close()
|
||||
cache_html.close()
|
||||
|
||||
print("Done!")
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
setup()
|
||||
file_dict = parse_yaml()
|
||||
gen_html()
|
@ -1,3 +1,4 @@
|
||||
@import url('/home/paul/.cache/wal/colors.css');
|
||||
@font-face {
|
||||
font-family: "Roboto Mono";
|
||||
src: url("./Hack.ttf");
|
||||
@ -15,7 +16,7 @@
|
||||
}
|
||||
|
||||
html {
|
||||
/* font-size */
|
||||
font-size: 22px;
|
||||
}
|
||||
|
||||
body {
|
||||
@ -59,7 +60,6 @@ h1 {
|
||||
ul {
|
||||
list-style: none;
|
||||
padding-left: 2.5rem;
|
||||
white-space:nowrap;
|
||||
}
|
||||
|
||||
li {
|
||||
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #9a9c9f;
|
||||
--cursor: #9a9c9f;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #04294d;
|
||||
--color2: #2d2d2d;
|
||||
--color3: #094c57;
|
||||
--color4: #176485;
|
||||
--color5: #585a5a;
|
||||
--color6: #62909b;
|
||||
--color7: #9a9c9f;
|
||||
--color8: #36393f;
|
||||
--color9: #04294d;
|
||||
--color10: #2d2d2d;
|
||||
--color11: #094c57;
|
||||
--color12: #176485;
|
||||
--color13: #585a5a;
|
||||
--color14: #62909b;
|
||||
--color15: #9a9c9f;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #bfc7c7;
|
||||
--cursor: #bfc7c7;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #0e9da8;
|
||||
--color2: #82b4b9;
|
||||
--color3: #1063aa;
|
||||
--color4: #2e45aa;
|
||||
--color5: #7e3ca9;
|
||||
--color6: #b82589;
|
||||
--color7: #bfc7c7;
|
||||
--color8: #415758;
|
||||
--color9: #0e9da8;
|
||||
--color10: #82b4b9;
|
||||
--color11: #1063aa;
|
||||
--color12: #2e45aa;
|
||||
--color13: #7e3ca9;
|
||||
--color14: #b82589;
|
||||
--color15: #bfc7c7;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #8fc5c6;
|
||||
--cursor: #8fc5c6;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #9E2A5E;
|
||||
--color2: #D03C6E;
|
||||
--color3: #9D596B;
|
||||
--color4: #378B77;
|
||||
--color5: #346D8A;
|
||||
--color6: #CD6A8C;
|
||||
--color7: #8fc5c6;
|
||||
--color8: #64898a;
|
||||
--color9: #9E2A5E;
|
||||
--color10: #D03C6E;
|
||||
--color11: #9D596B;
|
||||
--color12: #378B77;
|
||||
--color13: #346D8A;
|
||||
--color14: #CD6A8C;
|
||||
--color15: #8fc5c6;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #c8c4c2;
|
||||
--cursor: #c8c4c2;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #b07247;
|
||||
--color2: #a89e88;
|
||||
--color3: #89c0c0;
|
||||
--color4: #69a4b7;
|
||||
--color5: #358ec0;
|
||||
--color6: #1a6eae;
|
||||
--color7: #c8c4c2;
|
||||
--color8: #5a504a;
|
||||
--color9: #b07247;
|
||||
--color10: #a89e88;
|
||||
--color11: #89c0c0;
|
||||
--color12: #69a4b7;
|
||||
--color13: #358ec0;
|
||||
--color14: #1a6eae;
|
||||
--color15: #c8c4c2;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #a1bfa2;
|
||||
--cursor: #a1bfa2;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #264D33;
|
||||
--color2: #316B37;
|
||||
--color3: #255546;
|
||||
--color4: #316E4A;
|
||||
--color5: #3E6848;
|
||||
--color6: #3F8648;
|
||||
--color7: #a1bfa2;
|
||||
--color8: #708571;
|
||||
--color9: #264D33;
|
||||
--color10: #316B37;
|
||||
--color11: #255546;
|
||||
--color12: #316E4A;
|
||||
--color13: #3E6848;
|
||||
--color14: #3F8648;
|
||||
--color15: #a1bfa2;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #020303;
|
||||
--foreground: #9da0a0;
|
||||
--cursor: #9da0a0;
|
||||
|
||||
/* Colors */
|
||||
--color0: #020303;
|
||||
--color1: #2b3d30;
|
||||
--color2: #424a55;
|
||||
--color3: #405642;
|
||||
--color4: #5b6a55;
|
||||
--color5: #7f8d76;
|
||||
--color6: #82908c;
|
||||
--color7: #9da0a0;
|
||||
--color8: #3b4242;
|
||||
--color9: #2b3d30;
|
||||
--color10: #424a55;
|
||||
--color11: #405642;
|
||||
--color12: #5b6a55;
|
||||
--color13: #7f8d76;
|
||||
--color14: #82908c;
|
||||
--color15: #9da0a0;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
/* gruv for starttree */
|
||||
:root {
|
||||
--background: #282828;
|
||||
--foreground: #ebdbb2;
|
||||
--cursor: #bfc7c7;
|
||||
|
||||
--color0: #282828;
|
||||
--color1: #cc241d;
|
||||
--color2: #98971a;
|
||||
--color3: #d79921;
|
||||
--color4: #458588;
|
||||
--color5: #b16286;
|
||||
--color6: #689d6a;
|
||||
--color7: #a89984;
|
||||
--color8: #928374;
|
||||
--color9: #fb4934;
|
||||
--color10: #b8bb26;
|
||||
--color11: #fabd2f;
|
||||
--color12: #83a598;
|
||||
--color13: #d3869b;
|
||||
--color14: #8ec07c;
|
||||
--color15: #ebdbb2;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #a6c1b8;
|
||||
--cursor: #a6c1b8;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #554B41;
|
||||
--color2: #962A30;
|
||||
--color3: #F21B2B;
|
||||
--color4: #DF4D49;
|
||||
--color5: #2EA564;
|
||||
--color6: #F7934A;
|
||||
--color7: #a6c1b8;
|
||||
--color8: #748780;
|
||||
--color9: #554B41;
|
||||
--color10: #962A30;
|
||||
--color11: #F21B2B;
|
||||
--color12: #DF4D49;
|
||||
--color13: #2EA564;
|
||||
--color14: #F7934A;
|
||||
--color15: #a6c1b8;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #e58997;
|
||||
--cursor: #e58997;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #BB243D;
|
||||
--color2: #CC1B37;
|
||||
--color3: #E11F3D;
|
||||
--color4: #D8213E;
|
||||
--color5: #E2203E;
|
||||
--color6: #B42D44;
|
||||
--color7: #e58997;
|
||||
--color8: #a05f69;
|
||||
--color9: #BB243D;
|
||||
--color10: #CC1B37;
|
||||
--color11: #E11F3D;
|
||||
--color12: #D8213E;
|
||||
--color13: #E2203E;
|
||||
--color14: #B42D44;
|
||||
--color15: #e58997;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #9fc8e0;
|
||||
--cursor: #9fc8e0;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #8B1374;
|
||||
--color2: #2D3090;
|
||||
--color3: #512F91;
|
||||
--color4: #325AB7;
|
||||
--color5: #4C5AA5;
|
||||
--color6: #B91F9E;
|
||||
--color7: #9fc8e0;
|
||||
--color8: #6f8c9c;
|
||||
--color9: #8B1374;
|
||||
--color10: #2D3090;
|
||||
--color11: #512F91;
|
||||
--color12: #325AB7;
|
||||
--color13: #4C5AA5;
|
||||
--color14: #B91F9E;
|
||||
--color15: #9fc8e0;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #93d2d4;
|
||||
--cursor: #93d2d4;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #205556;
|
||||
--color2: #445142;
|
||||
--color3: #B63632;
|
||||
--color4: #9A9746;
|
||||
--color5: #2E52C2;
|
||||
--color6: #C610BE;
|
||||
--color7: #93d2d4;
|
||||
--color8: #669394;
|
||||
--color9: #205556;
|
||||
--color10: #445142;
|
||||
--color11: #B63632;
|
||||
--color12: #9A9746;
|
||||
--color13: #2E52C2;
|
||||
--color14: #C610BE;
|
||||
--color15: #93d2d4;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #9f9f9f;
|
||||
--cursor: #9f9f9f;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #2c3433;
|
||||
--color2: #5e2711;
|
||||
--color3: #303d44;
|
||||
--color4: #9d350a;
|
||||
--color5: #505c5b;
|
||||
--color6: #5e7078;
|
||||
--color7: #9f9f9f;
|
||||
--color8: #3f3f3f;
|
||||
--color9: #2c3433;
|
||||
--color10: #5e2711;
|
||||
--color11: #303d44;
|
||||
--color12: #9d350a;
|
||||
--color13: #505c5b;
|
||||
--color14: #5e7078;
|
||||
--color15: #9f9f9f;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #c5c5c5;
|
||||
--cursor: #c5c5c5;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #26292e;
|
||||
--color2: #292c31;
|
||||
--color3: #842133;
|
||||
--color4: #c91a36;
|
||||
--color5: #cf1f3b;
|
||||
--color6: #c52c46;
|
||||
--color7: #c5c5c5;
|
||||
--color8: #515152;
|
||||
--color9: #26292e;
|
||||
--color10: #292c31;
|
||||
--color11: #842133;
|
||||
--color12: #c91a36;
|
||||
--color13: #cf1f3b;
|
||||
--color14: #c52c46;
|
||||
--color15: #c5c5c5;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #aba0cb;
|
||||
--cursor: #aba0cb;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #8B2039;
|
||||
--color2: #A5244B;
|
||||
--color3: #E22A66;
|
||||
--color4: #B55F40;
|
||||
--color5: #EB9346;
|
||||
--color6: #0A6389;
|
||||
--color7: #aba0cb;
|
||||
--color8: #77708e;
|
||||
--color9: #8B2039;
|
||||
--color10: #A5244B;
|
||||
--color11: #E22A66;
|
||||
--color12: #B55F40;
|
||||
--color13: #EB9346;
|
||||
--color14: #0A6389;
|
||||
--color15: #aba0cb;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #2d2d2d;
|
||||
--foreground: #cccccc;
|
||||
--cursor: #cccccc;
|
||||
|
||||
/* Colors */
|
||||
--color0: #2d2d2d;
|
||||
--color1: #f2777a;
|
||||
--color2: #99cc99;
|
||||
--color3: #ffcc66;
|
||||
--color4: #6699cc;
|
||||
--color5: #cc99cc;
|
||||
--color6: #66cccc;
|
||||
--color7: #cccccc;
|
||||
--color8: #999999;
|
||||
--color9: #f2777a;
|
||||
--color10: #99cc99;
|
||||
--color11: #ffcc66;
|
||||
--color12: #6699cc;
|
||||
--color13: #cc99cc;
|
||||
--color14: #66cccc;
|
||||
--color15: #ffffff;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #06070A;
|
||||
--foreground: #79c4c6;
|
||||
--cursor: #79c4c6;
|
||||
|
||||
/* Colors */
|
||||
--color0: #06070A;
|
||||
--color1: #175564;
|
||||
--color2: #066C71;
|
||||
--color3: #414255;
|
||||
--color4: #0E7587;
|
||||
--color5: #64468F;
|
||||
--color6: #8D419F;
|
||||
--color7: #79c4c6;
|
||||
--color8: #54898a;
|
||||
--color9: #175564;
|
||||
--color10: #066C71;
|
||||
--color11: #414255;
|
||||
--color12: #0E7587;
|
||||
--color13: #64468F;
|
||||
--color14: #8D419F;
|
||||
--color15: #79c4c6;
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
:root {
|
||||
/* Special */
|
||||
--background: #000000;
|
||||
--foreground: #c0c6c7;
|
||||
--cursor: #c0c6c7;
|
||||
|
||||
/* Colors */
|
||||
--color0: #000000;
|
||||
--color1: #128faa;
|
||||
--color2: #558fa9;
|
||||
--color3: #9790a6;
|
||||
--color4: #b17379;
|
||||
--color5: #b45255;
|
||||
--color6: #bf3032;
|
||||
--color7: #c0c6c7;
|
||||
--color8: #425458;
|
||||
--color9: #128faa;
|
||||
--color10: #558fa9;
|
||||
--color11: #9790a6;
|
||||
--color12: #b17379;
|
||||
--color13: #b45255;
|
||||
--color14: #bf3032;
|
||||
--color15: #c0c6c7;
|
||||
}
|
Loading…
Reference in New Issue
Block a user