Skip to content

Commit

Permalink
Merge pull request #41 from goark/develop
Browse files Browse the repository at this point in the history
Add tags metadata
  • Loading branch information
spiegel-im-spiegel authored Mar 3, 2024
2 parents be0b8d0 + 08de181 commit c3b30dd
Show file tree
Hide file tree
Showing 7 changed files with 221 additions and 546 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v3
with:
# go-version-file: 'go.mod'
go-version: v1.20.6
go-version-file: 'go.mod'
- name: install syft
run: go install github.com/anchore/syft/cmd/syft@latest
-
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
# go-version-file: 'go.mod'
go-version: v1.20.6
go-version-file: 'go.mod'
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tasks:
- go mod verify
- go test -shuffle on ./...
- govulncheck ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.53.3 golangci-lint run --enable gosec --timeout 10m0s ./...
- docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:latest golangci-lint run --enable gosec --timeout 10m0s ./...
sources:
- ./go.mod
- '**/*.go'
Expand All @@ -33,7 +33,7 @@ tasks:
- '**/*.go'

prepare:
- go mod tidy -v -go=1.20
- go mod tidy -v -go=1.22

clean:
desc: Initialize module and build cache, and remake go.sum file.
Expand Down
29 changes: 28 additions & 1 deletion bluesky/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,19 @@ func (cfg *Bluesky) PostMessage(ctx context.Context, msg *Message) (string, erro
})
}

// add tags metadata
for _, entry := range getTagsFrom(msg.Msg) {
post.Facets = append(post.Facets, &bsky.RichtextFacet{
Features: []*bsky.RichtextFacet_Features_Elem{
{RichtextFacet_Tag: &bsky.RichtextFacet_Tag{Tag: entry.text}},
},
Index: &bsky.RichtextFacet_ByteSlice{
ByteStart: entry.start,
ByteEnd: entry.end,
},
})
}

// embeded images
if len(msg.ImageFiles) > 0 {
for _, fn := range msg.ImageFiles {
Expand Down Expand Up @@ -191,6 +204,7 @@ func (cfg *Bluesky) getEmbedImage(ctx context.Context, urlStr string) (*atproto.
var (
urlRegexp = regexp.MustCompile(`https?://[-A-Za-z0-9+&@#\/%?=~_|!:,.;\(\)]+`)
mentionRegexp = regexp.MustCompile(`@[a-zA-Z0-9.]+`)
tagsRegexp = regexp.MustCompile(`\B#\S+`)
)

type entry struct {
Expand Down Expand Up @@ -225,7 +239,20 @@ func getMentionsFrom(msg string) []entry {
return result
}

/* Copyright 2023 Spiegel
func getTagsFrom(msg string) []entry {
var result []entry
matches := tagsRegexp.FindAllStringSubmatchIndex(msg, -1)
for _, m := range matches {
result = append(result, entry{
text: strings.TrimPrefix(msg[m[0]:m[1]], "#"),
start: int64(len(msg[0:m[0]])),
end: int64(len(msg[0:m[1]]))},
)
}
return result
}

/* Copyright 2023-2024 Spiegel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
Binary file modified dependency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
99 changes: 56 additions & 43 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,99 +1,112 @@
module github.com/goark/toolbox

go 1.20
go 1.22

toolchain go1.22.0

require (
github.com/PuerkitoBio/goquery v1.8.1
github.com/bluesky-social/indigo v0.0.0-20230714174244-57d75d8cfc65
github.com/glebarez/sqlite v1.9.0
github.com/PuerkitoBio/goquery v1.9.1
github.com/bluesky-social/indigo v0.0.0-20240301203549-d06d65d92df6
github.com/glebarez/sqlite v1.10.0
github.com/goark/errs v1.3.2
github.com/goark/errs/zapobject v0.1.3
github.com/goark/fetch v0.4.1
github.com/goark/gocli v0.13.0
github.com/hymkor/go-multiline-ny v0.11.1
github.com/hymkor/go-multiline-ny v0.12.1
github.com/ipfs/go-log/v2 v2.5.1
github.com/joho/godotenv v1.5.1
github.com/mattn/go-encoding v0.0.2
github.com/mattn/go-mastodon v0.0.6
github.com/mmcdole/gofeed v1.2.1
github.com/nyaosorg/go-readline-ny v0.13.1
github.com/spf13/cobra v1.7.0
github.com/spf13/viper v1.16.0
go.uber.org/zap v1.24.0
golang.org/x/image v0.9.0
golang.org/x/net v0.12.0
gorm.io/gorm v1.25.2
github.com/mmcdole/gofeed v1.3.0
github.com/nyaosorg/go-readline-ny v1.2.0
github.com/spf13/cobra v1.8.0
github.com/spf13/viper v1.18.2
go.uber.org/zap v1.27.0
golang.org/x/image v0.15.0
golang.org/x/net v0.21.0
gorm.io/gorm v1.25.7
moul.io/zapgorm2 v1.3.0
)

require (
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/andybalholm/cascadia v1.3.2 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/carlmjohnson/versioninfo v0.22.5 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/glebarez/go-sqlite v1.21.2 // indirect
github.com/go-logr/logr v1.4.1 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/gorilla/websocket v1.5.1 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
github.com/hashicorp/go-retryablehttp v0.7.2 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/go-retryablehttp v0.7.5 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-block-format v0.1.2 // indirect
github.com/ipfs/go-block-format v0.2.0 // indirect
github.com/ipfs/go-cid v0.4.1 // indirect
github.com/ipfs/go-datastore v0.6.0 // indirect
github.com/ipfs/go-ipfs-blockstore v1.3.0 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.0 // indirect
github.com/ipfs/go-ipfs-util v0.0.2 // indirect
github.com/ipfs/go-ipld-cbor v0.0.7-0.20230126201833-a73d038d90bc // indirect
github.com/ipfs/go-ipld-format v0.4.0 // indirect
github.com/ipfs/go-ipfs-blockstore v1.3.1 // indirect
github.com/ipfs/go-ipfs-ds-help v1.1.1 // indirect
github.com/ipfs/go-ipfs-util v0.0.3 // indirect
github.com/ipfs/go-ipld-cbor v0.1.0 // indirect
github.com/ipfs/go-ipld-format v0.6.0 // indirect
github.com/ipfs/go-log v1.0.5 // indirect
github.com/ipfs/go-metrics-interface v0.0.1 // indirect
github.com/jbenet/goprocess v0.1.4 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/klauspost/cpuid/v2 v2.2.6 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mattn/go-tty v0.0.5 // indirect
github.com/minio/sha256-simd v1.0.0 // indirect
github.com/minio/sha256-simd v1.0.1 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mmcdole/goxpp v1.1.0 // indirect
github.com/mmcdole/goxpp v1.1.1-0.20240225020742-a0c311522b23 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mr-tron/base58 v1.2.0 // indirect
github.com/multiformats/go-base32 v0.1.0 // indirect
github.com/multiformats/go-base36 v0.2.0 // indirect
github.com/multiformats/go-multibase v0.2.0 // indirect
github.com/multiformats/go-multihash v0.2.1 // indirect
github.com/multiformats/go-multihash v0.2.3 // indirect
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
github.com/pelletier/go-toml/v2 v2.1.0 // indirect
github.com/polydawn/refmt v0.89.1-0.20221221234430-40501e09de1f // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.4 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.9.5 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/subosito/gotenv v1.4.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
github.com/tomnomnom/linkheader v0.0.0-20180905144013-02ca5825eb80 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20230331140348-1f892b517e70 // indirect
github.com/whyrusleeping/cbor-gen v0.0.0-20240201211319-bf2168ca937c // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.1 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.uber.org/atomic v1.11.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/crypto v0.11.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
golang.org/x/crypto v0.19.0 // indirect
golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/term v0.17.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
lukechampine.com/blake3 v1.1.7 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
modernc.org/libc v1.22.5 // indirect
modernc.org/mathutil v1.5.0 // indirect
modernc.org/memory v1.5.0 // indirect
Expand Down
Loading

0 comments on commit c3b30dd

Please sign in to comment.