Skip to content
Snippets Groups Projects
Select Git revision
  • f1a3f7c616731a08797d7f18189b22513ffd879e
  • master default protected
  • replication_test
  • dev protected
  • release-1.10 protected
  • 556-usage-statistics
  • 553-semantic-recommendation-2
  • 553-semantic-recommendation
  • release-1.9 protected
  • 551-init-broker-service-permissions
  • 549-test-oai-pmh
  • 545-saving-multiple-times-breaks-pid-metadata
  • 499-standalone-compute-service-2
  • 539-load-tests
  • hotfix/helm-chart
  • luca_ba_new_interface
  • 534-bug-when-adding-access-to-user-that-is-not-registered-at-dashboard-service
  • release-1.8 protected
  • 533-integrate-semantic-recommendation
  • feature/openshift
  • 518-spark-doesn-t-map-the-headers-correct
  • v1.10.4 protected
  • v1.10.3 protected
  • v1.10.2 protected
  • v1.10.1 protected
  • v1.10.0-rc13 protected
  • v1.10.0-rc12 protected
  • v1.10.0-rc11 protected
  • v1.10.0-rc10 protected
  • v1.10.0-rc9 protected
  • v1.10.0-rc8 protected
  • v1.10.0-rc7 protected
  • v1.10.0-rc6 protected
  • v1.10.0-rc5 protected
  • v1.10.0-rc4 protected
  • v1.10.0-rc3 protected
  • v1.10.0-rc2 protected
  • v1.10.0rc1 protected
  • v1.10.0rc0 protected
  • v1.10.0 protected
  • v1.9.3 protected
41 results

system-databases-data.md

Blame
  • TOC.pm 2.27 KiB
    #!/usr/bin/perl
    
    package Tomboy::TOC;
    
    use strict;
    
    use Tomboy::Directory;
    
    sub new
    {
      my $class= shift;
    
      my $self= {};
      bless $self, $class;
      $self->set (@_);
    
      $self;
    }
    
    sub set
    {
      my $self= shift;
      my %par= @_;
    
      foreach my $par (keys %par) { $self->{$par}= $par{$par}; }
    }
    
    =head2 $toc->find($pattern [, $where])
    
    Search TOC for matching $pattern in field specified by $where; if $where is not defined, 'title' is used.
    
    Returns a list of matching TOC entries
    
    =cut
    
    sub find
    {
      my $self= shift;
      my $pattern= shift;
      my $where= shift || 'title';
    
    print "find: where=[$where] pattern=[$pattern]\n";
      my ($mode, $toc, $rows)= $self->load_toc();
      my @res;
      foreach my $row (@$rows)
      {
        next unless ($row->{$where} =~ m#$pattern#i);
        # print "row: ", main::Dumper ($row);
        push (@res, $row);
      }
      @res;
    }
    
    # Note: there is also a Tomboy::Directoy::scan_dir()
    sub scan_dir
    {
      my $self= shift;
    
    print main::Dumper ($self);
      my ($note_dir, $toc_file)= map { $self->{$_} } qw(note_dir toc_file);
    
      $note_dir=~ s#/+$##;
      my $tb_d= new Tomboy::Directory ();
      # print "tb_d: ", Dumper ($tb_d);
      print "scanning [$note_dir]\n";
    
      my ($mode, $toc, $rows)= $self->load_toc();
    
      my $toc_data= $tb_d->scan_dir ($note_dir, $rows, $mode);
      # TODO: if verbose or so print "toc_data: ", Dumper ($toc_data);