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