aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar alecdwm 2015-10-05 18:47:00 +1100
committerGravatar alecdwm 2015-10-07 17:46:11 +1000
commit6e9a8abe81d409f74cb2a8d063497b63a7d4af7d (patch)
tree8c0c62ae1ef476f7297c73b3ec2eba879f354585
parent6cf444a70f730d376edbf9b883d77d1a991098ef (diff)
Improved 'profile page' display
-rw-r--r--lib/gogetme.go146
1 files changed, 114 insertions, 32 deletions
diff --git a/lib/gogetme.go b/lib/gogetme.go
index a635e1a..289111f 100644
--- a/lib/gogetme.go
+++ b/lib/gogetme.go
@@ -95,38 +95,120 @@ func handler(w http.ResponseWriter, r *http.Request) {
// Todo: versioning URLs e.g. go.owls.io/gogetme/v1
// go.owls.io/gogetme.v1
// constructed from git branches and tags
- fmt.Fprintf(w,
- "<!DOCTYPE html>\n"+
- "<html lang=\"en\">\n"+
- "<head>\n"+
- "<meta charset=\"utf-8\">\n"+
- "<meta name=\"go-import\" content=\"%s git https://github.com/%s/%s.git\">\n"+
- "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n"+
- "<title>%s %s/%s</title>\n"+
- "<link href=\"https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/darkly/bootstrap.min.css\" rel=\"stylesheet\" crossorigin=\"anonymous\">\n"+
- "<script src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js\"></script>\n"+
- "<script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js\" crossorigin=\"anonymous\"></script>\n"+
- "</head>\n"+
- "<body>\n"+
- "<div class=\"container\">\n"+
- "<div class=\"panel panel-default\">\n"+
- "<img class=\"pull-left panel-profile-img img-circle\" style=\"width:120px;height:120px;\" src=\"%s\" />\n"+
- "<div class=\"panel-body text-center\">\n"+
- "<h1 class=\"text-right panel-title\">%s</h5>\n"+
- "<p class=\"text-right\">%s/%s</p>\n"+
- "<a href=\"https://github.com/%s/%s\" class=\"pull-right btn btn-primary-outline btn-sm\">%s</a>\n"+
- "</div>\n"+
- "</div>\n"+
- "</div>\n"+
- "</div>\n"+
- "</body>\n"+
- "</html>",
- customUrl+"/"+r.URL.Path[1:], gitHubUser, r.URL.Path[1:],
- customUrl, gitHubUser, r.URL.Path[1:],
- gitHubUserAvatarURL,
- gitHubUser,
- customUrl, r.URL.Path[1:],
- gitHubUser, r.URL.Path[1:], "Click here to go to the repository")
+ pageCss := `
+.card {
+ padding-top: 20px;
+ margin: 10px 0 20px 0;
+ background-color: rgba(214, 224, 226, 0.2);
+ border-top-width: 0;
+ border-bottom-width: 2px;
+ -webkit-border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-radius: 3px;
+ -webkit-box-shadow: none;
+ -moz-box-shadow: none;
+ box-shadow: none;
+ -webkit-box-sizing: border-box;
+ -moz-box-sizing: border-box;
+ box-sizing: border-box;
+}
+.card.hovercard {
+ position: relative;
+ padding-top: 0;
+ overflow: hidden;
+ text-align: center;
+ background-color: rgba(214, 224, 226, 0.2);
+}
+.card.hovercard .cardheader {
+ background: url("http://blog.golang.org/gopher/header.jpg");
+ background-size: cover;
+ height: 135px;
+}
+.card.hovercard .avatar {
+ position: relative;
+ top: -50px;
+ margin-bottom: -50px;
+}
+.card.hovercard .avatar img {
+ width: 100px;
+ height: 100px;
+ max-width: 100px;
+ max-height: 100px;
+ -webkit-border-radius: 50%;
+ -moz-border-radius: 50%;
+ border-radius: 50%;
+ border: 5px solid rgba(255,255,255,0.5);
+}
+.card.hovercard .info {
+ padding: 4px 8px 10px;
+}
+.card.hovercard .info .title {
+ margin-bottom: 4px;
+ font-size: 24px;
+ line-height: 1;
+ color: #262626;
+ vertical-align: middle;
+}
+.card.hovercard .info .desc {
+ overflow: hidden;
+ font-size: 12px;
+ line-height: 20px;
+ color: #737373;
+ text-overflow: ellipsis;
+}
+.card.hovercard .bottom {
+ padding: 0 20px;
+ margin-bottom: 17px;
+}
+`
+
+ pageHtml := fmt.Sprintf(`<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <meta name="go-import" content="%s git https://github.com/%s.git">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <title>%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>
+ <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>
+ <body>
+ <div class="container">
+ <div class="card hovercard">
+ <div class="cardheader"></div>
+ <div class="avatar">
+ <img alt="%s's GitHub Avatar" src="%s">
+ </div>
+ <div class="info">
+ <div class="title">
+ <a href="https://github.com/%s">%s</a>
+ </div>
+ <div class="desc">go get -u %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>
+ </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")
+
+ fmt.Fprint(w, pageHtml)
}
func GoGetMe() {