summaryrefslogtreecommitdiff
path: root/IkiWiki/Setup/Standard.pm
blob: 25f038a064ac8ceab4333f0d93ba13b1203262f2 (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{disable_plugins}) {
  22. foreach my $plugin (@{$setup{disable_plugins}}) {
  23. $setup{plugin}=[grep { $_ ne $plugin } @{$setup{plugin}}];
  24. }
  25. delete $setup{disable_plugins};
  26. }
  27. debug("generating wrappers..");
  28. my @wrappers=@{$setup{wrappers}};
  29. delete $setup{wrappers};
  30. my %startconfig=(%config);
  31. foreach my $wrapper (@wrappers) {
  32. %config=(%startconfig, verbose => 0, %setup, %{$wrapper});
  33. checkconfig();
  34. gen_wrapper();
  35. }
  36. %config=(%startconfig);
  37. foreach my $c (keys %setup) {
  38. if (defined $setup{$c}) {
  39. if (! ref $setup{$c}) {
  40. $config{$c}=possibly_foolish_untaint($setup{$c});
  41. }
  42. elsif (ref $setup{$c} eq 'ARRAY') {
  43. $config{$c}=[map { possibly_foolish_untaint($_) } @{$setup{$c}}]
  44. }
  45. }
  46. else {
  47. $config{$c}=undef;
  48. }
  49. }
  50. if (! $config{refresh}) {
  51. $config{rebuild}=1;
  52. debug("rebuilding wiki..");
  53. }
  54. else {
  55. debug("refreshing wiki..");
  56. }
  57. checkconfig();
  58. lockwiki();
  59. loadindex();
  60. refresh();
  61. debug("done");
  62. saveindex();
  63. }
  64. 1