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