Added import page and route to import page.
This commit is contained in:
parent
4063c2c7bf
commit
63fdc6a225
21
account.go
21
account.go
|
@ -13,6 +13,13 @@ package writefreely
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/gorilla/sessions"
|
||||
"github.com/guregu/null/zero"
|
||||
|
@ -22,12 +29,6 @@ import (
|
|||
"github.com/writeas/web-core/log"
|
||||
"github.com/writeas/writefreely/author"
|
||||
"github.com/writeas/writefreely/page"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -655,6 +656,14 @@ func viewExportFull(app *app, w http.ResponseWriter, r *http.Request) ([]byte, s
|
|||
return data, filename, err
|
||||
}
|
||||
|
||||
func viewImportOptions(app *app, u *User, w http.ResponseWriter, r *http.Request) error {
|
||||
// Fetch extra user data
|
||||
p := NewUserPage(app, r, u, "Import", nil)
|
||||
|
||||
showUserPage(w, "import", p)
|
||||
return nil
|
||||
}
|
||||
|
||||
func viewMeAPI(app *app, w http.ResponseWriter, r *http.Request) error {
|
||||
reqJSON := IsJSON(r.Header.Get("Content-Type"))
|
||||
uObj := struct {
|
||||
|
|
|
@ -11,13 +11,14 @@
|
|||
package writefreely
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
"github.com/writeas/go-webfinger"
|
||||
"github.com/writeas/web-core/log"
|
||||
"github.com/writeas/writefreely/config"
|
||||
"github.com/writefreely/go-nodeinfo"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func initRoutes(handler *Handler, r *mux.Router, cfg *config.Config, db *datastore) {
|
||||
|
@ -78,6 +79,7 @@ func initRoutes(handler *Handler, r *mux.Router, cfg *config.Config, db *datasto
|
|||
me.HandleFunc("/posts/export.json", handler.Download(viewExportPosts, UserLevelUser)).Methods("GET")
|
||||
me.HandleFunc("/export", handler.User(viewExportOptions)).Methods("GET")
|
||||
me.HandleFunc("/export.json", handler.Download(viewExportFull, UserLevelUser)).Methods("GET")
|
||||
me.HandleFunc("/import", handler.User(viewImportOptions)).Methods("GET")
|
||||
me.HandleFunc("/settings", handler.User(viewSettings)).Methods("GET")
|
||||
me.HandleFunc("/invites", handler.User(handleViewUserInvites)).Methods("GET")
|
||||
me.HandleFunc("/logout", handler.Web(viewLogout, UserLevelNone)).Methods("GET")
|
||||
|
|
|
@ -24,28 +24,5 @@
|
|||
|
||||
</div>
|
||||
|
||||
<div class="snug content-container">
|
||||
<h2 id="posts-header">Import</h2>
|
||||
<p>You may import your data from another instance at any time here.</p>
|
||||
|
||||
<table class="classy export">
|
||||
<tr>
|
||||
<th style="width: 40%">Export</th>
|
||||
<th colspan="2">Format</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Posts</th>
|
||||
<td><p class="text-cta"><a href="">CSV</a></p></td>
|
||||
<td><p class="text-cta"><a href="">TXT</a></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>User + Blogs + Posts</th>
|
||||
<td><p class="text-cta"><a href="">JSON</a></p></td>
|
||||
<td><p class="text-cta"><a href="">Prettified</a></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "footer" .}}
|
||||
{{end}}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{{define "import"}}
|
||||
{{template "header" .}}
|
||||
|
||||
<div class="snug content-container">
|
||||
<h2 id="posts-header">Import</h2>
|
||||
<p>You may import your data from another instance at any time here.</p>
|
||||
|
||||
<table class="classy export">
|
||||
<tr>
|
||||
<th style="width: 40%">Export</th>
|
||||
<th colspan="2">Format</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Posts</th>
|
||||
<td><p class="text-cta"><a href="">CSV</a></p></td>
|
||||
<td><p class="text-cta"><a href="">TXT</a></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>User + Blogs + Posts</th>
|
||||
<td><p class="text-cta"><a href="">JSON</a></p></td>
|
||||
<td><p class="text-cta"><a href="">Prettified</a></p></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
{{template "footer" .}}
|
||||
{{end}}
|
Loading…
Reference in New Issue