Skip to content

Commit f991bf6

Browse files
authored
Merge pull request #36 from osspkg/develop
update vendors
2 parents a8881aa + 9a69f69 commit f991bf6

File tree

23 files changed

+402
-177
lines changed

23 files changed

+402
-177
lines changed

.deb.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package: urione
2+
source: urione
3+
version: 1:1.3.1
4+
architecture:
5+
- amd64
6+
- arm64
7+
maintainer: The OSSPkg Team <[email protected]>
8+
homepage: https://uri.one/
9+
description:
10+
- Link shortening service
11+
section: utils
12+
priority: optional
13+
control:
14+
depends:
15+
- systemd
16+
- ca-certificates
17+
build: devtool build --arch=%arch%
18+
conffiles:
19+
- /etc/urione/config.yaml
20+
preinst: scripts/preinst.sh
21+
postinst: scripts/postinst.sh
22+
prerm: scripts/prerm.sh
23+
postrm: scripts/postrm.sh
24+
data:
25+
bin/urione: build/urione_%arch%
26+
etc/urione/config.yaml: config/config.yaml
27+
var/log/urione.log: +empty
28+
etc/systemd/system/urione.service: init/urione.service
29+
var/lib/urione/migrations/00001.sql: migrations/00001.sql

.golangci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ linters:
362362
- unused
363363
- prealloc
364364
- durationcheck
365-
- nolintlint
366365
- staticcheck
367366
- makezero
368367
- nilerr

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2020-2023, Mikhail Knyazhev <[email protected]>
1+
Copyright (c) 2020-2024, Mikhail Knyazhev <[email protected]>
22

33
**************************************************************************
44

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,7 @@ pre-commite: setup lint build tests
3030
ci: install setup lint build tests
3131

3232
run_local:
33-
rm -rf config/config.dev.yaml
34-
go run cmd/uri-one/main.go --config=config/config.dev.yaml
33+
go run cmd/urione/main.go --config=config/config.dev.yaml
34+
35+
deb:
36+
deb-builder build

app/badges/badges.go

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2023 Mikhail Knyazhev <[email protected]>. All rights reserved.
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
33
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
44
*/
55

@@ -8,29 +8,31 @@ package badges
88
import (
99
"html"
1010

11-
"github.com/osspkg/go-badges"
12-
"github.com/osspkg/go-sdk/app"
13-
"github.com/osspkg/go-sdk/log"
14-
"github.com/osspkg/goppy/plugins"
15-
"github.com/osspkg/goppy/plugins/web"
11+
"github.com/osspkg/uri-one/app/mainapp"
12+
"go.osspkg.com/badges"
13+
"go.osspkg.com/goppy/plugins"
14+
"go.osspkg.com/goppy/web"
15+
"go.osspkg.com/goppy/xlog"
1616
)
1717

1818
var Plugin = plugins.Plugin{
1919
Inject: New,
2020
}
2121

2222
type Badge struct {
23-
route web.Router
24-
badge *badges.Badges
23+
address mainapp.Address
24+
route web.Router
25+
badge *badges.Badges
2526
}
2627

27-
func New(r web.RouterPool) *Badge {
28+
func New(r web.RouterPool, d mainapp.Address) *Badge {
2829
return &Badge{
29-
route: r.Main(),
30+
address: d,
31+
route: r.Main(),
3032
}
3133
}
3234

33-
func (v *Badge) Up(ctx app.Context) (err error) {
35+
func (v *Badge) Up() (err error) {
3436
if v.badge, err = badges.New(); err != nil {
3537
return err
3638
}
@@ -46,7 +48,7 @@ func (v *Badge) Down() error {
4648
}
4749

4850
func (v *Badge) Index(ctx web.Context) {
49-
ctx.String(200, indexHTML)
51+
ctx.String(200, indexHTML, string(v.address), string(v.address))
5052
}
5153

5254
var colors = map[string]badges.Color{
@@ -63,7 +65,7 @@ func (v *Badge) Draw(ctx web.Context) {
6365
title, err := ctx.Param("title").String()
6466
if err != nil {
6567
ctx.String(400, "Invalid `title`")
66-
ctx.Log().WithFields(log.Fields{
68+
ctx.Log().WithFields(xlog.Fields{
6769
"err": err.Error(),
6870
"key": "title",
6971
}).Errorf("Invalid badge key")
@@ -73,7 +75,7 @@ func (v *Badge) Draw(ctx web.Context) {
7375
data, err := ctx.Param("data").String()
7476
if err != nil {
7577
ctx.String(400, "Invalid `data`")
76-
ctx.Log().WithFields(log.Fields{
78+
ctx.Log().WithFields(xlog.Fields{
7779
"err": err.Error(),
7880
"key": "data",
7981
}).Errorf("Invalid badge key")
@@ -83,7 +85,7 @@ func (v *Badge) Draw(ctx web.Context) {
8385
color, err := ctx.Param("color").String()
8486
if err != nil {
8587
ctx.String(400, "Invalid `color`")
86-
ctx.Log().WithFields(log.Fields{
88+
ctx.Log().WithFields(xlog.Fields{
8789
"err": err.Error(),
8890
"key": "color",
8991
}).Errorf("Invalid badge key")
@@ -97,7 +99,7 @@ func (v *Badge) Draw(ctx web.Context) {
9799

98100
err = v.badge.WriteResponse(ctx.Response(), colored, html.EscapeString(title), html.EscapeString(data))
99101
if err != nil {
100-
ctx.Log().WithFields(log.Fields{
102+
ctx.Log().WithFields(xlog.Fields{
101103
"err": err.Error(),
102104
}).Errorf("Invalid badge response")
103105
}

app/badges/html.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2023 Mikhail Knyazhev <[email protected]>. All rights reserved.
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
33
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
44
*/
55

@@ -12,7 +12,7 @@ const indexHTML = `
1212
<meta charset='utf-8'>
1313
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
1414
<meta name='viewport' content='width=device-width, initial-scale=1'>
15-
<title>UriOne - Badge</title>
15+
<title>Badge</title>
1616
<style>
1717
body {
1818
margin: 30vh auto 0 auto;
@@ -25,7 +25,7 @@ const indexHTML = `
2525
<body>
2626
2727
<h1>Badge Generation</h1>
28-
<code>https://uri.one/badge/[color]/[title]/[data]/image.svg</code>
28+
<code>%s/badge/[color]/[title]/[data]/image.svg</code>
2929
<p>Color:
3030
<span style="color: #0d6efd">primary</span>,
3131
<span style="color: #6c757d">secondary</span>,
@@ -37,15 +37,15 @@ const indexHTML = `
3737
</p>
3838
<br><br>
3939
<h1>Example</h1>
40-
<pre>&lt;img src=&quot;https://uri.one/badge/light/User ID/12/image.svg&quot;&gt;</pre>
40+
<pre>&lt;img src=&quot;%s/badge/light/User ID/12/image.svg&quot;&gt;</pre>
4141
<p>
42-
<img src="/badge/primary/User ID/12/image.svg">
43-
<img src="/badge/secondary/User ID/12/image.svg">
44-
<img src="/badge/success/User ID/12/image.svg">
45-
<img src="/badge/danger/User ID/12/image.svg">
46-
<img src="/badge/warning/User ID/12/image.svg">
47-
<img src="/badge/info/User ID/12/image.svg">
48-
<img src="/badge/light/User ID/12/image.svg">
42+
<img src="/badge/primary/primary/color/image.svg">
43+
<img src="/badge/secondary/secondary/color/image.svg">
44+
<img src="/badge/success/success/color/image.svg">
45+
<img src="/badge/danger/danger/color/image.svg">
46+
<img src="/badge/warning/warning/color/image.svg">
47+
<img src="/badge/info/info/color/image.svg">
48+
<img src="/badge/light/light/color/image.svg">
4949
</p>
5050
5151
</body>

app/common/common.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
/*
2-
* Copyright (c) 2020-2023 Mikhail Knyazhev <[email protected]>. All rights reserved.
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
33
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
44
*/
55

66
package common
77

88
import (
9-
"github.com/osspkg/go-sdk/app"
10-
"github.com/osspkg/goppy/plugins"
11-
"github.com/osspkg/goppy/plugins/web"
9+
"go.osspkg.com/goppy/plugins"
10+
"go.osspkg.com/goppy/web"
1211
)
1312

1413
var Plugin = plugins.Plugin{
@@ -25,7 +24,7 @@ func New(r web.RouterPool) *Shorten {
2524
}
2625
}
2726

28-
func (v *Shorten) Up(ctx app.Context) error {
27+
func (v *Shorten) Up() error {
2928
v.route.NotFoundHandler(v.Page404)
3029
return nil
3130
}

app/common/html.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2020-2023 Mikhail Knyazhev <[email protected]>. All rights reserved.
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
33
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
44
*/
55

@@ -12,7 +12,7 @@ const page404HTML = `
1212
<meta charset='utf-8'>
1313
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
1414
<meta name='viewport' content='width=device-width, initial-scale=1'>
15-
<title>UriOne - 404</title>
15+
<title>404</title>
1616
<style>
1717
body {
1818
margin: 30vh auto 0 auto;
@@ -28,7 +28,7 @@ const page404HTML = `
2828
</head>
2929
<body>
3030
<h1 class="number">404</h1>
31-
<h1>Page not found</h1>
31+
<h1>Not found</h1>
3232
</body>
3333
</html>
3434
`

app/mainapp/common.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
3+
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
4+
*/
5+
6+
package mainapp
7+
8+
import "go.osspkg.com/goppy/plugins"
9+
10+
type Address string
11+
12+
var Plugin = plugins.Plugin{
13+
Config: &Config{},
14+
Inject: func(c *Config) Address {
15+
return Address(c.Address)
16+
},
17+
}

app/mainapp/config.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2020-2024 Mikhail Knyazhev <[email protected]>. All rights reserved.
3+
* Use of this source code is governed by a GPL-3.0 license that can be found in the LICENSE file.
4+
*/
5+
6+
package mainapp
7+
8+
type Config struct {
9+
Address string `yaml:"address"`
10+
}
11+
12+
func (v *Config) Default() {
13+
v.Address = "http://localhost:8080"
14+
}

0 commit comments

Comments
 (0)