Dancer-SearchApp
    
    
  
  
  
view release on metacpan or search on metacpan
bin/index-ical.pl view on Meta::CPAN
    'config|c:s' => \my $config_file,
);
$config_file ||= 'ical-import.yml';
my $config = get_defaults(
    env      => \%ENV,
    config   => LoadFile($config_file),
    names => [
        ['elastic_search/index' => 'elastic_search/index' => 'SEARCHAPP_ES_INDEX', 'dancer-searchapp'],
        ['elastic_search/nodes' => 'elastic_search/nodes' => 'SEARCHAPP_ES_NODES', 'localhost:9200'],
        ['calendars' => 'calendars' => undef, []],
    ],
);
my $index_name = $config->{elastic_search}->{index};
my $node = $config->{elastic_search}->{nodes};
my $e = Search::Elasticsearch::Async->new(
    nodes => [
        $node
    ],
    #plugins => ['Langdetect'],
bin/index-ical.pl view on Meta::CPAN
});
$indices_done->recv;
warn "Index: $_\n" for keys %indices;
sub in_exclude_list {
    my( $item, $list ) = @_;
    scalar grep { $item =~ /$_/ } @$list
};
sub get_messages_from_calendar {
    my( $calendar )= @_;
    # Add rate-limiting counter here, so we don't flood the IMAP server
    #     with reconnect attempts
    my $c = $calendar->cal;
    my $en  = $c->entries;
    return
        grep {
            $_->ical_entry_type =~ /^VEVENT$/
        }    
        @{ $en };
};
sub ical_property {
    join ' ', map{$_->value } @{$_[0]->property($_[1])||[]}
bin/index-ical.pl view on Meta::CPAN
    <p>%s</p>
    <br>
HTML
    return {
        summary => ical_property($event,'summary'),
        organizer => ical_property($event,'organizer'),
        body => $body,
        html_content => $html_content,
        uid => ical_property($event,'uid'),
        url => ical_property($event,'url'),
        # better open the event in the calendar app!
        # But iCal doesn't support that
    }
}
my @calendars = @{ $config->{calendars} || [] };
if( @ARGV ) {
    @calendars = map { +{ calendar => $_, name => $_, exclude => [], } } @ARGV;
};
for my $calendar_def (@calendars) {
    my @messages;
    my $calendar_file = $calendar_def->{calendar};
    print "Reading $calendar_def->{name}\n";
    
    # Also support network access here?!
    my $caldav = Cal::DAV->new(
        user => $calendar_def->{user} || 'none',
        pass => $calendar_def->{pass} || 'none',
        url  => "file://$calendar_file",
        calname => $calendar_def->{name},
    );
    if( $calendar_file !~ m!://! ) {
        my $res = $caldav->parse(
            filename => $calendar_file,
        );
        if(! $res or ! $caldav->cal) {
            # Yes, parse errors result in ->cal being a Class::ReturnValue
            # object that is false but has the ->error_message method
            die "Couldn't parse calendar '$calendar_file': "
                . $caldav->cal->error_message;
        };
    };
    
    push @messages, map {
        # This doesn't handle attachments yet :-/
        ical_to_msg($_)
    } get_messages_from_calendar( $caldav );
    my $done = AnyEvent->condvar;
    print sprintf "Importing %d items\n", 0+@messages;
    collect(
        map {
            my $msg = $_;
            my $body = $msg->{body};
            my $lang = 'en';
            find_or_create_index($e, $index_name,$lang, 'file')
bin/index-ical.pl view on Meta::CPAN
                $e->index({
                        index   => $full_name,
                        type    => 'file', # or 'attachment' ?!
                        #id      => $msg->messageid,
                        id      => $msg->{uid},
                        # index bcc, cc, to, from
                        # content-type, ...
                        body    => { # "body" for non-bulk, "source" for bulk ...
                        #source    => {
                            url       => $msg->{url},
                            title     => $msg->{summary} . "($calendar_def->{name})",
                            title_suggest => $msg->{title_suggest}, # ugh
                            folder    => $calendar_def->{name},
                            from      => $msg->{organizer},
                            #to      => [ $msg->recipients ],
                            content => $msg->{html_content},
                            language => $lang,
                            #date    => $msg->date->strftime('%Y-%m-%d %H:%M:%S'),
                        }
                 });
               })->then(sub{ $|=1; print "."; }, sub {warn Dumper \@_});
       } @messages
    )->then(sub {
        print "$calendar_file done\n";
        $done->send;
    });
    
    $done->recv;
};
config-examples/ical-import.yml view on Meta::CPAN
elastic_search:
    index: dancer-searchapp
calendars:
    - calendar: "t/documents/timetable.gpw2016.ics"
      name: 'gpw2016'
      exclude:
         - ".git"
    - calendar: "t/documents/timetable.yapce2016.ics"
      name: 'ye2016'
      exclude:
         - ".git"
lib/Dancer/SearchApp/Installation.pod view on Meta::CPAN
  perl -Ilib -w bin/index-filesystem.pl -f t/documents
=head2 Indexing an IMAP account
Copy the config file from C< config-examples/imap-import.yml >
and edit the username, password, server and folders to index.
  perl -Ilib -w bin/index-imap.pl -c my-imap-import.yml
=head2 Indexing an ICAL calendar
  perl -Ilib -w bin/index-ical.pl t/documents/timetable.yapce2016.ics \
    -c config-examples/ical-import.yml
=cut
pod/Features.pod view on Meta::CPAN
Direct, local links to documents
Links / redirects to external https? URLs
Restrict results to mime_type
Tabs with implicit restrictions/hidden queries
Search mp3 files
Search ICal calendars like Google calendar(?) and Davical
=head2 Distribution
=head3 Docker
Docker container
=head1 User Introduction
=head2 First Start Experience
public/css/bootstrap-3/bootstrap.css view on Meta::CPAN
}
.glyphicon-eye-close:before {
  content: "\e106";
}
.glyphicon-warning-sign:before {
  content: "\e107";
}
.glyphicon-plane:before {
  content: "\e108";
}
.glyphicon-calendar:before {
  content: "\e109";
}
.glyphicon-random:before {
  content: "\e110";
}
.glyphicon-comment:before {
  content: "\e111";
}
.glyphicon-magnet:before {
  content: "\e112";
public/css/bootstrap-3/bootstrap.min.css view on Meta::CPAN
/*!
 * Bootstrap v3.3.6 (http://getbootstrap.com)
 * Copyright 2011-2015 Twitter, Inc.
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 *//*! normalize.css v3.0.3 | MIT License | github.com/necolas/normalize.css */html{font-family:sans-serif;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,na...
/*# sourceMappingURL=bootstrap.min.css.map */
( run in 0.574 second using v1.01-cache-2.11-cpan-c333fce770f )