add struct fields
This commit is contained in:
@ -6,4 +6,6 @@ Dependencies:
|
|||||||
* http://github.com/jackpal/bencode-go
|
* http://github.com/jackpal/bencode-go
|
||||||
|
|
||||||
TODO:
|
TODO:
|
||||||
* Rename to libsyndie or something similar
|
* Rename to libsyndie or something similar
|
||||||
|
* Break URI into individual types
|
||||||
|
* Lots of renaming
|
||||||
|
@ -14,46 +14,46 @@ URI defines the URIs safely passable within syndie, capable of referencing speci
|
|||||||
They contain one of four reference types, plus a bencoded set of attributes:
|
They contain one of four reference types, plus a bencoded set of attributes:
|
||||||
*/
|
*/
|
||||||
type URI struct {
|
type URI struct {
|
||||||
RefType string
|
RefType string `bencode:"-"`
|
||||||
Name string `bencode:",omitempty"`
|
Name string `bencode:"name,omitempty"`
|
||||||
Desc string `bencode:",omitempty"`
|
Desc string `bencode:"desc,omitempty"`
|
||||||
Tag []string `bencode:",omitempty"`
|
Tag []string `bencode:"tag,omitempty"`
|
||||||
Author string `bencode:",omitempty"`
|
Author string `bencode:"author,omitempty"`
|
||||||
Net string `bencode:",omitempty"`
|
Net string `bencode:"net,omitempty"`
|
||||||
ReadKeyType string `bencode:",omitempty"`
|
ReadKeyType string `bencode:"readKeyType,omitempty"`
|
||||||
ReadKeyData string `bencode:",omitempty"`
|
ReadKeyData string `bencode:"readKeyData,omitempty"`
|
||||||
PostKeyType string `bencode:",omitempty"`
|
PostKeyType string `bencode:"postKeyType,omitempty"`
|
||||||
PostKeyData string `bencode:",omitempty"`
|
PostKeyData string `bencode:"postKeyData,omitempty"`
|
||||||
URL string `bencode:",omitempty"`
|
URL string `bencode:"url,omitempty"`
|
||||||
Channel string `bencode:",omitempty"`
|
Channel string `bencode:"channel,omitempty"`
|
||||||
MessageID int `bencode:",omitempty"`
|
MessageID int `bencode:"messageId,omitempty"`
|
||||||
Page int `bencode:",omitempty"`
|
Page int `bencode:"page,omitempty"`
|
||||||
Attachment int `bencode:",omitempty"`
|
Attachment int `bencode:"attatchment,omitempty"`
|
||||||
Scope []string `bencode:",omitempty"`
|
Scope []string `bencode:"scope,omitempty"`
|
||||||
PostByScope []string `bencode:",omitempty"`
|
PostByScope []string `bencode:"postbyscope,omitempty"`
|
||||||
Age int `bencode:",omitempty"`
|
Age int `bencode:"age,omitempty"`
|
||||||
AgeLocal int `bencode:",omitempty"`
|
AgeLocal int `bencode:"agelocal,omitempty"`
|
||||||
UnreadOnly bool `bencode:",omitempty"`
|
UnreadOnly bool `bencode:"unreadonly,omitempty"`
|
||||||
TagInclude []string `bencode:",omitempty"`
|
TagInclude []string `bencode:"taginclude,omitempty"`
|
||||||
TagRequire []string `bencode:",omitempty"`
|
TagRequire []string `bencode:"tagrequire,omitempty"`
|
||||||
TagExclude []string `bencode:",omitempty"`
|
TagExclude []string `bencode:"tagexclude,omitempty"`
|
||||||
TagMessages bool `bencode:",omitempty"`
|
TagMessages bool `bencode:"tagmessages,omitempty"`
|
||||||
PageMin int `bencode:",omitempty"`
|
PageMin int `bencode:"pagemin,omitempty"`
|
||||||
PageMax int `bencode:",omitempty"`
|
PageMax int `bencode:"pagemax,omitempty"`
|
||||||
AttachMin int `bencode:",omitempty"`
|
AttachMin int `bencode:"attachmin,omitempty"`
|
||||||
AttachMax int `bencode:",omitempty"`
|
AttachMax int `bencode:"attachmax,omitempty"`
|
||||||
RefMin int `bencode:",omitempty"`
|
RefMin int `bencode:"refmin,omitempty"`
|
||||||
RefMax int `bencode:",omitempty"`
|
RefMax int `bencode:"refmax,omitempty"`
|
||||||
KeyMin int `bencode:",omitempty"`
|
KeyMin int `bencode:"keymin,omitempty"`
|
||||||
KeyMax int `bencode:",omitempty"`
|
KeyMax int `bencode:"keymax,omitempty"`
|
||||||
Encrypted bool `bencode:",omitempty"`
|
Encrypted bool `bencode:"encrypted,omitempty"`
|
||||||
PBE bool `bencode:",omitempty"`
|
PBE bool `bencode:"pbe,omitempty"`
|
||||||
Private bool `bencode:",omitempty"`
|
Private bool `bencode:"private,omitempty"`
|
||||||
Public bool `bencode:",omitempty"`
|
Public bool `bencode:"public,omitempty"`
|
||||||
Authorized bool `bencode:",omitempty"`
|
Authorized bool `bencode:"authorized,omitempty"`
|
||||||
Threaded bool `bencode:",omitempty"`
|
Threaded bool `bencode:"threaded,omitempty"`
|
||||||
Keyword string `bencode:",omitempty"`
|
Keyword string `bencode:"keyword,omitempty"`
|
||||||
Body string `bencode:",omitempty"`
|
Body string `bencode:"body,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// trimSyndieURI trims "urn:", "urn:syndie", and "syndie:" from the left of a string
|
// trimSyndieURI trims "urn:", "urn:syndie", and "syndie:" from the left of a string
|
||||||
@ -90,7 +90,6 @@ func (u *URI) Marshall(s string) error {
|
|||||||
if len(s) < 3 {
|
if len(s) < 3 {
|
||||||
return errors.New("URI was too short to process")
|
return errors.New("URI was too short to process")
|
||||||
}
|
}
|
||||||
s = trimSyndieURI(s)
|
|
||||||
u.RefType = strings.Split(s, ":")[0]
|
u.RefType = strings.Split(s, ":")[0]
|
||||||
prepared, err := prepareURI(s)
|
prepared, err := prepareURI(s)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -104,3 +103,10 @@ func (u *URI) Marshall(s string) error {
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (u *URI) String() string {
|
||||||
|
var buf []byte
|
||||||
|
w := bytes.NewBuffer(buf)
|
||||||
|
bencode.Marshal(w, *u)
|
||||||
|
out, _ := prepareURI(w.String())
|
||||||
|
return "urn:syndie:" + u.RefType + ":" + out
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user