From 6263079573a5073f8c92101fefac5c982d2f3415 Mon Sep 17 00:00:00 2001 From: Platinum Date: Sun, 11 Feb 2024 00:34:57 +0100 Subject: [PATCH] documentation --- README.md | 16 +++++++-------- TODO.md | 10 +++++++++ config/link-preview.php | 3 ++- docs/configuration.md | 30 +++++++++++++++++++++++++++ docs/use-cases.md | 45 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 95 insertions(+), 9 deletions(-) create mode 100644 TODO.md create mode 100644 docs/configuration.md create mode 100644 docs/use-cases.md diff --git a/README.md b/README.md index 3450b21..0bb8a94 100644 --- a/README.md +++ b/README.md @@ -14,20 +14,20 @@ To install Laravel Link Preview, run the following command in your terminal: composer require teners/laravel-link-preview ``` - +php artisan vendor:publish --provider="Teners\LaravelLinkPreview\LaravelLinkPreviewServiceProvider" --tag="link-preview-config" +``` + +## Contents +1. [Use Cases](docs/use-cases.md) +2. [Configuration Options](docs/configuration.md) ## Contributions Contributions are **welcome** via Pull Requests on [Github](https://github.com/Teners-net/laravel-link-preview). - Please document any change you made as neccesary in the [README.md](README.md). - Pleas make only one pull request per feature/fix. -- See below for some ideas on what you can help with. - - Add Other Parsers: - - Youtube - - Vimeo - - Add JSReader with Puppeteer +- See below for some ideas on what you can help with here: [Todos](TODO.md) ## Issues Please report any issue you encounter in using the package through the [Github Issues](https://github.com/Teners-net/laravel-link-preview/issues) tab. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..071a0af --- /dev/null +++ b/TODO.md @@ -0,0 +1,10 @@ +# TODO: + +See below for some ideas on what you can help with. + +- Add Other Parsers to extrack videos: + - Youtube + - Vimeo +- Add JSReader with Puppeteer +- Check for image sizes and set a minimum for quality +- Fix: x/twitter links fails with 400: Bad Request (browser incompatible) \ No newline at end of file diff --git a/config/link-preview.php b/config/link-preview.php index 20deac1..e1b5f17 100644 --- a/config/link-preview.php +++ b/config/link-preview.php @@ -24,7 +24,7 @@ * COMING SOON: * 'global': a redix server maintained cache with CDN */ - 'cache_type' => env('LINK_PREVIEW_CACHE_TYPE', 'app'), + 'cache_type' => env('LINK_PREVIEW_CACHE_TYPE', 'model'), /** * Enable or disable specific parsers for link preview generation. @@ -34,6 +34,7 @@ * * COMING_SOON */ + /** @todo */ 'enabled_parsers' => [ // 'youtube' => env('LINK_PREVIEW_PARSER_YOUTUBE', false), // 'vimeo' => env('LINK_PREVIEW_PARSER_VIMEO', false), diff --git a/docs/configuration.md b/docs/configuration.md new file mode 100644 index 0000000..72bfc85 --- /dev/null +++ b/docs/configuration.md @@ -0,0 +1,30 @@ +# Configuration Options + +The `link-preview.php` configuration file in your Laravel application's `config` directory contains various options that you can customize to tailor the behavior of the Laravel Link Preview package to your needs. + +## `enable_caching` + +- **Description**: Enable or disable caching of link previews. +- **Type**: Boolean +- **Default**: `true` + +## `cache_duration` + +- **Description**: Set the duration in seconds for which link previews should be cached. +- **Type**: Integer +- **Default**: `604800` (1 week) + +## `cache_type` + +- **Description**: Choose the type of cache type to use for storing link previews. +- **Type**: String +- **options**: `'model'`, `'app'` +- **Default**: `'model'` + + +### How to Customize Configuration + +To customize these options, you can modify the `link-preview.php` file located in the `config` directory of your Laravel application. After making changes, be sure to clear the config cache: + +```bash +php artisan config:cache diff --git a/docs/use-cases.md b/docs/use-cases.md new file mode 100644 index 0000000..ce2f737 --- /dev/null +++ b/docs/use-cases.md @@ -0,0 +1,45 @@ +# Laravel Link Preview Use Cases + +The Laravel Link Preview package provides a powerful solution for extracting link previews within Laravel applications. Below are some common use cases where this package can be valuable: + +## 1. Displaying Link Previews in Content Management Systems (CMS) + +### Scenario: +You have a content management system where users can input and manage content that includes external links. Enhance the user experience by automatically generating and displaying link previews for these URLs. + +### Implementation: +Integrate the Laravel Link Preview package to parse external links within your CMS and dynamically fetch and display link previews alongside the content. + +## 2. Social Media Sharing + +### Scenario: +You are building a social media platform or application where users share links. Provide a visually appealing presentation of shared links by generating link previews for URLs shared within posts or comments. + +### Implementation: +Use the Laravel Link Preview package to extract link previews when users share URLs on your social media platform, making the shared content more engaging. + +## 3. Customized Link Preview Widgets + +### Scenario: +You want to create a customized link preview widget or component that you can reuse across different parts of your Laravel application. + +### Implementation: +Leverage the Laravel Link Preview package to easily fetch and display link previews within your custom widgets or components, ensuring a consistent and aesthetically pleasing design. + +## 4. Generating Rich Media Previews in Messaging Apps + +### Scenario: +You are developing a messaging application where users can send links to each other. Enhance the messaging experience by automatically generating and displaying rich link previews for shared URLs. + +### Implementation: +Integrate the Laravel Link Preview package to parse links within messages and generate visually appealing link previews, providing users with more context about the shared content. + +## 5. Content Aggregation Platforms + +### Scenario: +You are building a content aggregation platform that collects and displays content from various sources. Provide users with a preview of external content by generating link previews for aggregated links. + +### Implementation: +Incorporate the Laravel Link Preview package into your content aggregation platform to enhance the presentation of external content, making it more attractive and informative. + +Feel free to explore these use cases and adapt the Laravel Link Preview package to suit your specific application requirements.