Alert for outdated articles

Hello XWiki experts :slight_smile:

I’m looking for an extension (or any other way) which finds outdated articles and alerts some users. They should update the article or confirm its relevance.

An article is outdated, if its latest changes were made more than a year ago for example.

Can anyone out there help me?

THANK YOU!

Best regards :slight_smile:

I don’t know any such existing extension but it’s easy to implement it:

Hope it helps

Hi vmassol!

I thought I might not need to send reminders at all. I want to build a livetable which displays the outdated articles. Additionally, I want to insert a macro on the pages in order to display a warning box if an article is outdated. Do you think that’s a good Option and possible?

Your hints help to a certain extend. I managed to display all pages in a pretty random string, but I’d like to build a livetable with them. I failed to do so.

Could you help me?

I tried to figure out, how to filter livetables using this page, but I wasn’t able to do the filtered table. http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro

Best regards :slight_smile:

You’ll need a custom livetable results page that generates the correct JSON data, see http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro#HGeneratenewJSON

Good morning :slight_smile:

I’m very new to the whole velocity thing etc. Would you be so kind and gimme more guidance?!

I have to create two pages. One displays the livetable and one has the JSON data. Did I get that right?

I tried to adopt the JSON data code provided but it shows an error. This is what it looks like rn:

’ {{velocity wiki=“false”}}
#if(“$!{request.xpage}” == ‘plain’)
’ $response.setContentType(‘application/json’)
#end
’ ##==============================
’ ## Offset = item # at which to start displaying data
’ ##==============================
#set($offset = $numbertool.toNumber($request.get(‘offset’)))
’ ## offset starts from 0 in velocity and 1 in javascript
#set($offset = $offset - 1)
#if($offset < 0)
#set($offset = 0)
#end
’ ##==================
’ ## Limit = # of items to display
’ ##==================
#set($limit = $numbertool.toNumber($request.get(‘limit’)))
’ ##==================
’ ## Tag = one parameter per tag
’ ##==================
’ ##if($request.tag)
’ ##foreach($tag in $request.getParameterValues(‘tag’))
’ ### TODO: Add code to filter items based on the selected tags
’ ##end
’ ##end
’ ##==========
’ ## Sort direction
’ ##==========
#set($order = “$!request.sort”)
#if($order != ‘’)
#set($orderDirection = “$!{request.get(‘dir’).toLowerCase()}”)
#if(“$!orderDirection” != ‘’ && “$!orderDirection” != ‘asc’)
#set($orderDirection = ‘desc’)
#end
#end
’ ## ===========
’ ## Filter Data here…
’ ## ===========
’ ## TODO: Add code to filter data
’ ## Each column can be filtered and the filter for a column can be retrieved with:
’ ## #set($filterValue = “$!{request.get()}”)

#set($filterValue = “where doc.creationDate > $datetool.toDate(‘yyyy-MM-dd’, ‘2016-11-01’)”
#set($filterValue = “$!{request.get(doc.date)}”)

’ ## ===
’ ## JSON
’ ## ===
’ {
’ “totalrows”: 1,
’ “matchingtags”: {},
’ “tags” : ,
’ “returnedrows”: 1,
’ “offset”: 1,
’ “reqNo”: $util.parseInt($request.reqNo),
’ “rows”: [{
’ “doc_viewable” : true,
’ “doc.title” : ‘doc.title’,
’ “doc.author” : ‘doc.author’,
’ “doc.date” : ‘doc.date’
’ }]
’ }
’ {{/velocity}}

NOTE: I used the apostroph to avoid formating headings.

My livetable page says: “The Environment prevents table from loading data.” That’s quite obvious cause there’s an error at the JSON page.

’ {{velocity}}
#set($columns = [‘doc.title’, ‘doc.author’, ‘doc.date’])
#set($columnsProperties ={‘doc.title’: { “displayName”:“Title”, “type” : “text”, “link”:“view”},‘doc.author’: '{“displayName”:“Author”, “type”:“text”}, ‘doc.date’:{“displayName”:“Date”, “type”:“date”}})
#set($options = {
’ “resultPage”:“Playground.MyJSON”
’ })

livetable(“twitter” $columns $columnsProperties $options)
’ {{/velocity}}

You should use the code style: three back ticks then new line, then put your code and then three back ticks again.

For example:

line 1
line 2
line 3

More details: https://meta.discourse.org/t/syntax-highlighting-of-code-blocks/7242/3

More generally: Discourse Cheat Sheet - Community - SitePoint Forums | Web Development & Design Community
which leads to Learn markdown in Y Minutes

Your code is not correct; it’s actually not doing anything… :slight_smile:

You need to write the code to retrieve the data you want. And then you need to generate the proper JSON out of this data. What you pasted is just a skeleton which returns 1 row of static JSON. So you need to write a query and iterate over it.

You can google for “xwiki query”.

Just note that this is quite advanced stuff :slight_smile: If you don’t succeed you also have the option to ask someone else to do it for you. See for example: https://www.xwiki.org/xwiki/bin/view/Main/Support#HProfessionalSupport

You don’t necessarily need custom live table results. The new live table date filter supports date range, so you can write this:

{{velocity}}
#set ($columns = ['doc.title', 'doc.location', 'doc.date', 'doc.author'])
#set ($columnsProperties = {
  'doc.title': {'link': 'view'},
  'doc.location': {'html': true},
  'doc.author': {'link': 'author'}
})
#set ($start = $xwiki.jodatime.dateTime.minusDays(2).millis)
#set ($end = $xwiki.jodatime.dateTime.millis)
#set ($options = {
 'translationPrefix' : 'platform.index.',
 'extraParams': "&doc.date=${start}-${end}"
})
#livetable('pages' $columns $columnsProperties $options)
{{/velocity}}

Hope this helps,
Marius

Hi! Thanks for the hints :slight_smile:

That’s nice @mflorea didn’t know about it! Thx.

Note: I couldn’t find it documented so I’ve added it as an example on http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro#HDocumentswithdaterange (following the http://dev.xwiki.org/xwiki/bin/view/Community/Contributing#HStrategiesforansweringquestions strategy ;)).

That looks interesting and way easier :wink:

I inserted the code on my page, but the table shows 0 results. I have three pages: One was edited today, one yesterday and the other one on October, 5th. The table shows neither of them :stuck_out_tongue: I checked the values for $start (1511345695530) and $end (1511518495530). Do these values make sense?

Just to make sure, as i want to display pages, which have not been modified for a year, I will set start as any random date in the past. To set the end, I will insert:

#set ($end = $xwiki.jodatime.dateTime.minusDays(365).millis)

Am I right?!

Do you have a recent version of XWiki?

Indeed, there’s some version contraint mentioned on http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable%20Macro#HDocumentswithdaterange

No. I use 8.0 due to my java version. So far I’ve been trying the standalone version on my laptop. Will update soon!

Thank you for your help!

Hi :slight_smile:

I upgraded to version 9.10.1 now (wasn’t able to do it earlier) and the livetable date range works perfectly!

Thank you