Skip to content
Merged
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
32 changes: 18 additions & 14 deletions core/http/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,24 +447,28 @@
return prefixRedirect(c, "/app/"+p)
})

// Serve React static assets (JS, CSS, etc.)
serveReactAsset := func(c echo.Context) error {
p := "assets/" + c.Param("*")
f, err := reactFS.Open(p)
if err == nil {
defer f.Close()
stat, statErr := f.Stat()
if statErr == nil && !stat.IsDir() {
contentType := mime.TypeByExtension(filepath.Ext(p))
if contentType == "" {
contentType = echo.MIMEOctetStream
// Serve React static assets (JS, CSS, etc.) and i18n locale JSONs
// from the embedded React build.
serveReactSubdir := func(subdir string) echo.HandlerFunc {
return func(c echo.Context) error {
p := subdir + "/" + c.Param("*")
f, err := reactFS.Open(p)
if err == nil {
defer f.Close()

Check failure on line 457 in core/http/app.go

View workflow job for this annotation

GitHub Actions / golangci-lint

Error return value of `f.Close` is not checked (errcheck)
stat, statErr := f.Stat()
if statErr == nil && !stat.IsDir() {
contentType := mime.TypeByExtension(filepath.Ext(p))
if contentType == "" {
contentType = echo.MIMEOctetStream
}
return c.Stream(http.StatusOK, contentType, f)
}
return c.Stream(http.StatusOK, contentType, f)
}
return echo.NewHTTPError(http.StatusNotFound)
}
return echo.NewHTTPError(http.StatusNotFound)
}
e.GET("/assets/*", serveReactAsset)
e.GET("/assets/*", serveReactSubdir("assets"))
e.GET("/locales/*", serveReactSubdir("locales"))
}
}
routes.RegisterJINARoutes(e, requestExtractor, application.ModelConfigLoader(), application.ModelLoader(), application.ApplicationConfig())
Expand Down
12 changes: 12 additions & 0 deletions core/http/react-ui/i18next-parser.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
export default {
locales: ['en', 'it', 'es', 'de', 'zh-CN'],
defaultNamespace: 'common',
output: 'public/locales/$LOCALE/$NAMESPACE.json',
input: ['src/**/*.{js,jsx}'],
keySeparator: '.',
namespaceSeparator: ':',
defaultValue: (locale, _ns, key) => (locale === 'en' ? key : ''),
sort: true,
createOldCatalogs: false,
keepRemoved: false,
}
Loading
Loading