Add substack username handling (#3113)
* Add username link handling for substack --------- Co-authored-by: momijizukamori <momijizukamori+bugzilla@gmail.com>
This commit is contained in:
parent
e341d8c957
commit
8fbc52bc46
|
@ -99,6 +99,8 @@ $domaintosite{"instagram.com"} =
|
|||
DW::External::Site->new( "29", "www.instagram.com", "instagram.com", "Instagram", "instagram" );
|
||||
$domaintosite{"del.icio.us"} =
|
||||
DW::External::Site->new( "30", "del.icio.us", "del.icio.us", "Delicious", "delicious" );
|
||||
$domaintosite{"substack.com"} =
|
||||
DW::External::Site->new( "31", "substack.com", "substack.com", "Substack", "substack");
|
||||
|
||||
$domaintosite{"itch.io"} =
|
||||
DW::External::Site->new( "32", "www.itch.io", "itch.io", "Itch", "itch" );
|
||||
|
@ -148,6 +150,7 @@ $domaintosite{"facebook"} = $domaintosite{"facebook.com"};
|
|||
$domaintosite{"fb"} = $domaintosite{"facebook.com"};
|
||||
$domaintosite{"instagram"} = $domaintosite{"instagram.com"};
|
||||
$domaintosite{"ig"} = $domaintosite{"instagram.com"};
|
||||
$domaintosite{"substack"} = $domaintosite{"substack.com"};
|
||||
$domaintosite{"itch"} = $domaintosite{"itch.io"};
|
||||
|
||||
foreach my $value (@all_sites_without_alias) {
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
#!/usr/bin/perl
|
||||
#
|
||||
# DW::External::Site::Substack
|
||||
#
|
||||
# Class to support Substack linking.
|
||||
#
|
||||
# Authors:
|
||||
# Carly Ho <https://veryroundbird.dreamwidth.org>
|
||||
#
|
||||
# Copyright (c) 2011/2023 by Dreamwidth Studios, LLC.
|
||||
#
|
||||
# This program is free software; you may redistribute it and/or modify it under
|
||||
# the same terms as Perl itself. For a copy of the license, please reference
|
||||
# 'perldoc perlartistic' or 'perldoc perlgpl'.
|
||||
#
|
||||
|
||||
package DW::External::Site::Substack;
|
||||
|
||||
use strict;
|
||||
use base 'DW::External::Site';
|
||||
use Carp qw/ croak /;
|
||||
|
||||
# new does nothing for these classes
|
||||
sub new { croak 'cannot build with new'; }
|
||||
|
||||
# returns an object if we allow this domain; else undef
|
||||
sub accepts {
|
||||
my ( $class, $parts ) = @_;
|
||||
|
||||
# let's just assume the last two parts are good if we have them
|
||||
return undef unless scalar(@$parts) >= 2;
|
||||
|
||||
return bless { hostname => "$parts->[-2].$parts->[-1]" }, $class;
|
||||
}
|
||||
|
||||
# argument: DW::External::User
|
||||
# returns URL to this account
|
||||
sub journal_url {
|
||||
my ( $self, $u ) = @_;
|
||||
croak 'need a DW::External::User'
|
||||
unless $u && ref $u eq 'DW::External::User';
|
||||
|
||||
return 'http://' . $u->user . '.' . $self->{hostname} . '/';
|
||||
}
|
||||
|
||||
# argument: DW::External::User
|
||||
# links to the about page
|
||||
sub profile_url {
|
||||
my ( $self, $u ) = @_;
|
||||
croak 'need a DW::External::User'
|
||||
unless $u && ref $u eq 'DW::External::User';
|
||||
|
||||
return 'http://' . $u->user . '.' . $self->{hostname} . '/about';
|
||||
}
|
||||
|
||||
# argument: DW::External::User
|
||||
# returns info for the badge image (userhead icon) for this user
|
||||
sub badge_image {
|
||||
my ( $self, $u ) = @_;
|
||||
croak 'need a DW::External::User'
|
||||
unless $u && ref $u eq 'DW::External::User';
|
||||
|
||||
return {
|
||||
url => "https://substackcdn.com/icons/substack/favicon.ico",
|
||||
width => 16,
|
||||
height => 16,
|
||||
};
|
||||
}
|
||||
|
||||
1;
|
Loading…
Reference in New Issue