Commits

Anonymous committed 10f86a9

function:
post articles by WLW

  • Participants
  • Parent commits 1e9b92c

Comments (0)

Files changed (5)

 	
 Cocoa XML-RPC Client
 	http://ditchnet.org/xmlrpc/
+
+RFC: MetaWeblog API
+	http://www.xmlrpc.com/metaWeblogApi

File src/info/mrchen/gae/blog/controller/admin/AdminArticleController.java

 	public void form() {
 	}
 
-	@RequestMapping(value = "/admin/Article-Del-{articleID}.do", method = RequestMethod.GET)
-	public String del(@PathVariable Long arÏticleID) {
-		articleService.del(arÏticleID);
+	@RequestMapping(value = "/admin/Article-Del-{articleID}.do")
+	public String del(@PathVariable Long articleID) {
+		articleService.del(articleID);
 		return "redirect:/admin/Article-List.do";
 	}
 

File src/info/mrchen/gae/blog/xmlrpc/handder/MetaWeblogHandler.java

 package info.mrchen.gae.blog.xmlrpc.handder;
 
+import info.mrchen.gae.blog.service.ArticleService;
 import info.mrchen.gae.blog.service.CategoryService;
 
 import java.util.HashMap;
 
 @Component
 public class MetaWeblogHandler implements XmlRpcHandler {
-	private static final Object CATEGORY_ID = null;
+	private static final String CATEGORY_ID = null;
+	private static final String POST_TITLE = "title";
+	private static final String POST_DESCRIPTION = "description";
+
 	@Autowired
 	CategoryService categoryService;
 
+	@Autowired
+	ArticleService articleService;
+
 	public Map[] getRecentPosts(String blogid, String username, String password, int numberOfPosts) {
 		Map[] map = new HashMap[] {};
 		return map;
 
 	public Map[] getCategories(String blogid, String username, String password) {
 		categoryService.get(0, Integer.MAX_VALUE);
-		
+
 		Map[] map = new HashMap[] { new HashMap() };
 		map[0].put(CATEGORY_ID, -1);
 		return map;
 	}
+
+	public String newPost(String blogid, String username, String password, HashMap<String, Object> content, boolean publish) {
+		String title = (String) content.get(POST_TITLE);
+		String description = (String) content.get(POST_DESCRIPTION);
+		Long newID = articleService.add(title, description, new String[] {});
+		return "" + newID;
+	}
+
+	public boolean editPost(String blogid, String username, String password, HashMap<String, Object> content, boolean publish) {
+		String title = (String) content.get(POST_TITLE);
+		String description = (String) content.get(POST_DESCRIPTION);
+		Long newID = articleService.add(title, description, new String[] {});
+		return true;
+	}
+
+	public HashMap<String, Object> getPost(String blogid, String username, String password) {
+		return null;
+	}
 }

File war/WEB-INF/views/Article-Show.jsp

 <table width="90%">
 	<tr>
 		<td><input type="button" value="Delete"
-			onclick="window.location='/Article-Del-${ARTICLE.id}.do'"></td>
+			onclick="window.location='/admin/Article-Del-${ARTICLE.id}.do'"></td>
 	</tr>
 	<tr>
 		<td>
 		<td>日期:${ARTICLE.date}</td>
 	</tr>
 	<tr>
-		<td>${ARTICLE.content}</td>
+		<td>${ARTICLE.content.value}</td>
 	</tr>
 </table>
 </body>

File war/WEB-INF/views/admin/Article-List.jsp

 <table border="1" width="90%">
 	<c:forEach items="${LIST}" var="a">
 		<tr>
-			<td><a href="/Article-Show-${a.id}.do" target="_blank">${a.title }</a></td>
+			<td><a href="/Article-Show-${a.id}.do" target="_blank">${a.title}&nbsp;</a></td>
 		</tr>
 	</c:forEach>
 </table>