From 6a57963ebc8de6115fddd2c6dff7dc39fb96e877 Mon Sep 17 00:00:00 2001 From: jolzem Date: Thu, 31 Aug 2023 09:24:24 +0200 Subject: [PATCH] added automated deploy --- .gitignore | 1 + README.md | 118 +++++++++---------------------- config.yml | 22 ++++++ deploy.py | 88 +++++++++++++++++++++++ index.html => index.example.html | 0 requirements.txt | 1 + 6 files changed, 144 insertions(+), 86 deletions(-) create mode 100644 .gitignore create mode 100644 config.yml create mode 100644 deploy.py rename index.html => index.example.html (100%) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dcaf716 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +index.html diff --git a/README.md b/README.md index d019e8c..e647d1a 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ -# ./Startpage.sh -A simple tree style startpage in HTML and CSS with interchangeable and customisable themes. +# ./startpage.sh +A simple configurable tree style startpage in HTML and CSS with interchangeable and customisable themes. ![Preview](preview.png) @@ -22,94 +22,40 @@ A simple tree style startpage in HTML and CSS with interchangeable and customisa ## Configuration -### Themes +### General +Configure your starttree in the `config.yml` file like so: -#### Choosing themes -1. Open the index.html file in your favorite text editor. -2. Find the line that starts with ` - - text - - -``` -before or after another branch. -#### Adding Trees -1. Open the index.html file in your favorite text editor. -2. Add -``` -
-

- - Title: -

-
-
- -``` -Where X_REPLACE_ME is the number of your Tree with a maximum of 4. +You can find all themes in the `themes/` directory. +### Search +To configure your search, search for something in your favorite search engine. The URL will look something like this: -### Clock +`https://www.startpage.com/sp/search?query=something` -#### Removing Clock -1. Open the index.html file in your favorite text editor. -2. Find and remove the line `
`. +In this case the `search_url` would be `https://www.startpage.com/sp/search` and the `search_query` would be `query`. -#### Adding Clock -1. Open the index.html file in your favorite text editor. -2. Add the line `
` at the top of the `` section. - -#### Changing Clock to American style -1. Open the clock.js file in your favorite text editor. -2. Remove the comments (`/* */`). -3. Remove the comment (`//`) before your desired time format. You can find an explanation for each on the right side of the code. -4. Comment out old Clock style with `//`. - -#### Changing Clock back to Normal style -1. Open the clock.js in your favorite text editor. -2. Put a multi-line-comment start (`/*`) before `let period = "AM"`. -3. Put a multi-line-comment end (`*/`) after `period = "PM" }`. - -### Search Engine - -#### Choosing Search Engine -1. Open the index.html file in your favorite text editor. -2. Find the `
` tags -3. Change the content of the `action=""` attribute to your search Engine -4. Change the content of the `name=""` attribute in the `` \ -\ -Example for startpage search engine: -```` - -

Search:

- -
-```` -5. **Optional**: Find the `./search -e brave` element and change `brave` to your search engine's name. \ No newline at end of file diff --git a/config.yml b/config.yml new file mode 100644 index 0000000..9886116 --- /dev/null +++ b/config.yml @@ -0,0 +1,22 @@ +- theme: "black" +- clock: true +- username: "root" +- hostname: "startpage" +- num_trees: 3 +- trees: + - title: "General" + - items: + - gmail: "https://mail.google.com" + - github: "https://github.com" + - title: "Entertainment" + - items: + - youtube: "https://www.youtube.com/" + - reddit: "https://reddit.com/" + - title: "Work" + - items: + - git: "https://git.work.org" + - homepage: "https://www.work.org" +- search: true +- search_name: "brave" +- search_url: "https://search.brave.com/search" +- search_query: "q" # ?q=YourSearchQuery diff --git a/deploy.py b/deploy.py new file mode 100644 index 0000000..92b805b --- /dev/null +++ b/deploy.py @@ -0,0 +1,88 @@ +#!/usr/bin/env python + +import yaml + +with open("config.yml", "r") as stream: + try: + config = yaml.safe_load(stream) + #print(config) + except yaml.YAMLError as exc: + print(exc) + exit + +startpage = f""" + + + + + + New Tab + + + + """ + +if config[1]['clock']: + startpage += """ +
+ """ + +prompt = '#' if config[2]['username'] == 'root' else '$' + +startpage += f""" +
+

+ [{config[2]['username']}@{config[3]['hostname']}:~] + {prompt} + ./startpage.sh +

+
+""" + +i = 0 + +while i < int(config[4]['num_trees']) * 2: + startpage += f""" +
+

+ + {config[5]['trees'][i]['title']}: +

+
+
+
    + """ + + i += 1 + + for j in range(len(config[5]['trees'][i]['items'])): + for name, url in (config[5]['trees'][i]['items'][j]).items(): + startpage += f"
  • {name}
  • \n" + + startpage += "
\n
\n" + + i += 1 + +startpage += "
" + +if config[6]['search']: + startpage += f""" +

+ [{config[2]['username']}@{config[3]['hostname']}:~] + {prompt} + ./search.sh -e {config[7]['search_name']} +

+
+

Search:

+ +
""" + +startpage += """ +
+ + +""" + +f = open("index.html", "w") +f.write(startpage) +f.close() diff --git a/index.html b/index.example.html similarity index 100% rename from index.html rename to index.example.html diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..c3726e8 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyyaml