Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d41677a7a | ||
|
|
f6707f32ea | ||
|
|
f286ddb713 | ||
|
|
52f92a2d92 | ||
|
|
9ef186bf73 | ||
|
|
91ebade091 | ||
|
|
e4cf634040 | ||
|
|
25d52df9a3 | ||
|
|
e9abfc34c1 | ||
|
|
d73d983f32 | ||
|
|
84d7479954 | ||
|
|
b6521cded2 | ||
|
|
180136e6db | ||
|
|
cf9f5db56b | ||
|
|
d476017273 | ||
|
|
428972d76c | ||
|
|
a0c5600cc3 | ||
|
|
dd08b71215 | ||
|
|
f311bfd33c | ||
|
|
e8804848c7 | ||
|
|
b435031b2d | ||
|
|
ecf7fd1f90 | ||
|
|
6caf274300 | ||
|
|
d81124d454 | ||
|
|
adbbafe3ee |
+34
-10
@@ -8,20 +8,25 @@ import (
|
||||
|
||||
const (
|
||||
Namespace = "https://www.w3.org/ns/activitystreams"
|
||||
toPublic = "https://www.w3.org/ns/activitystreams#Public"
|
||||
ToPublic = "https://www.w3.org/ns/activitystreams#Public"
|
||||
)
|
||||
|
||||
var Extensions = map[string]string{}
|
||||
var (
|
||||
Extensions = map[string]string{}
|
||||
|
||||
apMonetizationContext = "https://webmonetization.org/ns.jsonld"
|
||||
)
|
||||
|
||||
// Activity describes actions that have either already occurred, are in the
|
||||
// process of occurring, or may occur in the future.
|
||||
type Activity struct {
|
||||
BaseObject
|
||||
Actor string `json:"actor"`
|
||||
Published time.Time `json:"published,omitempty"`
|
||||
To []string `json:"to,omitempty"`
|
||||
CC []string `json:"cc,omitempty"`
|
||||
Object *Object `json:"object"`
|
||||
Actor string `json:"actor"`
|
||||
Published time.Time `json:"published,omitempty"`
|
||||
Updated *time.Time `json:"updated,omitempty"`
|
||||
To []string `json:"to,omitempty"`
|
||||
CC []string `json:"cc,omitempty"`
|
||||
Object *Object `json:"object"`
|
||||
}
|
||||
|
||||
type FollowActivity struct {
|
||||
@@ -68,6 +73,9 @@ func NewUpdateActivity(o *Object) *Activity {
|
||||
Object: o,
|
||||
Published: o.Published,
|
||||
}
|
||||
if o.Updated != nil && !o.Updated.IsZero() {
|
||||
a.Updated = o.Updated
|
||||
}
|
||||
return &a
|
||||
}
|
||||
|
||||
@@ -107,6 +115,7 @@ func NewFollowActivity(actorIRI, followeeIRI string) *FollowActivity {
|
||||
type Object struct {
|
||||
BaseObject
|
||||
Published time.Time `json:"published,omitempty"`
|
||||
Updated *time.Time `json:"updated,omitempty"`
|
||||
Summary *string `json:"summary,omitempty"`
|
||||
InReplyTo *string `json:"inReplyTo,omitempty"`
|
||||
URL string `json:"url"`
|
||||
@@ -118,6 +127,7 @@ type Object struct {
|
||||
ContentMap map[string]string `json:"contentMap,omitempty"`
|
||||
Tag []Tag `json:"tag,omitempty"`
|
||||
Attachment []Attachment `json:"attachment,omitempty"`
|
||||
Preview *Object `json:"preview,omitempty"`
|
||||
|
||||
// Person
|
||||
Inbox string `json:"inbox,omitempty"`
|
||||
@@ -130,7 +140,7 @@ type Object struct {
|
||||
Endpoints *Endpoints `json:"endpoints,omitempty"`
|
||||
|
||||
// Extensions
|
||||
// NOTE: add extensions here
|
||||
Monetization string `json:"monetization,omitempty"`
|
||||
}
|
||||
|
||||
// NewNoteObject creates a basic Note object that includes the public
|
||||
@@ -139,9 +149,12 @@ func NewNoteObject() *Object {
|
||||
o := Object{
|
||||
BaseObject: BaseObject{
|
||||
Type: "Note",
|
||||
Context: []interface{}{
|
||||
Namespace,
|
||||
},
|
||||
},
|
||||
To: []string{
|
||||
toPublic,
|
||||
ToPublic,
|
||||
},
|
||||
}
|
||||
return &o
|
||||
@@ -153,9 +166,12 @@ func NewArticleObject() *Object {
|
||||
o := Object{
|
||||
BaseObject: BaseObject{
|
||||
Type: "Article",
|
||||
Context: []interface{}{
|
||||
Namespace,
|
||||
},
|
||||
},
|
||||
To: []string{
|
||||
toPublic,
|
||||
ToPublic,
|
||||
},
|
||||
}
|
||||
return &o
|
||||
@@ -166,7 +182,15 @@ func NewPersonObject() *Object {
|
||||
o := Object{
|
||||
BaseObject: BaseObject{
|
||||
Type: "Person",
|
||||
Context: []interface{}{
|
||||
Namespace,
|
||||
},
|
||||
},
|
||||
}
|
||||
return &o
|
||||
}
|
||||
|
||||
func (o *Object) AddWebMonetization(wallet string) {
|
||||
o.Context = append(o.Context, apMonetizationContext)
|
||||
o.Monetization = wallet
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type (
|
||||
type OrderedCollection struct {
|
||||
BaseObject
|
||||
TotalItems int `json:"totalItems"`
|
||||
First string `json:"first"`
|
||||
First string `json:"first,omitempty"`
|
||||
Last string `json:"last,omitempty"`
|
||||
}
|
||||
|
||||
@@ -43,9 +43,13 @@ func NewOrderedCollection(accountRoot, collType string, items int) *OrderedColle
|
||||
ID: accountRoot + "/" + collType,
|
||||
Type: "OrderedCollection",
|
||||
},
|
||||
First: accountRoot + "/" + collType + "?page=1",
|
||||
TotalItems: items,
|
||||
}
|
||||
if items > 0 {
|
||||
// Next page should only be indicated if there are potentially items on it. NOTE: with no knowledge of items-
|
||||
// per-page, this still may need to be altered by the func caller.
|
||||
oc.First = accountRoot + "/" + collType + "?page=1"
|
||||
}
|
||||
return &oc
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,9 @@ type Person struct {
|
||||
Summary string `json:"summary"`
|
||||
PublicKey PublicKey `json:"publicKey"`
|
||||
Endpoints Endpoints `json:"endpoints"`
|
||||
|
||||
// Extensions
|
||||
Monetization string `json:"monetization,omitempty"`
|
||||
}
|
||||
|
||||
func NewPerson(accountRoot string) *Person {
|
||||
@@ -49,3 +52,8 @@ func (p *Person) SetPrivKey(k []byte) {
|
||||
func (p *Person) GetPrivKey() []byte {
|
||||
return p.PublicKey.privateKey
|
||||
}
|
||||
|
||||
func (p *Person) AddWebMonetization(wallet string) {
|
||||
p.Context = append(p.Context, apMonetizationContext)
|
||||
p.Monetization = wallet
|
||||
}
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
module github.com/writeas/web-core
|
||||
|
||||
go 1.10
|
||||
go 1.25.0
|
||||
|
||||
require (
|
||||
github.com/gofrs/uuid v3.3.0+incompatible
|
||||
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec
|
||||
github.com/microcosm-cc/bluemonday v1.0.23
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
github.com/writeas/go-strip-markdown/v2 v2.1.1
|
||||
github.com/writeas/impart v1.1.1
|
||||
github.com/writeas/openssl-go v1.0.0
|
||||
github.com/writeas/saturday v1.7.1
|
||||
github.com/writeas/slug v1.2.0
|
||||
golang.org/x/crypto v0.1.0
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
|
||||
golang.org/x/crypto v0.52.0
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/aymerick/douceur v0.2.0 // indirect
|
||||
github.com/gorilla/css v1.0.0 // indirect
|
||||
github.com/rainycape/unidecode v0.0.0-20150907023854-cb7f23ec59be // indirect
|
||||
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
|
||||
golang.org/x/net v0.55.0 // indirect
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 // indirect
|
||||
)
|
||||
|
||||
@@ -4,11 +4,6 @@ github.com/gofrs/uuid v3.3.0+incompatible h1:8K4tyRfvU1CYPgJsveYFQMhpFd/wXNM7iK6
|
||||
github.com/gofrs/uuid v3.3.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY=
|
||||
github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c=
|
||||
github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec h1:ZXWuspqypleMuJy4bzYEqlMhJnGAYpLrWe5p7W3CdvI=
|
||||
github.com/kylemcc/twitter-text-go v0.0.0-20180726194232-7f582f6736ec/go.mod h1:voECJzdraJmolzPBgL9Z7ANwXf4oMXaTCsIkdiPpR/g=
|
||||
github.com/microcosm-cc/bluemonday v1.0.23 h1:SMZe2IGa0NuHvnVNAZ+6B38gsTbi5e4sViiWJyDDqFY=
|
||||
@@ -27,48 +22,9 @@ github.com/writeas/saturday v1.7.1 h1:lYo1EH6CYyrFObQoA9RNWHVlpZA5iYL5Opxo7PYAnZ
|
||||
github.com/writeas/saturday v1.7.1/go.mod h1:ETE1EK6ogxptJpAgUbcJD0prAtX48bSloie80+tvnzQ=
|
||||
github.com/writeas/slug v1.2.0 h1:EMQ+cwLiOcA6EtFwUgyw3Ge18x9uflUnOnR6bp/J+/g=
|
||||
github.com/writeas/slug v1.2.0/go.mod h1:RE8shOqQP3YhsfsQe0L3RnuejfQ4Mk+JjY5YJQFubfQ=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.1.0 h1:MDRAIl0xIo9Io2xV565hzXHw3zVseKrJKodhohM5CjU=
|
||||
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ=
|
||||
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
golang.org/x/crypto v0.52.0 h1:RMs7fP2rXdep0CftQlK8Uf+kibLm7qkCcradZWYz988=
|
||||
golang.org/x/crypto v0.52.0/go.mod h1:1QgfPxDqh0T2M/elOJtp9RvuR95kVjir0e6/BvEmGbc=
|
||||
golang.org/x/net v0.55.0 h1:bcvxaJn3e1U6InsFWt1JUq1aSjnRxLzT2rtD2KfkDF8=
|
||||
golang.org/x/net v0.55.0/go.mod h1:L5U2KuzuOe1lY7Z+aWVIKK6qEeJXnXV9yzGA+WCHJww=
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0 h1:POO/ycCATvegFmVuPpQzZFJ+pGZeX22Ufu6fibxDVjU=
|
||||
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg=
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package l10n
|
||||
|
||||
// Temporal korean localation by Hoto Ras (@ras@hoto.moe), 2024
|
||||
var phrasesKO = map[string]string{
|
||||
"Anonymous post": "모두의 게시물",
|
||||
"Blogs": "블로그",
|
||||
"Enter": "접속",
|
||||
"Newer": "신규",
|
||||
"Next": "다음",
|
||||
"Older": "오래됨",
|
||||
"Posts": "게시물",
|
||||
"Previous": "이전",
|
||||
"Publish to...": "다음으로 게시...",
|
||||
"Publish": "게시",
|
||||
"Read more...": "더 읽어보기...",
|
||||
"Subscribe": "구독",
|
||||
"This blog requires a password.": "이 블로그는 비밀번호가 필요합니다.",
|
||||
"Toggle theme": "테마 토글",
|
||||
"View posts": "게시물 보기",
|
||||
"delete": "삭제",
|
||||
"edit": "수정",
|
||||
"email subscription confirm": "이메일을 확인하고 확인 링크를 눌러 구독을 완료하세요.",
|
||||
"email subscription prompt": "새로운 소식을 보고 싶으신가요? 여기에 이메일을 입력해 구독하세요!",
|
||||
"email subscription success": "구독이 완료되었습니다! 이제 앞으로의 블로그 게시물을 이메일로 받아볼 수 있어요.",
|
||||
"move to...": "다음으로 이동...",
|
||||
"pin": "고정",
|
||||
"published with write.as": "write.as를 통해 배포됨",
|
||||
"share modal ending": "친구에게 보내거나, 인터넷에 공유하거나, 트윗할 수도 있습니다. 더 알아보기",
|
||||
"share modal introduction": "각각의 게시물에는 비밀이 있어요. 각자 특별한 주소가 있어 모두와 공유할 수 있답니다. 주소는 여기 있어요:",
|
||||
"share modal title": "이 게시물 공유하기",
|
||||
"share": "공유",
|
||||
"unpin": "고정 해제",
|
||||
"title dash": "—",
|
||||
}
|
||||
@@ -34,6 +34,8 @@ func Strings(lang string) map[string]string {
|
||||
return phrasesIT
|
||||
case "ja":
|
||||
return phrasesJA
|
||||
case "ko":
|
||||
return phrasesKO
|
||||
case "lt":
|
||||
return phrasesLT
|
||||
case "mk":
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package text
|
||||
|
||||
import (
|
||||
"github.com/kylemcc/twitter-text-go/extract"
|
||||
"net/url"
|
||||
"regexp"
|
||||
)
|
||||
|
||||
var imageURLRegex = regexp.MustCompile(`(?i)[^ ]+\.(gif|png|jpg|jpeg|image)$`)
|
||||
|
||||
func ExtractImages(content string) []string {
|
||||
matches := extract.ExtractUrls(content)
|
||||
urls := map[string]bool{}
|
||||
for i := range matches {
|
||||
uRaw := matches[i].Text
|
||||
// Parse the extracted text so we can examine the path
|
||||
u, err := url.Parse(uRaw)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
// Ensure the path looks like it leads to an image file
|
||||
if !imageURLRegex.MatchString(u.Path) {
|
||||
continue
|
||||
}
|
||||
urls[uRaw] = true
|
||||
}
|
||||
|
||||
resURLs := make([]string, 0)
|
||||
for k := range urls {
|
||||
resURLs = append(resURLs, k)
|
||||
}
|
||||
return resURLs
|
||||
}
|
||||
Reference in New Issue
Block a user