- made date properties on blg:releaseDetails aspect mandatory

- added webscripts for different blog filters
- adapted frontend for new filters

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9657 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Michael Ru
2008-07-04 17:17:50 +00:00
parent 0cf078cc21
commit 30e3243e2a
15 changed files with 260 additions and 15 deletions

View File

@@ -0,0 +1,10 @@
<webscript>
<shortname>Blog posts</shortname>
<description>Get all posts for a blog</description>
<url>/blog/site/{site}/{container}/{path}/posts/mydrafts</url>
<url>/blog/site/{site}/{container}/posts/mydrafts</url>
<url>/blog/node/{store_type}/{store_id}/{id}/posts/mydrafts</url>
<format default="json"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,43 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">
/**
* Fetches all posts of the given blog
*/
function getBlogPostList(node, index, count)
{
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\" " +
"+PATH:\"" + node.qnamePath + "/*\" ";
// add the drafts part
luceneQuery += "-ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
"+@cm\\:creator:\"" + person.properties.userName + "\"";
var sortAttribute = "@{http://www.alfresco.org/model/content/1.0}created";
// get the data
return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
}
function main()
{
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
return;
}
// process additional parameters
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
// fetch and assign the data
model.data = getBlogPostList(node, index, count);
model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
}
main();

View File

@@ -0,0 +1,5 @@
<#import "../blogpost.lib.ftl" as blogpostLib/>
<#import "../../generic-paged-results.lib.ftl" as gen/>
<@gen.pagedResults data=data ; item>
<@blogpostLib.blogpostJSON item=item />
</@gen.pagedResults>

View File

@@ -0,0 +1,10 @@
<webscript>
<shortname>Blog posts</shortname>
<description>Get all posts for a blog</description>
<url>/blog/site/{site}/{container}/{path}/posts/mypublished</url>
<url>/blog/site/{site}/{container}/posts/mypublished</url>
<url>/blog/node/{store_type}/{store_id}/{id}/posts/mypublished</url>
<format default="json"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,44 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">
/**
* Fetches all posts of the given blog
*/
function getBlogPostList(node, index, count)
{
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
" +PATH:\"" + node.qnamePath + "/*\" ";
// add the drafts part
luceneQuery += "+ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
"+@cm\\:creator:\"" + person.properties.userName + "\"";
var sortAttribute = "@{http://www.alfresco.org/model/blogintegration/1.0}released";
// get the data
return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
}
function main()
{
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
return;
}
// process additional parameters
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
// fetch and assign the data
model.data = getBlogPostList(node, index, count);
model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
}
main();

View File

@@ -0,0 +1,5 @@
<#import "../blogpost.lib.ftl" as blogpostLib/>
<#import "../../generic-paged-results.lib.ftl" as gen/>
<@gen.pagedResults data=data ; item>
<@blogpostLib.blogpostJSON item=item />
</@gen.pagedResults>

View File

@@ -0,0 +1,10 @@
<webscript>
<shortname>Blog posts</shortname>
<description>Get all posts for a blog</description>
<url>/blog/site/{site}/{container}/{path}/posts/new?numdays={numdays}</url>
<url>/blog/site/{site}/{container}/posts/new?numdays={numdays}</url>
<url>/blog/node/{store_type}/{store_id}/{id}/posts/new?numdays={numdays}</url>
<format default="json"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,46 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">
const DEFAULT_NUM_DAYS = 7;
/**
* Fetches all posts of the given blog
*/
function getBlogPostList(node, numdays, index, count)
{
var fromDate = getTodayMinusXDays(numdays);
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
" +PATH:\"" + node.qnamePath + "/*\" " +
" +ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
getCreationDateRangeQuery(fromDate, null);
var sortAttribute = "@{http://www.alfresco.org/model/content/1.0}created";
// get the data
return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
}
function main()
{
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
return;
}
// process additional parameters
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
var numdays = args["numdays"] != undefined ? parseInt(args["numdays"]) : DEFAULT_NUM_DAYS;
// fetch and assign the data
model.data = getBlogPostList(node, fromDate, toDate, index, count);
model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
}
main();

View File

@@ -0,0 +1,5 @@
<#import "../blogpost.lib.ftl" as blogpostLib/>
<#import "../../generic-paged-results.lib.ftl" as gen/>
<@gen.pagedResults data=data ; item>
<@blogpostLib.blogpostJSON item=item />
</@gen.pagedResults>

View File

@@ -0,0 +1,10 @@
<webscript>
<shortname>Blog posts</shortname>
<description>Get all posts for a blog</description>
<url>/blog/site/{site}/{container}/{path}/posts/publishedext</url>
<url>/blog/site/{site}/{container}/posts/publishedext</url>
<url>/blog/node/{store_type}/{store_id}/{id}/posts/publishedext</url>
<format default="json"/>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1,42 @@
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/requestutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/searchutils.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/blogs/blogpost.lib.js">
/**
* Fetches all posts of the given blog
*/
function getBlogPostList(node, index, count)
{
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
" +PATH:\"" + node.qnamePath + "/*\" ";
// add the drafts part
luceneQuery += "+ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}blogPost\" "
var sortAttribute = "@{http://www.alfresco.org/model/blogintegration/1.0}posted";
// get the data
return getPagedResultsDataByLuceneQuery(node, luceneQuery, sortAttribute, false, index, count, getBlogPostData);
}
function main()
{
// get requested node
var node = getRequestNode();
if (status.getCode() != status.STATUS_OK)
{
return;
}
// process additional parameters
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
// fetch and assign the data
model.data = getBlogPostList(node, index, count);
model.contentFormat = (args["contentFormat"] != undefined) ? args["contentFormat"] : "full";
}
main();

View File

@@ -0,0 +1,5 @@
<#import "../blogpost.lib.ftl" as blogpostLib/>
<#import "../../generic-paged-results.lib.ftl" as gen/>
<@gen.pagedResults data=data ; item>
<@blogpostLib.blogpostJSON item=item />
</@gen.pagedResults>

View File

@@ -11,6 +11,15 @@ function getBlogPostList(node, fromDate, toDate, index, count)
// query information
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/content/1.0}content\"" +
" +PATH:\"" + node.qnamePath + "/*\" ";
// include all published + my drafts
luceneQuery += "((" +
" -ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
"+@cm\\:creator:\"" + person.properties.userName + "\"" +
") OR (" +
" +ASPECT:\"{http://www.alfresco.org/model/blogintegration/1.0}releaseDetails\" " +
"))";
// date query ?
if (fromDate != null || toDate != null)
{
@@ -36,9 +45,6 @@ function main()
var index = args["startIndex"] != undefined ? parseInt(args["startIndex"]) : 0;
var count = args["pageSize"] != undefined ? parseInt(args["pageSize"]) : 10;
// check what drafts we want to fetch
// begin and end date
var fromDate = null;
if (args["fromDate"] != undefined)

View File

@@ -5,18 +5,6 @@
const DEFAULT_NUM_DAYS = 30;
/**
* Returns the date object for the date "numdays" ago
*/
function getTodayMinusXDays(numdays)
{
var date = new Date();
var dateMillis = new Date().getTime();
dateMillis -= 1000 * 60 * 60 * 24 * numdays;
date.setTime(dateMillis);
return date;
}
/**
* Fetches all posts added to the forum in the last numdays days
*/

View File

@@ -5,6 +5,22 @@
const FUTURE_DATE = "3000\\-12\\-31T00:00:00";
const ZERO_DATE = "1970\\-01\\-01T00:00:00";
/**
* Returns the date object for the date "numdays" ago
*/
function getTodayMinusXDays(numdays)
{
var date = new Date();
var dateMillis = new Date().getTime();
dateMillis -= 1000 * 60 * 60 * 24 * numdays;
date.setTime(dateMillis);
// PENDING: should it be from the beginning of the date or exactly x days back?
return date;
}
/**
* Returns the date string as required by Lucene,
* thus in the format "1970\\-01\\-01T00:00:00"