diff --git a/build.sbt b/build.sbt index 2eebc418..4b02d8a4 100644 --- a/build.sbt +++ b/build.sbt @@ -555,15 +555,15 @@ lazy val webapp = project libraryDependencies ++= Seq(D.laminar.value, D.waypoint.value, D.upickle.value), libraryDependencies ++= Seq(D.zio.value, D.zioJson.value), ) - .settings( // for doc - libraryDependencies += D.laika.value, - Compile / sourceGenerators += { - val needThis: Task[Unit] = (docs / mdoc).toTask("").taskValue - val generateCode: Task[Seq[File]] = makeDocSources.taskValue - needThis.flatMap(unit => generateCode) - // I have no clue what I did here but types match and its working =) - }, - ) + // .settings( // for doc + // libraryDependencies += D.laika.value, + // Compile / sourceGenerators += { + // val needThis: Task[Unit] = (docs / mdoc).toTask("").taskValue + // val generateCode: Task[Seq[File]] = makeDocSources.taskValue + // needThis.flatMap(unit => generateCode) + // // I have no clue what I did here but types match and its working =) + // }, + // ) .dependsOn(didExample.js) .dependsOn(serviceworker) diff --git a/webapp/src/main/scala/fmgp/webapp/App.scala b/webapp/src/main/scala/fmgp/webapp/App.scala index 670e2b26..e7f63c89 100644 --- a/webapp/src/main/scala/fmgp/webapp/App.scala +++ b/webapp/src/main/scala/fmgp/webapp/App.scala @@ -32,7 +32,12 @@ object App { lazy val appElement = { div( - AppUtils.drawer(linkPages, MyRouter.router.currentPageSignal), + AppUtils.drawer( + currentPage = MyRouter.router.currentPageSignal, + linkPages = linkPages, + wipLinkPages = wipLinkPages, + deprecatedLinkPages = deprecatedLinkPages + ), AppUtils.drawerScrim, AppUtils.topBarHeader(MyRouter.router.currentPageSignal.map { case p: HomePage.type => "DID Comm v2 - Playground" @@ -71,7 +76,7 @@ object App { .collectStatic(NFCScannerPage)(NFCScannerTool()) .collectStatic(WebBluetoothPage)(WebBluetoothTool()) .collectStatic(DiscordBotPage)(DiscordBotInfo()) - .collectSignal[DocPage](page => Doc(page)) + // .collectSignal[DocPage](page => Doc(page)) .collectStatic(AgentManagementPage)(AgentManagement()) // .collectStatic(AgentDBPage)(AgentDB()) .collectStatic(AgentMessageStoragePage)(AgentMessageStorage()) @@ -88,17 +93,23 @@ object App { SettingsPage, QRcodePage, NFCScannerPage, - WebBluetoothPage, - DiscordBotPage, OOBPage(oobExample), ResolverPage(didExample), AgentManagementPage, AgentMessageStoragePage, EncryptPage, DecryptPage, + ) + + private val wipLinkPages: List[Page] = List( + WebBluetoothPage, + DiscordBotPage, + ) + + private val deprecatedLinkPages: List[Page] = List( TapIntoStreamPage, // AgentDBPage, - DocPage(Seq()), + // DocPage(Seq()), BasicMessagePage, TrustPingPage, // DAppStorePage, diff --git a/webapp/src/main/scala/fmgp/webapp/AppUtils.scala b/webapp/src/main/scala/fmgp/webapp/AppUtils.scala index f5f22084..92ef4080 100644 --- a/webapp/src/main/scala/fmgp/webapp/AppUtils.scala +++ b/webapp/src/main/scala/fmgp/webapp/AppUtils.scala @@ -122,39 +122,95 @@ object AppUtils { // TODO RENAME TO UIUtils } val drawerScrim = div(className("mdc-drawer-scrim")) - def drawer(linkPages: List[Page], currentPage: Signal[Page]) = + + def drawer( + currentPage: Signal[Page], + linkPages: List[Page], + wipLinkPages: List[Page], + deprecatedLinkPages: List[Page] + ) = asideTag( className("mdc-drawer mdc-drawer--modal"), div( className("mdc-drawer__header"), - h3(className("mdc-drawer__title"), "FMGP scala-did"), + h3(className("mdc-drawer__title"), "FMGP Scala-DID"), h6(className("mdc-drawer__subtitle"), "fabiomgpinheiro@gmail.com"), ), div( className("mdc-drawer__content"), navTag( className("mdc-list"), - linkPages.map(page => - a( - className <-- currentPage.map { p => - if (p == page) "mdc-list-item mdc-list-item--activated" else "mdc-list-item" - }, - aria.current := "page", - tabIndex(0), - span(className("mdc-list-item__ripple")), - i( - className("material-icons mdc-list-item__graphic"), - aria.hidden(true), - page.icon - ), - navigateTo(page), - span(className("mdc-list-item__text"), page.title), - ), - ) + linkPages.map(page => drawerAux(currentPage, page)), + hr(className := "mdc-list-divider"), + h6(className := "mdc-list-group__subheader", "WIP Tools"), + wipLinkPages.map(page => drawerAux(currentPage, page)), + hr(className := "mdc-list-divider"), + h6(className := "mdc-list-group__subheader", "Deprecated Tools"), + deprecatedLinkPages.map(page => drawerAux(currentPage, page)), + hr(className := "mdc-list-divider"), + h6(className := "mdc-list-group__subheader", "External Links"), + drawerItemExternalLink( + url = "https://doc.did.fmgp.app/", + icon = "menu_book", + text = "Scala-DID Documentation" + ), + drawerItemExternalLink( + url = "https://doc.did.fmgp.app/api/", + icon = "api", + text = "Scala-DID Scaladoc API" + ), + drawerItemExternalLink( + url = "https://github.com/FabioPinheiro/scala-did", + icon = "code", + text = "Scala-DID Source" + ), + drawerItemExternalLink( + url = "https://identity.foundation/didcomm-messaging/spec/", + icon = "menu_book", + text = "DID Comm V2 Specification" + ), + drawerItemExternalLink( + url = "https://didcomm.org/search/?page=1", + icon = "design_services", + text = "DID Comm Protocols" + ), + drawerItemExternalLink( + url = "https://dev.uniresolver.io/", + icon = "travel_explore", + text = "Universal Resolver" + ), + drawerItemExternalLink(url = "https://demo.didcomm.org/", icon = "chat", text = "Chat Demo"), + drawerItemExternalLink(url = "https://didlint.ownyourdata.eu/", icon = "fact_check", text = "DID Lint"), ) ) ) + private def drawerAux(currentPage: Signal[Page], page: Page) = a( + className <-- currentPage.map { p => + if (p == page) "mdc-list-item mdc-list-item--activated" else "mdc-list-item" + }, + aria.current := "page", + tabIndex(0), + span(className("mdc-list-item__ripple")), + i( + className("material-icons mdc-list-item__graphic"), + aria.hidden(true), + page.icon + ), + navigateTo(page), + span(className("mdc-list-item__text"), page.title), + ) + private def drawerItemExternalLink(url: String, icon: String, text: String) = a( + href := url, + target := "_blank", + className := "mdc-list-item", + aria.current := "page", + tabIndex(0), + span(className("mdc-list-item__ripple")), + i(className("material-icons mdc-list-item__graphic"), aria.hidden(true), icon), + span(className("mdc-list-item__text"), text), + ) + def myButton(text: String) = { div( className("mdc-touch-target-wrapper"), @@ -170,4 +226,12 @@ object AppUtils { // TODO RENAME TO UIUtils def linkToResolveDID(subject: DIDSubject) = a(subject.did, MyRouter.navigateTo(MyRouter.ResolverPage(subject.did))) + def openDocumentation = a( + href := "https://doc.did.fmgp.app/", + "Open ", + b("Documentation"), + // MyRouter.navigateTo(page), + i(className("material-icons mdc-list-item__graphic"), aria.hidden(true), "menu_book") + ) + } diff --git a/webapp/src/main/scala/fmgp/webapp/Doc.scala b/webapp/src/main/scala/fmgp/webapp/Doc.scala index 5b241873..b9666fc5 100644 --- a/webapp/src/main/scala/fmgp/webapp/Doc.scala +++ b/webapp/src/main/scala/fmgp/webapp/Doc.scala @@ -1,3 +1,4 @@ +/* package fmgp.webapp import org.scalajs.dom @@ -53,7 +54,7 @@ object Doc { } .build .parser - .parse(fmgp.did.DocSource.quickstart_basic_examples_md) + .parse(fmgp.did.DocSource._01_about_01_scala_did_md) // .transform(fmgp.did.DocSource.quickstart_basic_examples_md, laika.ast.Path(List("doc", "fixme")) match // case Left(value) => value.message // case Right(value) => value @@ -86,3 +87,4 @@ object Doc { ) } } + */ diff --git a/webapp/src/main/scala/fmgp/webapp/Home.scala b/webapp/src/main/scala/fmgp/webapp/Home.scala index 584d5a1e..56796eda 100644 --- a/webapp/src/main/scala/fmgp/webapp/Home.scala +++ b/webapp/src/main/scala/fmgp/webapp/Home.scala @@ -24,6 +24,9 @@ object Home { def apply(): HtmlElement = // rootElement div( p("Sandbox for DID Comm v2.1"), + // showPage(MyRouter.DocPage(Seq()), "Documentation for scala-did lib"), + AppUtils.openDocumentation, + br(), showPage(MyRouter.SettingsPage, "Settings Page"), showPage(MyRouter.AgentManagementPage, "Agent Management"), showPage(MyRouter.AgentMessageStoragePage, "Agent Message Storage"), @@ -49,12 +52,12 @@ object Home { showPage(MyRouter.BasicMessagePage, "Basic Message"), showPage(MyRouter.TrustPingPage, "Trust Ping"), showPage(MyRouter.TapIntoStreamPage, "TapIntoStream Tool"), - showPage(MyRouter.DocPage(Seq()), "Documentation for scala-did lib"), br(), p("Ideas for experiments and applications:"), ul( li("[Done] DID Comm over Websocket"), li("[WIP] DID Comm over Push API"), + li("GitHub action step: a simple DID agent that sends a message"), li("DID Comm Protocol to Bootstrap WebRTC"), li("DID Comm over WebRTC: This would be indeed very interesting"), li("DID Comm over Email (in top of a SMTP server): Prove the control/ownership of emails addresses"), @@ -63,9 +66,10 @@ object Home { li("DID Comm over Audio Waves"), ), br(), - p("DIDs:"), + p("DIDs setup:"), div(child <-- statementVar.signal.map(e => getHtml(e))) ) + def getHtml(statement: Option[Statement], indent: Int = 0): ReactiveHtmlElement[HTMLElement] = div(className("mermaid"), statementToMermaid(statement), onMountCallback(ctx => { Global.update("div.mermaid") })) diff --git a/webapp/src/main/scala/fmgp/webapp/MyRouter.scala b/webapp/src/main/scala/fmgp/webapp/MyRouter.scala index aefe0497..174e562f 100644 --- a/webapp/src/main/scala/fmgp/webapp/MyRouter.scala +++ b/webapp/src/main/scala/fmgp/webapp/MyRouter.scala @@ -27,7 +27,7 @@ object MyRouter { case object NFCScannerPage extends Page("NFCScanner", "nfc") // or "contactless" case object WebBluetoothPage extends Page("WebBluetooth", "bluetooth") case object DiscordBotPage extends Page("DiscordBot", "smart_toy") - case class DocPage(path: Seq[String]) extends Page("Doc", "menu_book") + // case class DocPage(path: Seq[String]) extends Page("Doc", "menu_book") case object AgentManagementPage extends Page("AgentManagement", "manage_accounts") // case object DIDPage extends Page("DID", "visibility") // case object AgentDBPage extends Page("MessageDB", "folder_open") @@ -47,7 +47,7 @@ object MyRouter { given nfcScannerPageRW: ReadWriter[NFCScannerPage.type] = macroRW given webBluetoothPageRW: ReadWriter[WebBluetoothPage.type] = macroRW given discordBotPageRW: ReadWriter[DiscordBotPage.type] = macroRW - given docPageRW: ReadWriter[DocPage] = macroRW + // given docPageRW: ReadWriter[DocPage] = macroRW given keysPageRW: ReadWriter[AgentManagementPage.type] = macroRW // given agentDBPageRW: ReadWriter[AgentDBPage.type] = macroRW given agentMessageStoragePageRW: ReadWriter[AgentMessageStoragePage.type] = macroRW @@ -91,12 +91,12 @@ object MyRouter { Route.static(TrustPingPage, root / "trustping" / endOfSegments, Router.localFragmentBasePath), Route.static(TapIntoStreamPage, root / "stream" / endOfSegments, Router.localFragmentBasePath), Route.static(DAppStorePage, root / "dapp" / endOfSegments, Router.localFragmentBasePath), - Route[DocPage, List[String]]( - encode = page => page.path.toList, - decode = arg => DocPage(path = if (arg.isEmpty) Seq("readme.md") else arg.toSeq), - pattern = root / "doc" / remainingSegments, - Router.localFragmentBasePath - ), + // Route[DocPage, List[String]]( + // encode = page => page.path.toList, + // decode = arg => DocPage(path = if (arg.isEmpty) Seq("readme.md") else arg.toSeq), + // pattern = root / "doc" / remainingSegments, + // Router.localFragmentBasePath + // ), ) val router = new Router[Page](