Skip to content

Commit

Permalink
chore: correctly handle query parameters in new UI (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolznz committed Nov 3, 2023
1 parent 93f3ba0 commit 53b7182
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 250 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ As data storage SQLite or PostgreSQL (recommended) can be used.

## Development

`go run .`
`go run .` or `gow -e=go,mod,html,css run .` using [gow](https://github.com/mitranim/gow)

To build the CSS run:

Expand Down Expand Up @@ -83,7 +83,6 @@ If the client creates the secret the client only needs to share the public key o
- `expires_at` (optional) connection cannot be used after this date. Unix timestamp in seconds.
- `max_amount` (optional) maximum amount in sats that can be sent per renewal period
- `budget_renewal` (optional) reset the budget at the end of the given budget renewal. Can be `never` (default), `daily`, `weekly`, `monthly`, `yearly`
- `editable` (optional) set to `false` to disable form editing by the user
- `request_methods` (optional) url encoded, space separated list of request types that you need permission for: `pay_invoice` (default), `get_balance` (see NIP47). For example: `..&request_methods=pay_invoice%20get_balance`

Example:
Expand Down
26 changes: 13 additions & 13 deletions echo_handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,10 +244,10 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
budgetRenewal := strings.ToLower(c.QueryParam("budget_renewal"))
expiresAt := c.QueryParam("expires_at") // YYYY-MM-DD or MM/DD/YYYY or timestamp in seconds
if expiresAtTimestamp, err := strconv.Atoi(expiresAt); err == nil {
expiresAt = time.Unix(int64(expiresAtTimestamp), 0).Format(time.RFC3339)
expiresAt = time.Unix(int64(expiresAtTimestamp), 0).Format(time.RFC3339) // FIXME: should display like "January 2, 2006 03:04 PM" in the UI
}
disabled := c.QueryParam("editable") == "false"
requestMethods := c.QueryParam("request_methods")
customRequestMethods := requestMethods
if requestMethods == "" {
// if no request methods are given, enable them all by default
keys := []string{}
Expand Down Expand Up @@ -298,17 +298,17 @@ func (svc *Service) AppsNewHandler(c echo.Context) error {
}

return c.Render(http.StatusOK, "apps/new.html", map[string]interface{}{
"User": user,
"Name": appName,
"Pubkey": pubkey,
"ReturnTo": returnTo,
"MaxAmount": maxAmount,
"BudgetRenewal": budgetRenewal,
"ExpiresAt": expiresAt,
"RequestMethods": requestMethods,
"RequestMethodHelper": requestMethodHelper,
"Disabled": disabled,
"Csrf": csrf,
"User": user,
"Name": appName,
"Pubkey": pubkey,
"ReturnTo": returnTo,
"MaxAmount": maxAmount,
"BudgetRenewal": budgetRenewal,
"ExpiresAt": expiresAt,
"RequestMethods": requestMethods,
"CustomRequestMethods": customRequestMethods,
"RequestMethodHelper": requestMethodHelper,
"Csrf": csrf,
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"scripts": {
"css": "npx tailwindcss -i ./views/application.css -o ./public/css/application.css --watch"
"css": "tailwindcss -i ./views/application.css -o ./public/css/application.css --watch"
},
"devDependencies": {
"@tailwindcss/aspect-ratio": "^0.4.2",
Expand Down
Loading

0 comments on commit 53b7182

Please sign in to comment.