Ok here the correct description (sorry but trying to debug ):
I have a page “Personnalisation/GenPublicRSS” with velocity code who’s generate my “static” RSS page, when I open GenPublicRSS in view mode.
My scheduler periodicely open my page GenPublicRSS to refresh RSS feed and since 10.11.x, my RSS feed displayed “localhost”… but only when lauched by scheduler!
If I open “GenPublicRSS” with my browser, my RSS feed entries are fine.
My script in scheduler is:
xwiki.getDocument("Personnalisation.GenPublicRSS").getRenderedContent()
and code of “Personnalisation/GenPublicRSS”:
{{velocity}}
## Généré le feed RSS (entrées XML) dans $MyPublicRSSDocName
## L’exécution du script doit être planifié dans le scheduler
## Ver. 1.0 du 09/03/2018
#set($MyPublicRSSDocName = 'Public.Rss.Rss')
#set($MySpaces = ['FormSMQ','Encyclopédie','FAQ','Blog','Public'])
##set($MyTags = ['SMQ'])
#set($MyTags = '')
#set($LimitEntries = 10)
Lien du feed RSS: https://iwiki.din.developpement-durable.gouv.fr/bin/get/Public/Rss/Rss?outputSyntax=plain
Enregistre le feed RSS des espaces **"$MySpaces"** et des tags **"$MyTags"** dans la page publique: [[$MyPublicRSSDocName]]
(Code copié de [[Main.WebRss]])
#*
#if (("$!request.xpage" == 'plain' || "$!request.xpage" == 'rdf') && "$!request.outputSyntax" != 'plain')
$response.sendRedirect($xwiki.getURL($doc.fullName, 'view', 'xpage=plain&outputSyntax=plain'))
#end
#if ("$!request.xpage" == 'plain' && "$!request.outputSyntax" == 'plain')
$response.setContentType('application/rss+xml')
*#
## ======================
## Compute Query to find documents
## ======================
#if("$!{MyTags}" != '')
## RSS feed for documents tagged with $request.tag
#set ($query = 'from doc.object(XWiki.TagClass) as tag where (')
#foreach ($tag in $MyTags)
#set ($query = "$query :tag${foreach.count} member of tag.tags")
#if ($foreach.hasNext)
#set ($query = "$query OR ")
#end
#end
#set ($query = "$query) AND ")
#else
#set ($query = 'where')
#end
#if("$!{MySpaces}" == '')
## RSS feed for the whole wiki
#set ($query = "$query 1=1")
#else
## RSS feed for spaces
#set ($query = "$query (")
#foreach ($space in $MySpaces)
#set ($query = "$query doc.space=:space${foreach.count} OR doc.space LIKE :space_nested${foreach.count}")
#if ($foreach.hasNext)
#set ($query = "$query OR ")
#end
#end
#set ($query = "$query)")
#end
#set ($query = "$query order by doc.date desc")
## ==============
## Bind Query parameters
## ==============
## Bind query parameters depending on the passed query string parameters
#set ($queryObject = $services.query.xwql($query).addFilter('hidden/document').addFilter('currentlanguage').setLimit($LimitEntries).setOffset(0))
#if("$!{MyTags}" != '')
#foreach ($tag in $MyTags)
#set ($queryObject = $queryObject.bindValue("tag${foreach.count}", $tag))
#end
#end
#if("$!{MySpaces}" != '')
#foreach ($space in $MySpaces)
#set ($queryObject = $queryObject.bindValue("space${foreach.count}", $space))
#set ($queryObject = $queryObject.bindValue("space_nested${foreach.count}", "${space}.%"))
#end
#end
## ================
## Compute feed description
## ================
## 4 cases to handle: no spaces and tags specified, only spaces specified, only tags specified and spaces and tags specified
#if ("$!{MySpaces}" != '')
#if ("$!{MyTags}" != '')
#set ($description = $services.localization.render('activity.rss.feed.tagsAndSpaces.description', [$stringtool.join($MyTags, ','), $stringtool.join($MySpaces, ',')]))
#else
#set ($description = $services.localization.render('activity.rss.feed.spaces.description', [$stringtool.join($MySpaces, ',')]))
#end
#else
#if ("$!{MyTags}" != '')
#set ($description = $services.localization.render('activity.rss.feed.tags.description', [$stringtool.join($MyTags, ',')]))
#else
#set ($description = $services.localization.render('activity.rss.feed.description'))
#end
#end
## =====================
## Execute query and generate feed
## =====================
#set ($feed = $xwiki.feed.getWebFeed($queryObject.execute()))
## Modifie le champ description et la date de maj pour les franciser
#foreach($MyId in $feed.entries)
#if ( $MyId.description.value )
##* $MyId.description.value $MyId.updatedDate - $datetool.format("E dd MMMM yyyy à HH:mm:ss", $MyId.updatedDate, $services.localization.getCurrentLocale())
## Version 1.12, page modifiée par Michel GIBELLI, le jeu. 08 mars 2018 à 11:55:07
## Version 1.12, page crée par xxx et modifiée par yyyy le jeu. 08 mars 2018 à 11:55:07.
#set ($MyString=$MyId.description.value)
#set ($ToIndex=$MyString.indexOf(' edited by '))
#set ($MyString = $MyString.substring(0,$ToIndex))
##set ($MyString = $MyString.replaceFirst(' edited by ', ', page modifiée par '))
###set ($MyString = $MyString.split(' on ', 2))
## $datetool.toDate( convertit une date string en date mais je récupère plutôt la date ailleurs "jeu. 01 février 2018 à 15:47:10"
#set ($MyStrDate = $datetool.format("E dd MMMM yyyy à HH:mm:ss", $MyId.updatedDate, $services.localization.getCurrentLocale()))
##set ($MyString = "$MyString[0], le $MyStrDate.")
#if ("$MyId.author" == "$MyId.contributors[0]")
#set ($MyString = $MyString + ', page créée et modifiée par ' + $MyId.author + ' le ' + $MyStrDate + '.')
#else
#set ($MyString = $MyString + ', page créée par ' + $MyId.author + ' et dernièrement modifiée par ' + $MyId.contributors[0] + ' le ' + $MyStrDate + '.')
#end
#set ($MyString = $MyString + '<br><br>Rappel: pour retrouver cette page, cliquez sur le lien du site indiqué ci-dessus.')
#set ($MyId.description.value=$MyString)
## Met l'expéditeur de l'entrée RSS = contributeur
##set ($MyId.author.value="$MyId.contributors[0]")
##set ($MyId.modules[0].creators[0]="$MyId.contributors[0]")
#set ($MyId.modules[0].creator="$MyId.contributors[0]")
#end
#end
#set ($feedURI = $xwiki.getDocument('Main.WebHome').getExternalURL('view'))
#set ($discard = $feed.setLink($feedURI))
#set ($discard = $feed.setUri($feedURI))
#set ($discard = $feed.setAuthor('XWiki'))
#set ($discard = $feed.setTitle($services.localization.render('activity.rss.feed.description')))
#set ($discard = $feed.setDescription($description))
#set ($discard = $feed.setLanguage("$xcontext.locale"))
#set ($discard = $feed.setCopyright($xwiki.getXWikiPreference('copyright')))
## $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))
#*
## Debug
Début feed:
$feed
Fin feed
$xwiki.getXWikiPreference('feed_type', 'rss_2.0')
----
Début json feed:
$jsontool.serialize($feed)
Fin Json feed
Début getFeedOutput
$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))
Fin getFeedOutput
$services.rendering.getAvailableRendererSyntaxes()
#set ($MyFeed = $xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0')))
*#
##enregistre le feed RSS dans la page
#set($MyPublicRSS = $xwiki.getDocument($MyPublicRSSDocName))
#set ($discard=$MyPublicRSS.setContentType('application/rss+xml'))
#set ($discard=$MyPublicRSS.setSyntaxId('plain/1.0'))
#set ($discard=$MyPublicRSS.setContent("$xwiki.feed.getFeedOutput($feed, $xwiki.getXWikiPreference('feed_type', 'rss_2.0'))"))
##set ($discard=$MyPublicRSS.setContent($jsontool.serialize($feed)))
#set ($discard=$MyPublicRSS.save())
[[$MyPublicRSS]] sauvés
##end
{{/velocity}}