Skip to content
This repository has been archived by the owner on Dec 8, 2024. It is now read-only.

Commit

Permalink
Only electric-tutorial has legacy links [temporary]
Browse files Browse the repository at this point in the history
  • Loading branch information
ggeoffrey committed Jan 23, 2024
1 parent 9e7867a commit eea4532
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
11 changes: 1 addition & 10 deletions src-contrib/electric_fiddle/main.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,6 @@

(e/defn NotFoundPage [& args] (e/client (dom/h1 (dom/text "Page not found: " (pr-str r/route)))))

(e/defn RedirectLegacyLinks! [link]
;; Keep existing links working.
;; Demos used to be identified by their fully qualified name - e.g. `hello-fiddle.fiddles/Hello
;; They are now represented by an s-expression - e.g. `(electric-tutorial.demo-color/Color h s l)
(if (or (seq? link) (vector? link))
link
(do (r/Navigate!. [(list link)])
nil)))

(e/defn Main [ring-req]
(e/server
(binding [e/http-request ring-req]
Expand All @@ -26,7 +17,7 @@
(r/router (r/HTML5-History.)
(dom/pre (dom/text (pr-str r/route)))
(let [route (or (ffirst r/route) `(Index)) ; route looks like {(f args) nil} or nil
[f & args] (RedirectLegacyLinks!. route)]
[f & args] route]
(set! (.-title js/document) (str (some-> f name (str " – ")) "Electric Fiddle"))
(case f
`Index (Index.)
Expand Down
11 changes: 10 additions & 1 deletion src/electric_tutorial/tutorial.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,18 @@
{'fiddle Fiddle-fn
'fiddle-ns Fiddle-ns})

(e/defn RedirectLegacyLinks! [link]
;; Keep existing links working.
;; Demos used to be identified by their fully qualified name - e.g. `hello-fiddle.fiddles/Hello
;; They are now represented by an s-expression - e.g. `(electric-tutorial.demo-color/Color h s l)
(if (and (map? link) (ident? (ffirst link)))
(do (r/Navigate!. [(list (ffirst link))])
nil)
link))

(e/defn Tutorial []
(e/client
(let [[?tutorial] (ffirst r/route)
(let [[?tutorial] (ffirst (RedirectLegacyLinks!. r/route))
?tutorial (or ?tutorial `TwoClocks)]
(dom/h1 (dom/text "Electric Tutorial"))
(binding [hf/pages fiddles]
Expand Down

0 comments on commit eea4532

Please sign in to comment.