summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve Manuel <nilslice@gmail.com>2017-05-15 03:59:27 -0700
committerSteve Manuel <nilslice@gmail.com>2017-05-15 03:59:27 -0700
commit779631d5dc46afbc765ee138a79bab962f11312b (patch)
treeb856fbad147119c69e088e9785bc1844130b8d44
parent8f12938f28c0637a9261c7fcb4b0e311b8ba3b40 (diff)
flush csv writer and fix ui
-rw-r--r--system/admin/export.go11
-rw-r--r--system/admin/handlers.go24
2 files changed, 16 insertions, 19 deletions
diff --git a/system/admin/export.go b/system/admin/export.go
index 82b5279..cdd43b7 100644
--- a/system/admin/export.go
+++ b/system/admin/export.go
@@ -1,21 +1,20 @@
package admin
import (
+ "encoding/csv"
"fmt"
+ "io/ioutil"
"log"
"net/http"
+ "os"
"path/filepath"
"strings"
"time"
- "encoding/csv"
-
- "io/ioutil"
- "os"
-
"github.com/ponzu-cms/ponzu/management/format"
"github.com/ponzu-cms/ponzu/system/db"
"github.com/ponzu-cms/ponzu/system/item"
+
"github.com/tidwall/gjson"
)
@@ -109,6 +108,8 @@ func exportCSV(res http.ResponseWriter, req *http.Request, pt func() interface{}
}
}
+ csvBuf.Flush()
+
// write the buffer to a content-disposition response
csvB, err := ioutil.ReadAll(tmpFile)
if err != nil {
diff --git a/system/admin/handlers.go b/system/admin/handlers.go
index 2a76e58..2d8b814 100644
--- a/system/admin/handlers.go
+++ b/system/admin/handlers.go
@@ -1496,21 +1496,19 @@ func contentsHandler(res http.ResponseWriter, req *http.Request) {
btn := `<div class="col s3">
<a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">
New ` + t + `
- </a>
- </div>`
+ </a>`
html = html + b.String() + btn
if _, ok := pt.(format.CSVFormattable); ok {
- btn = `<div class="col s3">
- <a href="/admin/edit/export?type=` + t + `&format=csv" class="green darken-4 btn export-post waves-effect waves-light">
+ btn = `<br/>
+ <a href="/admin/contents/export?type=` + t + `&format=csv" class="green darken-4 btn export-post waves-effect waves-light">
<i class="material-icons left">system_update_alt</i>
.CSV
- </a>
- </div>`
+ </a>`
html = html + b.String() + btn
}
- html += `</div>` + script
+ html += `</div></div>` + script
adminView, err := Admin([]byte(html))
if err != nil {
@@ -2527,21 +2525,19 @@ func searchHandler(res http.ResponseWriter, req *http.Request) {
btn := `<div class="col s3">
<a href="/admin/edit?type=` + t + `" class="btn new-post waves-effect waves-light">
New ` + t + `
- </a>
- </div>`
+ </a>`
html = html + b.String() + btn
if _, ok := post.(format.CSVFormattable); ok {
- btn = `<div class="col s3">
- <a href="/admin/edit/export?type=` + t + `&format=csv" class="green darken-4 btn export-post waves-effect waves-light">
+ btn = `<br/>
+ <a href="/admin/contents/export?type=` + t + `&format=csv" class="green darken-4 btn export-post waves-effect waves-light">
<i class="material-icons left">system_update_alt</i>
.CSV
- </a>
- </div>`
+ </a>`
html = html + b.String() + btn
}
- html += `</div>`
+ html += `</div></div>`
adminView, err := Admin([]byte(html))
if err != nil {