svn commit: r1078829 - in /lenya/branches/BRANCH_2_1_X/src: java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf webapp/lenya/module-resources.xmap
[email protected] Mon, 07 Mar 2011 16:17:15 -0000
| Newsgroups | gmane.comp.cms.lenya.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: andreas
Date: Mon Mar 7 16:17:15 2011
New Revision: 1078829
URL: http://svn.apache.org/viewvc?rev=1078829&view=rev
Log:
Add last-modified header for CSS files.
Added:
lenya/branches/BRANCH_2_1_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf
Modified:
lenya/branches/BRANCH_2_1_X/src/webapp/lenya/module-resources.xmap
Added: lenya/branches/BRANCH_2_1_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java?rev=1078829&view=auto
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java (added)
+++ lenya/branches/BRANCH_2_1_X/src/java/org/apache/lenya/cms/cocoon/components/modules/input/LastModifiedModule.java Mon Mar 7 16:17:15 2011
@@ -0,0 +1,50 @@
+package org.apache.lenya.cms.cocoon.components.modules.input;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.source.SourceResolver;
+
+public class LastModifiedModule extends AbstractInputModule implements Serviceable {
+
+ private ServiceManager manager;
+ protected static final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
+
+ @Override
+ public Object getAttribute(String name, Configuration modeConf,
+ @SuppressWarnings("rawtypes") Map objectModel) throws ConfigurationException {
+
+ SourceResolver resolver = null;
+ try {
+ resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
+ Source source = null;
+ try {
+ source = resolver.resolveURI(name);
+ return format.format(new Date(source.getLastModified()));
+ } finally {
+ if (source != null) {
+ resolver.release(source);
+ }
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (resolver != null) {
+ this.manager.release(resolver);
+ }
+ }
+ }
+
+ @Override
+ public void service(ServiceManager manager) throws ServiceException {
+ this.manager = manager;
+ }
+
+}
Added: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf?rev=1078829&view=auto
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf (added)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/config/cocoon-xconf/input-modules/last-modified.xconf Mon Mar 7 16:17:15 2011
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+ <xconf xpath="/cocoon/input-modules" unless="/cocoon/input-modules/component-instance[@name = 'last-modified']">
+ <component-instance name="last-modified" logger="core.modules.input" class="org.apache.lenya.cms.cocoon.components.modules.input.LastModifiedModule">
+ <src-pattern>yyyy-MM-dd HH:mm:ss Z</src-pattern>
+ <pattern>EEE, d MMM yyyy HH:mm:ss Z</pattern>
+ <locale>en_US</locale>
+ </component-instance>
+ </xconf>
Modified: lenya/branches/BRANCH_2_1_X/src/webapp/lenya/module-resources.xmap
URL: http://svn.apache.org/viewvc/lenya/branches/BRANCH_2_1_X/src/webapp/lenya/module-resources.xmap?rev=1078829&r1=1078828&r2=1078829&view=diff
==============================================================================
--- lenya/branches/BRANCH_2_1_X/src/webapp/lenya/module-resources.xmap (original)
+++ lenya/branches/BRANCH_2_1_X/src/webapp/lenya/module-resources.xmap Mon Mar 7 16:17:15 2011
@@ -33,6 +33,9 @@
<map:resources>
<map:resource name="proxy-css">
+ <map:act type="set-header">
+ <map:parameter name="Last-Modified" value="{date-iso8601-rfc822:{last-modified:{url}}}"/>
+ </map:act>
<map:generate type="text" src="{url}.css"/>
<map:transform type="pattern" src="fallback://lenya/chaperon/grammars/link.xlex"/>
<map:transform src="fallback://lenya/chaperon/stylesheets/pattern-to-link.xsl"/>