Use uri for permalinks, fix Micropub Location header, and drop notes.shorturl #149

Merged
jonny merged 4 commits from 148-permalink-uri into develop 2026-11-01 16:49:49 +01:00
4 changed files with 18 additions and 3 deletions
Showing only changes of commit 5481956d78 - Show all commits

Use uri for the like and bookmark permalinks

`uri` is the attribute every other postable model uses for its absolute
permalink on this site. Add it to Like, which had none, and rename
Bookmark's `local_uri` to match. `url` stays as the thing being liked or
bookmarked.

Refs #148

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jonny Barnes 2026-11-01 15:28:30 +00:00
Signed by: jonny
SSH key fingerprint: SHA256:CTuSlns5U7qlD9jqHvtnVmfYV3Zwl2Z7WnJ4/dqOaL8

View file

@ -25,7 +25,7 @@ class Bookmark extends Model
return $this->belongsToMany('App\Models\Tag');
}
protected function localUri(): Attribute
protected function uri(): Attribute
{
return Attribute::get(
get: fn () => config('app.url').'/bookmarks/'.$this->id,

View file

@ -18,6 +18,13 @@ class Like extends Model
use FilterHtml;
use HasFactory;
protected function uri(): Attribute
{
return Attribute::get(
get: fn () => config('app.url').'/likes/'.$this->id,
);
}
protected function url(): Attribute
{
return Attribute::set(

View file

@ -92,10 +92,10 @@ class BookmarksTest extends TestCase
}
#[Test]
public function bookmark_local_uri_attribute_returns_correct_url(): void
public function bookmark_uri_attribute_returns_correct_url(): void
{
$bookmark = Bookmark::factory()->create();
$this->assertEquals(config('app.url').'/bookmarks/'.$bookmark->id, $bookmark->local_uri);
$this->assertEquals(config('app.url').'/bookmarks/'.$bookmark->id, $bookmark->uri);
}
#[Test]

View file

@ -13,6 +13,14 @@ class LikesTest extends TestCase
{
use RefreshDatabase;
#[Test]
public function like_uri_attribute_returns_our_permalink(): void
{
$like = Like::factory()->create();
$this->assertEquals(config('app.url').'/likes/'.$like->id, $like->uri);
}
#[Test]
public function we_can_set_the_author_url(): void
{