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
This commit is contained in:
Rob Loranger 2019-08-19 09:05:52 -07:00
parent 0ca198c715
commit 6c5d89ac86
No known key found for this signature in database
GPG Key ID: D6F1633A4F0903B8
2 changed files with 3 additions and 3 deletions

View File

@ -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")

View File

@ -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">