added abcex in/out convertion
This commit is contained in:
parent
d227c0368b
commit
9dc57ed8ce
6 changed files with 99 additions and 28 deletions
|
@ -1,10 +1,11 @@
|
|||
# url_shortiner
|
||||
# u.arns.lt (utilities)
|
||||
|
||||
Various utilities just for fun.
|
||||
|
||||
## Technical idea
|
||||
|
||||
* url shortiner (Trumpink nūruoda)
|
||||
* convert in/to Abcex
|
||||
* TODO: image uploader/viewer
|
||||
* TODO: text uploader/viewer. Support code highlighting
|
||||
|
||||
|
@ -12,4 +13,4 @@ Various utilities just for fun.
|
|||
|
||||
To try live version of this game visit https://u.arns.lt
|
||||
|
||||
<a href="https://www.buymeacoffee.com/zordsdavini" target="_blank" rel="nofollow noopener"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="40px"></a>
|
||||
<a href="https://www.buymeacoffee.com/zordsdavini" target="_blank" rel="nofollow noopener"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="40px"></a>
|
||||
|
|
2
go.mod
2
go.mod
|
@ -3,7 +3,7 @@ module g.arns.lt/zordsdavini/url_shortiner
|
|||
go 1.21.5
|
||||
|
||||
require (
|
||||
g.arns.lt/zordsdavini/abcex v1.0.0
|
||||
g.arns.lt/zordsdavini/abcex v1.0.2
|
||||
github.com/foolin/goview v0.3.0
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.9.1
|
||||
|
|
2
go.sum
2
go.sum
|
@ -1,5 +1,7 @@
|
|||
g.arns.lt/zordsdavini/abcex v1.0.0 h1:qQqlZ4DMfethCGK4I6yGaLqMrTzKNIshqpINd1l3t0E=
|
||||
g.arns.lt/zordsdavini/abcex v1.0.0/go.mod h1:YRcJgts3XZwI+LEkngpfUab3DkUAW387Irpr43hIym8=
|
||||
g.arns.lt/zordsdavini/abcex v1.0.2 h1:Q5+3J9NlHVnWGePetEAoDh/pUypkRTgcRrP13iy9y4s=
|
||||
g.arns.lt/zordsdavini/abcex v1.0.2/go.mod h1:YRcJgts3XZwI+LEkngpfUab3DkUAW387Irpr43hIym8=
|
||||
github.com/GeertJohan/go.incremental v1.0.0/go.mod h1:6fAjUhbVuX1KcMD3c8TEgVUqmo4seqhv0i0kdATSkM0=
|
||||
github.com/GeertJohan/go.rice v1.0.0/go.mod h1:eH6gbSOAUv07dQuZVnBmoDP8mgsM1rtixis4Tib9if0=
|
||||
github.com/akavel/rsrc v0.8.0/go.mod h1:uLoCtb9J+EyAqh+26kdrTgmzRBFPGOolLWKpdxkKq+c=
|
||||
|
|
28
main.go
28
main.go
|
@ -3,7 +3,9 @@ package main
|
|||
import (
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"g.arns.lt/zordsdavini/abcex"
|
||||
"github.com/foolin/goview/supports/ginview"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
|
@ -40,6 +42,32 @@ func main() {
|
|||
})
|
||||
})
|
||||
|
||||
r.POST("/abcex", func(c *gin.Context) {
|
||||
value, err := strconv.Atoi(c.PostForm("encode_abcex"))
|
||||
if err != nil {
|
||||
c.HTML(http.StatusOK, "index", gin.H{
|
||||
"abcex_err": true,
|
||||
})
|
||||
} else {
|
||||
c.HTML(http.StatusOK, "index", gin.H{
|
||||
"abcex": abcex.Encode(int64(value)),
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
r.POST("/de-abcex", func(c *gin.Context) {
|
||||
value := c.PostForm("decode_abcex")
|
||||
if err != nil {
|
||||
c.HTML(http.StatusOK, "index", gin.H{
|
||||
"de_abcex_err": true,
|
||||
})
|
||||
} else {
|
||||
c.HTML(http.StatusOK, "index", gin.H{
|
||||
"de_abcex": abcex.Decode(value),
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
r.GET("/:short_url", func(c *gin.Context) {
|
||||
redirectUrl := getRedirectUrl(db, c.Param("short_url"))
|
||||
|
||||
|
|
|
@ -6,23 +6,67 @@
|
|||
|
||||
{{define "content"}}
|
||||
|
||||
<p>
|
||||
<form method="POST" class="form-inline">
|
||||
<input
|
||||
type="url"
|
||||
name="url"
|
||||
class="form-control mb-2 mr-sm-2 border-success"
|
||||
/>
|
||||
<input
|
||||
type="submit"
|
||||
value="Trumpink nūruoda"
|
||||
class="btn btn-sm btn-success mb-2"
|
||||
/>
|
||||
</form>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<form method="POST" class="form-inline">
|
||||
<input
|
||||
type="url"
|
||||
name="url"
|
||||
class="form-control mb-2 mr-sm-2 border-success"
|
||||
/>
|
||||
<input
|
||||
type="submit"
|
||||
value="Trumpink nūruoda"
|
||||
class="btn btn-sm btn-success mb-2"
|
||||
/>
|
||||
</form>
|
||||
|
||||
{{if .shortUrl}}
|
||||
<b>{{ .shortUrl }}</b>
|
||||
{{end}}
|
||||
</p>
|
||||
{{if .shortUrl}}
|
||||
<b>{{ .shortUrl }}</b>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<form action="/abcex" method="POST" class="form-inline">
|
||||
<input
|
||||
name="encode_abcex"
|
||||
class="form-control mb-2 mr-sm-2 border-success"
|
||||
/>
|
||||
<input
|
||||
type="submit"
|
||||
value="Ožkuodouk i Abcex"
|
||||
class="btn btn-sm btn-success mb-2"
|
||||
/>
|
||||
</form>
|
||||
|
||||
{{if .abcex}}
|
||||
<b>{{ .abcex }}</b>
|
||||
{{end}}
|
||||
{{if .abcex_err}}
|
||||
<b class="text-danger">Naėšējė ožkuodoutė...</b>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<form action="/de-abcex" method="POST" class="form-inline">
|
||||
<input
|
||||
name="decode_abcex"
|
||||
class="form-control mb-2 mr-sm-2 border-success"
|
||||
/>
|
||||
<input
|
||||
type="submit"
|
||||
value="Atkuodouk ėš Abcex"
|
||||
class="btn btn-sm btn-success mb-2"
|
||||
/>
|
||||
</form>
|
||||
|
||||
{{if .de_abcex}}
|
||||
<b>{{ .de_abcex }}</b>
|
||||
{{end}}
|
||||
{{if .de_abcex_err}}
|
||||
<b class="text-danger">Naėšējė atkuodoutė...</b>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{end}}
|
||||
|
|
|
@ -10,18 +10,14 @@
|
|||
|
||||
<body>
|
||||
<div class="container py-2">
|
||||
<h1>Arna rakondā</h1>
|
||||
<div class="border-top row">
|
||||
<div class="col">
|
||||
<h1><a href="/">Arna rakondā</a></h1>
|
||||
<div class="row">
|
||||
<div class="col pb-3">
|
||||
<a href="https://www.buymeacoffee.com/zordsdavini" target="_blank" rel="nofollow noopener"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" height="40px"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
{{template "content" .}}
|
||||
</div>
|
||||
</div>
|
||||
{{template "content" .}}
|
||||
|
||||
{{include "layouts/footer"}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue