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:
parent
026dd7c647
commit
b2a01d0a6d
19
handlers.go
19
handlers.go
@ -121,8 +121,6 @@ func generateSiteMap() (sitemap string) {
|
|||||||
}
|
}
|
||||||
names = names[:i]
|
names = names[:i]
|
||||||
lastEdited = lastEdited[:i]
|
lastEdited = lastEdited[:i]
|
||||||
fmt.Println(names)
|
|
||||||
|
|
||||||
sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
sitemap = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`
|
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">`
|
||||||
for i := range names {
|
for i := range names {
|
||||||
@ -140,17 +138,16 @@ func generateSiteMap() (sitemap string) {
|
|||||||
}
|
}
|
||||||
func handlePageRequest(c *gin.Context) {
|
func handlePageRequest(c *gin.Context) {
|
||||||
page := c.Param("page")
|
page := c.Param("page")
|
||||||
|
command := c.Param("command")
|
||||||
|
|
||||||
if page == "sitemap.xml" {
|
if page == "sitemap.xml" {
|
||||||
c.Data(http.StatusOK, contentType("sitemap.xml"), []byte(generateSiteMap()))
|
c.Data(http.StatusOK, contentType("sitemap.xml"), []byte(generateSiteMap()))
|
||||||
return
|
return
|
||||||
}
|
} else if page == "favicon.ico" {
|
||||||
command := c.Param("command")
|
data, _ := Asset("/static/img/cowyo/favicon.ico")
|
||||||
if len(command) < 2 {
|
c.Data(http.StatusOK, contentType("/static/img/cowyo/favicon.ico"), data)
|
||||||
c.Redirect(302, "/"+page+"/edit")
|
|
||||||
return
|
return
|
||||||
}
|
} else if page == "static" {
|
||||||
// Serve static content from memory
|
|
||||||
if page == "static" {
|
|
||||||
filename := page + command
|
filename := page + command
|
||||||
data, err := Asset(filename)
|
data, err := Asset(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -159,6 +156,10 @@ func handlePageRequest(c *gin.Context) {
|
|||||||
c.Data(http.StatusOK, contentType(filename), data)
|
c.Data(http.StatusOK, contentType(filename), data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(command) < 2 {
|
||||||
|
c.Redirect(302, "/"+page+"/edit")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
version := c.DefaultQuery("version", "ajksldfjl")
|
version := c.DefaultQuery("version", "ajksldfjl")
|
||||||
p := Open(page)
|
p := Open(page)
|
||||||
|
@ -407,7 +407,7 @@ body#pad textarea {
|
|||||||
|
|
||||||
$("#publishPage").click(function(e) {
|
$("#publishPage").click(function(e) {
|
||||||
e.preventDefault();
|
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") {
|
if ($('#publishPage').text() == "Unpublish") {
|
||||||
message = "";
|
message = "";
|
||||||
}
|
}
|
||||||
@ -553,8 +553,7 @@ body#pad textarea {
|
|||||||
|
|
||||||
|
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
{{ if .EditPage }} <div id="pad"><textarea autofocus placeholder="Start typing, it will save automatically.
|
{{ 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 }}
|
||||||
Use Markdown for formatting and links (also make links like [[this]])." id="userInput">{{ .RawPage }}</textarea></div>{{ end }}
|
|
||||||
<div id="rendered">
|
<div id="rendered">
|
||||||
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
|
{{ if .DontKnowPage }} <strong><center>{{ .Route }} not understood!</center></strong>{{ end }}
|
||||||
{{ if .ViewPage }}{{ .RenderedPage }}
|
{{ if .ViewPage }}{{ .RenderedPage }}
|
||||||
|
Loading…
Reference in New Issue
Block a user