Skip to content

Commit

Permalink
vue
Browse files Browse the repository at this point in the history
  • Loading branch information
chereseeriepa committed Oct 31, 2022
1 parent 4cf603d commit 67196ca
Show file tree
Hide file tree
Showing 26 changed files with 428 additions and 61 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# SPDX-License-Identifier: Unlicense

node_moduels
node_modules
ssb-go-room-secrets
ssb-go-room-secrets/**/*
.git
Expand Down
2 changes: 1 addition & 1 deletion cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func runroomsrv() error {

// See for more https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP
// helpful: https://report-uri.com/home/generate
ContentSecurityPolicy: "default-src 'self'; img-src 'self' data:", // enforce no external content
ContentSecurityPolicy: "default-src 'self'; img-src 'self' https://graphql.planetary.pub data: ; connect-src 'self' https://graphql.planetary.pub", // enforce no external content

BrowserXssFilter: true,
FrameDeny: true,
Expand Down
4 changes: 0 additions & 4 deletions internal/network/mocked/endpoints.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/aliases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/auth.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/auth_fallback.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/denied.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/fixed_pages.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/invites.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/members.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/pages.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions roomdb/mockdb/roomconfig.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added web/.DS_Store
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
324 changes: 324 additions & 0 deletions web/assets/index.800a2f23.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions web/assets/index.f52c3173.css

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions web/assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" href="/assets/logo.3c6b6612.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Planetary</title>
<script type="module" crossorigin src="/assets/index.800a2f23.js"></script>
<link rel="stylesheet" href="/assets/index.f52c3173.css">
</head>
<body>
<div id="app"></div>

</body>
</html>
19 changes: 19 additions & 0 deletions web/assets/logo.3c6b6612.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion web/assets/style.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions web/embedded_dev.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: MIT

//go:build dev
// +build dev

package web
Expand Down
56 changes: 40 additions & 16 deletions web/handlers/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/gorilla/csrf"
"github.com/gorilla/sessions"
"github.com/russross/blackfriday/v2"
"go.mindeco.de/http/auth"
"go.mindeco.de/http/render"
"go.mindeco.de/log/level"
Expand Down Expand Up @@ -311,21 +310,21 @@ func New(
})

// landing page
m.Get(router.CompleteIndex).Handler(r.HTML("landing/index.tmpl", func(w http.ResponseWriter, req *http.Request) (interface{}, error) {
// TODO: try websocket upgrade (issue #)

notice, err := dbs.PinnedNotices.Get(req.Context(), roomdb.NoticeDescription, "en-GB")
if err != nil {
return nil, fmt.Errorf("failed to find description: %w", err)
}
markdown := blackfriday.Run([]byte(notice.Content), blackfriday.WithNoExtensions())
return noticeShowData{
ID: notice.ID,
Title: notice.Title,
Content: template.HTML(markdown),
Language: notice.Language,
}, nil
}))
// m.Get(router.CompleteIndex).Handler(r.HTML("landing/index.tmpl", func(w http.ResponseWriter, req *http.Request) (interface{}, error) {
// // TODO: try websocket upgrade (issue #)

// notice, err := dbs.PinnedNotices.Get(req.Context(), roomdb.NoticeDescription, "en-GB")
// if err != nil {
// return nil, fmt.Errorf("failed to find description: %w", err)
// }
// markdown := blackfriday.Run([]byte(notice.Content), blackfriday.WithNoExtensions())
// return noticeShowData{
// ID: notice.ID,
// Title: notice.Title,
// Content: template.HTML(markdown),
// Language: notice.Language,
// }, nil
// }))

// notices (the mini-CMS)
var nh = noticeHandler{
Expand Down Expand Up @@ -366,6 +365,7 @@ func New(
m.Get(router.OpenModeCreateInvite).HandlerFunc(r.HTML("admin/invite-created.tmpl", ih.createOpenMode))

// static assets

m.PathPrefix("/assets/").Handler(http.StripPrefix("/assets/", http.FileServer(web.Assets)))

// TODO: doesnt work because of of mainMux wrapper, see issue #35
Expand All @@ -375,6 +375,12 @@ func New(

// hook up main stdlib mux to the gorrilla/mux with named routes
// TODO: issue #35

http.Handle("/assets/", http.StripPrefix("/assets/", http.FileServer(http.Dir("assets"))))

m.PathPrefix("/test").HandlerFunc(IndexHandler2("../../web/assets/index.html"))
m.PathPrefix("/").HandlerFunc(IndexHandler("../../web/assets/index.html"))

mainMux.Handle("/", m)

consumeURL := urlTo(router.CompleteInviteConsume)
Expand Down Expand Up @@ -425,3 +431,21 @@ func concatTemplates(lst ...[]string) []string {
}
return catted
}

func IndexHandler2(entrypoint string) func(w http.ResponseWriter, r *http.Request) {
fn := func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprint(w, web.Assets)
http.ServeFile(w, r, entrypoint)
}

return http.HandlerFunc(fn)
}

func IndexHandler(entrypoint string) func(w http.ResponseWriter, r *http.Request) {
fn := func(w http.ResponseWriter, r *http.Request) {
// fmt.Fprint(w, web.Assets)
http.ServeFile(w, r, entrypoint)
}

return http.HandlerFunc(fn)
}
23 changes: 21 additions & 2 deletions web/router/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

// constant names for the named routes
const (
CompleteIndex = "complete:index"
// CompleteIndex = "complete:index"

CompleteNoticeShow = "complete:notice:show"
CompleteNoticeList = "complete:notice:list"
Expand All @@ -30,14 +30,21 @@ const (
OpenModeCreateInvite = "open:invites:create"
)

// |
// |-dev.go
// |-main.go
// |-prod.go
// |-server

// CompleteApp constructs a mux.Router containing the routes for batch Complete html frontend
func CompleteApp() *mux.Router {
m := mux.NewRouter()

// It's important that this is before your catch-all route ("/")
Auth(m)
Admin(m.PathPrefix("/admin").Subrouter())

m.Path("/").Methods("GET").Name(CompleteIndex)
// m.Path("/").Methods("GET").Name(CompleteIndex)

m.Path("/alias/{alias}").Methods("GET").Name(CompleteAliasResolve)

Expand All @@ -55,5 +62,17 @@ func CompleteApp() *mux.Router {

m.Path("/set-language").Methods("POST").Name(CompleteSetLanguage)

// Catch-all: Serve our JavaScript application's entry-point (index.html).

// m.PathPrefix("/assets/").Handler(http.StripPrefix("/assets/", http.FileServer(web.Assets)))

return m
}

// func HealthCheck(w http.ResponseWriter, r *http.Request) {
// fmt.Fprint(w, "API is alive and ready")
// }

// func handle(w http.ResponseWriter, r *http.Request) {
// http.Redirect(w, r, "/notice/list", http.StatusMovedPermanently)
// }

0 comments on commit 67196ca

Please sign in to comment.