build_index.pl 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env perl
  2. use 5.040;
  3. use re '/aa';
  4. use lib 'lib';
  5. use Trog::Data;
  6. use Trog::Config;
  7. use Trog::SQLite::TagIndex;
  8. =head1 SYNOPSIS
  9. Rebuild the FlatFile model's tag index and route table, data/posts.db, from the
  10. posts in data/files.
  11. Use this to build the index after you import posts, otherwise it is not needed:
  12. tCMS keeps the index up to date as it writes posts, so the only time it gets out
  13. of step with the flat files is when something other than tCMS put them there.
  14. The SQLite model keeps its tags and routes with the posts, and has no separate
  15. index. On a site served from it, this says so and changes nothing.
  16. =head2 USAGE
  17. bin/build_index.pl
  18. Takes no arguments, and must be run from the tCMS root, as the data paths in
  19. the configuration are relative to it.
  20. Safe to re-run. It empties the index first and builds it again, in one
  21. transaction, so tags and routes that no post has any more are gone afterwards.
  22. =cut
  23. my $data = Trog::Data->new( Trog::Config::get() );
  24. if ( !$data->isa('Trog::Data::FlatFile') ) {
  25. say "This site serves from " . ref($data) . ", which has no separate index. Nothing to do.";
  26. exit 0;
  27. }
  28. Trog::SQLite::TagIndex::rebuild($data);