roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ganes...@apache.org
Subject svn commit: r768483 - in /roller/branches/roller_mediablogging/apps/weblogger: src/java/org/apache/roller/weblogger/ui/struts2/editor/ web/WEB-INF/classes/ web/WEB-INF/jsps/editor/
Date Sat, 25 Apr 2009 07:05:17 GMT
Author: ganeshmb
Date: Sat Apr 25 07:05:16 2009
New Revision: 768483

URL: http://svn.apache.org/viewvc?rev=768483&view=rev
Log:
Added logic to navigate to weblog creation page with a link to media file auto-populated.

Added:
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
Modified:
    roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml
    roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp

Added: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java?rev=768483&view=auto
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
(added)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/EntryAddWithMediaFile.java
Sat Apr 25 07:05:16 2009
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  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.  For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+
+package org.apache.roller.weblogger.ui.struts2.editor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.roller.weblogger.business.MediaFileManager;
+import org.apache.roller.weblogger.business.WebloggerFactory;
+import org.apache.roller.weblogger.pojos.MediaFile;
+import org.apache.struts2.interceptor.validation.SkipValidation;
+
+/**
+ * Prepares creating a new weblog entry with a pointer to a media file.
+ */
+@SuppressWarnings("serial")
+public class EntryAddWithMediaFile extends MediaFileBase {
+    private static Log log = LogFactory.getLog(EntryAddWithMediaFile.class);
+    
+    private String mediaFileId; 
+
+    // bean for managing form data
+    private EntryBean bean = new EntryBean();
+
+    public EntryAddWithMediaFile() {
+    }
+    
+    /**
+     * Prepare bean for creating a new weblog entry with a link to a media file.
+     * 
+     * @return String The result of the action.
+     */
+    @SkipValidation
+    public String execute() {
+    	MediaFileManager manager = WebloggerFactory.getWeblogger().getMediaFileManager();
+		try {
+			MediaFile mediaFile = manager.getMediaFile(this.mediaFileId);
+			String link;
+			if (mediaFile.isImageFile()) {
+				link = "<img src='<url>' alt='<name>' width='<width>' height='<height>'
/>";
+				link = link
+				.replace("<url>", getMediaFileURL(mediaFile))
+				.replace("<name>", mediaFile.getName())
+				.replace("<width>", "")
+				.replace("<height>", "");
+			}
+			else {
+				link = "<a href='<url>'><name></a>";
+				link = link
+				.replace("<url>", getMediaFileURL(mediaFile))
+				.replace("<name>", mediaFile.getName());
+			}
+			bean.setText(link);
+		} catch (Exception e) {
+            log.error("Error while constructing media file link for new entry", e);
+		}
+		return SUCCESS;
+    }
+
+	public String getMediaFileId() {
+		return mediaFileId;
+	}
+
+	public void setMediaFileId(String mediaFileId) {
+		this.mediaFileId = mediaFileId;
+	}
+
+	public EntryBean getBean() {
+		return bean;
+	}
+
+	public void setBean(EntryBean bean) {
+		this.bean = bean;
+	}
+    
+}

Modified: roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java?rev=768483&r1=768482&r2=768483&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/src/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
Sat Apr 25 07:05:16 2009
@@ -126,6 +126,15 @@
             log.error("Error looking up media file directories", ex);
         }
     }
+    
+    /**
+     * Constructs the external URL for a given media file
+     * @param mediaFile
+     * @return
+     */
+    protected String getMediaFileURL(MediaFile mediaFile) {
+    	return getSiteURL() + "/roller-ui/rendering/media-resources/" + mediaFile.getId();
+    }
 
 	public String[] getSelectedMediaFiles() {
 		return selectedMediaFiles;

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml?rev=768483&r1=768482&r2=768483&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml (original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/classes/struts.xml Sat
Apr 25 07:05:16 2009
@@ -217,6 +217,12 @@
             <result name="input" type="tiles">.EntryAdd</result>
             <result name="success" type="chain">entryEdit</result>
         </action>
+        
+        <action name="entryAddWithMediaFile!*" method="{1}"
+                class="org.apache.roller.weblogger.ui.struts2.editor.EntryAddWithMediaFile">
+            <result name="success" type="chain">entryAdd</result>
+        </action>
+        
 
         <action name="mediaFileAdd!*" method="{1}"
                 class="org.apache.roller.weblogger.ui.struts2.editor.MediaFileAdd">

Modified: roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
URL: http://svn.apache.org/viewvc/roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp?rev=768483&r1=768482&r2=768483&view=diff
==============================================================================
--- roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
(original)
+++ roller/branches/roller_mediablogging/apps/weblogger/web/WEB-INF/jsps/editor/MediaFileAddSuccess.jsp
Sat Apr 25 07:05:16 2009
@@ -42,7 +42,14 @@
 </s:a>
 
 <div style="margin-top:20px;text-decoration:underline">
-<a href="#">Create a blog post out of <s:property value="bean.name" /></a><br/>
+
+<s:url id="createBlogPostURL" action="entryAddWithMediaFile">
+    <s:param name="weblog" value="actionWeblog.handle" />
+    <s:param name="mediaFileId" value="%{bean.id}" />
+</s:url>
+
+<s:a href="%{createBlogPostURL}">Create a blog post out of <s:property value="bean.name"
/></s:a>
+<br/>
 
 <s:url id="mediaFileAddURL" action="mediaFileAdd">
     <s:param name="weblog" value="%{actionWeblog.handle}" />



Mime
View raw message