mirror of
https://github.com/Paul-Houser/StartTree.git
synced 2024-11-23 07:43:14 +01:00
moved skeleton files to cache so that the python code doesn't need to be updated dynamically.
This commit is contained in:
parent
d6b96c3980
commit
eaeaa67807
13
README.md
13
README.md
@ -18,6 +18,9 @@ A terminal-style home page replicating the tree command, modified from [this](ht
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
# Usage
|
# Usage
|
||||||
|
## Requirements
|
||||||
|
Requires the `bs4` python package.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
To install StartTree for the first time, run the following commands:
|
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. )
|
(Note: If the `~/.config/StartTree` directory already exists, `init.sh` will not copy the example config to prevent accidentally overwriting a custom config. )
|
||||||
@ -50,7 +53,7 @@ tree_1: # each column should be named 'tree_X' where X is unique for each tree.
|
|||||||
# or containing characters that cannot be in a yaml variable name.
|
# or containing characters that cannot be in a yaml variable name.
|
||||||
frontpage:
|
frontpage:
|
||||||
- "https://www.reddit.com/"
|
- "https://www.reddit.com/"
|
||||||
- "front page" #
|
- "front page"
|
||||||
unixporn: "https://www.reddit.com/r/unixporn/"
|
unixporn: "https://www.reddit.com/r/unixporn/"
|
||||||
tree_2:
|
tree_2:
|
||||||
other:
|
other:
|
||||||
@ -80,10 +83,4 @@ vim docker-compose.yaml # edit specifics to your liking
|
|||||||
docker-compose -f docker-compose.yaml up -d
|
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!
|
This will make the `NGINX` server persist across reboots. You can point your browser's new tab and home page to `localhost:<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>`
|
|
||||||
|
12
generate.py
12
generate.py
@ -1,7 +1,6 @@
|
|||||||
#!/bin/python3
|
#!/bin/python3
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
import os
|
|
||||||
from os.path import expanduser
|
from os.path import expanduser
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@ -9,10 +8,6 @@ from bs4 import BeautifulSoup
|
|||||||
# get home directory
|
# get home directory
|
||||||
home = expanduser("~")
|
home = expanduser("~")
|
||||||
|
|
||||||
# install script will fill this in
|
|
||||||
# replace line
|
|
||||||
repo_dir = "/home/paul/Documents/GitHub/StartTree"
|
|
||||||
|
|
||||||
# get config path
|
# get config path
|
||||||
config_dir = home + '/.config/StartTree'
|
config_dir = home + '/.config/StartTree'
|
||||||
config_path = home + '/.config/StartTree/config.yaml'
|
config_path = home + '/.config/StartTree/config.yaml'
|
||||||
@ -28,7 +23,6 @@ def prettifyHTML(html):
|
|||||||
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()
|
|
||||||
return file_dict
|
return file_dict
|
||||||
|
|
||||||
def print_keys(dictionary):
|
def print_keys(dictionary):
|
||||||
@ -78,7 +72,7 @@ def gen_html(file_dict):
|
|||||||
print("Generating index.html...")
|
print("Generating index.html...")
|
||||||
|
|
||||||
# open files
|
# open files
|
||||||
skeleton_html = open(repo_dir + '/skeletons/index.html', 'r')
|
skeleton_html = open(cache_dir + '/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
|
||||||
@ -104,7 +98,7 @@ def gen_html(file_dict):
|
|||||||
print("Done!")
|
print("Done!")
|
||||||
|
|
||||||
def gen_style(file_dict):
|
def gen_style(file_dict):
|
||||||
skeleton_style = open(repo_dir + '/skeletons/style.css', 'r')
|
skeleton_style = open(cache_dir + '/skeletons/style.css', 'r')
|
||||||
cache_style = open(cache_dir + '/styles/style.css', 'w')
|
cache_style = open(cache_dir + '/styles/style.css', 'w')
|
||||||
|
|
||||||
# find style attributes in file_dict
|
# find style attributes in file_dict
|
||||||
@ -119,7 +113,7 @@ def gen_style(file_dict):
|
|||||||
if theme == "pywal":
|
if theme == "pywal":
|
||||||
theme = home + '/.cache/wal/colors.css'
|
theme = home + '/.cache/wal/colors.css'
|
||||||
else:
|
else:
|
||||||
theme = repo_dir + '/themes/' + theme + '.css'
|
theme = cache_dir + '/themes/' + theme + '.css'
|
||||||
|
|
||||||
copyfile(theme, home + '/.cache/StartTree/styles/colors.css')
|
copyfile(theme, home + '/.cache/StartTree/styles/colors.css')
|
||||||
|
|
||||||
|
15
init.sh
15
init.sh
@ -4,10 +4,6 @@ config_dir=$HOME/.config/StartTree
|
|||||||
config_path=$HOME/.config/StartTree/config.yaml
|
config_path=$HOME/.config/StartTree/config.yaml
|
||||||
cache_dir=$HOME/.cache/StartTree
|
cache_dir=$HOME/.cache/StartTree
|
||||||
|
|
||||||
# install pip reqs
|
|
||||||
echo "Downloading pip dependencies..."
|
|
||||||
pip install --user bs4
|
|
||||||
|
|
||||||
# check if .config path exists
|
# check if .config path exists
|
||||||
if [ ! -d "$HOME/.config" ]; then
|
if [ ! -d "$HOME/.config" ]; then
|
||||||
echo "The directory '~/.config' does not exist, or you do not have permissions to edit it."
|
echo "The directory '~/.config' does not exist, or you do not have permissions to edit it."
|
||||||
@ -20,6 +16,12 @@ if [ ! -d "$HOME/.cache" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# check if .local/bin exists
|
||||||
|
if [ ! -d "$HOME/.local/bin" ]; then
|
||||||
|
echo "The directory '~/.local/bin' 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
|
# check if .config/StartTree exists, create it and config if not
|
||||||
if [ ! -d "$config_dir" ]; then
|
if [ ! -d "$config_dir" ]; then
|
||||||
echo "Creating '~/.config/StartTree'..."
|
echo "Creating '~/.config/StartTree'..."
|
||||||
@ -46,6 +48,9 @@ if [ ! -d "$cache_dir" ]; then
|
|||||||
echo "Symlinking themes..."
|
echo "Symlinking themes..."
|
||||||
ln -s $(pwd)/themes $HOME/.cache/StartTree/themes
|
ln -s $(pwd)/themes $HOME/.cache/StartTree/themes
|
||||||
|
|
||||||
|
echo "Symlinking skeleton files..."
|
||||||
|
ln -s $(pwd)/skeletons $HOME/.cache/StartTree/skeletons
|
||||||
|
|
||||||
echo "Creating '$cache_dir/styles'..."
|
echo "Creating '$cache_dir/styles'..."
|
||||||
mkdir "$cache_dir/styles"
|
mkdir "$cache_dir/styles"
|
||||||
fi
|
fi
|
||||||
@ -64,5 +69,3 @@ echo "Make sure this directory is in your \$PATH"
|
|||||||
|
|
||||||
FILEPATH=$(readlink -f "docker/data/default.conf")
|
FILEPATH=$(readlink -f "docker/data/default.conf")
|
||||||
ln -s $FILEPATH $HOME/.cache/StartTree/default.conf
|
ln -s $FILEPATH $HOME/.cache/StartTree/default.conf
|
||||||
|
|
||||||
sed -i "/# replace line/{n;s@.*@repo_dir = \"$(pwd)\"@}" generate.py
|
|
||||||
|
Loading…
Reference in New Issue
Block a user