diff --git a/router_gen/main.go b/router_gen/main.go index feaede4b..c83c82f2 100644 --- a/router_gen/main.go +++ b/router_gen/main.go @@ -179,6 +179,7 @@ func main() { mapIt("routes.StaticFile") mapIt("routes.RobotsTxt") mapIt("routes.SitemapXml") + mapIt("routes.OpenSearchXml") mapIt("routes.BadRoute") mapIt("routes.HTTPSRedirect") tmplVars.AllRouteNames = allRouteNames @@ -832,6 +833,9 @@ func (r *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, user c //log.Print("req.URL.Path: ",req.URL.Path) routes.StaticFile(w,req) return nil + case "opensearch.xml": + counters.RouteViewCounter.Bump({{index .AllRouteMap "routes.OpenSearchXml"}}) + return routes.OpenSearchXml(w,req) /*case "sitemap.xml": counters.RouteViewCounter.Bump({{index .AllRouteMap "routes.SitemapXml"}}) return routes.SitemapXml(w,req)*/ diff --git a/routes/api.go b/routes/api.go index 7b0d9e93..1ac53a49 100644 --- a/routes/api.go +++ b/routes/api.go @@ -252,3 +252,19 @@ func APIMe(w http.ResponseWriter, r *http.Request, user c.User) c.RouteError { return nil } + +func OpenSearchXml(w http.ResponseWriter, r *http.Request) c.RouteError { + furl := "http" + if c.Site.EnableSsl { + furl += "s" + } + furl += "://"+c.Site.URL + w.Write([]byte(` + `+c.Site.Name+` + UTF-8 + + + `+furl+` +`)) + return nil +}