Fixed Konfigurationsprobleme bei themedirector, download default theme files nun möglich.

git-svn-id: https://svn.libreccm.org/ccm/trunk@1663 8810af33-2d31-482b-a856-94f89814c4df
master
pb 2012-05-18 00:16:03 +00:00
parent 95cfddd23e
commit 56e687b58e
11 changed files with 73 additions and 41 deletions

View File

@ -117,10 +117,11 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-bundle.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws-generic themedirector.default_theme_path=themes/static/aplaws-generic
themedirector.file_extensions=bmp css gif jpeg jpg js png xml xsl
# ccm-bundle (Loader only) # ccm-bundle (Loader only)

View File

@ -118,10 +118,11 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-bundle.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws-generic themedirector.default_theme_path=themes/static/aplaws-generic
themedirector.file_extensions=bmp css gif jpeg jpg js png xml xsl
# ccm-bundle (Loader only) # ccm-bundle (Loader only)

View File

@ -133,8 +133,10 @@ com.arsdigita.london.subsite.root_category_picker=com.arsdigita.london.terms.ui.
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_path=themes/static/aplaws # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-ldn-aplaws.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws themedirector.default_theme_path=themes/static/aplaws
# ccm-auth-http application # ccm-auth-http application

View File

@ -133,8 +133,10 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-ldn-aplaws.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws themedirector.default_theme_path=themes/static/aplaws
# ccm-auth-http application # ccm-auth-http application

View File

@ -132,8 +132,10 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-ldn-aplaws.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws themedirector.default_theme_path=themes/static/aplaws
# ccm-auth-http application # ccm-auth-http application

View File

@ -126,8 +126,10 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-ldn-aplaws.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws themedirector.default_theme_path=themes/static/aplaws
# ccm-auth-http application # ccm-auth-http application

View File

@ -131,8 +131,10 @@ com.arsdigita.subsite.root_category_picker=com.arsdigita.london.terms.ui.RootCat
# ccm-themedirector application # ccm-themedirector application
themedirector.default_theme_context= # Required to point to the package containing the theme to copy from when creating
# themedirector.default_theme_manifest=ccm-zes-aplaws.web.mf # a new theme! (In addition to default_theme_path. Otherwise no files are copied!
themedirector.default_theme_manifest=ccm-ldn-aplaws.web.mf
# Required to denote the dir containing the default theme!
themedirector.default_theme_path=themes/static/aplaws themedirector.default_theme_path=themes/static/aplaws
# ccm-auth-http application # ccm-auth-http application

View File

@ -64,13 +64,20 @@ public class ThemeDirectorConfig extends AbstractConfig {
} }
// set of configuration parameters // set of configuration parameters
// /////////////////////////////////////////////////////////////////
/** Directory that all of the default themes are copied from. */ /** Directory that all of the default themes are copied from. */
private final Parameter m_defaultThemePath = private final Parameter m_defaultThemePath =
new StringParameter new StringParameter
("themedirector.default_theme_path", ("themedirector.default_theme_path",
Parameter.OPTIONAL, "/themes/master/"); Parameter.OPTIONAL, "/themes/master/");
/** Servlet context path containing the theme. */ /** Servlet context path containing the default theme.
Previously ccm-themedirector used to be installed in its own
web context. In this case the appropriate web context should
be specified.
Currently, it is installed as part of the main application,
therefore it is empty by default. */
private final Parameter m_defaultThemeContext = private final Parameter m_defaultThemeContext =
new StringParameter new StringParameter
("themedirector.default_theme_context", ("themedirector.default_theme_context",
@ -79,7 +86,7 @@ public class ThemeDirectorConfig extends AbstractConfig {
/** File containing the default themes directory. Used in conjuntion with /** File containing the default themes directory. Used in conjuntion with
com.arsdigita.themedirectory.default_directory_filter to dictate the com.arsdigita.themedirectory.default_directory_filter to dictate the
final default directoroy. */ final default directory. */
private final Parameter m_defaultThemeManifest = private final Parameter m_defaultThemeManifest =
new StringParameter new StringParameter
("themedirector.default_theme_manifest", ("themedirector.default_theme_manifest",
@ -193,7 +200,7 @@ public class ThemeDirectorConfig extends AbstractConfig {
} }
/** /**
* This returns the name of the servlet context containing * This returns the name of the servlet context containing
* the default theme * the default theme
*/ */
public String getDefaultThemeContext() { public String getDefaultThemeContext() {

View File

@ -137,30 +137,30 @@ public class ThemeDownloadServlet extends BaseServlet implements ThemeDirectorCo
DispatcherHelper.maybeCacheDisable(sresp); DispatcherHelper.maybeCacheDisable(sresp);
sresp.setContentType("application/zip; charset=UTF-8"); sresp.setContentType("application/zip; charset=UTF-8");
// The WebAppRoot should be something like this: // Want the path in the filesystem to webcontext of this application
// /var/ccm-devel/web/<username>/<projectname>/webapps/ccm-ldn-theme; // (i.e. context root / document root)
// and we actually want the webapps directory File applicationRoot = new File(Web.getServletContext().getRealPath("/"));
File currentRoot = new File(Web.getServletContext().getRealPath("/"));
File webapps = currentRoot.getParentFile();
// if we have a Theme, we send back either prod or dev, depending on
// the url. If we don't have a theme, then we return everything.
if (theme != null) { if (theme != null) {
File downloadFiles = null; // if we have a Theme, we send back either prod or dev, depending on
String prefix = null; // the url.
File downloadFiles = null; // Path to the actual theme to download
String prefix = null; // Wether devel or prod
// If "themes-prod" is ever moved to a different directory, // If "themes-prod" is ever moved to a different directory,
// we could then get rid of the "type" argument (see below in // we could then get rid of the "type" argument (see below in
// DirectoryFilter) // DirectoryFilter)
String type = null; String type = null;
// Determine the path, dependet of devel / prod
if (sreq.getPathInfo().indexOf("/" + PUBLISHED_PREFIX) > -1) { if (sreq.getPathInfo().indexOf("/" + PUBLISHED_PREFIX) > -1) {
prefix = PUBLISHED_PREFIX; prefix = PUBLISHED_PREFIX;
downloadFiles = new File(currentRoot, PROD_THEMES_BASE_DIR); downloadFiles = new File(applicationRoot, PROD_THEMES_BASE_DIR);
type = PROD_DIR_STUB; type = PROD_DIR_STUB;
} else { } else {
downloadFiles = new File(currentRoot, DEV_THEMES_BASE_DIR); downloadFiles = new File(applicationRoot, DEV_THEMES_BASE_DIR);
prefix = DEVELOPMENT_PREFIX; prefix = DEVELOPMENT_PREFIX;
type = DEV_DIR_STUB; type = DEV_DIR_STUB;
} }
sresp.setHeader("Content-Disposition", sresp.setHeader("Content-Disposition",
"attachment; filename=\"" + prefix + theme.getURL() + "attachment; filename=\"" + prefix + theme.getURL() +
".zip\""); ".zip\"");
@ -170,12 +170,19 @@ public class ThemeDownloadServlet extends BaseServlet implements ThemeDirectorCo
Files.listFilesInTree(downloadFiles, Files.listFilesInTree(downloadFiles,
new DirectoryFilter(theme.getURL(), type)), new DirectoryFilter(theme.getURL(), type)),
downloadFiles); downloadFiles);
} else if (theme == null) { } else if (theme == null) {
// we have to create our own config becuase no other // If we don't have a theme, then we return everything (i.e. the
// web tree of each module installed).
// Get a list of all installed packages by querying
// registry.properties from registry.
// We have to create our own config instance because no other
// classes provide access to one // classes provide access to one
RegistryConfig rc = new RegistryConfig(); RegistryConfig rc = new RegistryConfig();
rc.load(); rc.load();
String[] packages = rc.getPackages(); String[] packages = rc.getPackages();
ClassLoader loader = Thread.currentThread().getContextClassLoader(); ClassLoader loader = Thread.currentThread().getContextClassLoader();
sresp.setHeader("Content-Disposition", sresp.setHeader("Content-Disposition",
@ -191,18 +198,16 @@ public class ThemeDownloadServlet extends BaseServlet implements ThemeDirectorCo
new ZipWriterManifestReader(is, out, current, new ZipWriterManifestReader(is, out, current,
packages[i]); packages[i]);
reader.setFileName(packages[i]); reader.setFileName(packages[i]);
reader.processFile(); reader.processFile(); // 2012-05 (PB): Doesn't work!
} else { } else {
s_log.warn("Unable to open up resource " + current); s_log.warn("Unable to open up resource " + current);
} }
} }
// Special case add the auto-generated XSL fiel for content types // Special case add the auto-generated XSL file for content types
Iterator paths = ContentType.getXSLFileURLs(); Iterator paths = ContentType.getXSLFileURLs();
out.putNextEntry(new ZipEntry("waf-xsl/themes/servlet/content-type/index.xsl")); out.putNextEntry(new ZipEntry("waf-xsl/themes/servlet/content-type/index.xsl"));
IO.copy(multiplexXSLFiles(paths), IO.copy(multiplexXSLFiles(paths), out);
out);
out.close(); out.close();
} }

View File

@ -110,13 +110,20 @@ public class ThemeControlPanel extends SelectionPanel implements ThemeDirectorCo
getBody().connect(addThemeLink, m_themeForm); getBody().connect(addThemeLink, m_themeForm);
addAction(addThemeLink, ActionGroup.ADD); addAction(addThemeLink, ActionGroup.ADD);
getBody().add(new Label(GlobalizationUtil.globalize("theme.download_default_base_styles"))); // add the "Download default base styxle" form
// PB 2012-05: Download in ThemeDownloadServlet doesn't work, commented
// out for now. Not useful anyway because it downloads web tree of every
// package installed, probably filtered by theme file extensions (xsl,
// css, etc).
/*
getBody().add(new Label(GlobalizationUtil
.globalize("theme.download_default_base_styles")));
Link downloadFilesLink = new Link(new Label(GlobalizationUtil.globalize Link downloadFilesLink = new Link(new Label(GlobalizationUtil.globalize
("theme.download_default_base_styles")), ("theme.download_default_base_styles")),
"download/" + ALL_STYLES_ZIP_NAME); "download/" + ALL_STYLES_ZIP_NAME);
addAction(downloadFilesLink, ActionGroup.ADD); addAction(downloadFilesLink, ActionGroup.ADD);
*/
// add the "Select Standard Theme" form
Form defaultThemeForm = createDefaultThemeForm(); Form defaultThemeForm = createDefaultThemeForm();
addAction( defaultThemeForm ); addAction( defaultThemeForm );
} }

View File

@ -74,10 +74,11 @@ public class ThemeXSLParameterGenerator implements XSLParameterGenerator,
} }
if (themeURL != null) { if (themeURL != null) {
// modified as ccm-ldn-theme is no longer installed in its own context // modified as ccm-themedirector (previously ccm-ldn-theme) is
// no longer installed in its own context
// return "/" + WEB_APP_NAME + "/" + THEMES_DIR + "/" + // return "/" + WEB_APP_NAME + "/" + THEMES_DIR + "/" +
// If we want to install it as a separate web application again we // If we want to install it as a separate web application again we
// should find a way to determin the name from a central configuration // should find a way to determine the name from a central configuration
return "/" + THEMES_DIR + "/" + return "/" + THEMES_DIR + "/" +
Web.getContext().getRequestURL().getContextPath() + Web.getContext().getRequestURL().getContextPath() +
baseDir + themeURL; baseDir + themeURL;