aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar alecdwm 2015-10-08 16:54:36 +1000
committerGravatar alecdwm 2015-10-08 17:10:37 +1000
commitb05838337b8963ec7e18d439fe9e87156dfeadf2 (patch)
tree076954ac4a84b2af38082e01eefa2e985d62d8cc
parentddb7be24df60af6e0d01b79847ad4446b8aa9115 (diff)
Improved variable substitution in HTML string
-rw-r--r--lib/gogetme.go30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/gogetme.go b/lib/gogetme.go
index cc4553a..ee2848c 100644
--- a/lib/gogetme.go
+++ b/lib/gogetme.go
@@ -159,13 +159,13 @@ func handler(w http.ResponseWriter, r *http.Request,
<html lang="en">
<head>
<meta charset="utf-8">
- <meta name="go-import" content="%s git https://github.com/%s.git">
+ <meta name="go-import" content="%[1]s/%[2]s git https://github.com/%[3]s/%[2]s.git">
<meta name="viewport" content="width=device-width, initial-scale=1">
- <title>%s</title>
+ <title>%[1]s/%[2]s</title>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<link href="//cdnjs.cloudflare.com/ajax/libs/bootstrap-social/4.10.1/bootstrap-social.min.css" rel="stylesheet">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
- <style>%s</style>
+ <style>%[5]s</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
@@ -174,32 +174,30 @@ func handler(w http.ResponseWriter, r *http.Request,
<div class="card hovercard">
<div class="cardheader"></div>
<div class="avatar">
- <img alt="%s's GitHub Avatar" src="%s">
+ <img alt="%[3]s's GitHub Avatar" src="%[4]s">
</div>
<div class="info">
<div class="title">
- <a href="https://github.com/%s">%s</a>
+ <a href="https://github.com/%[3]s">%[3]s</a>
</div>
- <div class="desc">go get -u %s</div>
+ <div class="desc">go get -u %[1]s/%[2]s</div>
</div>
</div>
<div class="bottom">
- <a class="btn btn-block btn-social btn-github" href="https://github.com/%s">
- <i class="fa fa-github"></i> %s
+ <a class="btn btn-block btn-social btn-github" href="https://github.com/%[3]s/%[2]s">
+ <i class="fa fa-github"></i> Visit the project on GitHub
</a>
</div>
</div>
</body>
</html>
`,
- customUrl+"/"+r.URL.Path[1:], githubUser+"/"+r.URL.Path[1:], // go-import
- customUrl+"/"+r.URL.Path[1:], // page title
- pageCss, // page custom css
-
- githubUser, githubUserAvatarURL, // github avatar img
- githubUser, githubUser, // github username
- customUrl+"/"+r.URL.Path[1:], // go get -u [project url]
- githubUser+"/"+r.URL.Path[1:], "Visit the project on GitHub")
+ customUrl, // %[1]s
+ r.URL.Path[1:], // %[2]s
+ githubUser, // %[3]s
+ githubUserAvatarURL, // %[4]s
+ pageCss, // %[5]s
+ )
fmt.Fprint(w, pageHtml)
}