Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for embedded images. #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $('.tweet').twittie({

## Templating

For now only two templating variables are available, more coming soon. You add as much as HTML elementes as you would like.
You can add as many HTML elements as you like.

Template | Description
--- | ---
Expand All @@ -92,6 +92,7 @@ Template | Description
`{{retweeted}}` | Returns `true` or `false` if tweet is retweeted
`{{screen_name}}` | Screen name of person who posted the tweet
`{{user_name}}` | Username of person who posted the tweet
`{{image}}` | Embedded image within the post

## Date Format
Format | Description
Expand Down
14 changes: 10 additions & 4 deletions tweetie.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,15 @@
*/
var templating = function (data) {
var temp = settings.template;
var temp_variables = ['date', 'tweet', 'avatar', 'url', 'retweeted', 'screen_name', 'user_name'];
var temp_variables = ['date', 'tweet', 'avatar', 'url', 'retweeted', 'screen_name', 'user_name', 'image'];

for (var i = 0, len = temp_variables.length; i < len; i++) {
temp = temp.replace(new RegExp('{{' + temp_variables[i] + '}}', 'gi'), data[temp_variables[i]]);
if(data[temp_variables[i]]){
temp = temp.replace(new RegExp('{{' + temp_variables[i] + '}}', 'gi'), data[temp_variables[i]]);
} else {
temp = temp.replace(new RegExp('{{' + temp_variables[i] + '}}', 'gi'), '');
}

}

return temp;
Expand Down Expand Up @@ -115,9 +120,10 @@
avatar: '<img src="'+ tweet.user.profile_image_url +'" />',
url: 'http://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id_str,
retweeted: tweet.retweeted,
screen_name: linking('@'+ tweet.user.screen_name)
screen_name: linking('@'+ tweet.user.screen_name),
image: (tweet.entities.media) ? "<img src='" + tweet.entities.media[0].media_url + "' />" : false
};

that.find('ul').append('<li>' + templating(temp_data) + '</li>');
}

Expand Down
6 changes: 1 addition & 5 deletions tweetie.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.