Articles
Software
Gallery
Other works
Contacts

#Site rendering for dummies.html



        {// examples
            >the goal is the same with each methodology
            >we have data.txt
            >it contains key-value pairs
            ¤its generated with this script
                {@begin=sh@
                    #!/bin/bash

                    # generator.sh

                    OUTPUT="data.txt"

                    while true; do 
                        rm $OUTPUT
                        for i in {0..7}; do 
                            (tr -dc A-Za-z0-9 > $OUTPUT
                        done
                        sleep 5
                    done
                 @end=sh@}
            >each website will attempt to display the contents of data.txt
        }
        Static:
            >completely handwritten
            >old school
            >fast both server and client side
            >there are no rapidly changing elements as every modification is manual
            >works very well for small sites consistent in content
            { // static.html
              @begin=html@
                

Example webpage

dYcoNjAe15810
aey3hj9V30474
w50EXL8K9688
gt3qgccG21265
z63cbqAt29301
uchA1fn81941
YRxi9MrI31986
AMqnWWNZ16368
@end=html@ >since its all manual, the values are hardcoded >was a chore just to create the example } Dynamic: >created at request >a (markup) generator must be used {php} { // dynamic.php @begin=php@

Example webpage

@end=php@ >the file is actually opened and read >the websites content is guaranteed to correspond to data.txt's contents } Prerendered: >a dynamic is eval-ed before being deployed >at runtime the pre-generated version is being shipped >hybrid of static and dynamic >often also called static for simplicity >less typing than with static >contents might get out of date >often used when the pages do not require updating, but all use the same template {every page needs the same header added} { // dynamic.php @begin=php@

Example webpage

@end=php@ // its rendered to disk $ php dynamic.php > prerendered.html // prerendered.html is shipped } Live: >the website is blank by default, the content is appended by communicating with the server in the background >uses websockets >stateful connection >can update the contents without refreshing the page >most reliable regarding data-freshness >requires by far the most work relative to the other methods >requires writing js, for this reason alone, it's cancer { // Socks server using python #!/bin/python # sockets.py import asyncio import websockets import json async def send_data(ws): while True: j = {} with open('data.txt', 'r') as f: for line in f: key, value = map(str.strip, line.split(':', 1)) j[key] = value await ws.send(json.dumps(j, indent=4)) await asyncio.sleep(2) asyncio.get_event_loop().run_until_complete(websockets.serve(send_data, 'localhost', 8765)) asyncio.get_event_loop().run_forever() // Socks client using Javascript nested into the webpage @begin=html@

Example webpage

@end=html@ >looks cool, i know }