If editing an HTML page, show that in the preview instead of just the index.
This commit is contained in:
parent
ce6524bb26
commit
8934a3e097
2 changed files with 34 additions and 20 deletions
|
@ -21,7 +21,7 @@
|
|||
{"path": "src/poo.js", "is_dir": false, "name": "poo.js"},
|
||||
{"path": "src/poo.py", "is_dir": false, "name": "poo.py"}
|
||||
],
|
||||
"file_path": "src/poo.js",
|
||||
"file_path": "src/poo.html",
|
||||
"is_dir": false,
|
||||
"file_content": "function x() {\n return 1;\n}",
|
||||
"csrf_token": "arg",
|
||||
|
|
52
src/App.elm
52
src/App.elm
|
@ -87,6 +87,9 @@ type alias Model =
|
|||
, elm_packages : List ElmPackage
|
||||
}
|
||||
|
||||
suffix : String -> String
|
||||
suffix = String.split "." >> List.reverse >> List.head >> Maybe.withDefault ""
|
||||
|
||||
init_model : Model
|
||||
init_model =
|
||||
{ show_preview = True
|
||||
|
@ -689,26 +692,37 @@ log_pane model =
|
|||
]
|
||||
|
||||
preview_pane model =
|
||||
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
|
||||
[ HA.id "preview-frame"
|
||||
, HA.src model.preview_url
|
||||
]
|
||||
[]
|
||||
]
|
||||
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"
|
||||
, HE.on "toggle" (JD.at ["target", "open"] JD.bool |> JD.map TogglePreview)
|
||||
]
|
||||
( [ H.summary
|
||||
[]
|
||||
[ H.text <| "Preview"
|
||||
]
|
||||
]
|
||||
++ if model.show_preview then
|
||||
[ H.iframe
|
||||
[ HA.id "preview-frame"
|
||||
, HA.src preview_url
|
||||
]
|
||||
[]
|
||||
]
|
||||
else
|
||||
[]
|
||||
)
|
||||
|
||||
commit_modal model =
|
||||
let
|
||||
|
|
Loading…
Reference in a new issue