2021-09-07 17:36:50 +03:00
|
|
|
package rui
|
|
|
|
|
|
|
|
import (
|
|
|
|
_ "embed"
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
"strings"
|
2021-09-07 17:36:50 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
//go:embed app_scripts.js
|
|
|
|
var defaultScripts string
|
|
|
|
|
|
|
|
//go:embed app_styles.css
|
|
|
|
var appStyles string
|
|
|
|
|
|
|
|
//go:embed defaultTheme.rui
|
|
|
|
var defaultThemeText string
|
|
|
|
|
|
|
|
// Application - app interface
|
|
|
|
type Application interface {
|
|
|
|
Finish()
|
|
|
|
removeSession(id int)
|
|
|
|
}
|
|
|
|
|
2022-01-30 00:25:46 +03:00
|
|
|
// AppParams defines parameters of the app
|
|
|
|
type AppParams struct {
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// Title - title of the app window/tab
|
|
|
|
Title string
|
|
|
|
// TitleColor - background color of the app window/tab (applied only for Safari and Chrome for Android)
|
2022-01-30 00:25:46 +03:00
|
|
|
TitleColor Color
|
Added some properties and functions
* Added "resize", "grid-auto-flow", "caret-color", and "backdrop-filter" properties
* Added BlurView, BlurViewByID, GetResize, GetGridAutoFlow, GetCaretColor, GetBackdropFilter functions
* The "warp" property for ListView and ListLayout renamed to "list-warp"
* The "warp" property for EditView renamed to "edit-warp"
* Added CertFile and KeyFile optional fields to the AppParams struct.If they are set, then an https connection is created, otherwise http.
2022-06-07 13:07:10 +03:00
|
|
|
// Icon - the icon file name
|
|
|
|
Icon string
|
|
|
|
// CertFile - path of a certificate for the server must be provided
|
|
|
|
// if neither the Server's TLSConfig.Certificates nor TLSConfig.GetCertificate are populated.
|
|
|
|
// If the certificate is signed by a certificate authority, the certFile should be the concatenation
|
|
|
|
// of the server's certificate, any intermediates, and the CA's certificate.
|
|
|
|
CertFile string
|
|
|
|
// KeyFile - path of a private key for the server must be provided
|
|
|
|
// if neither the Server's TLSConfig.Certificates nor TLSConfig.GetCertificate are populated.
|
|
|
|
KeyFile string
|
|
|
|
// Redirect80 - if true then the function of redirect from port 80 to 443 is created
|
|
|
|
Redirect80 bool
|
2022-01-30 00:25:46 +03:00
|
|
|
}
|
|
|
|
|
2022-10-27 16:14:30 +03:00
|
|
|
func getStartPage(buffer *strings.Builder, params AppParams, addScripts string) {
|
|
|
|
buffer.WriteString(`<head>
|
2021-09-07 17:36:50 +03:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<title>`)
|
2022-10-27 16:14:30 +03:00
|
|
|
buffer.WriteString(params.Title)
|
2021-09-07 17:36:50 +03:00
|
|
|
buffer.WriteString("</title>")
|
2022-10-27 16:14:30 +03:00
|
|
|
if params.Icon != "" {
|
2021-09-07 17:36:50 +03:00
|
|
|
buffer.WriteString(`
|
|
|
|
<link rel="icon" href="`)
|
2022-10-27 16:14:30 +03:00
|
|
|
buffer.WriteString(params.Icon)
|
2022-01-30 00:25:46 +03:00
|
|
|
buffer.WriteString(`">`)
|
|
|
|
}
|
|
|
|
|
2022-10-27 16:14:30 +03:00
|
|
|
if params.TitleColor != 0 {
|
2022-01-30 00:25:46 +03:00
|
|
|
buffer.WriteString(`
|
|
|
|
<meta name="theme-color" content="`)
|
2022-10-27 16:14:30 +03:00
|
|
|
buffer.WriteString(params.TitleColor.cssString())
|
2021-09-07 17:36:50 +03:00
|
|
|
buffer.WriteString(`">`)
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer.WriteString(`
|
|
|
|
<base target="_blank" rel="noopener">
|
|
|
|
<meta name="viewport" content="width=device-width">
|
|
|
|
<style>`)
|
|
|
|
buffer.WriteString(appStyles)
|
|
|
|
buffer.WriteString(`</style>
|
2022-11-08 16:31:21 +03:00
|
|
|
<style id="ruiAnimations"></style>
|
2022-10-27 16:14:30 +03:00
|
|
|
<script>
|
|
|
|
`)
|
2021-09-07 17:36:50 +03:00
|
|
|
buffer.WriteString(defaultScripts)
|
2022-10-27 16:14:30 +03:00
|
|
|
buffer.WriteString(addScripts)
|
2021-09-07 17:36:50 +03:00
|
|
|
buffer.WriteString(`</script>
|
|
|
|
</head>
|
2023-05-15 15:27:37 +03:00
|
|
|
<body id="body" onkeydown="keyDownEvent(this, event)">
|
2021-09-07 17:36:50 +03:00
|
|
|
<div class="ruiRoot" id="ruiRootView"></div>
|
2023-05-07 20:58:51 +03:00
|
|
|
<div class="ruiPopupLayer" id="ruiPopupLayer" style="visibility: hidden; isolation: isolate;"></div>
|
2023-04-25 17:20:47 +03:00
|
|
|
<div class="ruiTooltipLayer" id="ruiTooltipLayer" style="visibility: hidden; opacity: 0;">
|
|
|
|
<div id="ruiTooltipText" class="ruiTooltipText"></div>
|
|
|
|
<div id="ruiTooltipTopArrow" class="ruiTooltipTopArrow"></div>
|
|
|
|
<div id="ruiTooltipBottomArrow" class="ruiTooltipBottomArrow"></div>
|
|
|
|
</div>
|
|
|
|
|
2021-11-07 09:43:13 +03:00
|
|
|
<a id="ruiDownloader" download style="display: none;"></a>
|
2022-10-27 16:14:30 +03:00
|
|
|
</body>`)
|
2021-11-07 09:43:13 +03:00
|
|
|
}
|