-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6ecb0c6
Showing
12 changed files
with
277 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
github: phpsa |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Semantic Release | ||
|
||
on: [workflow_dispatch] | ||
|
||
jobs: | ||
release: | ||
name: release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Semantic Release | ||
uses: cycjimmy/semantic-release-action@v3 | ||
id: semantic | ||
with: | ||
branches: | | ||
[ | ||
'+([0-9])?(.{+([0-9]),x}).x', | ||
'master', | ||
'main', | ||
'next', | ||
'next-major', | ||
{ | ||
name: 'beta', | ||
prerelease: true | ||
}, | ||
{ | ||
name: 'alpha', | ||
prerelease: true | ||
} | ||
] | ||
extra_plugins: | | ||
@semantic-release/commit-analyzer | ||
@semantic-release/git | ||
@semantic-release/changelog | ||
@semantic-release/exec | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
SEMANTIC_RELEASE_PACKAGE: Filament Feed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
plugins: | ||
- "@semantic-release/commit-analyzer" | ||
- "@semantic-release/release-notes-generator" | ||
- - "@semantic-release/exec" | ||
- verifyReleaseCmd: "echo ${nextRelease.version} > VERSION.txt" | ||
- - "@semantic-release/changelog" | ||
- changelogFile: CHANGELOG.md | ||
- - "@semantic-release/github" | ||
- - "@semantic-release/git" | ||
- assets: | ||
- CHANGELOG.md | ||
message: "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}" | ||
branches: | ||
- "master" | ||
- "main" | ||
- "next" | ||
- "next-major" | ||
- "+([0-9])?(.{+([0-9]),x}).x" | ||
- name: "beta" | ||
prerelease: true | ||
- name: "alpha" | ||
prerelease: true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2022 phspa | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[![Latest Version on Packagist](https://img.shields.io/packagist/v/phpsa/filament-feed.svg?style=flat-square)](https://packagist.org/packages/phpsa/filament-feed) | ||
[![Semantic Release](https://github.com/phpsa/filament-feed/actions/workflows/release.yml/badge.svg)](https://github.com/phpsa/filament-feed/actions/workflows/release.yml) | ||
[![Total Downloads](https://img.shields.io/packagist/dt/phpsa/filament-feed.svg?style=flat-square)](https://packagist.org/packages/phpsa/filament-feed) | ||
|
||
# Filament Feed Widget | ||
|
||
With DadJokes every time you load your control panel you'll be greeted by an epic dad joke on the dashboard. | ||
|
||
## Installation | ||
|
||
|
||
You can install the package via composer: | ||
|
||
```bash | ||
composer require phpsa/filament-feed | ||
``` | ||
|
||
## Changelog | ||
|
||
Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. | ||
|
||
## Credits | ||
|
||
- [Phpsa](https://github.com/phpsa) | ||
|
||
## License | ||
|
||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{ | ||
"name": "phpsa/filament-feed", | ||
"description": "Display news on your Dashboard.", | ||
"keywords": [ | ||
"laravel", | ||
"user", | ||
"cli", | ||
"resource", | ||
"ui", | ||
"filament", | ||
"widget", | ||
"fun" | ||
], | ||
"homepage": "https://cgs4k.nz", | ||
"license": "MIT", | ||
"autoload": { | ||
"psr-4": { | ||
"Phpsa\\FilamentFeed\\": "src/" | ||
} | ||
}, | ||
"authors": [ | ||
{ | ||
"name": "Craig G Smith", | ||
"email": "vxdhost@gmail.com" | ||
} | ||
], | ||
"minimum-stability": "dev", | ||
"require": { | ||
"php": "^8.0", | ||
"filament/filament": "^2.9", | ||
"spatie/laravel-package-tools": "^1.10", | ||
"simplepie/simplepie": "^1.5" | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"Phpsa\\FilamentFeed\\FilamentFeedProvider" | ||
] | ||
} | ||
}, | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
return [ | ||
'feeds' => [ | ||
'Laravel News' => [ | ||
'url' => 'https://feed.laravel-news.com/', | ||
'limit' => 5, | ||
'refresh' => 300, | ||
], | ||
'Filament Releases' => [ | ||
'url' => 'https://github.com/laravel-filament/filament/releases.atom' | ||
] | ||
], | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
@foreach ($feeds as $feed => $data) | ||
|
||
<x-filament::widget> | ||
<x-filament::card> | ||
<h2 class="text-lg sm:text-xl font-bold tracking-tight mb-10 text-center justify-center items-center"> | ||
|
||
<a | ||
href="{{$data['permalink']}}" | ||
target="_new" | ||
@class([ | ||
'text-center flex items-end space-x-2 rtl:space-x-reverse text-gray-800 hover:text-primary-500 transition', | ||
'dark:text-primary-500 dark:hover:text-primary-400' => config('filament.dark_mode'), | ||
]) | ||
>{{$feed}}</a> | ||
</h2> | ||
|
||
<div class="overflow-y-auto relative dark:border-gray-700 border-t" x-bind:class="{ | ||
'rounded-t-xl': ! hasHeader, | ||
'border-t': hasHeader, | ||
}"> | ||
|
||
<div class="divide-y divide-dashed dark:divide-gray-700"> | ||
@foreach ($data['items'] as $row) | ||
<div class="px-4 py-3 filament-tables-text-column"> | ||
|
||
<a class="text-sm truncate" href="{{ $row->get_permalink() }}" target="_blank"> | ||
|
||
{{ $row->get_title() }} | ||
</a> | ||
</div> | ||
@endforeach | ||
</div> | ||
</div> | ||
</x-filament::card> | ||
</x-filament::widget> | ||
@endforeach |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Phpsa\FilamentFeed; | ||
|
||
use Filament\PluginServiceProvider; | ||
use Phpsa\FilamentFeed\Widgets\FeedWidget; | ||
use Spatie\LaravelPackageTools\Package; | ||
|
||
class FilamentFeedProvider extends PluginServiceProvider | ||
{ | ||
public static string $name = 'filament-feed'; | ||
|
||
protected array $widgets = [ | ||
FeedWidget::class | ||
]; | ||
|
||
public function configurePackage(Package $package): void | ||
{ | ||
$package->name('filament-feed')->hasViews()->hasConfigFile(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
namespace Phpsa\FilamentFeed\Widgets; | ||
|
||
use Filament\Widgets\Concerns\CanPoll; | ||
use Filament\Widgets\Widget; | ||
use Illuminate\Support\Facades\Cache; | ||
use Illuminate\Support\Facades\Config; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class FeedWidget extends Widget | ||
{ | ||
use CanPoll; | ||
|
||
protected static string $view = 'filament-feed::filament.widgets.feed'; | ||
|
||
protected function getViewData(): array | ||
{ | ||
return [ | ||
'feeds' => $this->getFeeds() | ||
]; | ||
} | ||
|
||
protected function getFeeds(): array | ||
{ | ||
return collect(Config::get('filament-feed.feeds', [])) | ||
->map(fn($feed, $key) => $this->fetchFeed($feed, $key)) | ||
->filter() | ||
->toArray(); | ||
} | ||
|
||
protected function fetchFeed(array $feed, string $key): ?array | ||
{ | ||
|
||
$feedUrl = $feed['url'] ?? null; | ||
if ($feedUrl === null) { | ||
return null; | ||
} | ||
$limit = $feed['limit'] ?? 5; | ||
$refresh = $feed['refresh'] ?? 300; | ||
|
||
$key = 'php-f-feed-' . md5($feedUrl . $limit); | ||
|
||
$data = Cache::remember($key, $refresh, fn () => $this->getFeed($feedUrl, $limit)); | ||
return $data; | ||
} | ||
|
||
public function getFeed(string $url, int $limit): array | ||
{ | ||
$simplePie = new \SimplePie(); | ||
$simplePie->enable_cache(false); | ||
$simplePie->set_feed_url($url); | ||
$simplePie->init(); | ||
|
||
return [ | ||
'title' => $simplePie->get_title(), | ||
'permalink' => $simplePie->get_permalink(), | ||
'items' => $simplePie->get_items(0, $limit), | ||
]; | ||
} | ||
} |