move import post handler under /api

handler for post request to import is now under /api/me/import
form target updated

also allow all plaintext files in form
import-zips
Rob Loranger 5 years ago
parent 0ca198c715
commit 6c5d89ac86
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8
  1. 2
      routes.go
  2. 4
      templates/user/import.tmpl

@ -95,7 +95,6 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
me.HandleFunc("/export", handler.User(viewExportOptions)).Methods("GET")
me.HandleFunc("/export.json", handler.Download(viewExportFull, UserLevelUser)).Methods("GET")
me.HandleFunc("/import", handler.User(viewImport)).Methods("GET")
me.HandleFunc("/import", handler.User(handleImport)).Methods("POST")
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")
@ -108,6 +107,7 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
apiMe.HandleFunc("/password", handler.All(updatePassphrase)).Methods("POST")
apiMe.HandleFunc("/self", handler.All(updateSettings)).Methods("POST")
apiMe.HandleFunc("/invites", handler.User(handleCreateUserInvite)).Methods("POST")
apiMe.HandleFunc("/import", handler.User(handleImport)).Methods("POST")
// Sign up validation
write.HandleFunc("/api/alias", handler.All(handleUsernameCheck)).Methods("POST")

@ -10,9 +10,9 @@
<h2 id="posts-header">Import</h2>
<p>Upload text or markdown files to import as posts.</p>
<div class="formContainer">
<form id="importPosts" class="import" enctype="multipart/form-data" action="/me/import" method="POST">
<form id="importPosts" class="import" enctype="multipart/form-data" action="/api/me/import" method="POST">
<label for="file" hidden>Browse files to upload</label>
<input class="fileInput" name="files" type="file" multiple accept=".txt,.md"/>
<input class="fileInput" name="files" type="file" multiple accept="text/plain"/>
<br />
<label for="collection">Select a blog to import the posts under.</label>
<select name="collection">

Loading…
Cancel
Save