Git Product home page Git Product logo

tweet-to-html's People

Contributors

blessanm86 avatar coreation avatar dependabot[bot] avatar marlow-payne-hs avatar mehulkar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

tweet-to-html's Issues

Fails to convert url in tweet

Some times twitter truncates urls with elippsis. This makes the search/replace logic fail as the url in the entities will be an actual full url. May need to get rid of the complete search/replace approach and use the indices given by the api.

[{"created_at":"Sat Oct 31 16:20:13 +0000 2015","id":660491474795040800,"id_str":"660491474795040768","text":"RT @RonJeffries: At the time of the Agile Manifesto, we all did the best we knew. Here's something I wish we had done.\nhttps://t.co/iosgKEK…","source":"<a href="http://twitter.com/download/iphone" rel="nofollow">Twitter for iPhone","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":676363,"id_str":"676363","name":"xnoɹǝʃ uɐıɹq","screen_name":"brianleroux","location":"Vancouver || San Francisco","description":"Nitobi ➡ Adobe ✨ PhoneGap ➡ Cordova\n\n♥ JS. ⚛ Mostly mobile. ⚓ All web.","url":"http://t.co/6r02plqypy","entities":{"url":{"urls":[{"url":"http://t.co/6r02plqypy","expanded_url":"http://brian.io","display_url":"brian.io","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":14765,"friends_count":6360,"listed_count":1097,"created_at":"Sun Jan 21 19:54:27 +0000 2007","favourites_count":15184,"utc_offset":-25200,"time_zone":"Pacific Time (US & Canada)","geo_enabled":true,"verified":false,"statuses_count":45811,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"1A1B1F","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/3231316/bg_wood.jpg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/3231316/bg_wood.jpg","profile_background_tile":true,"profile_image_url":"http://pbs.twimg.com/profile_images/2268928025/qg507kknw872kmyqhet9_normal.jpeg","profile_image_url_https":"https://pbs.twimg.com/profile_images/2268928025/qg507kknw872kmyqhet9_normal.jpeg","profile_banner_url":"https://pbs.twimg.com/profile_banners/676363/1398222233","profile_link_color":"4A913C","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"252429","profile_text_color":"666666","profile_use_background_image":true,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"retweeted_status":{"created_at":"Sat Oct 31 16:11:37 +0000 2015","id":660489311998091300,"id_str":"660489311998091265","text":"At the time of the Agile Manifesto, we all did the best we knew. Here's something I wish we had done.\nhttps://t.co/iosgKEKVzM","source":"<a href="http://itunes.apple.com/us/app/twitter/id409789998?mt=12" rel="nofollow">Twitter for Mac","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":14979481,"id_str":"14979481","name":"Ron Jeffries","screen_name":"RonJeffries","location":"Pinckney, MI","description":"I'm sure you can figure out who I am if you really want to.","url":"http://t.co/NA4canheR0","entities":{"url":{"urls":[{"url":"http://t.co/NA4canheR0","expanded_url":"http://www.RonJeffries.com","display_url":"RonJeffries.com","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":18496,"friends_count":515,"listed_count":1311,"created_at":"Mon Jun 02 11:31:09 +0000 2008","favourites_count":35,"utc_offset":-14400,"time_zone":"Eastern Time (US & Canada)","geo_enabled":false,"verified":false,"statuses_count":44899,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"EDECE9","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/14209532/PICT0001a.jpg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/14209532/PICT0001a.jpg","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/479052206260244480/WQA0NXQT_normal.jpeg","profile_image_url_https":"https://pbs.twimg.com/profile_images/479052206260244480/WQA0NXQT_normal.jpeg","profile_banner_url":"https://pbs.twimg.com/profile_banners/14979481/1403049024","profile_link_color":"088253","profile_sidebar_border_color":"D3D2CF","profile_sidebar_fill_color":"E3E2DE","profile_text_color":"634047","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":7,"favorite_count":3,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[{"url":"https://t.co/iosgKEKVzM","expanded_url":"http://ronjeffries.com/articles/015-10/wish-prac/","display_url":"ronjeffries.com/articles/015-1…","indices":[102,125]}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"},"is_quote_status":false,"retweet_count":7,"favorite_count":0,"entities":{"hashtags":[],"symbols":[],"user_mentions":[{"screen_name":"RonJeffries","name":"Ron Jeffries","id":14979481,"id_str":"14979481","indices":[3,15]}],"urls":[{"url":"https://t.co/iosgKEKVzM","expanded_url":"http://ronjeffries.com/articles/015-10/wish-prac/","display_url":"ronjeffries.com/articles/015-1…","indices":[119,140]}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"}]

https://twitter.com/RonJeffries/status/660489311998091265

Not detecting mentions with mixed cases

Certain mentions are not getting replaced. This because the mentions screen_name are converted to lowercase before doing a replace. For username mentions that mix cases, the replace will fail. Fixed it locally using a regex. Needs a test before pushing to remote.

var regex = new RegExp('@' + userObj.screen_name, 'gi' );

JSON
{
"created_at": "Tue Oct 27 09:42:06 +0000 2015",
"id": 658941734139875300,
"id_str": "658941734139875329",
"text": ".@realDonaldJS There are Haskell fundamentalists who uh have training camps and uh, what I mean is, when can we get rid of them?",
"source": "<a href="http://www.twitter.com\" rel="nofollow">Twitter for Windows Phone",
"truncated": false,
"in_reply_to_status_id": 655468867779739600,
"in_reply_to_status_id_str": "655468867779739648",
"in_reply_to_user_id": 3981786520,
"in_reply_to_user_id_str": "3981786520",
"in_reply_to_screen_name": "realDonaldJS",
"user": {
"id": 160514302,
"id_str": "160514302",
"name": "Richard Dalton",
"screen_name": "richardadalton",
"location": "Kildare, Ireland",
"description": "I write code, as a last resort. I make it simple, when I can. Please visit: http://t.co/GtWXf7dbfa",
"url": "http://t.co/mArwXmywZl",
"entities": {
"url": {
"urls": [
{
"url": "http://t.co/mArwXmywZl",
"expanded_url": "http://www.devjoy.com",
"display_url": "devjoy.com",
"indices": [
0,
22
]
}
]
},
"description": {
"urls": [
{
"url": "http://t.co/GtWXf7dbfa",
"expanded_url": "http://freepaconow.com",
"display_url": "freepaconow.com",
"indices": [
76,
98
]
}
]
}
},
"protected": false,
"followers_count": 1069,
"friends_count": 504,
"listed_count": 97,
"created_at": "Mon Jun 28 11:27:14 +0000 2010",
"favourites_count": 231,
"utc_offset": null,
"time_zone": null,
"geo_enabled": true,
"verified": false,
"statuses_count": 28390,
"lang": "en",
"contributors_enabled": false,
"is_translator": false,
"is_translation_enabled": false,
"profile_background_color": "C0DEED",
"profile_background_image_url": "http://pbs.twimg.com/profile_background_images/687927535/b2ebf72ba8fc96d4e126d2810c37467a.jpeg",
"profile_background_image_url_https": "https://pbs.twimg.com/profile_background_images/687927535/b2ebf72ba8fc96d4e126d2810c37467a.jpeg",
"profile_background_tile": false,
"profile_image_url": "http://pbs.twimg.com/profile_images/629300041455435776/dCbJf6WT_normal.jpg",
"profile_image_url_https": "https://pbs.twimg.com/profile_images/629300041455435776/dCbJf6WT_normal.jpg",
"profile_banner_url": "https://pbs.twimg.com/profile_banners/160514302/1357347025",
"profile_link_color": "0084B4",
"profile_sidebar_border_color": "FFFFFF",
"profile_sidebar_fill_color": "DDEEF6",
"profile_text_color": "333333",
"profile_use_background_image": true,
"has_extended_profile": false,
"default_profile": false,
"default_profile_image": false,
"following": true,
"follow_request_sent": false,
"notifications": false
},
"geo": null,
"coordinates": null,
"place": null,
"contributors": null,
"is_quote_status": false,
"retweet_count": 0,
"favorite_count": 0,
"entities": {
"hashtags": [],
"symbols": [],
"user_mentions": [
{
"screen_name": "realDonaldJS",
"name": "Trump on JavaScript",
"id": 3981786520,
"id_str": "3981786520",
"indices": [
1,
14
]
}
],
"urls": []
},
"favorited": false,
"retweeted": false,
"lang": "en"
}

Build script

Is there a build process for this package before publishing?

I see browserify in the package script:

"build": "browserify demo/js/demo.js -o demo/js/browserify-build.js"

and a reference to parcel in the gitignore:

.parcel-cache

but neither are dependencies, so I'm not sure if it's being used.

Would you be interested in setting something up? (esbuild/swc/etc). Couple motivations:

  • Transpiling purposes, so we can use const/let and continue to have support for older environments if you want that (although if that's not important, maybe we don't need to transpile anything)
  • For #17, I was thinking it might be worthwhile to add another module that makes requests to the API as well (using twitter-api-sdk. In that case, transpiling may be more important if we want to use fetch, async/await, etc
  • Browser vs node usage. I am using this in Vercel's serverless functions, so I only care about Node, but if you want this to run in a browser also, there may be more use cases for transpiling, as well as minification.

v2 API support

This package doesnt support the v2 api. Couple of things changed like how quoted tweets are represented in the structure. Now the response seems to be nested in a data property while referenced tweets don't have that.

The challenge is finding some different example tweets, check how their response structure is and modify the function to handle those.

Ability to customize rendered output

Figure out a way for users to customize the output such as adding classes or attributes to the rendered markup.
Eg. Specify preload attribute for video tag.

2 solutions I can think of.
- have an options object.
- Use a template system and expose the entity values as variables.

Handle quoted tweets

Handle quoted tweets if found. Sample data below.

https://twitter.com/sindresorhus/status/664112304540155905

{"created_at":"Tue Nov 10 16:08:06 +0000 2015","id":664112304540155905,"id_str":"664112304540155905","text":"For once I was right. https://t.co/CQAqQClGKN","source":"\u003ca href="http://twitter.com" rel="nofollow"\u003eTwitter Web Client\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":170686450,"id_str":"170686450","name":"Sindre Sorhus","screen_name":"sindresorhus","location":"\u2708","description":"Aspiring rebel. \u2665\ufe0f Node.js .\u2022\u25cb\u00b0\u2605\u263e Creator of AVA, TodoMVC, @yeoman. Blog: https://t.co/v33jOTfXIi","url":"https://t.co/Po2lqJEFOu","entities":{"url":{"urls":[{"url":"https://t.co/Po2lqJEFOu","expanded_url":"https://sindresorhus.com","display_url":"sindresorhus.com","indices":[0,23]}]},"description":{"urls":[{"url":"https://t.co/v33jOTfXIi","expanded_url":"https://blog.sindresorhus.com","display_url":"blog.sindresorhus.com","indices":[74,97]}]}},"protected":false,"followers_count":19476,"friends_count":164,"listed_count":714,"created_at":"Sun Jul 25 13:48:23 +0000 2010","favourites_count":8237,"utc_offset":3600,"time_zone":"Stockholm","geo_enabled":true,"verified":false,"statuses_count":9174,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FAFAFA","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/170686450/1439144356","profile_link_color":"27276A","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"quoted_status_id":69389011847884800,"quoted_status_id_str":"69389011847884800","quoted_status":{"created_at":"Sat May 14 13:10:04 +0000 2011","id":69389011847884800,"id_str":"69389011847884800","text":"#nodejs and #python is soo awesome, I'm never touching #PHP again.","source":"\u003ca href="http://twitter.com/#!/download/ipad" rel="nofollow"\u003eTwitter for iPad\u003c/a\u003e","truncated":false,"in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":170686450,"id_str":"170686450","name":"Sindre Sorhus","screen_name":"sindresorhus","location":"\u2708","description":"Aspiring rebel. \u2665\ufe0f Node.js .\u2022\u25cb\u00b0\u2605\u263e Creator of AVA, TodoMVC, @yeoman. Blog: https://t.co/v33jOTfXIi","url":"https://t.co/Po2lqJEFOu","entities":{"url":{"urls":[{"url":"https://t.co/Po2lqJEFOu","expanded_url":"https://sindresorhus.com","display_url":"sindresorhus.com","indices":[0,23]}]},"description":{"urls":[{"url":"https://t.co/v33jOTfXIi","expanded_url":"https://blog.sindresorhus.com","display_url":"blog.sindresorhus.com","indices":[74,97]}]}},"protected":false,"followers_count":19476,"friends_count":164,"listed_count":714,"created_at":"Sun Jul 25 13:48:23 +0000 2010","favourites_count":8237,"utc_offset":3600,"time_zone":"Stockholm","geo_enabled":true,"verified":false,"statuses_count":9174,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"FAFAFA","profile_background_image_url":"http://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_image_url_https":"https://pbs.twimg.com/profile_background_images/378800000162762149/nc8yEsGJ.jpeg","profile_background_tile":false,"profile_image_url":"http://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_image_url_https":"https://pbs.twimg.com/profile_images/630442696608354304/v_NKeZ5W_normal.png","profile_banner_url":"https://pbs.twimg.com/profile_banners/170686450/1439144356","profile_link_color":"27276A","profile_sidebar_border_color":"FFFFFF","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":false,"has_extended_profile":false,"default_profile":false,"default_profile_image":false,"following":true,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":2,"favorite_count":13,"entities":{"hashtags":[{"text":"nodejs","indices":[0,7]},{"text":"python","indices":[12,19]},{"text":"PHP","indices":[55,59]}],"symbols":[],"user_mentions":[],"urls":[]},"favorited":false,"retweeted":false,"lang":"en"},"is_quote_status":true,"retweet_count":2,"favorite_count":18,"entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[{"url":"https://t.co/CQAqQClGKN","expanded_url":"https://twitter.com/sindresorhus/status/69389011847884800","display_url":"twitter.com/sindresorhus/s\u2026","indices":[22,45]}]},"favorited":false,"retweeted":false,"possibly_sensitive":false,"possibly_sensitive_appealable":false,"lang":"en"}

Async suuport

Add support for async and maybe look into some kind of way to parse array items in parallel.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.