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">
|
<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",
|
"slug": "loaded-thing",
|
||||||
"files": [
|
"files": [
|
||||||
{"path": ".", "is_dir": true, "name": ".."},
|
{"path": ".", "is_dir": true, "name": ".."},
|
||||||
|
|
57
src/App.elm
57
src/App.elm
|
@ -339,6 +339,16 @@ link url text =
|
||||||
[ HA.href url]
|
[ HA.href url]
|
||||||
[ H.text text ]
|
[ 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 -> List (H.Attribute Msg) -> List (Html Msg) -> Html Msg
|
||||||
form model attrs children =
|
form model attrs children =
|
||||||
|
@ -391,7 +401,7 @@ header model =
|
||||||
[ HA.id "think-controls" ]
|
[ HA.id "think-controls" ]
|
||||||
[ H.a
|
[ H.a
|
||||||
[ HA.target "preview"
|
[ HA.target "preview"
|
||||||
, HA.href model.preview_url
|
, HA.href <| preview_url model
|
||||||
]
|
]
|
||||||
[ H.text "Preview" ]
|
[ H.text "Preview" ]
|
||||||
, link "rename" "Rename"
|
, link "rename" "Rename"
|
||||||
|
@ -692,37 +702,26 @@ log_pane model =
|
||||||
]
|
]
|
||||||
|
|
||||||
preview_pane model =
|
preview_pane model =
|
||||||
let
|
H.details
|
||||||
file_suffix = suffix model.file_path
|
[ HA.attribute "open" ""
|
||||||
|
, HA.id "preview"
|
||||||
page_suffixes = ["html", "php"]
|
, HE.on "toggle" (JD.at ["target", "open"] JD.bool |> JD.map TogglePreview)
|
||||||
|
]
|
||||||
preview_url =
|
( [ H.summary
|
||||||
if List.member file_suffix page_suffixes then
|
[]
|
||||||
model.preview_url ++ "/" ++ model.file_path
|
[ H.text <| "Preview"
|
||||||
else
|
|
||||||
model.preview_url
|
|
||||||
in
|
|
||||||
H.details
|
|
||||||
[ HA.attribute "open" ""
|
|
||||||
, HA.id "preview"
|
|
||||||
, HE.on "toggle" (JD.at ["target", "open"] JD.bool |> JD.map TogglePreview)
|
|
||||||
]
|
|
||||||
( [ H.summary
|
|
||||||
[]
|
|
||||||
[ H.text <| "Preview"
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
++ if model.show_preview then
|
]
|
||||||
[ H.iframe
|
++ if model.show_preview then
|
||||||
[ HA.id "preview-frame"
|
[ H.iframe
|
||||||
, HA.src preview_url
|
[ HA.id "preview-frame"
|
||||||
]
|
, HA.src <| preview_url model
|
||||||
[]
|
|
||||||
]
|
]
|
||||||
else
|
|
||||||
[]
|
[]
|
||||||
)
|
]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
)
|
||||||
|
|
||||||
commit_modal model =
|
commit_modal model =
|
||||||
let
|
let
|
||||||
|
|
Loading…
Reference in a new issue