diff options
Diffstat (limited to 'tls-pem2html.go')
-rw-r--r-- | tls-pem2html.go | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/tls-pem2html.go b/tls-pem2html.go index be93b44..6cecbf6 100644 --- a/tls-pem2html.go +++ b/tls-pem2html.go @@ -28,8 +28,10 @@ func handleBool(ok bool, str string, a ...interface{}) { var tmpl = template.Must(template.New("pem2html"). Funcs(template.FuncMap{ - "red": red, - "green": green, + "red": red, + "green": green, + "time": fTime, + "datetime": fDateTime, }).Parse(`<!DOCTYPE html> <html lang="en"> <head> @@ -77,6 +79,9 @@ var tmpl = template.Must(template.New("pem2html"). height: 100%; color: black; } + time .time { + display: none + } </style> <script src="sorttable.js"></script> <base target="_parent" /> @@ -84,7 +89,7 @@ var tmpl = template.Must(template.New("pem2html"). <body> <table class=sortable> <caption> - <p>Live Certs (Updated {{.now.Local.Format "2006-01-02 15:04:05"}})</p> + <p>Live Certs (Updated {{.now | datetime}})</p> </caption> <tr> <th>NotBefore</th> @@ -94,8 +99,8 @@ var tmpl = template.Must(template.New("pem2html"). </tr> {{range $cert := .certs}} <tr class="{{$cert.Class}}"> - <td style="background-color: {{$cert.X509.NotBefore | green}}"><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.X509.NotBefore.Local.Format "2006-01-02"}}</a></td> - <td style="background-color: {{$cert.X509.NotAfter | red }}"><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.X509.NotAfter.Local.Format "2006-01-02"}}</a></td> + <td style="background-color: {{$cert.X509.NotBefore | green}}"><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.X509.NotBefore | time}}</a></td> + <td style="background-color: {{$cert.X509.NotAfter | red }}"><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.X509.NotAfter | time}}</a></td> <td><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.X509.Subject.CommonName | html}}</a></td> <td><a href="{{$cert.Url}}" title="{{$cert.Error}}">{{$cert.Socket | html}}</a></td> </tr> @@ -105,6 +110,14 @@ var tmpl = template.Must(template.New("pem2html"). </html> `)) +func fTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\" title=\"2006-01-02 15:04:05\">2006-01-02 <span class=time>15:04:05</span></time>")) +} + +func fDateTime(t time.Time) template.HTML { + return template.HTML(t.Local().Format("<time datetime=\"2006-01-02 15:04:05\">2006-01-02 15:04:05</time>")) +} + func getNow() time.Time { stat, err := os.Stdin.Stat() if err == nil { |