mirror of
https://github.com/tenox7/wrp.git
synced 2024-11-21 19:30:48 +00:00
add / path prefix
This commit is contained in:
parent
f838caa328
commit
407907bece
3
txt.go
3
txt.go
@ -128,7 +128,7 @@ type astTransformer struct{}
|
|||||||
func (t *astTransformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context) {
|
func (t *astTransformer) Transform(node *ast.Document, reader text.Reader, pc parser.Context) {
|
||||||
ast.Walk(node, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
|
ast.Walk(node, func(n ast.Node, entering bool) (ast.WalkStatus, error) {
|
||||||
if link, ok := n.(*ast.Link); ok && entering {
|
if link, ok := n.(*ast.Link); ok && entering {
|
||||||
link.Destination = append([]byte("?t=txt&url="), link.Destination...)
|
link.Destination = append([]byte("/?t=txt&url="), link.Destination...)
|
||||||
}
|
}
|
||||||
if img, ok := n.(*ast.Image); ok && entering {
|
if img, ok := n.(*ast.Image); ok && entering {
|
||||||
// TODO: dynamic extension based on form value
|
// TODO: dynamic extension based on form value
|
||||||
@ -214,7 +214,6 @@ func smallGif(src []byte) ([]byte, error) {
|
|||||||
img = resize.Thumbnail(uint(*txtImgSize), uint(*txtImgSize), img, resize.NearestNeighbor)
|
img = resize.Thumbnail(uint(*txtImgSize), uint(*txtImgSize), img, resize.NearestNeighbor)
|
||||||
var gifBuf bytes.Buffer
|
var gifBuf bytes.Buffer
|
||||||
err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{})
|
err = gif.Encode(&gifBuf, gifPalette(img, 216), &gif.Options{})
|
||||||
//err =jpeg.Encode(&gifBuf, img, &jpeg.Options{Quality: 50})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("gif encode problem: %v", err)
|
return nil, fmt.Errorf("gif encode problem: %v", err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user