1.1 --- a/moinsetup.py Wed May 26 02:32:05 2010 +0200
1.2 +++ b/moinsetup.py Mon Jun 07 01:18:35 2010 +0200
1.3 @@ -2,6 +2,7 @@
1.4
1.5 from os.path import abspath, exists, extsep, isdir, join, normpath, split
1.6 from getpass import getpass
1.7 +from glob import glob
1.8 import os
1.9 import sys
1.10 import shutil
1.11 @@ -280,6 +281,13 @@
1.12
1.13 return "moin_static%s" % self.moin_version.replace(".", "")
1.14
1.15 + def get_plugin_directory(self, plugin_type):
1.16 +
1.17 + "Return the directory for plugins of the given 'plugin_type'."
1.18 +
1.19 + data_dir = join(self.conf_dir, "data")
1.20 + return join(data_dir, "plugin", plugin_type)
1.21 +
1.22 def limited_hosting(self):
1.23
1.24 "Return whether limited Web hosting is being used."
1.25 @@ -597,8 +605,7 @@
1.26 theme_name = split(theme_dir)[-1]
1.27 theme_module = join(theme_dir, theme_name + extsep + "py")
1.28
1.29 - data_dir = join(self.conf_dir, "data")
1.30 - plugin_theme_dir = join(data_dir, "plugin", "theme")
1.31 + plugin_theme_dir = self.get_plugin_directory("theme")
1.32
1.33 # Copy the theme module.
1.34
1.35 @@ -634,6 +641,68 @@
1.36 if exists(css_file_path):
1.37 shutil.copy(css_file_path, target_dir)
1.38
1.39 + def install_plugins(self, plugins_dir, plugin_type):
1.40 +
1.41 + """
1.42 + Install Wiki actions provided in the given 'plugins_dir' of the
1.43 + specified 'plugin_type'.
1.44 + """
1.45 +
1.46 + plugin_target_dir = self.get_plugin_directory(plugin_type)
1.47 +
1.48 + # Copy the modules.
1.49 +
1.50 + status("Copying %s modules to %s..." % (plugin_type, plugin_target_dir))
1.51 +
1.52 + for module in glob(join(plugins_dir, "*%spy" % extsep)):
1.53 + shutil.copy(module, plugin_target_dir)
1.54 +
1.55 + def install_actions(self, actions_dir):
1.56 +
1.57 + "Install Wiki actions provided in the given 'actions_dir'."
1.58 +
1.59 + self.install_plugins(actions_dir, "action")
1.60 +
1.61 + def install_macros(self, macros_dir):
1.62 +
1.63 + "Install Wiki macros provided in the given 'macros_dir'."
1.64 +
1.65 + self.install_plugins(macros_dir, "macro")
1.66 +
1.67 + def install_theme_resources(self, theme_resources_dir, theme_name=None):
1.68 +
1.69 + """
1.70 + Install theme resources provided in the given 'theme_resources_dir'. If
1.71 + a specific 'theme_name' is given, only that theme will be given the
1.72 + specified resources.
1.73 + """
1.74 +
1.75 + # Copy the resources.
1.76 +
1.77 + filenames = theme_name and [theme_name] or os.listdir(self.htdocs_dir)
1.78 +
1.79 + for filename in filenames:
1.80 + theme_dir = join(self.htdocs_dir, filename)
1.81 +
1.82 + if not exists(theme_dir) or not isdir(theme_dir):
1.83 + continue
1.84 +
1.85 + copied = 0
1.86 +
1.87 + for d in ("css", "img"):
1.88 + source_dir = join(theme_resources_dir, d)
1.89 + target_dir = join(theme_dir, d)
1.90 +
1.91 + if not exists(target_dir):
1.92 + continue
1.93 +
1.94 + for resource in glob(join(source_dir, "*%s*" % extsep)):
1.95 + shutil.copy(resource, target_dir)
1.96 + copied = 1
1.97 +
1.98 + if copied:
1.99 + status("Copied theme resources into %s..." % theme_dir)
1.100 +
1.101 # Command line option syntax.
1.102
1.103 syntax_description = "<argument> ... [ --method=METHOD [ <method-argument> ... ] ]"