Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixed fallback github content url #307

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ Bugfixes:

Other improvements:

## [v2023-12-22.1](https://github.com/purescript/trypurescript/releases/tag/v2023-12-22.1)

Other improvements:
- Bump PureScript to `0.15.13` (#306 by @JordanMartinez)
- Update to latest package set (#306 by @JordanMartinez)

## [v2023-07-18.1](https://github.com/purescript/trypurescript/releases/tag/v2023-07-18.1)

Other improvements:
- Bump PureScript to `0.15.10` (#310 by @JordanMartinez)
- Update to latest package set (#310 by @JordanMartinez)

## [v2023-03-06.1](https://github.com/purescript/trypurescript/releases/tag/v2023-03-06.1)

Other improvements:
Expand Down
2 changes: 1 addition & 1 deletion client/config/dev/Try.Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ tag :: String
tag = "master"

mainGitHubExample :: String
mainGitHubExample = "/purescript/trypurescript/" <> tag <> "/client/examples/Main.purs"
mainGitHubExample = "purescript/trypurescript/" <> tag <> "/client/examples/Main.purs"
2 changes: 1 addition & 1 deletion client/config/prod/Try.Config.purs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ tag :: String
tag = "master"

mainGitHubExample :: String
mainGitHubExample = "/purescript/trypurescript/" <> tag <> "/client/examples/Main.purs"
mainGitHubExample = "purescript/trypurescript/" <> tag <> "/client/examples/Main.purs"
66 changes: 66 additions & 0 deletions client/packages.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,69 @@ let upstream =
sha256:60eee64b04ca0013fae3e02a69fc3b176105c6baa2f31865c67cd5f881a412fd

in upstream
with foreign-generic =
{ dependencies =
[ "arrays"
, "assert"
, "bifunctors"
, "console"
, "control"
, "effect"
, "either"
, "exceptions"
, "foldable-traversable"
, "foreign"
, "foreign-object"
, "identity"
, "lists"
, "maybe"
, "newtype"
, "partial"
, "prelude"
, "typelevel-prelude"
, "record"
, "strings"
, "transformers"
, "tuples"
, "unsafe-coerce"
]
, repo = "https://github.com/imsaravana369/purescript-foreign-generic.git"
, version = "v0.15.0-updates"
}
with language-cst-parser =
{ dependencies =
[ "arrays"
, "console"
, "const"
, "control"
, "effect"
, "either"
, "enums"
, "foldable-traversable"
, "free"
, "functions"
, "functors"
, "identity"
, "integers"
, "lazy"
, "lists"
, "maybe"
, "newtype"
, "node-process"
, "numbers"
, "ordered-collections"
, "partial"
, "prelude"
, "st"
, "strings"
, "transformers"
, "tuples"
, "typelevel-prelude"
, "unfoldable"
, "unsafe-coerce"
, "foreign"
, "foreign-generic"
]
, repo = "https://github.com/imsaravana369/purescript-language-cst-parser.git"
, version = "main"
}
30 changes: 30 additions & 0 deletions client/public/css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,33 @@ footer {
display: none;
}
}


details {
padding-left: 1em;
}

summary {
cursor: pointer;
font-weight: bold;

}

details .tree-content {
margin-left: 1em;
}


details {
padding-left: 1em;
}

summary {
cursor: pointer;
font-weight: bold;

}

details .tree-content {
margin-left: 1em;
}
4 changes: 4 additions & 0 deletions client/spago.dhall
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
, "either"
, "exceptions"
, "foldable-traversable"
, "foreign"
, "language-cst-parser"
, "foreign-generic"
, "foreign-object"
, "functions"
, "functors"
Expand All @@ -39,6 +42,7 @@
, "tuples"
, "unsafe-coerce"
, "web-html"
, "debug"
]
, packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
Expand Down
1 change: 1 addition & 0 deletions client/src/Try/CSTTree.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const toString = (fgn) => JSON.stringify(fgn)
113 changes: 113 additions & 0 deletions client/src/Try/CSTTree.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
module Try.CSTBuilder where

import Control.Alt
import Prelude

import Control.Monad.Except (runExcept)
import Data.Array (length, null)
import Data.Either (hush)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..), maybe)
import Data.Traversable (traverse)
import Data.TraversableWithIndex (traverseWithIndex)
import Debug (spy, traceM)
import Effect.Aff (Aff)
import Foreign (F, Foreign, ForeignError(..), fail, readArray)
import Foreign.Generic (defaultOptions, genericDecode)
import Foreign.Generic.Class (class Decode, decode, encode)
import Foreign.Index (readProp)
import Foreign.Object (Object)
import Foreign.Object (toArrayWithKey)
import Foreign.Object as Object
import Halogen as H
import Halogen.HTML as HH
import Halogen.HTML.Properties as HP
import Unsafe.Coerce (unsafeCoerce)

foreign import toString :: Foreign -> String

data Tree = NodeArr (Maybe String) (Array Tree)
| NodeObject (Maybe String) (Object Tree)
| Leaf Foreign

readMTag :: Foreign -> Maybe String
readMTag fgn = hush $ runExcept do
t <- readProp "tag" fgn
decode t

decodeArr :: Foreign -> F Tree
decodeArr fgn = do
let mTag = readMTag fgn
case mTag of
Just tag -> do
arr <- readProp "contents" fgn >>= readArray
NodeArr mTag <$> (traverse decode arr)
Nothing -> do
arr <- readArray fgn
NodeArr Nothing <$> (traverse decode arr)


decodeObject :: Foreign -> F Tree
decodeObject fgn = do
let mTag = readMTag fgn
case mTag of
Just tag -> do
obj <- readProp "contents" fgn
NodeObject mTag <$> (decode obj)
Nothing -> NodeObject Nothing <$> (decode fgn)

instance Decode Tree where
decode fgn = decodeArr fgn <|> (decodeObject fgn) <|> (pure $ Leaf fgn)

component :: forall q i o. H.Component q Tree o Aff
component = H.mkComponent
{ initialState
, render
, eval: H.mkEval $ H.defaultEval
}
where
initialState i = i
render :: Tree -> H.ComponentHTML Unit () Aff
render tree = renderTree tree




createNested :: forall w i .Maybe String -> Array (HH.HTML w i) -> HH.HTML w i
createNested mTag children = case mTag of
Just tag -> HH.details_ [ HH.summary_ [ HH.text tag ] , content]
Nothing -> content
where
content
| null children = HH.text "[]"
| otherwise = HH.div
[ HP.class_ $ HH.ClassName "tree-content" ]
children


renderArr :: forall w i. Maybe String -> Array Tree -> HH.HTML w i
renderArr tag children = createNested tag (renderTree <$> children)

renderObj :: forall w i. Maybe String -> Object Tree -> HH.HTML w i
renderObj tag children = createNested tag (toArrayWithKey renderKeyVal children)

renderKeyVal :: forall w i. String -> Tree -> HH.HTML w i
renderKeyVal key valTree =
HH.div_
[ HH.i_ [ HH.text (key <> ": ") ]
, renderTree valTree
]

renderTree :: forall w i. Tree -> HH.HTML w i
renderTree (NodeArr tag children) = renderArr tag children
renderTree (NodeObject tag children) = renderObj tag children
renderTree (Leaf fgn) = HH.text (toString fgn)









Loading