summaryrefslogtreecommitdiff
path: root/lib/Bookmarks/C/Main.pm
blob: b25ef9aae22ddba349501604d876bd8057b649f3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package Bookmarks::C::Main; 
 
use strict;
use base 'Catalyst::Base';
 
=head1 NAME
 
Bookmarks::C::Main - Catalyst component
 
=head1 SYNOPSIS
 
See L<Bookmarks>
 
=head1 DESCRIPTION
 
Catalyst component.
 
=head1 METHODS
 
=over 4
 
=item default
 
=cut
 
sub tags : Global {
    my ( $self$c ) = @_;
    $c->stash->{template}='tags';
    $c->stash->{tags}=[Bookmarks::M::DB::Tags->get_all_tags_by_popularity()];
}
 
sub tag : Regex('^tag/(.*)$') {
    my ( $self$c ) = @_;
 
    my $tagname=$c->req->snippets->[0];
    my ($tag)=Bookmarks::M::DB::Tags->search({name=>$tagname});
    if (!defined $tag) {
        $c->stash->{tagname}=$tagname;
        $c->stash->{template}='notag';
    }
    else {
        my @links=$tag->ordered_links();
        $c->stash->{tag}=$tag;
        $c->stash->{links}=[@links];
        $c->stash->{template}='links';
    }
}
 
sub icon : Global {
    my ( $self$c ) = @_;
 
    my $link=Bookmarks::M::DB::Links->retrieve($c->req->param('link'));
    if ($link->get_icon()) {
        $c->res->content_type('image/x-icon');
        $c->res->body($link->get_icon());
    }
    else {
        $c->res->status(404);
        $c->res->body('nonce');
    }
}
 
=back
 
 
=head1 AUTHOR
 
A clever guy
 
=head1 LICENSE
 
This library is free software . You can redistribute it and/or modify
it under the same terms as perl itself.
 
=cut
 
1;