Ok here It Is :

 

 

1 - the creation of a RSS feed page: “PersonalRSS” in space “ Main” with code :

 

$response.setContentType("text/xml")

#set($baseurl =  "http://${request.serverName}")

#set($member = $request.uid)

#set($title = "$member.replace('XWiki.','') Personal")

#set($description = "Flux RSS Personal of $member.replace('XWiki.','')")

#includeForm("XWiki.PersonalRssCode") 

 

 

2 – the creation of the RSS Code page: “PersonalRssCode” in space Xwiki with code :

 

{pre}

 

#if($member=="")

#set($member="XWiki.XWikiGuest")

#end

 

#set($memberdoc = $xwiki.getDocument($member))

#set($cobj = $memberdoc.getObject("XWiki.XWikiUsers"))

#set($personalrss = $memberdoc.display("blogfeed","view",$cobj))

#set($personalrss = $personalrss.replace("@","','"))

#set($sql = "where doc.fullName in ('${personalrss}') order by doc.date desc")

 

#set($list = $xwiki.searchDocuments($sql ,0, 0))

#set($rsvc= $xwiki.xWiki.getRightService())

 

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://purl.org/rss/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:wiki="http://purl.org/rss/1.0/modules/wiki/"

encoding="ISO-8859-1" >

 

<channel rdf:about="$baseurl">

<title>$title</title>

<link>$baseurl</link>

<description>$description</description>

<image rdf:resource="${baseurl}/xwiki/skins/default/logo.gif" />

<dc:language>$doc.defaultLanguage</dc:language>

<dc:rights>$xwiki.webCopyright</dc:rights>

<dc:publisher>$doc.author</dc:publisher>

<dc:creator>$doc.author</dc:creator>

 

<items>

<rdf:Seq>

#foreach ($item in $list)

#if($xwiki.hasAccessLevel("view", "${context.database}:${item}"))

#set ($currentdoc = $xwiki.getDocument($item))

<rdf:li rdf:resource="${baseurl}/xwiki/bin/view/${currentdoc.web}/${currentdoc.name}" />

#end

#end

</rdf:Seq>

</items>

</channel>

<image rdf:about="${baseurl}/xwiki/skins/default/logo.gif">

  <title>XWiki Logo</title>

  <link>${baseurl}</link>

  <url>${baseurl}/xwiki/skins/default/logo.gif</url>

</image>

#foreach ($item in $list)

#if($xwiki.hasAccessLevel("view", "${context.database}:${item}"))

#set($currentdoc = $xwiki.getDocument($item))

#set($url = "${baseurl}/xwiki/bin/view/${currentdoc.web}/${currentdoc.name}")

#if($currentdoc.content.length() < 255)

#set($length = $currentdoc.content.length())

#else

#set($length = 255)

#end

<item rdf:about="$url">

#set($itemtitle = ${currentdoc.title})

#if( $itemtitle!="" )

<title>$itemtitle</title>

#else

<title>${currentdoc.web}.${currentdoc.name}</title>

#end

<link>$url</link>

<description>

#set($i = $currentdoc.author.indexOf(".")+1)

This page (v$currentdoc.version) has been modified by $currentdoc.author.substring($i) on $xwiki.formatDate($currentdoc.date,"MMMM dd, yyyy HH:mm:ss")

</description>

<dc:date>$xwiki.formatDate($currentdoc.date,"dd MMMM yyyy HH:mm:ss")</dc:date>

<dc:contributor>

<rdf:Description link="">

<rdf:value>$currentdoc.author</rdf:value>

</rdf:Description>

</dc:contributor>

</item>

#end

#end

</rdf:RDF>

{/pre}

 

 

3 – the creation of the page which add and remove chosen pages : “EditPersonalRSS”  in space “Xwiki” with code :

 

#if($request.page)

 

#set($newrsspage = "@${request.page}")

 

####### on cherche la liste

#set($member = $context.getUser())

#set($memberdoc = $xwiki.getDocument($member))

#set($cobj = $memberdoc.getObject("XWiki.XWikiUsers"))

 

####### on recupere les pages existantes

#set($oldrsspages = $memberdoc.display("blogfeed","view",$cobj))

 

######################################################################

#if($request.action == "add")

 

####### on injecte la nouvelle

#if($oldrsspages == "")

#set($oldrsspages = "$newrsspage")

#else

#set($oldrsspages = "${newrsspage}${oldrsspages}")

#end

 

######################################################################

#elseif($request.action == "sub")

 

####### on enleve la page choisie

#set($oldrsspages = $oldrsspages.replace("${newrsspage}","")))

 

######################################################################

#end

 

####### on sauve

$memberdoc.use("XWiki.XWikiUsers")

$memberdoc.set("blogfeed",$oldrsspages)

$memberdoc.save()

 

####### on redirige

#$response.sendRedirect($xwiki.getURL(${request.page}))

 

#else

#$response.sendRedirect($xwiki.getURL("Main.WebHome"))

#end

 

 

4 – Implement the links to this Personal RSS Feed

 

The link to create the RSS Feed:

 

<a href="$xwiki.getURL("Main.PersonalRSS", "view", "uid=${context.user}&xpage=rdf")")">Personal RSS <img src="$xwiki.getSkinFile("icons/black-rss-mini.png")"></a>

 

And in the pages you want to be followed (you can add this code in the “view.vm” page for example):

 

#set($mdoc = $xwiki.getDocument(${context.user}))

#set($cobj = $mdoc.getObject("XWiki.XWikiUsers"))

#set($prss = $mdoc.display("blogfeed","view",$cobj))

#if($prss.contains(${doc.fullName}))

<a href="$xwiki.getURL("XWiki.EditPersonalRSS","view","page=${doc.fullName}&action=sub")">Unfollow This Page</a>

#else

<a href="$xwiki.getURL("XWiki.EditPersonalRSS","view","page=${doc.fullName}&action=add")">Follow This Page with RSS</a>

#end

 

 

5 – Problems encountered

 

-          I’m using the field “blogfeed”, the best is to create a new property in the Object XWiki.XWikiUsers

-          Everybody can follow the Personal RSS Feed of everybody just by adding the Feed with a “Xwiki.login_of_user” instead of the “${context.user}”

 

 

 

That’s work fine, but I think it is possible to ameliorate my code.

 

Regards, Mathieu

---------------------------------------------------
Mathieu Emptoz
CEA Cadarache
DRFC/STEP

XWiki's EFDA Remote Participation Administrator
---------------------------------------------------