diff options
-rw-r--r-- | README.md | 18 | ||||
-rwxr-xr-x | non-empty-sites.cgi | 31 | ||||
-rwxr-xr-x | non-empty-sites.sh | 32 |
3 files changed, 49 insertions, 32 deletions
diff --git a/README.md b/README.md index d566408..0e2afd9 100644 --- a/README.md +++ b/README.md @@ -12,8 +12,24 @@ The output file is named `sites` by default, but may be given a different name o By default, the script makes up to five backup copies of the output file. The number of backups can also be specified on the command line. -## non-empty-sites.cgi +## non-empty-sites.sh A Python script that generates a web page with links to the sites in the file generated by `site-scan.` As written, this script expects the list of sites to be in a file named `sites.` ## non-empty-sites.css A stylesheet used by `non-empty-sites.cgi`. + +# Instructions +Generate the list of apparently non-empty sites +``` +$ ./site-scan +``` + +Generate the web page +``` +$ ./non-empty-sites.sh >non-empty-sites.html +``` + +Deploy the web page +``` +$ cp ./non-empty-sites.html ~/public_html +``` diff --git a/non-empty-sites.cgi b/non-empty-sites.cgi deleted file mode 100755 index 75d60a5..0000000 --- a/non-empty-sites.cgi +++ /dev/null @@ -1,31 +0,0 @@ -#!/usr/bin/env python3 - -import sys -import os -from datetime import datetime - -sites_file = "./sites" -mtime = datetime.fromtimestamp(os.path.getmtime(sites_file)).strftime("%Y-%m-%d %H:%M") - -print("Content-Type: text/html; charset=utf-8\r\n"); -print("\r\n\r\n"); - -print("<!doctype html>"); -print('<html lang="en">'); -print("<head>"); -print("<meta charset=\"utf-8\">"); -print("<title>Non-Empty Sites</title>"); -print("<link href='non-empty-sites.css' rel='stylesheet' type='text/css'"); -print("</head>"); -print("<body>"); -print("<h1>Apparently non-empty sites at tilde.institute</h1>"); -print('<p>As of {}, the following <b>tilde.institute</b> users had at least one file in their <i>public_html</i> folder, so you might find some sort of web site there.</p>'.format(mtime)) -print("<ul class='sites'>") -with open(sites_file) as file: - for line in file: - l = line.rstrip() - print("<li><a href='https://% s.tilde.institute/'>%s</a></li>" % (l, l)) -print("</ul>") -print("<p>I put this together to learn something about writing shell and CGI scripts on tilde.institue.</p>") -print("</body>"); -print("</html>"); diff --git a/non-empty-sites.sh b/non-empty-sites.sh new file mode 100755 index 0000000..87647ac --- /dev/null +++ b/non-empty-sites.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import array +import sys +import os +from datetime import datetime + +sites_file = "./sites" +mtime = datetime.fromtimestamp(os.path.getmtime(sites_file)).strftime("%Y-%m-%d %H:%M") + +sites_list = ['<ul class="sites">'] +with open(sites_file) as file: + for line in file: + l = line.rstrip() + sites_list.append("<li><a href='https://% s.tilde.institute/'>%s</a></li>" % (l, l)) +sites_list.append("</ul>") + +payload = ("<!doctype html>" + '<html lang="en">' + "<head>" + "<meta charset=\"utf-8\">" + "<title>Non-Empty Sites</title>" + "<link href='non-empty-sites.css' rel='stylesheet' type='text/css'" + "</head>" + "<body>" + "<h1>Apparently non-empty sites at tilde.institute</h1>" + '<p>As of {}, the following <b>tilde.institute</b> users had at least one file in their <i>public_html</i> folder, so you might find some sort of web site there.</p>' + "{}" + "<p>I put this together to learn something about writing shell and CGI scripts on tilde.institue. <a href='https://git.tilde.institute/padeso/non-empty-sites/'>[source]</a></p>" + "</body>" + "</html>").format(mtime, "".join(sites_list)) +print(payload) |