App-LinkSite

 view release on metacpan or  search on metacpan

lib/App/LinkSite/Social.pm  view on Meta::CPAN

    },
    tiktok     => {
      url  => "https://tiktok.com/@",
      name => 'TikTok',
    },
    linkedin   => {
      url  => "https://linkedin.com/in/",
      name => 'LinkedIn',
    },
    substack   => {
      url  => "https://XXXX.substack.com/",
      name => 'Substack',
    },
    github     => {
      url  => "https://github.com/",
      name => 'GitHub',
    },
    medium     => {
      url  => "https://XXXX.medium.com/",
      name => 'Medium',
    },
    reddit     => {
      url  => "https://reddit.com/user/",
      name => 'Reddit',
    },
    quora      => {
      url  => "https://quora.com/profile/",
      name => 'Quora',
    },
    mastodon   => {
      # Hmm...
      url  => "https://fosstodon.org/@",
      name => 'Mastodon',
    },
    threads    => {
      url  => "https://www.threads.net/@",
      name => 'Threads',
    },
    bluesky   => {
      url  => 'https://bsky.app/profile/',
      name => 'Bluesky',
    },
    letterboxd => {
      url  => 'https://letterboxd.com/',
      name => 'Letterboxd',
    },
    lastfm => {
      url  => 'https://last.fm/user/',
      name => 'last.fm',
    },
    'ko-fi' => {
      url  => 'https://ko-fi.com/',
      name => 'Ko-fi',
    }
  };

=head1 METHODS

=head2 mk_social_link

Return a fragment of HTML that is used to represent this social media link
on the link site.

=cut

  method mk_social_link {
    return $url if $url;

    my $social_url;

    if (exists $urls->{$service}) {
      $social_url = $urls->{$service}{url};
    } else {
      warn('Unknown social service: ', $service);
      return;
    }

    if ($social_url =~ /XXXX/) {
      $social_url =~ s/XXXX/$handle/g;
    } else {
      $social_url .= $handle;
    }

    return $social_url;
  }


=head2 social_icon_template

Return a string that is used to produce the HTML that displays the social
icon and link on the link site. The template string will expect three
substitution values:

=over 4

=item *

The title for the link (probably the `name` from the `$urls` field)

=item *

The link for the social account (as built by `mk_social_link()`)

=item *

The name of the social media site's icon as represented in Font Awesome
(probably a key from the `$urls` field).

=back

=cut

  method social_icon_template {
    return q[<a rel='me' title='%s' href='%s'><i class='fa-brands fa-3x fa-%s'></i></a>];
  }

=head2 mk_social_icon

Returns a fragment of HTML that will be used to display the social media
account on the web site.

=cut

  method mk_social_icon {
    return sprintf $self->social_icon_template,
      $urls->{$service}{name}, $self->mk_social_link(), $service;
  }
}

=head1 AUTHOR

Dave Cross <dave@davecross.co.uk>

=head1 COPYRIGHT AND LICENCE

Copyright (c) 2024, Magnum Solutions Ltd. All Rights Reserved.

This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.

=cut

1;



( run in 1.011 second using v1.01-cache-2.11-cpan-364913b4093 )