Skip to content

Commit

Permalink
implement media links in twitter updater
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed May 6, 2014
1 parent 92880e0 commit a2080fe
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions updater/twitter.go
Expand Up @@ -83,6 +83,7 @@ func renderTweet(tweet anaconda.Tweet) string {
urlt := `<a href="%s" rel="nofollow">%s</a>`
usert := `<a href="https://twitter.com/%s" title="@%s"
class="tweet-url username" rel="nofollow">@%s</a>`
mediat := `<a href="%s" rel="nofollow">%s</a>`

// allocate replacements
e := tweet.Entities
Expand Down Expand Up @@ -112,7 +113,14 @@ func renderTweet(tweet anaconda.Tweet) string {
Replacement: fmt.Sprintf(usert, user.Screen_name, user.Screen_name, user.Screen_name),
}
repl = append(repl, r)
}

for _, media := range e.Media {
r := trepl{
Indices: [2]int{media.Indices[0], media.Indices[1]},
Replacement: fmt.Sprintf(mediat, media.Expanded_url, media.Display_url),
}
repl = append(repl, r)
}

sort.Sort(sort.Reverse(repl))
Expand Down

0 comments on commit a2080fe

Please sign in to comment.