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