Allow bookmarklet to be shared (#5)
This commit is contained in:
parent
1eabb65c4c
commit
c5fdaf4a02
|
@ -1,6 +1,7 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="css/style.css">
|
||||||
<script src="https://borkdude.github.io/scittle/js/scittle.js" type="application/javascript"></script>
|
<script src="https://borkdude.github.io/scittle/js/scittle.js" type="application/javascript"></script>
|
||||||
|
|
||||||
|
@ -38,8 +39,8 @@
|
||||||
(.open oreq "GET" "cljs/bookmarklet.cljs")
|
(.open oreq "GET" "cljs/bookmarklet.cljs")
|
||||||
(.send oreq)
|
(.send oreq)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script type="application/x-scittle" src="cljs/bookmarklet.cljs"></script>
|
<script type="application/x-scittle" src="cljs/bookmarklet.cljs"></script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -62,7 +62,7 @@
|
||||||
(def *initial-code (r/atom nil))
|
(def *initial-code (r/atom nil))
|
||||||
|
|
||||||
;; Initialize code
|
;; Initialize code
|
||||||
(let [{:keys [gist]} (query-params)]
|
(let [{:keys [gist code name]} (query-params)]
|
||||||
(cond gist
|
(cond gist
|
||||||
(do
|
(do
|
||||||
(reset! *initial-name "---")
|
(reset! *initial-name "---")
|
||||||
|
@ -74,7 +74,10 @@
|
||||||
(when bookmark-name
|
(when bookmark-name
|
||||||
(reset! *initial-name bookmark-name))
|
(reset! *initial-name bookmark-name))
|
||||||
(reset! *initial-code code)))))
|
(reset! *initial-code code)))))
|
||||||
|
code
|
||||||
|
(do
|
||||||
|
(reset! *initial-name (or name "My first bookmarklet"))
|
||||||
|
(reset! *initial-code code))
|
||||||
:else
|
:else
|
||||||
(do
|
(do
|
||||||
(reset! *initial-name "My first bookmarklet")
|
(reset! *initial-name "My first bookmarklet")
|
||||||
|
@ -124,11 +127,13 @@
|
||||||
[editor *code]
|
[editor *code]
|
||||||
[:br]
|
[:br]
|
||||||
[:br]
|
[:br]
|
||||||
"Click the link below"[:br]
|
"Click the following link or drag it to the bookmarks bar: "
|
||||||
"or"[:br]
|
|
||||||
"Drag the link to the bookmarks bar" [:br]
|
|
||||||
[(fn []
|
[(fn []
|
||||||
[(fn [] [:a {:href (bookmarklet-href @*code)} @*bookmark-name])])
|
[(fn [] [:a {:href (bookmarklet-href @*code)} @*bookmark-name])])
|
||||||
*code]]))
|
*code]
|
||||||
|
[:br]
|
||||||
|
[(fn []
|
||||||
|
[:a {:href (str "?name=" (js/encodeURIComponent @*bookmark-name)
|
||||||
|
"&code=" (js/encodeURIComponent @*code))} "Copy this link to share ⤴️"])]]))
|
||||||
|
|
||||||
(rdom/render [workspace] (.getElementById js/document "app"))
|
(rdom/render [workspace] (.getElementById js/document "app"))
|
||||||
|
|
Loading…
Reference in a new issue