use the URL being previewed in the Preview link
This commit is contained in:
parent
8934a3e097
commit
a688f4e0fb
2 changed files with 29 additions and 30 deletions
|
@ -13,7 +13,7 @@
|
|||
|
||||
<script id="think-editor-data" type="application/json">
|
||||
{
|
||||
"preview_url": "https://somethingorotherwhatever.com/tiny-elvis/",
|
||||
"preview_url": "https://somethingorotherwhatever.com/tiny-elvis",
|
||||
"slug": "loaded-thing",
|
||||
"files": [
|
||||
{"path": ".", "is_dir": true, "name": ".."},
|
||||
|
|
25
src/App.elm
25
src/App.elm
|
@ -339,6 +339,16 @@ link url text =
|
|||
[ HA.href url]
|
||||
[ H.text text ]
|
||||
|
||||
preview_url model =
|
||||
let
|
||||
file_suffix = suffix model.file_path
|
||||
|
||||
page_suffixes = ["html", "php"]
|
||||
in
|
||||
if List.member file_suffix page_suffixes then
|
||||
model.preview_url ++ "/" ++ model.file_path
|
||||
else
|
||||
model.preview_url
|
||||
|
||||
form : Model -> List (H.Attribute Msg) -> List (Html Msg) -> Html Msg
|
||||
form model attrs children =
|
||||
|
@ -391,7 +401,7 @@ header model =
|
|||
[ HA.id "think-controls" ]
|
||||
[ H.a
|
||||
[ HA.target "preview"
|
||||
, HA.href model.preview_url
|
||||
, HA.href <| preview_url model
|
||||
]
|
||||
[ H.text "Preview" ]
|
||||
, link "rename" "Rename"
|
||||
|
@ -692,17 +702,6 @@ log_pane model =
|
|||
]
|
||||
|
||||
preview_pane model =
|
||||
let
|
||||
file_suffix = suffix model.file_path
|
||||
|
||||
page_suffixes = ["html", "php"]
|
||||
|
||||
preview_url =
|
||||
if List.member file_suffix page_suffixes then
|
||||
model.preview_url ++ "/" ++ model.file_path
|
||||
else
|
||||
model.preview_url
|
||||
in
|
||||
H.details
|
||||
[ HA.attribute "open" ""
|
||||
, HA.id "preview"
|
||||
|
@ -716,7 +715,7 @@ preview_pane model =
|
|||
++ if model.show_preview then
|
||||
[ H.iframe
|
||||
[ HA.id "preview-frame"
|
||||
, HA.src preview_url
|
||||
, HA.src <| preview_url model
|
||||
]
|
||||
[]
|
||||
]
|
||||
|
|
Loading…
Reference in a new issue