* Added Story.add() method as counterpart to Story.remove() and to establish kind of internal API
* Rewrote external API (Api prototype) reducing redundant code by calling Story.add() method
This commit is contained in:
parent
fe159c3112
commit
2ca26e4f28
7 changed files with 70 additions and 53 deletions
|
@ -19,13 +19,13 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $Author$
|
||||
// $Date$
|
||||
// $URL$
|
||||
|
||||
/**
|
||||
* @fileOverview Methods that implement Blogger's XML-RPC API.
|
||||
* See http://www.blogger.com/developers/api/1_docs/ for further details.
|
||||
* See http://goo.gl/u8lZZ for further details.
|
||||
* The blogger.getTemplate and blogger.setTemplate methods are not supported
|
||||
*/
|
||||
|
||||
|
@ -185,16 +185,16 @@ Api.blogger.newPost = function(appKey, id, name, password, content, publish) {
|
|||
}
|
||||
|
||||
var parts = Api.blogger._getContentParts(content);
|
||||
var story = new Story;
|
||||
story.site = site;
|
||||
story.creator = user;
|
||||
story.update({
|
||||
|
||||
var story = Story.add(site, {
|
||||
title: parts.title,
|
||||
text: parts.text,
|
||||
status: publish ? Story.PUBLIC : Story.CLOSED,
|
||||
mode: Story.FEATURED
|
||||
});
|
||||
site.stories.add(story);
|
||||
|
||||
story.site = site;
|
||||
story.creator = user;
|
||||
return story._id;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
//
|
||||
// The Antville Project
|
||||
// http://code.google.com/p/antville
|
||||
//
|
||||
// Copyright 2001-2007 by The Antville People
|
||||
// Copyright 2007-2011 by Tobi Schäfer.
|
||||
//
|
||||
// Copyright 2001–2007 Robert Gaggl, Hannes Wallnöfer, Tobi Schäfer,
|
||||
// Matthias & Michael Platzer, Christoph Lincke.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the ``License'');
|
||||
// you may not use this file except in compliance with the License.
|
||||
|
@ -17,10 +19,9 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $Author$
|
||||
// $Date$
|
||||
// $URL$
|
||||
//
|
||||
|
||||
/**
|
||||
* @fileOverview Methods that implement the MetaWeblog XML-RPC API.
|
||||
|
@ -50,7 +51,8 @@ Api.metaWeblog._getStruct = function(story) {
|
|||
mt_allow_comments: story.commentMode === Story.OPEN ? 1 : 0,
|
||||
mt_allow_pings: 0,
|
||||
mt_convert_breaks: null,
|
||||
mt_keywords: null
|
||||
mt_keywords: null,
|
||||
postSource: story.getMetadata('postSource')
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,11 +122,8 @@ Api.metaWeblog.newPost = function(id, name, password, content, publish) {
|
|||
throw Error("Permission denied for user " + user.name +
|
||||
" to add a post to site " + site.name);
|
||||
}
|
||||
|
||||
var story = new Story;
|
||||
story.site = site;
|
||||
story.creator = user;
|
||||
story.update({
|
||||
|
||||
var story = Story.add(site.stories, {
|
||||
title: content.title,
|
||||
text: content.description,
|
||||
status: publish ? Story.PUBLIC : Story.CLOSED,
|
||||
|
@ -132,7 +131,10 @@ Api.metaWeblog.newPost = function(id, name, password, content, publish) {
|
|||
commentMode: content.discussions === 0 ? Story.CLOSED : Story.OPEN,
|
||||
tags: content.categories
|
||||
});
|
||||
site.stories.add(story);
|
||||
|
||||
story.site = site;
|
||||
story.creator = user;
|
||||
story.setMetadata('postSource', content.postSource);
|
||||
return story._id;
|
||||
}
|
||||
|
||||
|
@ -165,6 +167,8 @@ Api.metaWeblog.editPost = function(id, name, password, content, publish) {
|
|||
Story.OPEN : Story.CLOSED,
|
||||
tags: content.categories
|
||||
});
|
||||
|
||||
story.setMetadata('postSource', content.postSource);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,13 @@
|
|||
// limitations under the License.
|
||||
//
|
||||
// $Revision$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $Author$
|
||||
// $Date$
|
||||
// $URL$
|
||||
|
||||
/**
|
||||
* @fileOverview Methods that implement Movable Type's XML-RPC API.
|
||||
* See http://www.sixapart.com/developers/xmlrpc/movable_type_api for details.
|
||||
* See http://www.sixapart.com/pronet/breese/xmlrpc/movable_type_api/ for details.
|
||||
*/
|
||||
|
||||
/** @namespace */
|
||||
|
@ -122,7 +122,7 @@ Api.mt.getPostCategories = function(id, name, password) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// FIXME: What kind of stupid API is this?
|
||||
// FIXME: How do I post a new story?
|
||||
/**
|
||||
*
|
||||
* @param {Number} id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue