summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordemo <demo@antix1>2026-05-08 10:37:02 -0400
committerdemo <demo@antix1>2026-05-08 10:37:02 -0400
commit6ae1c16ec74dfef44dad2b49fc19bef4ee945ec4 (patch)
tree2021dbddecc67941dca4da5e643175fd3c689355
parent8a3554d4f32d631bd1c7cc6254ab11b14b541c67 (diff)
feat: implement localclient logic
I've also added the local html files I'll be working with.
-rw-r--r--cmd/localclient/main.go31
-rw-r--r--html/ex1.html6
-rw-r--r--html/ex2.html17
-rw-r--r--html/ex3.html62
-rw-r--r--html/ex4.html5
5 files changed, 121 insertions, 0 deletions
diff --git a/cmd/localclient/main.go b/cmd/localclient/main.go
index 21d405d..e65e49f 100644
--- a/cmd/localclient/main.go
+++ b/cmd/localclient/main.go
@@ -2,13 +2,44 @@ package main
import (
"flag"
+ "fmt"
"log"
+ "os"
+ "strings"
+
+ "git.brandonirizarry.xyz/links/internal/findlinks"
)
func main() {
+ // Set up logging.
+ log.SetFlags(log.LstdFlags | log.Lshortfile)
+
+ // Retrieve the CLI flags, and check them.
filename := flag.String("file", "", "Local HTML file")
+ flag.Parse()
+
if *filename == "" {
log.Fatal("Missing -file argument")
}
+ // FIXME: .htm is possible as well, but I'm skipping that for
+ // now. Also, we could look into templates and that sort of
+ // thing at some point.
+ if !strings.HasSuffix(*filename, ".html") {
+ log.Fatal("Need HTML file (.html)")
+ }
+
+ // Open the local file.
+ f, err := os.Open(*filename)
+ if err != nil {
+ log.Fatalf("can't open %s: %v", *filename, err)
+ }
+ defer f.Close()
+
+ links, err := findlinks.FindLinks(f)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ fmt.Println(links)
}
diff --git a/html/ex1.html b/html/ex1.html
new file mode 100644
index 0000000..833f110
--- /dev/null
+++ b/html/ex1.html
@@ -0,0 +1,6 @@
+<html>
+<body>
+ <h1>Hello!</h1>
+ <a href="/other-page">A link to another page</a>
+</body>
+</html>
diff --git a/html/ex2.html b/html/ex2.html
new file mode 100644
index 0000000..3d22f94
--- /dev/null
+++ b/html/ex2.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
+</head>
+<body>
+ <h1>Social stuffs</h1>
+ <div>
+ <a href="https://www.twitter.com/joncalhoun">
+ Check me out on twitter
+ <i class="fa fa-twitter" aria-hidden="true"></i>
+ </a>
+ <a href="https://github.com/gophercises">
+ Gophercises is on <strong>Github</strong>!
+ </a>
+ </div>
+</body>
+</html>
diff --git a/html/ex3.html b/html/ex3.html
new file mode 100644
index 0000000..1e718e2
--- /dev/null
+++ b/html/ex3.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<!--[if lt IE 7]> <html class="ie ie6 lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
+<!--[if IE 7]> <html class="ie ie7 lt-ie9 lt-ie8" lang="en"> <![endif]-->
+<!--[if IE 8]> <html class="ie ie8 lt-ie9" lang="en"> <![endif]-->
+<!--[if IE 9]> <html class="ie ie9" lang="en"> <![endif]-->
+<!--[if !IE]><!-->
+<html lang="en" class="no-ie">
+<!--<![endif]-->
+
+<head>
+ <title>Gophercises - Coding exercises for budding gophers</title>
+</head>
+
+<body>
+ <section class="header-section">
+ <div class="jumbo-content">
+ <div class="pull-right login-section">
+ Already have an account?
+ <a href="#" class="btn btn-login">Login <i class="fa fa-sign-in" aria-hidden="true"></i></a>
+ </div>
+ <center>
+ <img src="https://gophercises.com/img/gophercises_logo.png" style="max-width: 85%; z-index: 3;">
+ <h1>coding exercises for budding gophers</h1>
+ <br/>
+ <form action="/do-stuff" method="post">
+ <div class="input-group">
+ <input type="email" id="drip-email" name="fields[email]" class="btn-input" placeholder="Email Address" required>
+ <button class="btn btn-success btn-lg" type="submit">Sign me up!</button>
+ <a href="/lost">Lost? Need help?</a>
+ </div>
+ </form>
+ <p class="disclaimer disclaimer-box">Gophercises is 100% FREE, but is currently in beta. There will be bugs, and things will be changing significantly over the coming weeks.</p>
+ </center>
+ </div>
+ </section>
+ <section class="footer-section">
+ <div class="row">
+ <div class="col-md-6 col-md-offset-1 vcenter">
+ <div class="quote">
+ "Success is no accident. It is hard work, perseverance, learning, studying, sacrifice and most of all, love of what you are doing or learning to do." - Pele
+ </div>
+ </div>
+ <div class="col-md-4 col-md-offset-0 vcenter">
+ <center>
+ <img src="https://gophercises.com/img/gophercises_lifting.gif" style="width: 80%">
+ <br/>
+ <br/>
+ </center>
+ </div>
+ </div>
+ <div class="row">
+ <div class="col-md-10 col-md-offset-1">
+ <center>
+ <p class="disclaimer">
+ Artwork created by Marcus Olsson (<a href="https://twitter.com/marcusolsson">@marcusolsson</a>), animated by Jon Calhoun (that's me!), and inspired by the original Go Gopher created by Renee French.
+ </p>
+ </center>
+ </div>
+ </div>
+ </section>
+</body>
+</html>
diff --git a/html/ex4.html b/html/ex4.html
new file mode 100644
index 0000000..0e893b8
--- /dev/null
+++ b/html/ex4.html
@@ -0,0 +1,5 @@
+<html>
+<body>
+ <a href="/dog-cat">dog cat <!-- commented text SHOULD NOT be included! --></a>
+</body>
+</html>