This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-01
Channels
- # adventofcode (66)
- # announcements (12)
- # aws (8)
- # babashka (28)
- # beginners (160)
- # cider (28)
- # clara (22)
- # clj-kondo (5)
- # cljdoc (40)
- # clojure (129)
- # clojure-australia (2)
- # clojure-europe (24)
- # clojure-gamedev (19)
- # clojure-nl (5)
- # clojure-norway (15)
- # clojure-sanfrancisco (25)
- # clojure-seattle (2)
- # clojure-spec (13)
- # clojure-uk (29)
- # clojurescript (14)
- # cryogen (5)
- # cursive (7)
- # data-science (1)
- # datascript (5)
- # datomic (8)
- # deps-new (5)
- # emacs (19)
- # events (8)
- # fulcro (32)
- # graalvm (7)
- # helix (9)
- # kaocha (3)
- # lambdaisland (1)
- # london-clojurians (4)
- # malli (5)
- # meander (32)
- # off-topic (143)
- # pathom (4)
- # portal (32)
- # re-frame (7)
- # reagent (33)
- # reitit (2)
- # shadow-cljs (5)
- # spacemacs (4)
- # tools-deps (30)
- # vim (1)
Is it possible to add a default viewer setting? I've implemented nav for some of my datatypes to provide additional metadata/docs, and it would be super nice to have them default to :portal.viewer/md
or :portal.viewer/hiccup
. I tried adding some metadata to the naved objects (`^{:portal.api/default-viewer ...} data`), but I got stuck looking through the portal code trying to figure out how to set the viewer when clicking a nav item.
Hi @U5P29DSUS, I've been thinking about adding this feature for a while. It should be a pretty self contained addition.
I think https://github.com/djblue/portal/blob/master/src/portal/ui/app.cljs#L154 is the place you are looking for. You have can grab the meta
from the value and use it when trying to figure out the viewer
I think the easiest thing to do is sort the compatible-viewers
where the default viewer is at the top
I just made the changes and tested on my fork. It all passes CI, would you like a PR?
(I may need to run the formatted again before I make a PR. Seems like intellij borked it before I committed) https://github.com/djblue/portal/compare/master...JJ-Atkinson:master
I think the easiest thing to do would be to checkout from master all the formatting changes, otherwise a PR would be awesome!
I'm very confused. I ran make fmt
before committing both times, and it still fails the check...
Thanks for the PR! When I checkout the PR make fmt
seems to fix the issue. What os are you running?
diff --git a/src/portal/ui/app.cljs b/src/portal/ui/app.cljs
index 11130a5..23a8561 100644
--- a/src/portal/ui/app.cljs
+++ b/src/portal/ui/app.cljs
@@ -155,11 +155,11 @@
viewers (cons default-viewer viewers)
compatible-viewers (filter #(when-let [pred (:predicate %)] (pred value)) viewers)]
{:compatible-viewers compatible-viewers
- :viewer
+ :viewer
(or
- (some #(when (= (:name %) selected-viewer) %)
- compatible-viewers)
- (first compatible-viewers))
+ (some #(when (= (:name %) selected-viewer) %)
+ compatible-viewers)
+ (first compatible-viewers))
:set-viewer!
(fn [viewer]
(set-settings! {:selected-viewer viewer}))}))
I couldn't tell ya what changed, but it appears to have worked this time 🙂. I'm on Ubuntu 18 LTS btw.