소스 검색

Started Implementing User Sitemap

Yoginth 7 년 전
부모
커밋
c2ce26dc0a
3개의 변경된 파일27개의 추가작업 그리고 2개의 파일을 삭제
  1. 2 0
      cmd/web.go
  2. 0 2
      routes/user/certificate.go
  3. 25 0
      routes/user/sitemap.go

+ 2 - 0
cmd/web.go

@@ -310,6 +310,8 @@ func runWeb(c *cli.Context) error {
 
 	// ***** END: Pages *****
 
+	m.Get("/user.sitemap.xml", ignSignIn, user.Sitemap)
+
 	// ***** START: Misc *****
 	m.Get("/certificate/:username", ignSignIn, user.InternCertificate)
 	// ***** END: Misc *****

+ 0 - 2
routes/user/certificate.go

@@ -11,8 +11,6 @@ const (
 
 func InternCertificate(c *context.Context) {
 	ctxUser := GetUserByName(c, strings.TrimSuffix(c.Params(":username"), ""))
-
-	c.Data["PageIsUserProfile"] = true
 	c.Data["Owner"] = ctxUser
 
 	c.HTML(200, INTERNCERTIFICATE)

+ 25 - 0
routes/user/sitemap.go

@@ -0,0 +1,25 @@
+package user
+
+import (
+	"encoding/xml"
+	"net/http"
+)
+
+type Urlset struct {
+	Loc        string `xml:"url>loc"`
+	Changefreq string `xml:"url>changefreq"`
+	Priority   string `xml:"url>priority"`
+}
+
+func Sitemap(w http.ResponseWriter, r *http.Request) {
+	profile := Urlset{"dfsdf", "dgg", "fsdjfn"}
+
+	x, err := xml.MarshalIndent(profile, "", "  ")
+	if err != nil {
+		http.Error(w, err.Error(), http.StatusInternalServerError)
+		return
+	}
+
+	w.Header().Set("Content-Type", "application/xml")
+	w.Write(x)
+}