summaryrefslogtreecommitdiff
path: root/IkiWiki/Setup/Standard.pm
blob: 0c4272286d13eace9ee24c393717b6edd93066b9 (plain)
  1. #!/usr/bin/perl
  2. # Standard ikiwiki setup module.
  3. # Parameters to import should be all the standard ikiwiki config stuff,
  4. # plus an array of wrappers to set up.
  5. use warnings;
  6. use strict;
  7. use IkiWiki::Wrapper;
  8. use IkiWiki::Render;
  9. package IkiWiki::Setup::Standard;
  10. sub import {
  11. IkiWiki::setup_standard(@_);
  12. }
  13. package IkiWiki;
  14. sub setup_standard {
  15. my %setup=%{$_[1]};
  16. $setup{plugin}=$config{plugin};
  17. if (exists $setup{add_plugins}) {
  18. push @{$setup{plugin}}, @{$setup{add_plugins}};
  19. delete $setup{add_plugins};
  20. }
  21. if (exists $setup{exclude}) {
  22. push @{$config{wiki_file_prune_regexps}}, $setup{exclude};
  23. }
  24. if (! $config{render} && (! $config{refresh} || $config{wrappers})) {
  25. debug(gettext("generating wrappers.."));
  26. my @wrappers=@{$setup{wrappers}};
  27. delete $setup{wrappers};
  28. my %startconfig=(%config);
  29. foreach my $wrapper (@wrappers) {
  30. %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
  31. checkconfig();
  32. gen_wrapper();
  33. }
  34. %config=(%startconfig);
  35. }
  36. foreach my $c (keys %setup) {
  37. if (defined $setup{$c}) {
  38. if (! ref $setup{$c}) {
  39. $config{$c}=possibly_foolish_untaint($setup{$c});
  40. }
  41. elsif (ref $setup{$c} eq 'ARRAY') {
  42. $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
  43. }
  44. elsif (ref $setup{$c} eq 'HASH') {
  45. foreach my $key (keys %{$setup{$c}}) {
  46. $config{$c}{$key}=possibly_foolish_untaint($setup{$c}{$key});
  47. }
  48. }
  49. }
  50. else {
  51. $config{$c}=undef;
  52. }
  53. }
  54. if ($config{render}) {
  55. commandline_render();
  56. }
  57. elsif (! $config{refresh}) {
  58. $config{rebuild}=1;
  59. debug(gettext("rebuilding wiki.."));
  60. }
  61. else {
  62. debug(gettext("refreshing wiki.."));
  63. }
  64. loadplugins();
  65. checkconfig();
  66. lockwiki();
  67. loadindex();
  68. refresh();
  69. debug(gettext("done"));
  70. saveindex();
  71. }
  72. 1