package yatwiki import ( "database/sql" "fmt" "html/template" "net/http" "net/url" ) func (this *WikiServer) routeModify(w http.ResponseWriter, r *http.Request, articleTitle string) { isNewArticle := false a, err := this.db.GetLatestVersion(articleTitle) if err != nil { if err == sql.ErrNoRows { // this is fine - we're creating it for the first time isNewArticle = true } else { this.serveErrorMessage(w, err) return } } var pageTitleHTML string var baseRev int64 var existingBody string if isNewArticle { pageTitleHTML = `Creating new article` baseRev = 0 } else { pageTitleHTML = `Editing article "` + template.HTMLEscapeString(articleTitle) + `"` baseRev = a.ID existingBody = string(a.Body) } content := `

` + pageTitleHTML + `


| formatting help ` if len(this.opts.ContentedServer) > 0 { content += ` | upload... ` } content += `
` pto := DefaultPageTemplateOptions(this.opts) if isNewArticle { pto.CurrentPageName = "New article" } else { pto.CurrentPageName = articleTitle pto.CurrentPageIsArticle = true } pto.Content = template.HTML(content) this.servePageResponse(w, r, pto) return }