Documentation ¶
Overview ¶
Package uirules defines useful UIRewriteRule values for use with the tailsql server package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var FormatJSONText = tailsql.UIRewriteRule{ Value: regexp.MustCompile(`null|true|false|[{},:\[\]]`), Apply: func(col, s string, _ []string) any { if json.Valid([]byte(s)) { esc := template.HTMLEscapeString(s) return template.HTML(fmt.Sprintf(`<tt>%s</tt>`, esc)) } return nil }, }
FormatJSONText is a UI rewrite rule to render JSON text preformatted.
View Source
var FormatSQLSource = tailsql.UIRewriteRule{ Value: regexp.MustCompile(`(?is)\b(select\s+.*?(;\s*$|from\b)|create\s+(table|view)\b)`), Apply: func(col, s string, _ []string) any { esc := template.HTMLEscapeString(s) return template.HTML(fmt.Sprintf(`<code><pre>%s</pre></code>`, esc)) }, }
FormatSQLSource is a UI rewrite rule to render SQL query text preformatted.
View Source
var LinkURLText = tailsql.UIRewriteRule{ Value: regexp.MustCompile(`^https?://\S+$`), Apply: func(col, s string, _ []string) any { if u, err := url.Parse(s); err == nil { return template.HTML(fmt.Sprintf(`<a href="%s" referrerpolicy=no-referrer rel=noopener>%s</a>`, u.String(), template.HTMLEscaper(s))) } return s }, }
LinkURLText is a UI rewrite rule to add links for URL-shaped results.
View Source
var StripeIDLink = tailsql.UIRewriteRule{ Value: regexp.MustCompile(`^(cus|in|sub)_[a-zA-Z0-9]+$`), Apply: func(col, s string, m []string) any { var kind string switch m[1] { case "cus": kind = "customer" case "in": kind = "invoice" case "sub": kind = "subscription" default: return s } return template.HTML(fmt.Sprintf( `<a href="https://dashboard.stripe.com/%[2]ss/%[1]s" `+ `title="%[2]s details in Stripe" `+ `referrerpolicy=no-referrer rel=noopener>%[1]s</a>`, s, kind)) }, }
StripeIDLink is a UI rewrite rule that wraps Stripe customer and invoice ID strings to the Stripe dashboard.
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.