migrate3.pl 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. foreach my $post (@all) {
  26. next unless $post->{form} eq 'series.tx';
  27. $post->{tiled} = scalar(grep { $_ eq $post->{local_href} } qw{/files /audio /video /image /series /about});
  28. $search_info->add($post);
  29. }
  30. # Rebuild the index
  31. Trog::SQLite::TagIndex::build_index($search_info);
  32. Trog::SQLite::TagIndex::build_routes($search_info);
  33. # Add in the series
  34. my $series = [
  35. {
  36. "acls" => [],
  37. aliases => [],
  38. "callback" => "Trog::Routes::HTML::posts",
  39. method => 'GET',
  40. "data" => "All Posts",
  41. "href" => "/posts",
  42. "local_href" => "/posts",
  43. "preview" => "/img/sys/testpattern.jpg",
  44. "tags" => [qw{series}],
  45. visibility => 'unlisted',
  46. "title" => "All Posts",
  47. user => $user,
  48. form => 'series.tx',
  49. child_form => 'series.tx',
  50. aclname => 'posts',
  51. },
  52. ];
  53. #$search_info->add(@$series,@extra_series);