diff --git a/README.md b/README.md
index 16e0cbd..8bfd869 100644
--- a/README.md
+++ b/README.md
@@ -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
-
\ No newline at end of file
+
diff --git a/go.mod b/go.mod
index f822576..5ba4c08 100644
--- a/go.mod
+++ b/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
diff --git a/go.sum b/go.sum
index 13c7b0b..12ef3c4 100644
--- a/go.sum
+++ b/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=
diff --git a/main.go b/main.go
index b214e6d..bd0b2b2 100644
--- a/main.go
+++ b/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"))
diff --git a/views/index.html b/views/index.html
index fa407fc..fa3e5ff 100644
--- a/views/index.html
+++ b/views/index.html
@@ -6,23 +6,67 @@
{{define "content"}}
-
-
+