Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
Added --html parameter for ddg_attribution
Browse files Browse the repository at this point in the history
  • Loading branch information
Getty committed May 11, 2012
1 parent 68ba65c commit d2d76fe
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
30 changes: 20 additions & 10 deletions lib/DDG/App/Attribution.pm
Expand Up @@ -8,25 +8,35 @@ use Module::Runtime qw( use_module );
use lib ();
use Path::Class;

option 'html' => (
is => 'ro',
default => sub { 0 },
negativable => 1,
);

sub BUILD {
my ( $self ) = @_;
my $curdir = dir('lib')->absolute;
lib->import($curdir->stringify);
if (@ARGV) {
for (@ARGV) {
use_module($_);
my @attributions = @{$_->get_attributions};
if (@attributions) {
print "\nAttributions for ".$_.":\n\n";
while (@attributions) {
my $key = shift @attributions;
my $value = shift @attributions;
print " - ".$key." (".$value.")\n";
}
if ($self->html) {
print $_->get_attributions_html;
print "\n";
} else {
print "\nNo attributions for ".$_."\n\n";
my @attributions = @{$_->get_attributions};
if (@attributions) {
print "\nAttributions for ".$_.":\n\n";
while (@attributions) {
my $key = shift @attributions;
my $value = shift @attributions;
print " - ".$key." (".$value.")\n";
}
} else {
print "\nNo attributions for ".$_."\n\n";
}
}

}
} else {
# TODO, load all and show all attributions
Expand Down
3 changes: 3 additions & 0 deletions lib/DDG/Meta/Attribution.pm
Expand Up @@ -42,6 +42,9 @@ sub apply_keywords {
}
return \@attribution_links;
});
$stash->add_symbol('&get_attributions_html', sub {
# TODO
});
$stash->add_symbol('&attribution', sub {
while (@_) {
my $type = shift;
Expand Down

0 comments on commit d2d76fe

Please sign in to comment.