diff --git a/README.md b/README.md new file mode 100644 index 0000000..d588a1e --- /dev/null +++ b/README.md @@ -0,0 +1,47 @@ +# HOMEMAKER +Keep making the web your own! Create your own custom static homepage! + +live demo: https://home.domdit.com/ + +#### Features: +- Customizable background images +- Background images persist in new tabs and browser instances through the use of a cookie +- Customizable links +- Links have keybinds so you can type a letter and automatically be redirected to the page of your choice +- Tabbing system to sort your links +- Customizable fonts, colors, links, page title +- Configuration file based generation + +## Quickstart: + +1. Clone this repository +2. Modify homemaker.conf +3. Run `python3 homemaker.py build` to compile your homepage +4. The compiled homepage is now in a folder called `build/` +5. Run `python3 homemaker.py serve` +6. Go to http://localhost:8000 to view your homepage +7. repeat steps 2 through 7 until you have a homepage you are happy with. +8. Take the files in the `build/` folder and host them wherever you host everything else +9. Update all of your browsers so that the home button and new tab button point to your new homepage + +## How to Host: + +### With your own server using nginx +I am not going to go in depth here. If you have your own server, I would: +- put the compiled files in the `build/` directory in `/var/www/homepage` +- create an nginx config entry that looks something like this: +``` +server { + server_name home..com www.home..com; + + location / { + root /var/www/homepage; + } +} +``` +- reload nginx and you are good to go! + +### Hosting locally +Similar to hosting remotely, probably, just read for yourself: https://tcude.net/hosting-internal-sites-with-nginx/ + + diff --git a/build/bg/crystal.png b/build/bg/crystal.png new file mode 100644 index 0000000..dac671d Binary files /dev/null and b/build/bg/crystal.png differ diff --git a/build/bg/dbz.png b/build/bg/dbz.png new file mode 100644 index 0000000..7d7c87c Binary files /dev/null and b/build/bg/dbz.png differ diff --git a/build/bg/frogs.jpg b/build/bg/frogs.jpg new file mode 100644 index 0000000..46b9063 Binary files /dev/null and b/build/bg/frogs.jpg differ diff --git a/build/bg/konata.png b/build/bg/konata.png new file mode 100644 index 0000000..5f486a1 Binary files /dev/null and b/build/bg/konata.png differ diff --git a/build/bg/lain.png b/build/bg/lain.png new file mode 100644 index 0000000..9e2bb4e Binary files /dev/null and b/build/bg/lain.png differ diff --git a/build/bg/mary_and_gabriel.png b/build/bg/mary_and_gabriel.png new file mode 100644 index 0000000..c0a08fa Binary files /dev/null and b/build/bg/mary_and_gabriel.png differ diff --git a/build/bg/sakura.jpg b/build/bg/sakura.jpg new file mode 100644 index 0000000..54b7f19 Binary files /dev/null and b/build/bg/sakura.jpg differ diff --git a/build/bg/squirtle.gif b/build/bg/squirtle.gif new file mode 100644 index 0000000..c0b87d2 Binary files /dev/null and b/build/bg/squirtle.gif differ diff --git a/build/index.html b/build/index.html new file mode 100644 index 0000000..8ef5532 --- /dev/null +++ b/build/index.html @@ -0,0 +1,177 @@ + + Home + + + + + + + + +
+ +
+ + + + + + diff --git a/homemaker.conf b/homemaker.conf new file mode 100644 index 0000000..6e4c3dc --- /dev/null +++ b/homemaker.conf @@ -0,0 +1,27 @@ +[style] +title Home +font monospace +font_color #e6e6fa +font_size 25 +link_color #e6e6fa +link_hover_color #FF3F33 + +[links] +section main +d domdit.com https://www.domdit.com +s shrinkin-minkin https://www.shrinkinminkin.com +t transmission https://transmission.domdit.com +g git https://git.domdit.com +m mail https://www.purelymail.com +y youtube https://www.youtube.com +f 4chan https://www.4chan.org + +section torrents +j jpopsuki https://www.jpopsuki.eu +v avistaz https://www.avistaz.to +n nyaa https://www.nyaa.si + +section other +i dukenukem https://icum.to +l luke smith https://www.lukesmith.xyz +p digdeeper https://digdeeper.club/ diff --git a/homemaker.py b/homemaker.py new file mode 100755 index 0000000..824ef5b --- /dev/null +++ b/homemaker.py @@ -0,0 +1,157 @@ +#!/usr/bin/python3 +import argparse +import http.server +import json +import os +import re +import shutil +import socketserver + + +class Builder: + def __init__(self): + self.config_file_path = 'homemaker.conf' + self.template_path = 'templates/template.html' + self.build_directory = 'build' + + self.key_map = {} + self.bg_map = {} + self.bg_options = '' + self.links = '' + + self.style_map = { + 'title': 'Homepage', + 'bg_img': 'null', + 'font': 'monospace', + 'font_color': '#e6e6fa', + 'font_size': '25', + 'link_color': '#e6e6fa', + 'link_hover_color': '#ff3f33', + } + + self.section_count = 0 + self.section_links = '' + self.section_array = [] + self.section_map = {} + + def main(self): + self.handle_backgrounds() + self.set_up_build_dir() + self.parse_config_file() + self.cleanup() + self.generate_files() + self.copy_bgs() + + def set_up_build_dir(self): + if os.path.exists(self.build_directory): + print('Deleting build directory...') + shutil.rmtree(self.build_directory) + + print('Creating build directory...') + os.makedirs(self.build_directory) + + def handle_backgrounds(self): + print('Parsing background images...') + for root, dirs, files in os.walk("bg/", topdown=False): + for idx, file_path in enumerate(files): + + file_name = file_path.split('/')[-1].split('.')[0] + if idx == 0: + self.style_map['bg_img'] = file_path + self.bg_map[file_name] = file_path + option = f'\t\n' + self.bg_options += option + + def parse_config_file(self): + print('Parsing config file...') + with open(self.config_file_path) as f: + mode = None + for line in f: + line = line.strip() + + if line == "[style]": + print('Handling styles...') + mode = 'style' + continue + + if line == "[links]": + print('Handling links...') + mode = 'links' + continue + + if mode == 'links': + self.handle_links(line) + elif mode == 'style': + self.handle_styles(line) + + def handle_styles(self, line): + style = re.split(r'[ \t]+', line) + if style[0] in self.style_map: + self.style_map[style[0]] = style[1] + + def handle_links(self, line): + links = re.split(r'[ \t]+', line) + if links[0] == 'section': + self.section_count += 1 + + self.section_links += f'[{self.section_count}] {links[1]} ' + self.section_array.append(links[1]) + + if self.links == '': + self.links += f'
\n' + else: + self.links += f'\n' + + else: + self.links += f'\t[{links[0]}] {links[1]}
\n' + + self.key_map[links[0]] = links[2] + + def cleanup(self): + self.links += '
\n\n' + + def generate_files(self): + print('Generating Files...') + with open(self.template_path) as f: + compiled_file = f.read() \ + .replace('{{bg_options}}', self.bg_options) \ + .replace('{{links}}', self.links) \ + .replace('{{section_links}}', self.section_links) \ + .replace('{{bg_map}}', json.dumps(self.bg_map)) \ + .replace('{{key_map}}', json.dumps(self.key_map)) \ + .replace('{{section_array}}', json.dumps(self.section_array)) \ + .replace('{{section_map}}', json.dumps(self.section_map)) + + for style, value in self.style_map.items(): + compiled_file = compiled_file.replace('{{' + style + '}}', value) + + with open(self.build_directory + '/index.html', 'w+') as f: + f.write(compiled_file) + + def copy_bgs(self): + print('Copying backgrounds..') + shutil.copytree('bg/', self.build_directory + '/bg/') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + parser.add_argument('action', type=str, help='OPTIONS:\n build - delete and recompile your build folder. \n serve - run webserver') + + args = parser.parse_args() + + if args.action == 'build': + b = Builder() + b.main() + elif args.action == 'serve': + os.chdir('build/') + PORT = 8000 + Handler = http.server.SimpleHTTPRequestHandler + + with socketserver.TCPServer(("", PORT), Handler) as httpd: + print(f"Check out your homepage here: http://localhost:{PORT}") + httpd.serve_forever() diff --git a/index.html b/index.html deleted file mode 100644 index 9e525d5..0000000 --- a/index.html +++ /dev/null @@ -1,150 +0,0 @@ - - domspace - - - - - - -
- -
- - - - diff --git a/style.css b/style.css deleted file mode 100644 index eb9603b..0000000 --- a/style.css +++ /dev/null @@ -1,53 +0,0 @@ -body { - background-image: url("bg/frogs.jpg"); - background-size: cover; - background-position: center; - font-family: monospace, monospace; - font-size: 25px; - color: #e6e6fa; -} - -table, th, td { - border: 1px solid black; -} - -.settings { - position: absolute; - top: 10px; - right: 20px; - font-size: 14px; -} - -option, select { - width: 70px; - font-family: monospace, monospace; - background: grey; -} - -.container { - display: flex; - align-items: center; - justify-content: center; - height: 100%; -} - -.link-container { - width: 300px; - background: rgba(255, 255, 50, 0.11); - box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1); - backdrop-filter: blur(15px); - -webkit-backdrop-filter: blur(15px); - border: 1px solid rgba(255, 255, 255, 0.26); - padding: 20px; -} - -.link { - color: #e6e6fa; - text-decoration: none; -} - -.link:hover { - color: #FF3F33; - text-decoration: none; -} - diff --git a/templates/template.html b/templates/template.html new file mode 100644 index 0000000..7e5dfe0 --- /dev/null +++ b/templates/template.html @@ -0,0 +1,149 @@ + + {{title}} + + + + + + + + +
+ +
+
+ +
+ + + + +