Compare commits

..

5 Commits

Author SHA1 Message Date
httpjamesm 073cc57e56 Merge branch 'main' into redirect-short-links 2023-08-21 02:01:48 -04:00
httpjamesm 1d8feea290 fix: remove log 2023-08-21 00:56:53 -04:00
httpjamesm 7fa26139bc fix: tell resty not to follow redirect 2023-08-21 00:56:39 -04:00
httpjamesm 6c7f8248e7 feat: accept shortened URLs in converter 2023-08-21 00:51:38 -04:00
httpjamesm 1db9b465d7 feat: redirect shortened URLs 2023-08-21 00:50:29 -04:00
6 changed files with 26 additions and 53 deletions
-6
View File
@@ -1,6 +0,0 @@
{
"trailingComma": "es5",
"tabWidth": 4,
"semi": false,
"singleQuote": true
}
+9 -14
View File
@@ -1,24 +1,19 @@
FROM golang:1.19-alpine as build
FROM golang:1.18-alpine
RUN apk add musl-dev
RUN apk add libc-dev
RUN apk add gcc
WORKDIR /app
COPY go.mod .
COPY go.sum .
COPY go.mod ./
COPY go.sum ./
RUN go mod download
COPY . .
COPY ./ /app
ENV CGO_ENABLED=0
RUN go build -o anonymousoverflow
FROM scratch
COPY --from=build /app/anonymousoverflow /anonymousoverflow
COPY templates /templates
COPY public /public
COPY --from=build /etc/ssl/certs /etc/ssl/certs
RUN go build -o /anonymousoverflow
EXPOSE 8080
+1 -1
View File
@@ -1,3 +1,3 @@
package config
var Version = "1.9.0"
var Version = "1.8.3"
+4 -3
View File
@@ -10,7 +10,7 @@
--link-color: #92adff;
}
[data-theme='light'] {
[data-theme="light"] {
--main-bg: rgb(219, 219, 219);
--text-color: #000;
--muted-text-color: #636363;
@@ -26,6 +26,7 @@ a {
color: var(--link-color);
}
html {
margin: 0;
padding: 0;
@@ -44,9 +45,9 @@ html {
.icon img {
background: white;
border-radius: 50%;
padding: 0.25rem;
padding: .25rem;
}
details {
cursor: pointer;
}
}
+5 -13
View File
@@ -19,17 +19,9 @@ body {
box-sizing: border-box;
}
@media (orientation: landscape) {
.parent {
max-width: 50%;
width: fit-content;
}
}
@media (orientation: portrait) {
.parent {
max-width: 90%;
width: fit-content;
}
.parent {
max-width: 90%;
width: fit-content;
}
.header {
@@ -39,7 +31,7 @@ body {
.card-tags {
display: flex;
gap: 0.5rem;
gap: .5rem;
}
.card-tags .tag {
@@ -102,7 +94,7 @@ img {
margin-bottom: 1rem;
background-color: var(--meta-bg);
color: var(--text-color);
display: flex;
justify-content: space-between;
align-items: center;
+7 -16
View File
@@ -6,7 +6,6 @@ import (
"os"
"regexp"
"strings"
"sync"
"time"
"github.com/golang-jwt/jwt/v4"
@@ -15,28 +14,20 @@ import (
var imgTagRegex = regexp.MustCompile(`<img[^>]*\s+src\s*=\s*"(.*?)"[^>]*>`)
func ReplaceImgTags(inHtml string) string {
// find all img tags
imgTags := imgTagRegex.FindAllString(inHtml, -1)
var wg sync.WaitGroup
var mu sync.Mutex
for _, imgTag := range imgTags {
wg.Add(1)
go func(imgTag string) {
defer wg.Done()
srcRegex := regexp.MustCompile(`src\s*=\s*"(.*?)"`)
src := srcRegex.FindStringSubmatch(imgTag)[1]
// parse the src="" attribute
srcRegex := regexp.MustCompile(`src\s*=\s*"(.*?)"`)
src := srcRegex.FindStringSubmatch(imgTag)[1]
authToken, _ := generateImageProxyAuth(src)
authToken, _ := generateImageProxyAuth(src)
mu.Lock()
defer mu.Unlock()
inHtml = strings.Replace(inHtml, imgTag, fmt.Sprintf(`<img src="%s/proxy?auth=%s">`, os.Getenv("APP_URL"), authToken), 1)
}(imgTag)
// replace the img tag with a proxied url
inHtml = strings.Replace(inHtml, imgTag, fmt.Sprintf(`<img src="%s/proxy?auth=%s">`, os.Getenv("APP_URL"), authToken), 1)
}
wg.Wait()
return inHtml
}