Compare commits

..

No commits in common. "a4111ca13be320c73a1fcb87ae9bd9f11be6dfce" and "b9d5c2df468ba6ae09a0faea49b0d5a0c9d132fd" have entirely different histories.

5 changed files with 17 additions and 61 deletions

1
.envrc
View file

@ -1 +0,0 @@
use nix;

1
.gitignore vendored
View file

@ -1,3 +1,2 @@
main
index.html
.direnv

20
main.go
View file

@ -57,7 +57,7 @@ type HatsSite struct {
}
func getSite(domainName string, wd selenium.WebDriver) (hatsSite HatsSite) {
log.Printf("Retrieving info for %v\n", domainName)
log.Printf("Retrieving info for %v\n", hatsSite.DomainName)
hatsSite.DomainName = domainName
hatsSite.FetchTime = time.Now()
@ -147,7 +147,7 @@ func main() {
const (
geckoDriverPath = "deps/geckodriver"
geckoDriverPort = 8081
geckoDriverPort = 8080
)
opts := []selenium.ServiceOption{
@ -162,9 +162,7 @@ func main() {
}
defer service.Stop()
wd, err := selenium.NewRemote(selenium.Capabilities{
"acceptInsecureCerts": true,
}, fmt.Sprintf("http://localhost:%d", geckoDriverPort))
wd, err := selenium.NewRemote(nil, fmt.Sprintf("http://localhost:%d", geckoDriverPort))
if err != nil {
panic(err)
}
@ -172,12 +170,12 @@ func main() {
if *serve {
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
err = generateHTML(getSites(*largest, wd), w)
if err != nil {
w.Write([]byte(err.Error()))
}
// err := generateHTML(w, *largest, wd)
// if err != nil {
// w.Write([]byte(err.Error()))
// }
})
fmt.Printf("Serving on %v\n", *port)
fmt.Printf("Serving on %v\n", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%v", *port), nil))
} else {
file, err := os.Create(*filename)
@ -186,7 +184,7 @@ func main() {
}
err = generateHTML(getSites(*largest, wd), file)
if err != nil {
log.Fatal(err)
fmt.Println(err)
}
}
}

View file

@ -1,12 +0,0 @@
let
nixpkgs = fetchTarball "https://github.com/NixOS/nixpkgs/tarball/nixos-24.05";
pkgs = import nixpkgs { config = {}; overlays = []; };
in
pkgs.mkShellNoCC {
packages = with pkgs; [
go
xorg.xorgserver # xorg.xvfb once https://github.com/NixOS/nixpkgs/commit/43ebb05c575221362b44d7cc9a0f0cd1b5d3a53d hits stable
xorg.xauth
];
}

View file

@ -6,63 +6,36 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{n}hats.com domains</title>
<style>
body { max-width: 800px; font-family: sans-serif; margin: auto; padding: 0 20px; }
body { max-width: 800px; font-family: sans-serif; margin: auto; }
dt { font-weight: bold; }
img { max-width: 100%; box-shadow: 0 0 10px 10px lightgray; }
img:hover { box-shadow: 0 0 10px 10px darkgray}
h3 { margin-top: 100px; }
.errors { padding: 0.5rem; border: 1px solid #f5c6cb; color: #721c24; background: #f8d7da; }
* { line-height: 1.5em; }
</style>
</head>
<body>
<h1>{n}hats.com domains</h1>
<p><em>Last updated {{(index . 0).FetchTime.Format "Jan 2, 2006" }}</em></p>
{{ $errors := false -}}
{{- range . -}}
{{- with .Error -}}
{{- $errors = true -}}
{{- end -}}
{{- end -}}
{{- if $errors -}}
<div class="errors">
<h4>Errors occurred during processing</h3>
<ol>
{{- range . -}}
{{- if .Error }}
<li>{{.DomainName}}: {{.Error}}</li>
{{ end -}}
{{- end -}}
</ol>
</div>
{{end}}
<h3>Summary</h3>
<ul>
{{range .}}
{{if not .Error}}
{{if .Available}}
<li><a href="#{{.DomainName}}">{{.DomainName}}</a> &ndash; Available!</li>
{{else}}
<li><a href="#{{.DomainName}}">{{.DomainName}}</a> &ndash; Registered since {{(parseTime .DomainInfo.CreatedDate).Format "Jan 2, 2006" }}</li>
{{end}}
<li><a href="#{{.DomainName}}">{{.DomainName}}</a> &ndash; Registered since {{(parseTime .DomainInfo.CreatedDate).Format "Mon Jan 2 2006" }}</li>
{{end}}
{{end}}
</ul>
{{range .}}
{{if not .Error}}
<h3 id="{{.DomainName}}">{{.DomainName}}</h3>
<dl>
<dt>Fetched</dt>
<dd>{{.FetchTime.Format "Jan 2, 2006 15:04:05 -0700" }}</dd>
<dd>{{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}</dd>
{{if not .Available}}
<dt>Owner</dt>
{{if .Registrant}}
<dd><a href="mailto:{{.Registrant.Email}}">{{.Registrant.Name}} &lt;{{.Registrant.Email}}&gt</a></dd>
{{else}}
<dd>Information unavailable</dd>
{{end}}
<dt>Since</dt>
<dd>{{(parseTime .DomainInfo.CreatedDate).Format "Jan 2, 2006" }}</dd>
<dd>{{(parseTime .DomainInfo.CreatedDate).Format "Mon Jan 2 2006" }}</dd>
{{end}}
{{with .Title}}
<dt>Title</dt>
@ -75,10 +48,9 @@
</dl>
{{if .ScreenshotURL}}
<a href="http://{{.DomainName}}">
<img src="{{.ScreenshotURL}}" alt="screenshot of {{.DomainName}} as of {{.FetchTime.Format "Jan 2, 2006 15:04:05 -0700" }}">
<img src="{{.ScreenshotURL}}" alt="screenshot of {{.DomainName}} as of {{.FetchTime.Format "Mon Jan 2 15:04:05 -0700 MST 2006" }}">
</a>
{{end}}
{{end}}
{{end}}
</body>
</html>