# HG changeset patch # User Paul Boddie # Date 1275866315 -7200 # Node ID 79d05f365e2bddabdb13310944c12b509440c5a7 # Parent 7750259374e6caf9b8b71c89cf04b15e8ea6cec8 Added methods to install actions, macros, general plugins and additional theme materials. diff -r 7750259374e6 -r 79d05f365e2b TO_DO.txt --- a/TO_DO.txt Wed May 26 02:32:05 2010 +0200 +++ b/TO_DO.txt Mon Jun 07 01:18:35 2010 +0200 @@ -5,3 +5,4 @@ Support Xapian search. Support OpenID and other authentication methods. Remember anonymous_session_lifetime for 1.8.x and cookie_lifetime for 1.9.x. +Support integration of additional theme material with themes. diff -r 7750259374e6 -r 79d05f365e2b moinsetup.py --- a/moinsetup.py Wed May 26 02:32:05 2010 +0200 +++ b/moinsetup.py Mon Jun 07 01:18:35 2010 +0200 @@ -2,6 +2,7 @@ from os.path import abspath, exists, extsep, isdir, join, normpath, split from getpass import getpass +from glob import glob import os import sys import shutil @@ -280,6 +281,13 @@ return "moin_static%s" % self.moin_version.replace(".", "") + def get_plugin_directory(self, plugin_type): + + "Return the directory for plugins of the given 'plugin_type'." + + data_dir = join(self.conf_dir, "data") + return join(data_dir, "plugin", plugin_type) + def limited_hosting(self): "Return whether limited Web hosting is being used." @@ -597,8 +605,7 @@ theme_name = split(theme_dir)[-1] theme_module = join(theme_dir, theme_name + extsep + "py") - data_dir = join(self.conf_dir, "data") - plugin_theme_dir = join(data_dir, "plugin", "theme") + plugin_theme_dir = self.get_plugin_directory("theme") # Copy the theme module. @@ -634,6 +641,68 @@ if exists(css_file_path): shutil.copy(css_file_path, target_dir) + def install_plugins(self, plugins_dir, plugin_type): + + """ + Install Wiki actions provided in the given 'plugins_dir' of the + specified 'plugin_type'. + """ + + plugin_target_dir = self.get_plugin_directory(plugin_type) + + # Copy the modules. + + status("Copying %s modules to %s..." % (plugin_type, plugin_target_dir)) + + for module in glob(join(plugins_dir, "*%spy" % extsep)): + shutil.copy(module, plugin_target_dir) + + def install_actions(self, actions_dir): + + "Install Wiki actions provided in the given 'actions_dir'." + + self.install_plugins(actions_dir, "action") + + def install_macros(self, macros_dir): + + "Install Wiki macros provided in the given 'macros_dir'." + + self.install_plugins(macros_dir, "macro") + + def install_theme_resources(self, theme_resources_dir, theme_name=None): + + """ + Install theme resources provided in the given 'theme_resources_dir'. If + a specific 'theme_name' is given, only that theme will be given the + specified resources. + """ + + # Copy the resources. + + filenames = theme_name and [theme_name] or os.listdir(self.htdocs_dir) + + for filename in filenames: + theme_dir = join(self.htdocs_dir, filename) + + if not exists(theme_dir) or not isdir(theme_dir): + continue + + copied = 0 + + for d in ("css", "img"): + source_dir = join(theme_resources_dir, d) + target_dir = join(theme_dir, d) + + if not exists(target_dir): + continue + + for resource in glob(join(source_dir, "*%s*" % extsep)): + shutil.copy(resource, target_dir) + copied = 1 + + if copied: + status("Copied theme resources into %s..." % theme_dir) + # Command line option syntax. syntax_description = " ... [ --method=METHOD [ ... ] ]"