HTML for tweet #233

Merged
michaelhelmick merged 2 commits from html-for-tweet into master 2013-06-27 16:29:38 -07:00
michaelhelmick commented 2013-06-25 19:02:56 -07:00 (Migrated from github.com)

fixes #224

@trevoriancox does this look good to you?

Also, @ryanmcgrath In the files changed, you'll see the function. I am returning specific classes class=twython-hashtag, etc.. in case they want to style it different or do something with javascript to it. Should I leave it like this or should I make use of the mention_html, hashtag_html and user_html as variables I have and let them pass their own string formatted custom html or is that to complicated? My vote is for the first and just add the twython custom classes to the anchor tags

Example:

from twython import Twython

t = Twython()
tweet = {u'contributors': None, u'truncated': False, u'text': u'http://t.co/FCmXyI6VHd is a #cool site, lol! @mikehelmick should #checkitout. If you can! #thanks Love, @__twython__ https://t.co/67pwRvY6z9', u'in_reply_to_status_id': None, u'id': 349683012054683648, u'favorite_count': 0, u'source': u'web', u'retweeted': False, u'coordinates': None, u'entities': {u'symbols': [], u'user_mentions': [{u'id': 29251354, u'indices': [45, 57], u'id_str': u'29251354', u'screen_name': u'mikehelmick', u'name': u'Mike Helmick'}, {u'id': 1431865928, u'indices': [104, 116], u'id_str': u'1431865928', u'screen_name': u'__twython__', u'name': u'Twython'}], u'hashtags': [{u'indices': [28, 33], u'text': u'cool'}, {u'indices': [65, 76], u'text': u'checkitout'}, {u'indices': [90, 97], u'text': u'thanks'}], u'urls': [{u'url': u'http://t.co/FCmXyI6VHd', u'indices': [0, 22], u'expanded_url': u'http://google.com', u'display_url': u'google.com'}, {u'url': u'https://t.co/67pwRvY6z9', u'indices': [117, 140], u'expanded_url': u'https://github.com', u'display_url': u'github.com'}]}, u'in_reply_to_screen_name': None, u'id_str': u'349683012054683648', u'retweet_count': 0, u'in_reply_to_user_id': None, u'favorited': False, u'user': {u'follow_request_sent': False, u'profile_use_background_image': True, u'default_profile_image': True, u'id': 1431865928, u'verified': False, u'profile_text_color': u'333333', u'profile_image_url_https': u'https://si0.twimg.com/sticky/default_profile_images/default_profile_3_normal.png', u'profile_sidebar_fill_color': u'DDEEF6', u'entities': {u'description': {u'urls': []}}, u'followers_count': 1, u'profile_sidebar_border_color': u'C0DEED', u'id_str': u'1431865928', u'profile_background_color': u'3D3D3D', u'listed_count': 0, u'profile_background_image_url_https': u'https://si0.twimg.com/images/themes/theme1/bg.png', u'utc_offset': None, u'statuses_count': 2, u'description': u'', u'friends_count': 1, u'location': u'', u'profile_link_color': u'0084B4', u'profile_image_url': u'http://a0.twimg.com/sticky/default_profile_images/default_profile_3_normal.png', u'following': False, u'geo_enabled': False, u'profile_background_image_url': u'http://a0.twimg.com/images/themes/theme1/bg.png', u'screen_name': u'__twython__', u'lang': u'en', u'profile_background_tile': False, u'favourites_count': 0, u'name': u'Twython', u'notifications': False, u'url': None, u'created_at': u'Thu May 16 01:11:09 +0000 2013', u'contributors_enabled': False, u'time_zone': None, u'protected': False, u'default_profile': False, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': None, u'possibly_sensitive': False, u'lang': u'en', u'created_at': u'Wed Jun 26 00:18:21 +0000 2013', u'in_reply_to_status_id_str': None, u'place': None}

print Twython.html_for_tweet(tweet)

Which produces:

<a href="http://t.co/FCmXyI6VHd" class="twython-url">google.com</a> is a <a href="https://twitter.com/search?q=%23cool" class="twython-hashtag">#cool</a> site, lol! <a href="https://twitter.com/mikehelmick" class="twython-mention">@mikehelmick</a> should <a href="https://twitter.com/search?q=%23checkitout" class="twython-hashtag">#checkitout</a>. If you can! <a href="https://twitter.com/search?q=%23thanks" class="twython-hashtag">#thanks</a> Love, <a href="https://twitter.com/__twython__" class="twython-mention">@__twython__</a> <a href="https://t.co/67pwRvY6z9" class="twython-url">github.com</a>
fixes #224 @trevoriancox does this look good to you? Also, @ryanmcgrath In the files changed, you'll see the function. I am returning specific classes `class=twython-hashtag`, etc.. in case they want to style it different or do something with javascript to it. Should I leave it like this or should I make use of the `mention_html`, `hashtag_html` and `user_html` as variables I have and let them pass their own string formatted custom html or is that to complicated? My vote is for the first and just add the twython custom classes to the anchor tags Example: ``` python from twython import Twython t = Twython() tweet = {u'contributors': None, u'truncated': False, u'text': u'http://t.co/FCmXyI6VHd is a #cool site, lol! @mikehelmick should #checkitout. If you can! #thanks Love, @__twython__ https://t.co/67pwRvY6z9', u'in_reply_to_status_id': None, u'id': 349683012054683648, u'favorite_count': 0, u'source': u'web', u'retweeted': False, u'coordinates': None, u'entities': {u'symbols': [], u'user_mentions': [{u'id': 29251354, u'indices': [45, 57], u'id_str': u'29251354', u'screen_name': u'mikehelmick', u'name': u'Mike Helmick'}, {u'id': 1431865928, u'indices': [104, 116], u'id_str': u'1431865928', u'screen_name': u'__twython__', u'name': u'Twython'}], u'hashtags': [{u'indices': [28, 33], u'text': u'cool'}, {u'indices': [65, 76], u'text': u'checkitout'}, {u'indices': [90, 97], u'text': u'thanks'}], u'urls': [{u'url': u'http://t.co/FCmXyI6VHd', u'indices': [0, 22], u'expanded_url': u'http://google.com', u'display_url': u'google.com'}, {u'url': u'https://t.co/67pwRvY6z9', u'indices': [117, 140], u'expanded_url': u'https://github.com', u'display_url': u'github.com'}]}, u'in_reply_to_screen_name': None, u'id_str': u'349683012054683648', u'retweet_count': 0, u'in_reply_to_user_id': None, u'favorited': False, u'user': {u'follow_request_sent': False, u'profile_use_background_image': True, u'default_profile_image': True, u'id': 1431865928, u'verified': False, u'profile_text_color': u'333333', u'profile_image_url_https': u'https://si0.twimg.com/sticky/default_profile_images/default_profile_3_normal.png', u'profile_sidebar_fill_color': u'DDEEF6', u'entities': {u'description': {u'urls': []}}, u'followers_count': 1, u'profile_sidebar_border_color': u'C0DEED', u'id_str': u'1431865928', u'profile_background_color': u'3D3D3D', u'listed_count': 0, u'profile_background_image_url_https': u'https://si0.twimg.com/images/themes/theme1/bg.png', u'utc_offset': None, u'statuses_count': 2, u'description': u'', u'friends_count': 1, u'location': u'', u'profile_link_color': u'0084B4', u'profile_image_url': u'http://a0.twimg.com/sticky/default_profile_images/default_profile_3_normal.png', u'following': False, u'geo_enabled': False, u'profile_background_image_url': u'http://a0.twimg.com/images/themes/theme1/bg.png', u'screen_name': u'__twython__', u'lang': u'en', u'profile_background_tile': False, u'favourites_count': 0, u'name': u'Twython', u'notifications': False, u'url': None, u'created_at': u'Thu May 16 01:11:09 +0000 2013', u'contributors_enabled': False, u'time_zone': None, u'protected': False, u'default_profile': False, u'is_translator': False}, u'geo': None, u'in_reply_to_user_id_str': None, u'possibly_sensitive': False, u'lang': u'en', u'created_at': u'Wed Jun 26 00:18:21 +0000 2013', u'in_reply_to_status_id_str': None, u'place': None} print Twython.html_for_tweet(tweet) ``` Which produces: ``` html <a href="http://t.co/FCmXyI6VHd" class="twython-url">google.com</a> is a <a href="https://twitter.com/search?q=%23cool" class="twython-hashtag">#cool</a> site, lol! <a href="https://twitter.com/mikehelmick" class="twython-mention">@mikehelmick</a> should <a href="https://twitter.com/search?q=%23checkitout" class="twython-hashtag">#checkitout</a>. If you can! <a href="https://twitter.com/search?q=%23thanks" class="twython-hashtag">#thanks</a> Love, <a href="https://twitter.com/__twython__" class="twython-mention">@__twython__</a> <a href="https://t.co/67pwRvY6z9" class="twython-url">github.com</a> ```
coveralls commented 2013-06-25 19:06:23 -07:00 (Migrated from github.com)

Coverage Status

Changes Unknown when pulling 173adee4a6 on html-for-tweet into * on master*.

[![Coverage Status](https://coveralls.io/builds/88127/badge)](https://coveralls.io/builds/88127) Changes Unknown when pulling **173adee4a68b3a01292a3878e7fc33fa9622ee32 on html-for-tweet** into *\* on master**.
coveralls commented 2013-06-25 19:06:23 -07:00 (Migrated from github.com)

Coverage Status

Changes Unknown when pulling 173adee4a6 on html-for-tweet into * on master*.

[![Coverage Status](https://coveralls.io/builds/88127/badge)](https://coveralls.io/builds/88127) Changes Unknown when pulling **173adee4a68b3a01292a3878e7fc33fa9622ee32 on html-for-tweet** into *\* on master**.
ryanmcgrath commented 2013-06-25 19:23:36 -07:00 (Migrated from github.com)

Yo, I'ma let you finish, but this is sickness.

On Tue, Jun 25, 2013 at 10:06 PM, Coveralls notifications@github.comwrote:

[image: Coverage Status] https://coveralls.io/builds/88127

Changes Unknown when pulling *173adee173adee4a6on html-for-tweet

  • into * on master*.


Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/pull/233#issuecomment-20023135
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

Yo, I'ma let you finish, but this is sickness. On Tue, Jun 25, 2013 at 10:06 PM, Coveralls notifications@github.comwrote: > [image: Coverage Status] https://coveralls.io/builds/88127 > > Changes Unknown when pulling *173adeehttps://github.com/ryanmcgrath/twython/commit/173adee4a68b3a01292a3878e7fc33fa9622ee32on html-for-tweet > - into *\* on master**. > > — > Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/pull/233#issuecomment-20023135 > . ## Skype: ryanmcgrathr Twitter: http://twitter.com/ryanmcgrath/ Web: http://venodesigns.net/ GitHub: http://github.com/ryanmcgrath/
michaelhelmick commented 2013-06-26 07:51:10 -07:00 (Migrated from github.com)

Not sure if you saw my mention in the PR but

@ryanmcgrath In the files changed, you'll see the function. I am returning specific classes class=twython-hashtag, etc.. in case they want to style it different or do something with javascript to it. Should I leave it like this or should I make use of the mention_html, hashtag_html and user_html as variables I have and let them pass their own string formatted custom html or is that to complicated? My vote is for the first and just add the twython custom classes to the anchor tags

Not sure if you saw my mention in the PR but > @ryanmcgrath In the files changed, you'll see the function. I am returning specific classes class=twython-hashtag, etc.. in case they want to style it different or do something with javascript to it. Should I leave it like this or should I make use of the mention_html, hashtag_html and user_html as variables I have and let them pass their own string formatted custom html or is that to complicated? My vote is for the first and just add the twython custom classes to the anchor tags
ryanmcgrath commented 2013-06-26 08:00:17 -07:00 (Migrated from github.com)

Do the first and let 'em regex or DOM Manip.

On Wednesday, June 26, 2013, Mike Helmick wrote:

Not sure if you saw my mention in the PR but

@ryanmcgrath https://github.com/ryanmcgrath In the files changed,
you'll see the function. I am returning specific classes
class=twython-hashtag, etc.. in case they want to style it different or do
something with javascript to it. Should I leave it like this or should I
make use of the mention_html, hashtag_html and user_html as variables I
have and let them pass their own string formatted custom html or is that to
complicated? My vote is for the first and just add the twython custom
classes to the anchor tags


Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/pull/233#issuecomment-20052765
.

Skype: ryanmcgrathr
Twitter: http://twitter.com/ryanmcgrath/
Web: http://venodesigns.net/
GitHub: http://github.com/ryanmcgrath/

Do the first and let 'em regex or DOM Manip. On Wednesday, June 26, 2013, Mike Helmick wrote: > Not sure if you saw my mention in the PR but > > @ryanmcgrath https://github.com/ryanmcgrath In the files changed, > you'll see the function. I am returning specific classes > class=twython-hashtag, etc.. in case they want to style it different or do > something with javascript to it. Should I leave it like this or should I > make use of the mention_html, hashtag_html and user_html as variables I > have and let them pass their own string formatted custom html or is that to > complicated? My vote is for the first and just add the twython custom > classes to the anchor tags > > — > Reply to this email directly or view it on GitHubhttps://github.com/ryanmcgrath/twython/pull/233#issuecomment-20052765 > . ## Skype: ryanmcgrathr Twitter: http://twitter.com/ryanmcgrath/ Web: http://venodesigns.net/ GitHub: http://github.com/ryanmcgrath/
trevoriancox commented 2013-06-26 08:48:35 -07:00 (Migrated from github.com)

Works for me! Great to see this coming together!

Works for me! Great to see this coming together!
coveralls commented 2013-06-27 16:23:16 -07:00 (Migrated from github.com)

Coverage Status

Changes Unknown when pulling 3c637ddc7d on html-for-tweet into * on master*.

[![Coverage Status](https://coveralls.io/builds/91444/badge)](https://coveralls.io/builds/91444) Changes Unknown when pulling **3c637ddc7d19cd47cc3432892cfe72b067de57c1 on html-for-tweet** into *\* on master**.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: code/twython#233
No description provided.