Skip to content

Commit fb4b6d9

Browse files
committed
MediaEmbed: updated Mastodon
1 parent 10fed3e commit fb4b6d9

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

docs/testdox.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6840,6 +6840,8 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
68406840
[x] Scraping tests with data set #51
68416841
[x] Scraping tests with data set #52
68426842
[x] Scraping tests with data set #53
6843+
[x] Scraping tests with data set #54
6844+
[x] Scraping tests with data set #55
68436845
[x] Scraping+rendering tests with data set #0
68446846
[x] Scraping+rendering tests with data set #1
68456847
[x] Scraping+rendering tests with data set #2
@@ -7217,6 +7219,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
72177219
[x] Parsing tests with data set #322
72187220
[x] Parsing tests with data set #323
72197221
[x] Parsing tests with data set #324
7222+
[x] Parsing tests with data set #325
72207223
[x] Parsing tests (JavaScript) with data set #0
72217224
[x] Parsing tests (JavaScript) with data set #1
72227225
[x] Parsing tests (JavaScript) with data set #2
@@ -7542,6 +7545,7 @@ Parser (s9e\TextFormatter\Tests\Plugins\MediaEmbed\Parser)
75427545
[x] Parsing tests (JavaScript) with data set #322
75437546
[x] Parsing tests (JavaScript) with data set #323
75447547
[x] Parsing tests (JavaScript) with data set #324
7548+
[x] Parsing tests (JavaScript) with data set #325
75457549
[x] Parsing+rendering tests with data set #0
75467550
[x] Parsing+rendering tests with data set #1
75477551
[x] Parsing+rendering tests with data set #2

src/Bundles/MediaPack.php

Lines changed: 3 additions & 3 deletions
Large diffs are not rendered by default.

src/Plugins/MediaEmbed/Configurator/Collections/CachedDefinitionCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class CachedDefinitionCollection extends SiteDefinitionCollection
7272
'liveleak'=>['attributes'=>[],'example'=>'https://www.liveleak.com/view?t=yIcw_1520190567','extract'=>['!liveleak\\.com/(?:e/|view\\?i=)(?\'id\'\\w+)!'],'homepage'=>'https://www.liveleak.com/','host'=>['liveleak.com'],'iframe'=>['src'=>'//www.liveleak.com/e/{@id}'],'name'=>'Liveleak','scrape'=>[['extract'=>['!liveleak\\.com/e/(?\'id\'\\w+)!'],'match'=>['!liveleak\\.com/view\\?t=!']]],'tags'=>['videos']],
7373
'livestream'=>['attributes'=>[],'example'=>['https://new.livestream.com/jbtvlive/musicmarathon','https://livestream.com/ccscsl/USChessChampionships/videos/83267610','https://livestre.am/58XNV'],'extract'=>['!livestream\\.com/accounts/(?\'account_id\'\\d+)/events/(?\'event_id\'\\d+)!','!/videos/(?\'video_id\'\\d+)!','!original\\.livestream\\.com/(?\'channel\'\\w+)/video\\?clipId=(?\'clip_id\'[-\\w]+)!'],'homepage'=>'https://new.livestream.com/','host'=>['livestre.am','livestream.com'],'iframe'=>['src'=>'//<xsl:choose><xsl:when test="@clip_id">cdn.livestream.com/embed/<xsl:value-of select="@channel"/>?layout=4&amp;autoplay=false&amp;clip=<xsl:value-of select="@clip_id"/></xsl:when><xsl:otherwise>livestream.com/accounts/<xsl:value-of select="@account_id"/>/events/<xsl:value-of select="@event_id"/><xsl:if test="@video_id">/videos/<xsl:value-of select="@video_id"/></xsl:if>/player?autoPlay=false</xsl:otherwise></xsl:choose>'],'name'=>'Livestream','scrape'=>[['extract'=>['!accounts/(?\'account_id\'\\d+)/events/(?\'event_id\'\\d+)!'],'match'=>['@livestream\\.com/(?!accounts/\\d+/events/\\d)@']],['extract'=>['!//original\\.livestream\\.com/(?\'channel\'\\w+)/video/(?\'clip_id\'[-\\w]+)!'],'match'=>['!livestre.am!']]],'tags'=>['livestreaming','videos']],
7474
'mailru'=>['attributes'=>[],'example'=>['https://my.mail.ru/corp/auto/video/testdrive/34.html','https://my.mail.ru/mail/alenka1957/video/1/7.html'],'extract'=>[],'homepage'=>'https://my.mail.ru/','host'=>['my.mail.ru'],'iframe'=>['src'=>'https://my.mail.ru/video/embed/{@id}'],'name'=>'Mail.Ru','scrape'=>[['extract'=>['!"itemId": ?"?(?\'id\'\\d+)!'],'match'=>['!my\\.mail\\.ru/\\w+/\\w+/video/\\w+/\\d!']]],'tags'=>['.ru']],
75-
'mastodon'=>['attributes'=>['host'=>['required'=>true]],'example'=>'https://mastodon.social/@HackerNewsBot/100181134752056592','extract'=>['#//(?\'host\'[-.\\w]+)/@(?\'name\'\\w+)/(?\'id\'\\d+)#'],'homepage'=>'https://mastodon.social/','host'=>['mastodon.social'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>300,'onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+\'px\';this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/mastodon.min.html#<xsl:value-of select="@name"/><xsl:if test="@host and@host!=\'mastodon.social\'">@<xsl:value-of select="@host"/></xsl:if>/<xsl:value-of select="@id"/>','width'=>550],'name'=>'Mastodon','oembed'=>['endpoint'=>'https://mastodon.social/api/oembed','scheme'=>'https://mastodon.social/@{@name}/{@id}'],'scrape'=>[['extract'=>['#"url":"https://(?\'host\'[-.\\w]+)/@(?\'name\'\\w+)/(?\'id\'\\d+)"#'],'match'=>['#^(?\'origin\'https://[^/]+)/@\\w+@[-.\\w]+/(?\'id\'\\d+)#'],'url'=>'{@origin}/api/v1/statuses/{@id}']],'tags'=>['social']],
75+
'mastodon'=>['attributes'=>['host'=>['required'=>true]],'example'=>'https://mastodon.social/@HackerNewsBot/100181134752056592','extract'=>['#//(?\'host\'[-.\\w]+)/(?:web/)?(?:@|users/)(?\'name\'\\w+)/(?:posts/|statuses/)?(?\'id\'\\d+)#'],'homepage'=>'https://mastodon.social/','host'=>['mastodon.social'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>300,'onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+\'px\';this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/mastodon.min.html#<xsl:value-of select="@name"/><xsl:if test="@host and@host!=\'mastodon.social\'">@<xsl:value-of select="@host"/></xsl:if>/<xsl:value-of select="@id"/>','width'=>550],'name'=>'Mastodon','oembed'=>['endpoint'=>'https://mastodon.social/api/oembed','scheme'=>'https://mastodon.social/@{@name}/{@id}'],'scrape'=>[['extract'=>['#"url":"https://(?\'host\'[-.\\w]+)/@(?\'name\'\\w+)/(?\'id\'\\d+)"#'],'match'=>['#^(?\'origin\'https://[^/]+)/(?:web/)?(?:@\\w+@[-.\\w]+|statuses)/(?\'id\'\\d+)#'],'url'=>'{@origin}/api/v1/statuses/{@id}']],'tags'=>['social']],
7676
'medium'=>['attributes'=>[],'example'=>'https://medium.com/@donnydonny/team-internet-is-about-to-win-net-neutrality-and-they-didnt-need-googles-help-e7e2cf9b8a95','extract'=>['#medium\\.com/(?:s/\\w+/|@?[-\\w]+/)?(?:\\w+-)*(?\'id\'[0-9a-f]+)(?!\\w)#'],'homepage'=>'https://medium.com/','host'=>['medium.com'],'iframe'=>['data-s9e-livepreview-ignore-attrs'=>'style','height'=>316,'max-width'=>900,'onload'=>'let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+\'px\';this.contentWindow.postMessage(\'s9e:init\',\'*\',[c.port2])','src'=>'https://s9e.github.io/iframe/2/medium.min.html#{@id}','width'=>'100%'],'name'=>'Medium','scrape'=>[],'tags'=>['blogging']],
7777
'megaphone'=>['amp'=>['custom-element'=>'amp-megaphone','src'=>'https://cdn.ampproject.org/v0/amp-megaphone-0.1.js','template'=>'<amp-megaphone layout="fixed-height" height="200" data-episode="{@id}"><xsl:if test="$MEDIAEMBED_THEME=\'light\'"><xsl:attribute name="data-light"/></xsl:if></amp-megaphone>'],'attributes'=>[],'example'=>['https://cms.megaphone.fm/channel/lockedonheat?selected=LKN8165322853','https://player.megaphone.fm/LKN8165322853'],'extract'=>['@megaphone\\.fm/.*?\\?(?:e|selected)=(?\'id\'\\w+)@','@(?:dcs|player|traffic)\\.megaphone\\.fm/(?\'id\'\\w+)@','@megaphone\\.link/(?\'id\'\\w+)@'],'homepage'=>'https://megaphone.fm/','host'=>['megaphone.fm','megaphone.link'],'iframe'=>['height'=>200,'max-width'=>900,'src'=>'https://player.megaphone.fm/<xsl:value-of select="@id"/><xsl:if test="$MEDIAEMBED_THEME=\'light\'">?light=true</xsl:if>','width'=>'100%'],'name'=>'Megaphone','scrape'=>[],'tags'=>['podcasts']],
7878
'metacafe'=>['attributes'=>[],'example'=>'https://www.metacafe.com/watch/10785282/chocolate_treasure_chest_epic_meal_time/','extract'=>['!metacafe\\.com/watch/(?\'id\'\\d+)!'],'homepage'=>'https://www.metacafe.com/','host'=>['metacafe.com'],'iframe'=>['src'=>'//www.metacafe.com/embed/{@id}/'],'name'=>'Metacafe','scrape'=>[],'tags'=>['videos']],

src/Plugins/MediaEmbed/Configurator/sites/mastodon.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
</attributes>
1212

1313
<host>mastodon.social</host>
14-
<extract>#//(?'host'[-.\w]+)/@(?'name'\w+)/(?'id'\d+)#</extract>
14+
<extract>#//(?'host'[-.\w]+)/(?:web/)?(?:@|users/)(?'name'\w+)/(?:posts/|statuses/)?(?'id'\d+)#</extract>
1515
<scrape url="{@origin}/api/v1/statuses/{@id}">
16-
<match>#^(?'origin'https://[^/]+)/@\w+@[-.\w]+/(?'id'\d+)#</match>
16+
<match>#^(?'origin'https://[^/]+)/(?:web/)?(?:@\w+@[-.\w]+|statuses)/(?'id'\d+)#</match>
1717
<extract>#"url":"https://(?'host'[-.\w]+)/@(?'name'\w+)/(?'id'\d+)"#</extract>
1818
</scrape>
1919
<iframe width="550" height="300" onload="let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])" data-s9e-livepreview-ignore-attrs="style">

tests/Plugins/MediaEmbed/ParserTest.php

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,26 @@ function ($configurator)
968968
$configurator->MediaEmbed->add('mastodon');
969969
}
970970
],
971+
[
972+
'https://mastodon.social/statuses/100181134752056592',
973+
'<r><MASTODON host="mastodon.social" id="100181134752056592" name="HackerNewsBot">https://mastodon.social/statuses/100181134752056592</MASTODON></r>',
974+
[],
975+
function ($configurator)
976+
{
977+
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
978+
$configurator->MediaEmbed->add('mastodon');
979+
}
980+
],
981+
[
982+
'https://mastodon.social/web/statuses/100181134752056592',
983+
'<r><MASTODON host="mastodon.social" id="100181134752056592" name="HackerNewsBot">https://mastodon.social/web/statuses/100181134752056592</MASTODON></r>',
984+
[],
985+
function ($configurator)
986+
{
987+
$configurator->registeredVars['cacheDir'] = __DIR__ . '/../../.cache';
988+
$configurator->MediaEmbed->add('mastodon');
989+
}
990+
],
971991
[
972992
'https://www.npr.org/blogs/goatsandsoda/2015/02/11/385396431/the-50-most-effective-ways-to-transform-the-developing-world',
973993
'<r><NPR i="385396431" m="385396432">https://www.npr.org/blogs/goatsandsoda/2015/02/11/385396431/the-50-most-effective-ways-to-transform-the-developing-world</NPR></r>',
@@ -2632,8 +2652,17 @@ function ($configurator)
26322652
}
26332653
],
26342654
[
2635-
'https://mastodon.social/@HackerNewsBot/100181134752056592',
2636-
'<r><MASTODON host="mastodon.social" id="100181134752056592" name="HackerNewsBot">https://mastodon.social/@HackerNewsBot/100181134752056592</MASTODON></r>',
2655+
'https://mastodon.social/web/@HackerNewsBot/100181134752056592',
2656+
'<r><MASTODON host="mastodon.social" id="100181134752056592" name="HackerNewsBot">https://mastodon.social/web/@HackerNewsBot/100181134752056592</MASTODON></r>',
2657+
[],
2658+
function ($configurator)
2659+
{
2660+
$configurator->MediaEmbed->add('mastodon');
2661+
}
2662+
],
2663+
[
2664+
'https://mastodon.social/users/HackerNewsBot/statuses/100181134752056592',
2665+
'<r><MASTODON host="mastodon.social" id="100181134752056592" name="HackerNewsBot">https://mastodon.social/users/HackerNewsBot/statuses/100181134752056592</MASTODON></r>',
26372666
[],
26382667
function ($configurator)
26392668
{

0 commit comments

Comments
 (0)