mirror of
https://github.com/TheAnachronism/docspell.git
synced 2025-03-27 09:35:04 +00:00
Change webapp url paths
Don't use `#`, because many people find it awkward. Now "normal" urls are used and elm takes care to not issue a server request when these change.
This commit is contained in:
parent
b15b9cc217
commit
36a6fdd746
modules
microsite
webapp/src/main/elm
@ -53,7 +53,7 @@ Example screenshot:
|
||||
|
||||
This example shows a source with name "test". It defines two urls:
|
||||
|
||||
- `/app#/upload/<id>`
|
||||
- `/app/upload/<id>`
|
||||
- `/api/v1/open/upload/item/<id>`
|
||||
|
||||
The first points to a web page where everyone could upload files into
|
||||
@ -66,7 +66,7 @@ files (which is used by the first url).
|
||||
For example, this url can be used to upload files with curl:
|
||||
|
||||
``` bash
|
||||
$ curl -XPOST -F file=@test.pdf http://localhost:7880/api/v1/open/upload/item/5DxhjkvWf9S-CkWqF3Kr892-WgoCspFWDo7-XBykwCyAUxQ
|
||||
$ curl -XPOST -F file=@test.pdf http://localhost:7880/api/v1/open/upload/item/CqpFTb7UmGe-9nMVPZSmnwc-AHH6nWFh52t-M1JFQ9y7cdH
|
||||
{"success":true,"message":"Files submitted."}
|
||||
```
|
||||
|
||||
@ -126,5 +126,5 @@ uploading two files with meta data:
|
||||
curl -XPOST -F meta='{"multiple":false, "direction": "outgoing"}' \
|
||||
-F file=@letter-en-source.pdf \
|
||||
-F file=@letter-de-source.pdf \
|
||||
http://localhost:7880/api/v1/open/upload/item/5DxhjkvWf9S-CkWqF3Kr892-WgoCspFWDo7-XBykwCyAUxQ
|
||||
http://localhost:7880/api/v1/open/upload/item/CqpFTb7UmGe-9nMVPZSmnwc-AHH6nWFh52t-M1JFQ9y7cdH
|
||||
```
|
||||
|
@ -25,3 +25,7 @@
|
||||
.docs h4 {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.docs .thumbnail img {
|
||||
width: 100%;
|
||||
}
|
||||
|
Binary file not shown.
Before ![]() (image error) Size: 153 KiB After ![]() (image error) Size: 182 KiB ![]() ![]() |
@ -188,7 +188,7 @@ urlInfoMessage flags model =
|
||||
]
|
||||
, p []
|
||||
[ text "This source defines URLs that can be used by anyone to send files to "
|
||||
, text "you. There is a web page that you can share or tha API url can be used "
|
||||
, text "you. There is a web page that you can share or the API url can be used "
|
||||
, text "with other clients."
|
||||
]
|
||||
, dl [ class "ui list" ]
|
||||
@ -196,7 +196,7 @@ urlInfoMessage flags model =
|
||||
, dd []
|
||||
[ let
|
||||
url =
|
||||
flags.config.baseUrl ++ "/app#/upload/" ++ model.source.id
|
||||
flags.config.baseUrl ++ "/app/upload/" ++ model.source.id
|
||||
in
|
||||
a [ href url, target "_blank" ] [ code [] [ text url ] ]
|
||||
]
|
||||
|
@ -139,44 +139,51 @@ pageToString : Page -> String
|
||||
pageToString page =
|
||||
case page of
|
||||
HomePage ->
|
||||
"#/home"
|
||||
"/app/home"
|
||||
|
||||
LoginPage referer ->
|
||||
Maybe.map (\p -> "/" ++ p) referer
|
||||
|> Maybe.withDefault ""
|
||||
|> (++) "#/login"
|
||||
|> (++) "/app/login"
|
||||
|
||||
ManageDataPage ->
|
||||
"#/manageData"
|
||||
"/app/managedata"
|
||||
|
||||
CollectiveSettingPage ->
|
||||
"#/collectiveSettings"
|
||||
"/app/csettings"
|
||||
|
||||
UserSettingPage ->
|
||||
"#/userSettings"
|
||||
"/app/usettings"
|
||||
|
||||
QueuePage ->
|
||||
"#/queue"
|
||||
"/app/queue"
|
||||
|
||||
RegisterPage ->
|
||||
"#/register"
|
||||
"/app/register"
|
||||
|
||||
UploadPage sourceId ->
|
||||
Maybe.map (\id -> "/" ++ id) sourceId
|
||||
|> Maybe.withDefault ""
|
||||
|> (++) "#/upload"
|
||||
|> (++) "/app/upload"
|
||||
|
||||
NewInvitePage ->
|
||||
"#/newinvite"
|
||||
"/app/newinvite"
|
||||
|
||||
|
||||
pageFromString : String -> Maybe Page
|
||||
pageFromString str =
|
||||
let
|
||||
urlNormed =
|
||||
if String.startsWith str "http" then
|
||||
str
|
||||
|
||||
else
|
||||
"http://somehost" ++ str
|
||||
|
||||
url =
|
||||
Url.Url Url.Http "" Nothing str Nothing Nothing
|
||||
Url.fromString urlNormed
|
||||
in
|
||||
Parser.parse parser url
|
||||
Maybe.andThen (Parser.parse parser) url
|
||||
|
||||
|
||||
href : Page -> Attribute msg
|
||||
@ -189,24 +196,28 @@ goto page =
|
||||
Nav.load (pageToString page)
|
||||
|
||||
|
||||
pathPrefix : String
|
||||
pathPrefix =
|
||||
"app"
|
||||
|
||||
|
||||
parser : Parser (Page -> a) a
|
||||
parser =
|
||||
oneOf
|
||||
[ Parser.map HomePage (oneOf [ s "", s "home" ])
|
||||
, Parser.map (\s -> LoginPage (Just s)) (s "login" </> string)
|
||||
, Parser.map (LoginPage Nothing) (s "login")
|
||||
, Parser.map ManageDataPage (s "manageData")
|
||||
, Parser.map CollectiveSettingPage (s "collectiveSettings")
|
||||
, Parser.map UserSettingPage (s "userSettings")
|
||||
, Parser.map QueuePage (s "queue")
|
||||
, Parser.map RegisterPage (s "register")
|
||||
, Parser.map (\s -> UploadPage (Just s)) (s "upload" </> string)
|
||||
, Parser.map (UploadPage Nothing) (s "upload")
|
||||
, Parser.map NewInvitePage (s "newinvite")
|
||||
[ Parser.map HomePage (oneOf [ Parser.top, s pathPrefix </> s "home" ])
|
||||
, Parser.map (\s -> LoginPage (Just s)) (s pathPrefix </> s "login" </> string)
|
||||
, Parser.map (LoginPage Nothing) (s pathPrefix </> s "login")
|
||||
, Parser.map ManageDataPage (s pathPrefix </> s "managedata")
|
||||
, Parser.map CollectiveSettingPage (s pathPrefix </> s "csettings")
|
||||
, Parser.map UserSettingPage (s pathPrefix </> s "usettings")
|
||||
, Parser.map QueuePage (s pathPrefix </> s "queue")
|
||||
, Parser.map RegisterPage (s pathPrefix </> s "register")
|
||||
, Parser.map (\s -> UploadPage (Just s)) (s pathPrefix </> s "upload" </> string)
|
||||
, Parser.map (UploadPage Nothing) (s pathPrefix </> s "upload")
|
||||
, Parser.map NewInvitePage (s pathPrefix </> s "newinvite")
|
||||
]
|
||||
|
||||
|
||||
fromUrl : Url -> Maybe Page
|
||||
fromUrl url =
|
||||
{ url | path = Maybe.withDefault "" url.fragment, fragment = Nothing }
|
||||
|> Parser.parse parser
|
||||
Parser.parse parser url
|
||||
|
Loading…
x
Reference in New Issue
Block a user