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

v9.7.0 #807

Merged
merged 39 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
ac6814f
routing func support (#806)
maxence-charriere Jan 19, 2023
d6dc4df
fix typo in defer documentation
maxence-charriere Jan 20, 2023
3c881ea
Merge branch 'master' into v9.7.0
maxence-charriere Jan 20, 2023
ccbb62b
AppendClass helper takes variadic parameters
maxence-charriere Jan 20, 2023
92c6a82
Merge branch 'v9.7.0' of https://github.com/maxence-charriere/go-app …
maxence-charriere Jan 20, 2023
1b96c5b
Update README.md
maxence-charriere Jan 20, 2023
a313eaa
No wasm mode (#810)
maxence-charriere Feb 8, 2023
5e10543
load all styles before scripts
maxence-charriere Feb 8, 2023
d70b6f3
load ga async
maxence-charriere Feb 10, 2023
40e1280
remove not used css
maxence-charriere Feb 14, 2023
c52ba05
reduce generated html size
maxence-charriere Feb 14, 2023
b4e06ed
reduce html size further
maxence-charriere Feb 14, 2023
7a021ba
reduce generated html size 3
maxence-charriere Feb 14, 2023
a01f58b
handler preconnect link
maxence-charriere Feb 17, 2023
cf4b387
src multiple call support + fix resolving
maxence-charriere Feb 23, 2023
8287d70
test srcset attribute
maxence-charriere Feb 23, 2023
494fb79
update deps
maxence-charriere Mar 2, 2023
04e47c5
fix html resolve attribute URL
maxence-charriere Mar 2, 2023
641085a
enriched http handler src
maxence-charriere Mar 7, 2023
e9399a1
fix preconnect default crossorigin
maxence-charriere Mar 7, 2023
3fc30b1
update doc
maxence-charriere Mar 7, 2023
c0447b7
Remove pre render caching (#818)
maxence-charriere Mar 12, 2023
76f9e6e
ignore empty attribute value when generating html string
maxence-charriere Mar 22, 2023
c820713
fix ignore empty attr when generating html
maxence-charriere Mar 22, 2023
f46b35c
revert attr filter
maxence-charriere Mar 22, 2023
e057b62
preload styles
maxence-charriere Mar 27, 2023
412979c
generated html don't add resources without url
maxence-charriere Mar 27, 2023
d73b0c7
preload right after preconnect
maxence-charriere Mar 27, 2023
bd385b3
add preload font support
maxence-charriere Apr 4, 2023
3164a12
fix font preload type
maxence-charriere Apr 4, 2023
fac3ed4
fix font resolver
maxence-charriere Apr 4, 2023
830ce58
add font to cacheable resources
maxence-charriere Apr 4, 2023
7f7a4c4
Optimize html gen (#827)
maxence-charriere Apr 7, 2023
8fec445
Datset with map (#828)
maxence-charriere Apr 10, 2023
b16d4de
change loader display
maxence-charriere Apr 28, 2023
0e9bd11
fix server side resource resolver
maxence-charriere May 8, 2023
920073f
Update page_test.go
maxence-charriere May 8, 2023
eac5262
twitter card page support
maxence-charriere May 9, 2023
0bdbd62
remove expired persisted states (#837)
maxence-charriere Jun 27, 2023
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">
<a href="https://go-app.dev">
<img alt="go-app" width="150" height="150" src="https://storage.googleapis.com/murlok-github/icon-192.png">
<img alt="go-app" width="150" height="150" src="docs/web/icon.png">
</a>
</h1>

Expand Down
8 changes: 4 additions & 4 deletions docs/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,16 @@ func main() {
BackgroundColor: backgroundColor,
ThemeColor: backgroundColor,
LoadingLabel: "go-app documentation {progress}%",
Scripts: []string{
"/web/js/prism.js",
},
Styles: []string{
"https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500&display=swap",
"/web/css/prism.css",
"/web/css/docs.css",
},
Scripts: []string{
"/web/js/prism.js defer",
"https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1013306768105236 async crossorigin=anonymous",
},
RawHeaders: []string{
`<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1013306768105236" crossorigin="anonymous"></script>`,
analytics.GoogleAnalyticsHeader("G-SW4FQEM9VM"),
},
CacheableResources: []string{
Expand Down
Binary file modified docs/web/app.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion docs/web/documents/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (f *foo) OnNav(ctx app.Context) {
## Defer

```go
func (c *Compo) Defer(fn func(Context))
func (ctx Context) Defer(fn func(Context))
```

[Defer()](/reference#Compo.Defer) is a [Compo](/reference#Compo) method that like [Dispatch()](#dispatch), executes a given function on the [UI goroutine](#ui-goroutine). The difference is that the given function is executed after a component has its UI updated.
Expand Down
79 changes: 59 additions & 20 deletions docs/web/documents/reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@



<script>var goVersion = "go1.19.5";</script>
<script>var goVersion = "go1.20.1";</script>
<script src="/lib/godoc/godocs.js" defer></script>
</head>
<body>
Expand Down Expand Up @@ -125,7 +125,7 @@ <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>



<dd><a href="#AppendClass">func AppendClass(class, c string) string</a></dd>
<dd><a href="#AppendClass">func AppendClass(class string, v ...string) string</a></dd>


<dd><a href="#Broadcast">func Broadcast(s *State)</a></dd>
Expand Down Expand Up @@ -176,9 +176,15 @@ <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
<dd><a href="#Route">func Route(path string, c Composer)</a></dd>


<dd><a href="#RouteFunc">func RouteFunc(path string, newComponent func() Composer)</a></dd>


<dd><a href="#RouteWithRegexp">func RouteWithRegexp(pattern string, c Composer)</a></dd>


<dd><a href="#RouteWithRegexpFunc">func RouteWithRegexpFunc(pattern string, newComponent func() Composer)</a></dd>


<dd><a href="#RunWhenOnBrowser">func RunWhenOnBrowser()</a></dd>


Expand Down Expand Up @@ -1566,13 +1572,13 @@ <h2 id="pkg-variables">Variables</h2>



<h2 id="AppendClass">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/strings.go?s=1795:1835#L104">AppendClass</a>
<h2 id="AppendClass">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/strings.go?s=1689:1739#L96">AppendClass</a>
<a class="permalink" href="#AppendClass">&#xb6;</a>


</h2>
<pre>func AppendClass(class, c <a href="/pkg/builtin/#string">string</a>) <a href="/pkg/builtin/#string">string</a></pre>
<p>AppendClass adds c to the given class string.
<pre>func AppendClass(class <a href="/pkg/builtin/#string">string</a>, v ...<a href="/pkg/builtin/#string">string</a>) <a href="/pkg/builtin/#string">string</a></pre>
<p>AppendClass adds values to the given class string.



Expand Down Expand Up @@ -1811,33 +1817,59 @@ <h2 id="PrintHTMLWithIndent">func <a href="/src/github.com/maxence-charriere/go-



<h2 id="Route">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=287:322#L7">Route</a>
<h2 id="Route">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=182:217#L5">Route</a>
<a class="permalink" href="#Route">&#xb6;</a>


</h2>
<pre>func Route(path <a href="/pkg/builtin/#string">string</a>, c <a href="#Composer">Composer</a>)</pre>
<p>Route associates the type of the given component to the given path.
<p>When a page is requested and matches the route, a new instance of the given
component is created before being displayed.
<p>Route set the type of component to be mounted when a page is navigated to the
given path.







<h2 id="RouteWithRegexp">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=639:687#L18">RouteWithRegexp</a>
<h2 id="RouteFunc">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=620:677#L18">RouteFunc</a>
<a class="permalink" href="#RouteFunc">&#xb6;</a>


</h2>
<pre>func RouteFunc(path <a href="/pkg/builtin/#string">string</a>, newComponent func() <a href="#Composer">Composer</a>)</pre>
<p>RouteFunc set a function that creates the component to be mounted when a page
is navigated to the given path.







<h2 id="RouteWithRegexp">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=394:442#L11">RouteWithRegexp</a>
<a class="permalink" href="#RouteWithRegexp">&#xb6;</a>


</h2>
<pre>func RouteWithRegexp(pattern <a href="/pkg/builtin/#string">string</a>, c <a href="#Composer">Composer</a>)</pre>
<p>RouteWithRegexp associates the type of the given component to the given
regular expression pattern.
<p>Patterns use the Go standard regexp format.
<p>When a page is requested and matches the pattern, a new instance of the given
component is created before being displayed.
<p>RouteWithRegexp set the type of component to be mounted when a page is
navigated to a path that matches the given pattern.







<h2 id="RouteWithRegexpFunc">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/route.go?s=866:936#L24">RouteWithRegexpFunc</a>
<a class="permalink" href="#RouteWithRegexpFunc">&#xb6;</a>


</h2>
<pre>func RouteWithRegexpFunc(pattern <a href="/pkg/builtin/#string">string</a>, newComponent func() <a href="#Composer">Composer</a>)</pre>
<p>RouteWithRegexpFunc set a function that creates the component to be mounted
when a page is navigated to a path that matches the given pattern.



Expand Down Expand Up @@ -2787,7 +2819,7 @@ <h2 id="Dispatcher">type <a href="/src/github.com/maxence-charriere/go-app/v9/pk



<h2 id="Environment">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=20982:21016#L856">Environment</a>
<h2 id="Environment">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=22153:22187#L903">Environment</a>
<a class="permalink" href="#Environment">&#xb6;</a>


Expand Down Expand Up @@ -24968,7 +25000,7 @@ <h3 id="Wbr">func <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/h



<h2 id="Handler">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=480:5153#L22">Handler</a>
<h2 id="Handler">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=469:5488#L21">Handler</a>
<a class="permalink" href="#Handler">&#xb6;</a>


Expand Down Expand Up @@ -25093,6 +25125,13 @@ <h2 id="Handler">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/a
<span class="comment">// would be the URL for an OAuth authentication.</span>
<span id="Handler.InternalURLs"></span> InternalURLs []<a href="/pkg/builtin/#string">string</a>

<span class="comment">// The URLs of the origins to preconnect in order to improve the user</span>
<span class="comment">// experience by preemptively initiating a connection to those origins.</span>
<span class="comment">// Preconnecting speeds up future loads from a given origin by preemptively</span>
<span class="comment">// performing part or all of the handshake (DNS+TCP for HTTP, and</span>
<span class="comment">// DNS+TCP+TLS for HTTPS origins).</span>
<span id="Handler.Preconnect"></span> Preconnect []<a href="/pkg/builtin/#string">string</a>

<span class="comment">// The cache that stores pre-rendered pages.</span>
<span class="comment">//</span>
<span class="comment">// Default: A LRU cache that keeps pages up to 24h and have a maximum size</span>
Expand Down Expand Up @@ -25152,7 +25191,7 @@ <h2 id="Handler">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/a



<h3 id="Handler.ServeHTTP">func (*Handler) <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=13065:13132#L520">ServeHTTP</a>
<h3 id="Handler.ServeHTTP">func (*Handler) <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=13511:13578#L532">ServeHTTP</a>
<a class="permalink" href="#Handler.ServeHTTP">&#xb6;</a>


Expand All @@ -25166,7 +25205,7 @@ <h3 id="Handler.ServeHTTP">func (*Handler) <a href="/src/github.com/maxence-char



<h2 id="Icon">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=20305:20890#L830">Icon</a>
<h2 id="Icon">type <a href="/src/github.com/maxence-charriere/go-app/v9/pkg/app/http.go?s=21476:22061#L877">Icon</a>
<a class="permalink" href="#Icon">&#xb6;</a>


Expand Down Expand Up @@ -26795,7 +26834,7 @@ <h2 id="pkg-subdirectories">Subdirectories</h2>


<div id="footer">
Build version go1.19.5.<br>
Build version go1.20.1.<br>
Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
the content of this page is licensed under the
Creative Commons Attribution 3.0 License,
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ go 1.18

require (
github.com/SherClockHolmes/webpush-go v1.2.0
github.com/gomarkdown/markdown v0.0.0-20220607163217-45f7c050e2d1
github.com/gomarkdown/markdown v0.0.0-20221013030248-663e2500819c
github.com/google/uuid v1.3.0
github.com/stretchr/testify v1.6.1
golang.org/x/net v0.0.0-20220615171555-694bf12d69de
golang.org/x/net v0.7.0
)

require (
github.com/davecgh/go-spew v1.1.0 // indirect
github.com/golang-jwt/jwt v3.2.2+incompatible // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e // indirect
golang.org/x/crypto v0.6.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keL
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
github.com/gomarkdown/markdown v0.0.0-20220607163217-45f7c050e2d1 h1:wAupuFkZ/yq219/mSbqDtMfUZQY0gTYEtoz3/LKtppU=
github.com/gomarkdown/markdown v0.0.0-20220607163217-45f7c050e2d1/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/gomarkdown/markdown v0.0.0-20221013030248-663e2500819c h1:iyaGYbCmcYK0Ja9a3OUa2Fo+EaN0cbLu0eKpBwPFzc8=
github.com/gomarkdown/markdown v0.0.0-20221013030248-663e2500819c/go.mod h1:JDGcbDT52eL4fju3sZ4TeHGsQwhG9nbDV21aMyhwPoA=
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand All @@ -16,8 +18,12 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
golang.org/x/crypto v0.0.0-20190131182504-b8fe1690c613/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e h1:T8NU3HyQ8ClP4SEE+KbFlg6n0NhuTsN4MyznaarGsZM=
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc=
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
golang.org/x/net v0.0.0-20220615171555-694bf12d69de h1:ogOG2+P6LjO2j55AkRScrkB2BFpd+Z8TY2wcM0Z3MGo=
golang.org/x/net v0.0.0-20220615171555-694bf12d69de/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g=
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
Expand Down
3 changes: 1 addition & 2 deletions pkg/analytics/google-analytics.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
// field to initialize Google Analytics.
func GoogleAnalyticsHeader(propertyID string) string {
return fmt.Sprintf(`<!-- Global site tag (gtag.js) - Google Analytics -->
<script defer src="https://www.googletagmanager.com/gtag/js?id=%s"></script>
<script async src="https://www.googletagmanager.com/gtag/js?id=%s"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
Expand All @@ -25,7 +25,6 @@ func NewGoogleAnalytics() Backend {
}

type googleAnalytics struct {
propertyID string
}

func (a googleAnalytics) Identify(userID string, traits map[string]interface{}) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func RunWhenOnBrowser() {
StaticResourceResolver: staticResourcesResolver,
ActionHandlers: actionHandlers,
}
disp.Page = browserPage{dispatcher: &disp}
disp.Page = browserPage{resolveStaticResource: staticResourcesResolver}
disp.Body = newClientBody(&disp)
disp.init()
defer disp.Close()
Expand Down
20 changes: 16 additions & 4 deletions pkg/app/attribute.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ func (a attributes) Set(name string, value any) {
if s != "" {
s += " "
}
s += toAttributeValue(value)
a[name] = s
a[name] = s + toAttributeValue(value)

case "srcset":
s := a[name]
if s != "" {
s += ", "
}
a[name] = s + toAttributeValue(value)

default:
a[name] = toAttributeValue(value)
Expand Down Expand Up @@ -68,10 +74,16 @@ func resolveAttributeURLValue(name, value string, resolve attributeURLResolver)
case "cite",
"data",
"href",
"src",
"srcset":
"src":
return resolve(value)

case "srcset":
srcs := strings.Split(value, ", ")
for i, src := range srcs {
srcs[i] = resolve(src)
}
return strings.Join(srcs, ", ")

default:
return value
}
Expand Down
18 changes: 18 additions & 0 deletions pkg/app/attribute_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,19 @@ func TestAttributesSet(t *testing.T) {
require.Equal(t, "foo bar", attributes["class"])
})

t.Run("set srcset", func(t *testing.T) {
attributes := make(attributes)
attributes.Set("srcset", "/hi")
require.Equal(t, "/hi", attributes["srcset"])
})

t.Run("set multiple srcset", func(t *testing.T) {
attributes := make(attributes)
attributes.Set("srcset", "/hi")
attributes.Set("srcset", "/bye")
require.Equal(t, "/hi, /bye", attributes["srcset"])
})

t.Run("set common attribute", func(t *testing.T) {
attributes := make(attributes)
attributes.Set("value", "foo")
Expand Down Expand Up @@ -140,6 +153,11 @@ func TestResolveAttributeURLValue(t *testing.T) {
value: "bar",
resolvedValue: "/foo/bar",
},
{
name: "srcset",
value: "hi, bye",
resolvedValue: "/foo/hi, /foo/bye",
},
}

for _, u := range utests {
Expand Down
Loading