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;
|
namespace App\Models;
|
||||||
|
|
||||||
|
use App\Support\CustomFeedItem;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||||
@@ -10,7 +11,6 @@ use Spatie\Comments\Models\Concerns\HasComments;
|
|||||||
use Spatie\EloquentSortable\Sortable;
|
use Spatie\EloquentSortable\Sortable;
|
||||||
use Spatie\EloquentSortable\SortableTrait;
|
use Spatie\EloquentSortable\SortableTrait;
|
||||||
use Spatie\Feed\Feedable;
|
use Spatie\Feed\Feedable;
|
||||||
use Spatie\Feed\FeedItem;
|
|
||||||
use Spatie\Image\Manipulations;
|
use Spatie\Image\Manipulations;
|
||||||
use Spatie\MediaLibrary\HasMedia;
|
use Spatie\MediaLibrary\HasMedia;
|
||||||
use Spatie\MediaLibrary\InteractsWithMedia;
|
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()
|
return CustomFeedItem::create()
|
||||||
->id('news/'.$this->slug)
|
->id('news/'.$this->slug)
|
||||||
->title($this->name)
|
->title($this->name)
|
||||||
->enclosure($this->getFirstMediaUrl('main'))
|
->content($this->value)
|
||||||
->enclosureLength($this->getFirstMedia('main')->size)
|
->enclosure($this->getFirstMediaUrl('main'))
|
||||||
->enclosureType($this->getFirstMedia('main')->mime_type)
|
->enclosureLength($this->getFirstMedia('main')->size)
|
||||||
->summary($this->excerpt)
|
->enclosureType($this->getFirstMedia('main')->mime_type)
|
||||||
->updated($this->updated_at)
|
->summary($this->excerpt)
|
||||||
->image($this->getFirstMediaUrl('main'))
|
->updated($this->updated_at)
|
||||||
->link(url()->route('article.view', ['libraryItem' => $this]))
|
->image($this->getFirstMediaUrl('main'))
|
||||||
->authorName($this->lecturer->name);
|
->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>
|
<author>{!! \Spatie\Feed\Helpers\Cdata::out($item->authorName.(empty($item->authorEmail)?'':' <'.$item->authorEmail.'>')) !!}</author>
|
||||||
<guid isPermaLink="true">{{ url($item->id) }}</guid>
|
<guid isPermaLink="true">{{ url($item->id) }}</guid>
|
||||||
<pubDate>{{ $item->timestamp() }}</pubDate>
|
<pubDate>{{ $item->timestamp() }}</pubDate>
|
||||||
|
<content:encoded>
|
||||||
|
{!! $item->content !!}
|
||||||
|
</content:encoded>
|
||||||
@if($item->__isset('enclosure'))
|
@if($item->__isset('enclosure'))
|
||||||
<enclosure url="{{ url($item->enclosure) }}" length="{{ url($item->enclosureLength) }}" type="{{ $item->enclosureType }}"/>
|
<enclosure url="{{ url($item->enclosure) }}" length="{{ url($item->enclosureLength) }}" type="{{ $item->enclosureType }}"/>
|
||||||
<media:content url="{{ url($item->enclosure) }}" medium="image" type="{{ $item->enclosureType }}"/>
|
<media:content url="{{ url($item->enclosure) }}" medium="image" type="{{ $item->enclosureType }}"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user