migrate3.pl 1.8 KB

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