1package Mail::LMLM::Types::Base; 2$Mail::LMLM::Types::Base::VERSION = '0.6807'; 3use strict; 4use warnings; 5 6use Mail::LMLM::Object; 7 8use vars qw(@ISA); 9 10@ISA = qw(Mail::LMLM::Object); 11 12sub parse_args 13{ 14 my $self = shift; 15 16 my $args = shift; 17 18 my ( @left, $key, $value ); 19 20 while ( scalar(@$args) ) 21 { 22 $key = shift(@$args); 23 $value = shift(@$args); 24 if ( $key =~ /^-?(id)$/ ) 25 { 26 $self->{'id'} = $value; 27 } 28 elsif ( $key =~ /^-?(group_base)$/ ) 29 { 30 $self->{'group_base'} = $value; 31 } 32 elsif ( $key =~ /^-?(desc|description)$/ ) 33 { 34 $self->{'description'} = $value; 35 } 36 elsif ( $key =~ /^-?(hostname|host)$/ ) 37 { 38 $self->{'hostname'} = $value; 39 } 40 elsif ( $key =~ /^-?(homepage)$/ ) 41 { 42 $self->{'homepage'} = $value; 43 } 44 elsif ( $key =~ /^-?(online_archive)$/ ) 45 { 46 $self->{'online_archive'} = $value; 47 } 48 elsif ( $key =~ /^-?(guidelines)$/ ) 49 { 50 $self->{'guidelines'} = $value; 51 } 52 elsif ( $key =~ /^-?(notes)$/ ) 53 { 54 $self->{'notes'} = $value; 55 } 56 else 57 { 58 push @left, $key, $value; 59 } 60 } 61 62 return ( \@left ); 63} 64 65sub initialize 66{ 67 my $self = shift; 68 69 $self->parse_args( [@_] ); 70 71 return 0; 72} 73 74sub get_id 75{ 76 my $self = shift; 77 78 return $self->{'id'}; 79} 80 81sub get_description 82{ 83 my $self = shift; 84 85 return $self->{'description'}; 86} 87 88sub get_homepage 89{ 90 my $self = shift; 91 92 return $self->{'homepage'}; 93} 94 95sub get_group_base 96{ 97 my $self = shift; 98 99 return $self->{'group_base'}; 100} 101 102sub get_hostname 103{ 104 my $self = shift; 105 106 return $self->{'hostname'} || $self->get_default_hostname(); 107} 108 109sub get_online_archive 110{ 111 my $self = shift; 112 113 return $self->{'online_archive'}; 114} 115 116sub get_guidelines 117{ 118 my $self = shift; 119 120 return $self->{'guidelines'}; 121} 122 123sub render_subscribe 124{ 125 my $self = shift; 126 127 my $htmler = shift; 128 129 return 0; 130} 131 132sub render_unsubscribe 133{ 134 my $self = shift; 135 136 my $htmler = shift; 137 138 return 0; 139} 140 141sub render_post 142{ 143 my $self = shift; 144 145 my $htmler = shift; 146 147 return 0; 148} 149 150sub render_owner 151{ 152 my $self = shift; 153 154 my $htmler = shift; 155 156 return 0; 157} 158 159sub render_none 160{ 161 my $self = shift; 162 163 my $htmler = shift; 164 165 $htmler->para("None."); 166 167 return 0; 168} 169 170sub render_homepage 171{ 172 my $self = shift; 173 174 my $htmler = shift; 175 176 my $homepage = $self->get_homepage(); 177 178 if ($homepage) 179 { 180 $htmler->start_para(); 181 $htmler->url($homepage); 182 $htmler->end_para(); 183 } 184 else 185 { 186 $self->render_none($htmler); 187 } 188 189 return 0; 190} 191 192sub render_online_archive 193{ 194 my $self = shift; 195 196 my $htmler = shift; 197 198 my $archive = $self->get_online_archive(); 199 200 if ( ref($archive) eq "CODE" ) 201 { 202 $archive->( $self, $htmler ); 203 } 204 elsif ( ref($archive) eq "" ) 205 { 206 $htmler->start_para(); 207 $htmler->url($archive); 208 $htmler->end_para(); 209 } 210 else 211 { 212 $self->render_none($htmler); 213 } 214 215 return 0; 216} 217 218sub render_field 219{ 220 my $self = shift; 221 222 my $htmler = shift; 223 224 my $desc = shift; 225 226 if ( ref($desc) eq "CODE" ) 227 { 228 $desc->( $self, $htmler ); 229 } 230 elsif ( ref($desc) eq "ARRAY" ) 231 { 232 foreach my $paragraph (@$desc) 233 { 234 $htmler->para($paragraph); 235 } 236 } 237 elsif ( ref($desc) eq "" ) 238 { 239 $htmler->para($desc); 240 } 241 return 0; 242} 243 244sub render_description 245{ 246 my $self = shift; 247 my $htmler = shift; 248 $self->render_field( $htmler, $self->get_description() ); 249} 250 251sub render_guidelines 252{ 253 my $self = shift; 254 my $htmler = shift; 255 $self->render_field( $htmler, $self->get_guidelines() ); 256} 257 258sub render_something_with_email_addr 259{ 260 my $self = shift; 261 262 my $htmler = shift; 263 my $begin_msg = shift; 264 my $address_method = shift; 265 266 $htmler->para($begin_msg); 267 $htmler->indent_inc(); 268 $htmler->start_para(); 269 $htmler->email_address( $self->$address_method() ); 270 $htmler->end_para(); 271 $htmler->indent_dec(); 272 273 return 0; 274} 275 2761; 277 278__END__ 279 280=pod 281 282=encoding UTF-8 283 284=head1 NAME 285 286Mail::LMLM::Types::Base - the base class for the mailing list types. 287 288=head1 VERSION 289 290version 0.6807 291 292=head1 SYNOPSIS 293 294Extend the class. 295 296=head1 METHODS 297 298=head2 Mail::LMLM::Types::MyMailingListType->new(%args) 299 300%args keys can be: 301 302=over 4 303 304=item * id 305 306The id of the mailing list - used for URLs, etc. 307 308=item * group_base 309 310The base username of the mailing list. 311 312=item * desc (or description) 313 314The description of the mailing list. 315 316=item * hostname 317 318The hostname where the mailing list is hosted. 319 320=item * homepage 321 322The mailing list's homepage 323 324=item * online_archive 325 326The online archive of the mailing list (can be a coderef). 327 328=item * guidelines 329 330Guidelines for posting on the list. 331 332=item * notes 333 334Notes for the mailing list. 335 336=back 337 338=head2 get_id() 339 340An accessor for the ID. 341 342=head2 get_description() 343 344An accessor for the description. 345 346=head2 get_homepage 347 348An accessor for the homepage. (may be overrided by derived classes). 349 350=head2 get_group_base 351 352An accessor for the group base. 353 354=head2 get_hostname 355 356An accessor for the hostname. 357 358=head2 get_online_archive 359 360An accessor for the online archive. 361 362=head2 get_guidelines 363 364An accessor for the guidelines. 365 366=head2 render_subscribe 367 368Render the subscribe part. 369 370=head2 render_unsubscribe 371 372Render the unsubscribe part. 373 374=head2 render_post 375 376Render the post part. 377 378=head2 render_owner 379 380Render the owner part. 381 382=head2 render_none 383 384Render a paragraph saying "None". 385 386=head2 render_homepage 387 388Render the homepage part. 389 390=head2 render_online_archive 391 392Render the online archive part. 393 394=head2 $self->render_field($htmler, $desc) 395 396Renders the $desc using the rendered. 397 398=head2 render_description 399 400Render the description part. 401 402=head2 render_guidelines 403 404Render the guidelines part. 405 406=head2 $type->render_something_with_email_addr($htmler, $begin_msg, $address_method) 407 408Render something with the email address. 409 410=head1 INTERNAL METHODS 411 412=head2 initialize() 413 414This is a helper for new(). For internal use. 415 416=head2 parse_args() 417 418This is a helper for initialize(). For internal use. 419 420=head1 SEE ALSO 421 422L<Mail::LMLM> 423 424=head1 AUTHOR 425 426Shlomi Fish, L<http://www.shlomifish.org/> 427 428=for :stopwords cpan testmatrix url bugtracker rt cpants kwalitee diff irc mailto metadata placeholders metacpan 429 430=head1 SUPPORT 431 432=head2 Websites 433 434The following websites have more information about this module, and may be of help to you. As always, 435in addition to those websites please use your favorite search engine to discover more resources. 436 437=over 4 438 439=item * 440 441MetaCPAN 442 443A modern, open-source CPAN search engine, useful to view POD in HTML format. 444 445L<https://metacpan.org/release/Mail-LMLM> 446 447=item * 448 449RT: CPAN's Bug Tracker 450 451The RT ( Request Tracker ) website is the default bug/issue tracking system for CPAN. 452 453L<https://rt.cpan.org/Public/Dist/Display.html?Name=Mail-LMLM> 454 455=item * 456 457CPANTS 458 459The CPANTS is a website that analyzes the Kwalitee ( code metrics ) of a distribution. 460 461L<http://cpants.cpanauthors.org/dist/Mail-LMLM> 462 463=item * 464 465CPAN Testers 466 467The CPAN Testers is a network of smoke testers who run automated tests on uploaded CPAN distributions. 468 469L<http://www.cpantesters.org/distro/M/Mail-LMLM> 470 471=item * 472 473CPAN Testers Matrix 474 475The CPAN Testers Matrix is a website that provides a visual overview of the test results for a distribution on various Perls/platforms. 476 477L<http://matrix.cpantesters.org/?dist=Mail-LMLM> 478 479=item * 480 481CPAN Testers Dependencies 482 483The CPAN Testers Dependencies is a website that shows a chart of the test results of all dependencies for a distribution. 484 485L<http://deps.cpantesters.org/?module=Mail::LMLM> 486 487=back 488 489=head2 Bugs / Feature Requests 490 491Please report any bugs or feature requests by email to C<bug-mail-lmlm at rt.cpan.org>, or through 492the web interface at L<https://rt.cpan.org/Public/Bug/Report.html?Queue=Mail-LMLM>. You will be automatically notified of any 493progress on the request by the system. 494 495=head2 Source Code 496 497The code is open to the world, and available for you to hack on. Please feel free to browse it and play 498with it, or whatever. If you want to contribute patches, please send me a diff or prod me to pull 499from your repository :) 500 501L<https://github.com/shlomif/perl-mail-lmlm> 502 503 git clone git://github.com/shlomif/perl-mail-lmlm.git 504 505=head1 AUTHOR 506 507Shlomi Fish 508 509=head1 BUGS 510 511Please report any bugs or feature requests on the bugtracker website 512L<https://github.com/shlomif/perl-mail-lmlm/issues> 513 514When submitting a bug or request, please include a test-file or a 515patch to an existing test-file that illustrates the bug or desired 516feature. 517 518=head1 COPYRIGHT AND LICENSE 519 520This software is Copyright (c) 2020 by Shlomi Fish. 521 522This is free software, licensed under: 523 524 The MIT (X11) License 525 526=cut 527