1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Sitemap now working

This commit is contained in:
Zack Scholl 2017-10-15 07:58:43 -06:00
parent 026dd7c647
commit b2a01d0a6d
2 changed files with 12 additions and 12 deletions

View File

@ -121,8 +121,6 @@ func generateSiteMap() (sitemap string) {
}
names = names[:i]
lastEdited = lastEdited[:i]
fmt.Println(names)
sitemap = `<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`
for i := range names {
@ -140,17 +138,16 @@ func generateSiteMap() (sitemap string) {
}
func handlePageRequest(c *gin.Context) {
page := c.Param("page")
command := c.Param("command")
if page == "sitemap.xml" {
c.Data(http.StatusOK, contentType("sitemap.xml"), []byte(generateSiteMap()))
return
}
command := c.Param("command")
if len(command) < 2 {
c.Redirect(302, "/"+page+"/edit")
} else if page == "favicon.ico" {
data, _ := Asset("/static/img/cowyo/favicon.ico")
c.Data(http.StatusOK, contentType("/static/img/cowyo/favicon.ico"), data)
return
}
// Serve static content from memory
if page == "static" {
} else if page == "static" {
filename := page + command
data, err := Asset(filename)
if err != nil {
@ -159,6 +156,10 @@ func handlePageRequest(c *gin.Context) {
c.Data(http.StatusOK, contentType(filename), data)
return
}
if len(command) < 2 {
c.Redirect(302, "/"+page+"/edit")
return
}
version := c.DefaultQuery("version", "ajksldfjl")
p := Open(page)

View File

@ -407,7 +407,7 @@ body#pad textarea {
$("#publishPage").click(function(e) {
e.preventDefault();
var message = " This will add your page to the sitemap.xml so it will be indexed.";
var message = " This will add your page to the sitemap.xml so it will be indexed by search engines.";
if ($('#publishPage').text() == "Unpublish") {
message = "";
}
@ -553,8 +553,7 @@ body#pad textarea {
<div id="wrap">
{{ if .EditPage }} <div id="pad"><textarea autofocus placeholder="Start typing, it will save automatically.
Use Markdown for formatting and links (also make links like [[this]])." id="userInput">{{ .RawPage }}</textarea></div>{{ end }}
{{ if .EditPage }} <div id="pad"><textarea autofocus placeholder="Use markdown to write your note! New: you can publish your note when you are done ({{ .Page }} -> Publish)." id="userInput">{{ .RawPage }}</textarea></div>{{ end }}
<div id="rendered">
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
{{ if .ViewPage }}{{ .RenderedPage }}