migrate3.pl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/perl
  2. use strict;
  3. use warnings;
  4. # Migrate early on tcms3 flatfile sites to 'all posts are series code' (august 2021) code
  5. use FindBin;
  6. use lib "$FindBin::Bin/../lib";
  7. use Trog::Config;
  8. use Trog::Data;
  9. use List::Util;
  10. use UUID::Tiny;
  11. use Trog::SQLite;
  12. use Trog::SQLite::TagIndex;
  13. # Kill the post index
  14. unlink "$FindBin::Bin/../data/posts.db";
  15. $ENV{NOHUP} = 1;
  16. sub uuid { return UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_V1, UUID::Tiny::UUID_NS_DNS); }
  17. # Modify these variables to suit your installation.
  18. my $user = 'george';
  19. my @extra_series = (
  20. );
  21. my $conf = Trog::Config::get();
  22. my $search_info = Trog::Data->new($conf);
  23. my @all = $search_info->get( raw => 1, limit => 0 );
  24. #TODO add in the various things we need to data
  25. # Rebuild the index
  26. Trog::SQLite::TagIndex::build_index($search_info);
  27. Trog::SQLite::TagIndex::build_routes($search_info);
  28. # Add in the series
  29. my $series = [
  30. {
  31. "acls" => [],
  32. aliases => [],
  33. "callback" => "Trog::Routes::HTML::posts",
  34. method => 'GET',
  35. "data" => "All Posts",
  36. "href" => "/posts",
  37. "local_href" => "/posts",
  38. "preview" => "/img/sys/testpattern.jpg",
  39. "tags" => [qw{series}],
  40. visibility => 'unlisted',
  41. "title" => "All Posts",
  42. user => $user,
  43. form => 'series.tx',
  44. child_form => 'series.tx',
  45. aclname => 'posts',
  46. },
  47. ];
  48. $search_info->add(@$series,@extra_series);