summaryrefslogtreecommitdiffstats
path: root/play
diff options
context:
space:
mode:
authorAndrés Cuervo <acwervo@gmail.com>2023-04-03 17:17:40 +0000
committerAndrés Cuervo <acwervo@gmail.com>2023-04-03 17:17:40 +0000
commitc7f6843ea2dfe31dbd4e3edfd09e5ad230e2af24 (patch)
treea1bcdd59369fda699e23b15580da375b4b355e49 /play
parentDocument negation and non-capturing (diff)
downloadfolk-c7f6843ea2dfe31dbd4e3edfd09e5ad230e2af24.tar.gz
folk-c7f6843ea2dfe31dbd4e3edfd09e5ad230e2af24.zip
Add circle to pi Display, center shapes correctly
Diffstat (limited to 'play')
-rw-r--r--play/Example_Domain.html46
-rw-r--r--play/wget.tcl35
2 files changed, 81 insertions, 0 deletions
diff --git a/play/Example_Domain.html b/play/Example_Domain.html
new file mode 100644
index 00000000..5a9b52fc
--- /dev/null
+++ b/play/Example_Domain.html
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+ <title>Example Domain</title>
+
+ <meta charset="utf-8" />
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <style type="text/css">
+ body {
+ background-color: #f0f0f2;
+ margin: 0;
+ padding: 0;
+ font-family: -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+
+ }
+ div {
+ width: 600px;
+ margin: 5em auto;
+ padding: 2em;
+ background-color: #fdfdff;
+ border-radius: 0.5em;
+ box-shadow: 2px 3px 7px 2px rgba(0,0,0,0.02);
+ }
+ a:link, a:visited {
+ color: #38488f;
+ text-decoration: none;
+ }
+ @media (max-width: 700px) {
+ div {
+ margin: 0 auto;
+ width: auto;
+ }
+ }
+ </style>
+</head>
+
+<body>
+<div>
+ <h1>Example Domain</h1>
+ <p>This domain is for use in illustrative examples in documents. You may use this
+ domain in literature without prior coordination or asking for permission.</p>
+ <p><a href="https://www.iana.org/domains/example">More information...</a></p>
+</div>
+</body>
+</html>
diff --git a/play/wget.tcl b/play/wget.tcl
new file mode 100644
index 00000000..65e03076
--- /dev/null
+++ b/play/wget.tcl
@@ -0,0 +1,35 @@
+if {0} {
+ example syntax: Wish $this downloads "URL"
+
+ When someone wishes for a page to be downloaded we check to see if there's
+ $title.html in the current directory. If there is, we don't download it.
+
+ If there isn't, we download the page and save it as $title.html
+}
+
+
+# proc called findTitle that searches a string of HTML for the title using regexp and returns the text of the title
+proc findTitle {webpage} {
+ set title [regexp -inline -all -line -lineanchor {<title>(.*)</title>} $webpage]
+ return [lindex $title 1]
+}
+
+# proc called getWebpage that takes a URL, uses exec & wget to print out the content as a string
+proc getWebpage {URL} {
+ set webpage [exec wget -q -O - $URL]
+ return $webpage
+}
+
+# proc called download that takes a URL, uses getWebpage to download the content to a file
+proc download {URL} {
+ set webpage [getWebpage $URL]
+ set title [string map {" " "_"} [findTitle $webpage]]
+ puts "title: $title"
+ puts "writing to file $title.html"
+ set file [open $title.html w]
+ puts $file $webpage
+ close $file
+}
+
+# this works! downloads example.com to Example_Domain.html
+download example.com \ No newline at end of file