/
linkedinidentity.go
64 lines (56 loc) · 1.25 KB
/
linkedinidentity.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package user
import (
"github.com/ungerik/go-start/model"
"github.com/ungerik/go-start/view"
"strings"
)
///////////////////////////////////////////////////////////////////////////////
// LinkedInIdentity
type LinkedInIdentity struct {
ID model.String
Name model.String
Confirmed model.DateTime
AccessToken model.String
}
func (self *LinkedInIdentity) ProfileURL() string {
if self == nil {
return ""
}
if !self.Name.IsEmpty() {
name := self.Name.Get()
if strings.IndexRune(name, '/') == -1 {
return "http://linkedin.com/in/" + name
} else {
return "http://linkedin.com/pub/" + name
}
}
if !self.ID.IsEmpty() {
return "http://linkedin.com/profile/view?id=" + self.ID.Get()
}
return ""
}
func (self *LinkedInIdentity) URL(ctx *view.Context) string {
return self.ProfileURL()
}
func (self *LinkedInIdentity) LinkContent(ctx *view.Context) view.View {
if self == nil {
return nil
}
return view.Escape(self.LinkTitle(ctx))
}
func (self *LinkedInIdentity) LinkTitle(ctx *view.Context) string {
if self == nil {
return ""
}
name := self.Name.Get()
if name == "" {
name = self.ID.Get()
if name == "" {
return ""
}
}
return name
}
func (self *LinkedInIdentity) LinkRel(ctx *view.Context) string {
return ""
}