mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig-portal.git
synced 2025-12-11 06:46:47 +00:00
rss feed added
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use App\Support\CustomFeedItem;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
@@ -10,7 +11,6 @@ use Spatie\Comments\Models\Concerns\HasComments;
|
||||
use Spatie\EloquentSortable\Sortable;
|
||||
use Spatie\EloquentSortable\SortableTrait;
|
||||
use Spatie\Feed\Feedable;
|
||||
use Spatie\Feed\FeedItem;
|
||||
use Spatie\Image\Manipulations;
|
||||
use Spatie\MediaLibrary\HasMedia;
|
||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
||||
@@ -146,18 +146,19 @@ class LibraryItem extends Model implements HasMedia, Sortable, Feedable
|
||||
}
|
||||
}
|
||||
|
||||
public function toFeedItem(): FeedItem
|
||||
public function toFeedItem(): CustomFeedItem
|
||||
{
|
||||
return FeedItem::create()
|
||||
->id('news/'.$this->slug)
|
||||
->title($this->name)
|
||||
->enclosure($this->getFirstMediaUrl('main'))
|
||||
->enclosureLength($this->getFirstMedia('main')->size)
|
||||
->enclosureType($this->getFirstMedia('main')->mime_type)
|
||||
->summary($this->excerpt)
|
||||
->updated($this->updated_at)
|
||||
->image($this->getFirstMediaUrl('main'))
|
||||
->link(url()->route('article.view', ['libraryItem' => $this]))
|
||||
->authorName($this->lecturer->name);
|
||||
return CustomFeedItem::create()
|
||||
->id('news/'.$this->slug)
|
||||
->title($this->name)
|
||||
->content($this->value)
|
||||
->enclosure($this->getFirstMediaUrl('main'))
|
||||
->enclosureLength($this->getFirstMedia('main')->size)
|
||||
->enclosureType($this->getFirstMedia('main')->mime_type)
|
||||
->summary($this->excerpt)
|
||||
->updated($this->updated_at)
|
||||
->image($this->getFirstMediaUrl('main'))
|
||||
->link(url()->route('article.view', ['libraryItem' => $this]))
|
||||
->authorName($this->lecturer->name);
|
||||
}
|
||||
}
|
||||
|
||||
17
app/Support/CustomFeedItem.php
Normal file
17
app/Support/CustomFeedItem.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Spatie\Feed\FeedItem;
|
||||
|
||||
class CustomFeedItem extends FeedItem
|
||||
{
|
||||
protected string $content;
|
||||
|
||||
public function content(string $content): self
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
3
resources/views/vendor/feed/rss.blade.php
vendored
3
resources/views/vendor/feed/rss.blade.php
vendored
@@ -26,6 +26,9 @@
|
||||
<author>{!! \Spatie\Feed\Helpers\Cdata::out($item->authorName.(empty($item->authorEmail)?'':' <'.$item->authorEmail.'>')) !!}</author>
|
||||
<guid isPermaLink="true">{{ url($item->id) }}</guid>
|
||||
<pubDate>{{ $item->timestamp() }}</pubDate>
|
||||
<content:encoded>
|
||||
{!! $item->content !!}
|
||||
</content:encoded>
|
||||
@if($item->__isset('enclosure'))
|
||||
<enclosure url="{{ url($item->enclosure) }}" length="{{ url($item->enclosureLength) }}" type="{{ $item->enclosureType }}"/>
|
||||
<media:content url="{{ url($item->enclosure) }}" medium="image" type="{{ $item->enclosureType }}"/>
|
||||
|
||||
Reference in New Issue
Block a user