diff --git a/src-contrib/electric_fiddle/main.cljc b/src-contrib/electric_fiddle/main.cljc index 9fbbddb..aaf18ab 100644 --- a/src-contrib/electric_fiddle/main.cljc +++ b/src-contrib/electric_fiddle/main.cljc @@ -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] @@ -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.) diff --git a/src/electric_tutorial/tutorial.cljc b/src/electric_tutorial/tutorial.cljc index 8f89a5b..4d1039a 100644 --- a/src/electric_tutorial/tutorial.cljc +++ b/src/electric_tutorial/tutorial.cljc @@ -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]