|
1 | | -oEmbed Spec |
2 | | -=========== |
| 1 | +<h1 align="center"> |
| 2 | + <a href="https://github.com/iamcal/oembed"> |
| 3 | + <img src="docs/images/logo.svg" alt="Logo" width="100" height="100"> |
| 4 | + </a> |
| 5 | +</h1> |
| 6 | + |
| 7 | +<div align="center"> |
| 8 | + <br /> |
| 9 | + <a href="#about"><strong>Explore the docs »</strong></a> |
| 10 | + <br /> |
| 11 | + <br /> |
| 12 | + <a href="https://github.com/iamcal/oembed/issues/new?assignees=&labels=bug&template=01_BUG_REPORT.md&title=bug%3A+">Report a Bug</a> |
| 13 | + · |
| 14 | + <a href="https://github.com/iamcal/oembed/issues/new?assignees=&labels=enhancement&template=02_FEATURE_REQUEST.md&title=feat%3A+">Request a Feature</a> |
| 15 | + . |
| 16 | + <a href="https://github.com/iamcal/oembed/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+">Ask a Question</a> |
| 17 | +</div> |
| 18 | + |
| 19 | +<div align="center"> |
| 20 | +<br /> |
| 21 | + |
| 22 | +[](LICENSE) |
3 | 23 |
|
4 | 24 | [](https://github.com/iamcal/oembed/actions) |
5 | 25 | <span class="badge-npmversion"><a href="https://npmjs.org/package/oembed-providers" title="View this project on NPM"><img src="https://img.shields.io/npm/v/oembed-providers.svg" alt="NPM version" /></a></span> |
6 | 26 |
|
7 | | -This repo represents the current oEmbed spec as seen at |
8 | | -<a href="http://oembed.com">http://oembed.com</a> and any drafts, in the `www` directory. |
| 27 | +</div> |
| 28 | + |
| 29 | +<details> |
| 30 | +<summary>Table of Contents</summary> |
| 31 | + |
| 32 | +- [About](#about) |
| 33 | + - [What is oEmbed?](#what-is-oembed) |
| 34 | + - [Repository Overview](#repository-overview) |
| 35 | + - [Project Structure](#project-structure) |
| 36 | +- [Getting Started](#getting-started) |
| 37 | + - [Prerequisites](#prerequisites) |
| 38 | + - [Installation](#installation) |
| 39 | + - [Development Setup](#development-setup) |
| 40 | +- [Usage](#usage) |
| 41 | + - [Consuming the Provider Registry](#consuming-the-provider-registry) |
| 42 | + - [Provider Configuration](#provider-configuration) |
| 43 | + - [Code Examples](#code-examples) |
| 44 | +- [Provider Management](#provider-management) |
| 45 | + - [Available Providers](#available-providers) |
| 46 | + - [Adding a New Provider](#adding-a-new-provider) |
| 47 | + - [Provider Configuration Format](#provider-configuration-format) |
| 48 | +- [Troubleshooting](#troubleshooting) |
| 49 | +- [Contributing](#contributing) |
| 50 | +- [Support](#support) |
| 51 | +- [License](#license) |
| 52 | + |
| 53 | +</details> |
| 54 | + |
| 55 | +--- |
| 56 | + |
| 57 | +## About |
| 58 | + |
| 59 | +### What is oEmbed? |
| 60 | + |
| 61 | +oEmbed is a format for allowing an embedded representation of a URL on third party sites. The simple API allows a website to display embedded content (such as photos or videos) when a user posts a link to that resource, without having to parse the resource directly. |
| 62 | + |
| 63 | +Key features: |
| 64 | +- Simple HTTP-based protocol |
| 65 | +- Support for photos, videos, links, and rich content |
| 66 | +- Standardized response format |
| 67 | +- Wide adoption by major content providers |
| 68 | + |
| 69 | +### Repository Overview |
| 70 | + |
| 71 | +This repository serves two main purposes: |
| 72 | + |
| 73 | +1. **oEmbed Specification**: Contains the current oEmbed spec as seen at [oembed.com](http://oembed.com) and any drafts in the `www` directory. |
| 74 | +2. **Provider Registry**: Maintains configuration information for oEmbed providers as YAML files in the `providers` directory. |
| 75 | + |
| 76 | +## Getting Started |
| 77 | + |
| 78 | +### Prerequisites |
| 79 | + |
| 80 | +To work with this repository, you'll need: |
| 81 | + |
| 82 | +- **Web Server**: Nginx or Apache |
| 83 | +- **PHP**: For running the specification website |
| 84 | +- **Node.js**: Version 22 or higher |
| 85 | +- **npm**: For package management |
| 86 | + |
| 87 | +### Installation |
| 88 | + |
| 89 | +1. Clone the repository: |
| 90 | + ```bash |
| 91 | + git clone https://github.com/iamcal/oembed.git |
| 92 | + cd oembed |
| 93 | + ``` |
| 94 | + |
| 95 | +2. Install dependencies: |
| 96 | + ```bash |
| 97 | + npm install |
| 98 | + ``` |
| 99 | + |
| 100 | +### Development Setup |
| 101 | + |
| 102 | +1. Configure your development environment: |
| 103 | + ```bash |
| 104 | + # Install development dependencies |
| 105 | + npm install --dev |
| 106 | + |
| 107 | + # Set up pre-commit hooks |
| 108 | + npm run prepare |
| 109 | + ``` |
| 110 | + |
| 111 | +2. Run tests: |
| 112 | + ```bash |
| 113 | + npm test |
| 114 | + ``` |
| 115 | + |
| 116 | +## Usage |
| 117 | + |
| 118 | +### Consuming the Provider Registry |
| 119 | + |
| 120 | +Install the package via npm: |
| 121 | + |
| 122 | +```bash |
| 123 | +npm install oembed-providers |
| 124 | +``` |
| 125 | + |
| 126 | +The provider registry will be available at: |
| 127 | +``` |
| 128 | +node_modules/oembed-providers/providers.json |
| 129 | +``` |
| 130 | + |
| 131 | +### Provider Configuration |
| 132 | + |
| 133 | +Each provider is configured using a YAML file in the `providers` directory. The configuration specifies: |
| 134 | + |
| 135 | +- Provider name and URL |
| 136 | +- Endpoint information |
| 137 | +- Supported URL schemes |
| 138 | +- Discovery settings |
| 139 | +- Documentation links |
| 140 | + |
| 141 | +### Code Examples |
| 142 | + |
| 143 | +**Basic oEmbed Request:** |
| 144 | +```javascript |
| 145 | +// Example: Fetching oEmbed data from Flickr |
| 146 | +const url = 'http://www.flickr.com/services/oembed/'; |
| 147 | +const params = new URLSearchParams({ |
| 148 | + format: 'json', |
| 149 | + url: 'http://www.flickr.com/photos/bees/2341623661/' |
| 150 | +}); |
| 151 | + |
| 152 | +fetch(`${url}?${params}`) |
| 153 | + .then(response => response.json()) |
| 154 | + .then(data => console.log(data)); |
| 155 | +``` |
| 156 | + |
| 157 | +**Example Response:** |
| 158 | +```json |
| 159 | +{ |
| 160 | + "version": "1.0", |
| 161 | + "type": "photo", |
| 162 | + "width": 240, |
| 163 | + "height": 160, |
| 164 | + "title": "ZB8T0193", |
| 165 | + "url": "http://farm4.static.flickr.com/3123/2341623661_7c99f48bbf_m.jpg", |
| 166 | + "author_name": "Bees", |
| 167 | + "author_url": "http://www.flickr.com/photos/bees/", |
| 168 | + "provider_name": "Flickr", |
| 169 | + "provider_url": "http://www.flickr.com/" |
| 170 | +} |
| 171 | +``` |
| 172 | + |
| 173 | +## Provider Management |
| 174 | + |
| 175 | +### Available Providers |
| 176 | + |
| 177 | +The registry includes providers such as: |
| 178 | +- YouTube |
| 179 | +- Vimeo |
| 180 | +- Twitter |
| 181 | +- Instagram |
| 182 | +- Flickr |
| 183 | +- And many more... |
| 184 | + |
| 185 | +For a complete list, browse the `providers` directory. |
| 186 | + |
| 187 | +### Adding a New Provider |
| 188 | + |
| 189 | +1. Create a new YAML file in the `providers` directory |
| 190 | +2. Follow the provider configuration format |
| 191 | +3. Submit a pull request |
9 | 192 |
|
10 | | -It also contains configuration information (the registry) for oEmbed providers, as YAML files in the `providers` directory. |
| 193 | +### Provider Configuration Format |
11 | 194 |
|
| 195 | +```yaml |
| 196 | +--- |
| 197 | +- provider_name: Example Provider |
| 198 | + provider_url: https://example.com |
| 199 | + endpoints: |
| 200 | + - schemes: |
| 201 | + - https://example.com/watch/* |
| 202 | + - https://example.com/v/* |
| 203 | + url: https://example.com/oembed |
| 204 | + docs_url: https://example.com/docs/oembed |
| 205 | + example_urls: |
| 206 | + - https://example.com/oembed?url=https://example.com/watch/123 |
| 207 | + discovery: true |
| 208 | +``` |
12 | 209 |
|
13 | | -## Consuming the provider registry |
| 210 | +## Contributing |
14 | 211 |
|
15 | | -If you need to use the provider registry directly, you can install this package using NPM: |
| 212 | +We welcome contributions! Please read our [Contributing Guidelines](docs/CONTRIBUTING.md) before submitting pull requests. |
16 | 213 |
|
17 | | - npm install https://github.com/iamcal/oembed |
| 214 | +Key areas for contribution: |
| 215 | +- Adding new providers |
| 216 | +- Updating existing provider configurations |
| 217 | +- Improving documentation |
| 218 | +- Fixing bugs |
| 219 | +- Adding tests |
18 | 220 |
|
19 | | -That will install the providers file into `node_modules/oembed-providers/providers.json`, where you can ingest it directly. |
| 221 | +## Support |
20 | 222 |
|
| 223 | +Need help? Here's how to get support: |
21 | 224 |
|
22 | | -## Maintainers: Publishing to NPM |
| 225 | +- [GitHub Issues](https://github.com/iamcal/oembed/issues/new?assignees=&labels=question&template=04_SUPPORT_QUESTION.md&title=support%3A+) |
| 226 | +- [Contact the maintainer](https://github.com/iamcal) |
| 227 | +- Visit [iamcal.com](https://www.iamcal.com/) |
23 | 228 |
|
24 | | -* Update version in `package.json` to today's date |
25 | | -* `npm login` if you haven't already |
26 | | -* `npm publish` |
27 | | -* Check https://www.npmjs.com/package/oembed-providers |
| 229 | +## License |
28 | 230 |
|
| 231 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments