https://github.com/zestia/ember-twitter-entities
:bird: Renders entities from Twitter's API as Ember components
https://github.com/zestia/ember-twitter-entities
ember tweets twitter
Last synced: 10 months ago
JSON representation
:bird: Renders entities from Twitter's API as Ember components
- Host: GitHub
- URL: https://github.com/zestia/ember-twitter-entities
- Owner: zestia
- License: mit
- Created: 2015-04-04T15:19:10.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2025-07-08T08:49:52.000Z (11 months ago)
- Last Synced: 2025-07-08T09:49:55.915Z (11 months ago)
- Topics: ember, tweets, twitter
- Language: JavaScript
- Homepage:
- Size: 5.41 MB
- Stars: 6
- Watchers: 15
- Forks: 1
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
README
# @zestia/ember-twitter-entities
[npm-badge]: https://img.shields.io/npm/v/@zestia/ember-twitter-entities.svg
[npm-badge-url]: https://www.npmjs.com/package/@zestia/ember-twitter-entities
[github-actions-badge]: https://github.com/zestia/ember-twitter-entities/workflows/CI/badge.svg
[github-actions-url]: https://github.com/zestia/ember-twitter-entities/actions
[ember-observer-badge]: https://emberobserver.com/badges/-zestia-ember-twitter-entities.svg
[ember-observer-url]: https://emberobserver.com/addons/@zestia/ember-twitter-entities
This Ember CLI addon parses [Twitter Entities](https://dev.twitter.com/overview/api/entities-in-twitter-objects) from the Twitter API and renders a them as Ember Components.
## Important
⚠️ This repo is no longer actively maintained
## Installation
```
ember install @zestia/ember-twitter-entities
```
Add the following to `~/.npmrc` to pull @zestia scoped packages from Github instead of NPM.
```
@zestia:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=
```
## Demo
https://zestia.github.io/ember-twitter-entities
## Notes
- Supported entity types are: `hashtags`, `media`, `urls`, `user_mentions`, `symbols`. Basically any entity which has an `indices` property and occurs in the tweet text. So this excludes `polls`.
## Example
Given the following:
```javascript
entities: {
urls: [{
url: 'https://t.co/emberjs',
display_url: 'emberjs.com',
indices: [6, 17]
}],
hashtags: [],
user_mentions: [],
media: [],
symbols: []
}
```
```handlebars
```
The addon will render:
```html
visit emberjs.com
```
...using the built in components for each entity type.
## `TwitterEntities`
### Arguments
#### `@text`
Required. The text to parse to find entities within.
#### `@entities`
Required. An object of entities that includes information about where each entity appears within the `@text`.
#### `@Url`
Optional. The component that will be used to display a URL entity.
#### `@Hashtag`
Optional. The component that will be used to display a hashtag entity.
#### `@UserMention`
Optional. The component that will be used to display a user mention entity.
#### `@Media`
Optional. The component that will be used to display a media entity.
#### `@Symbol`
Optional. The component that will be used to display a symbol entity.
### API
#### `entity`
Each component receives the entity so it can be displayed however you wish.
## HTML in tweets
If the tweet you are rendering is already encoded, flag it as html-safe to prevent double encoding.
Example
```javascript
const tweet = 'This tweet contains <br> HTML';
this.text = htmlSafe(tweet);
```
```handlebars
```
```
Outputs: This tweet contains
HTML
Instead of: This tweet contains <br> HTML
```