<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FSmalljim%2FDiscussionIndexTest</id>
	<title>Module:Sandbox/Smalljim/DiscussionIndexTest - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://stockhub.co/index.php?action=history&amp;feed=atom&amp;title=Module%3ASandbox%2FSmalljim%2FDiscussionIndexTest"/>
	<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Smalljim/DiscussionIndexTest&amp;action=history"/>
	<updated>2026-04-21T14:40:40Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://stockhub.co/index.php?title=Module:Sandbox/Smalljim/DiscussionIndexTest&amp;diff=146199&amp;oldid=prev</id>
		<title>imported&gt;Smalljim: drop times in future (try 1)</title>
		<link rel="alternate" type="text/html" href="https://stockhub.co/index.php?title=Module:Sandbox/Smalljim/DiscussionIndexTest&amp;diff=146199&amp;oldid=prev"/>
		<updated>2013-04-01T21:17:04Z</updated>

		<summary type="html">&lt;p&gt;drop times in future (try 1)&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
20130330: I have unashamedly copied this from User:Dragons flight&amp;#039;s DiscussionIndex module, whose comments follow:&lt;br /&gt;
&lt;br /&gt;
This module provides a formatted index of the discussions that have occurred on a target page.&lt;br /&gt;
&lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
p = {};&lt;br /&gt;
pp = require( &amp;#039;Module:Sandbox/Smalljim/ParsePageTest&amp;#039; ); --a set of page parsing functions&lt;br /&gt;
&lt;br /&gt;
function p.summary( frame )&lt;br /&gt;
    local target = frame.args[1] or frame.args.target or &amp;#039;&amp;#039;; --the page to parse&lt;br /&gt;
    local exc = frame.args.excerpts or false; --opt to show an excerpt from start of each section&lt;br /&gt;
    if type( exc ) == &amp;#039;string&amp;#039; then --deal with optional ways of specifying show excerpt&lt;br /&gt;
        exc = exc:lower();&lt;br /&gt;
        if exc == &amp;#039;false&amp;#039; or exc == &amp;#039;&amp;#039; or exc == &amp;#039;0&amp;#039; or exc == &amp;#039;no&amp;#039; then&lt;br /&gt;
            exc = false;&lt;br /&gt;
        else&lt;br /&gt;
            exc = true; --anything but &amp;#039;false&amp;#039;, &amp;#039;&amp;#039;, &amp;#039;0&amp;#039; or &amp;#039;no&amp;#039; (case insensitive)&lt;br /&gt;
        end&lt;br /&gt;
    end  &lt;br /&gt;
    local rt = ( tonumber( frame.args.recent ) or 120 )*60; --green cell if &amp;lt; 120 min or use &amp;quot;recent&amp;quot; to specify&lt;br /&gt;
    local ot = ( tonumber( frame.args.old ) or 60*24*2 )*60; --red cell if &amp;gt; 2 days or use &amp;quot;old&amp;quot; to specify&lt;br /&gt;
&lt;br /&gt;
    if target == &amp;#039;&amp;#039; then --no target page specified&lt;br /&gt;
        return &amp;#039;&amp;#039;;&lt;br /&gt;
    end&lt;br /&gt;
    local text = frame:preprocess( &amp;#039;{{:&amp;#039; .. target .. &amp;#039;}}&amp;#039; ); --does this expand templates in target page?&lt;br /&gt;
&lt;br /&gt;
    return frame:preprocess( p._summary( text, target, exc, rt, ot ) );&lt;br /&gt;
end&lt;br /&gt;
    &lt;br /&gt;
function p._summary( text, target, exc, rt, ot )&lt;br /&gt;
    local lang = mw.getContentLanguage();&lt;br /&gt;
    local now = lang:formatDate( &amp;#039;U&amp;#039; );&lt;br /&gt;
        &lt;br /&gt;
    local sections, headings = pp.getSections( text, 2 ); --2 is header level&lt;br /&gt;
    local result;&lt;br /&gt;
    &lt;br /&gt;
    result = &amp;#039;== Discussion summary report for [[&amp;#039; .. target .. &amp;#039;]] ==\n\n&amp;#039;&lt;br /&gt;
    result = result .. &amp;#039;This is an automated summary of the discussions occurring on &amp;#039; ..&lt;br /&gt;
        target .. &amp;#039;.\n\n&amp;#039; ..&lt;br /&gt;
        &amp;#039;It was last generated at &amp;#039; .. lang:formatDate( &amp;#039;l, j F Y, H:i:s&amp;#039; ) .. &amp;#039; UTC &amp;#039; ..&lt;br /&gt;
        &amp;#039;([{{fullurl:{{FULLPAGENAME}}|action=purge}} update now]).\n\n&amp;#039; ..&lt;br /&gt;
        &amp;#039;The current version of this report is still experimental and may contain &amp;#039; ..&lt;br /&gt;
        &amp;#039;significant inaccuracies.\n\n&amp;#039;&lt;br /&gt;
    &lt;br /&gt;
    if exc then&lt;br /&gt;
        result = result .. &amp;#039;{| class=&amp;quot;wikitable&amp;quot; \n&amp;#039;;&lt;br /&gt;
    else&lt;br /&gt;
        result = result .. &amp;#039;{| class=&amp;quot;wikitable sortable&amp;quot; \n&amp;#039;; --no excerpts, so can make it sortable&lt;br /&gt;
    end&lt;br /&gt;
    &lt;br /&gt;
    result = result .. &amp;#039;! Section title !! data-sort-type=&amp;quot;number&amp;quot; | Age &amp;#039; ..&lt;br /&gt;
        &amp;#039; !! data-sort-type=&amp;quot;number&amp;quot; | &amp;#039; ..&lt;br /&gt;
        &amp;#039; Last Comment !! Bytes !! Originator !! data-sort-type=&amp;quot;number&amp;quot; | Other Participants \n|-\n|&amp;#039;;&lt;br /&gt;
    local result_lines = {};&lt;br /&gt;
    &lt;br /&gt;
    for k, tt in ipairs( sections ) do&lt;br /&gt;
        local users = pp.getUsers( tt, false, true );&lt;br /&gt;
        local times = pp.getTimestamps( tt );&lt;br /&gt;
        local min_time, max_time&lt;br /&gt;
        local min_time_string, max_time_string&lt;br /&gt;
        local line_item = {};&lt;br /&gt;
&lt;br /&gt;
        for k, v in ipairs (times) do --drop times in the future&lt;br /&gt;
            if now - v[2] &amp;lt; 0 then&lt;br /&gt;
                table.remove( times, k)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        &lt;br /&gt;
        for k, v in ipairs( times ) do&lt;br /&gt;
            if min_time == nil or min_time &amp;gt; v[2] then&lt;br /&gt;
                min_time = v[2];&lt;br /&gt;
            end&lt;br /&gt;
            if max_time == nil or max_time &amp;lt; v[2] then&lt;br /&gt;
                max_time = v[2];&lt;br /&gt;
            end&lt;br /&gt;
        end        &lt;br /&gt;
    &lt;br /&gt;
        for k, v in ipairs( times ) do&lt;br /&gt;
            if min_time == v[2] then&lt;br /&gt;
                min_time_string = v[1];&lt;br /&gt;
            end&lt;br /&gt;
            if max_time == v[2] then&lt;br /&gt;
                max_time_string = v[1];&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        min_time = now - (min_time or now);&lt;br /&gt;
        max_time = now - (max_time or now);&lt;br /&gt;
&lt;br /&gt;
        local user_list = {}&lt;br /&gt;
        for _, tt in pairs( users ) do&lt;br /&gt;
            table.insert( user_list, tt[2] );&lt;br /&gt;
        end&lt;br /&gt;
        if headings[k] ~= &amp;#039;&amp;#039; and user_list[1] ~= nil then&lt;br /&gt;
            line_item = { pp.formatSectionLink( target, headings[k] ), &lt;br /&gt;
                p._formatTimeDiff(min_time, rt, ot ), &lt;br /&gt;
                p._formatTimeDiff(max_time, rt, ot ), &lt;br /&gt;
                tostring( #tt ), user_list[1] };&lt;br /&gt;
&lt;br /&gt;
            table.remove( user_list, 1 );&lt;br /&gt;
            table.sort( user_list );&lt;br /&gt;
            table.insert( line_item, tostring( #user_list ) .. &amp;#039;: &amp;#039; .. table.concat( user_list, &amp;#039;, &amp;#039; ) )&lt;br /&gt;
            if exc then&lt;br /&gt;
                table.insert( line_item, pp.getExcerpt( tt, 500 ) )&lt;br /&gt;
            end                    &lt;br /&gt;
            &lt;br /&gt;
            table.insert( result_lines, line_item );&lt;br /&gt;
        end        &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    comp = function( a, b )        &lt;br /&gt;
        local a2, b2&lt;br /&gt;
        a2 = mw.ustring.gsub( a[3], &amp;#039;%b&amp;lt;&amp;gt;&amp;#039;, &amp;#039;&amp;#039; );&lt;br /&gt;
        a2 = mw.ustring.gsub( a2, &amp;#039;.*|%s*&amp;#039;, &amp;#039;&amp;#039; );&lt;br /&gt;
        b2 = mw.ustring.gsub( b[3], &amp;#039;%b&amp;lt;&amp;gt;&amp;#039;, &amp;#039;&amp;#039; );&lt;br /&gt;
        b2 = mw.ustring.gsub( b2, &amp;#039;.*|%s*&amp;#039;, &amp;#039;&amp;#039; );&lt;br /&gt;
        a2 = tonumber( mw.ustring.match( a2, &amp;#039;^(%d-)_&amp;#039; ) ) or 0;&lt;br /&gt;
        b2 = tonumber( mw.ustring.match( b2, &amp;#039;^(%d-)_&amp;#039; ) ) or 0;&lt;br /&gt;
        return a2 &amp;lt; b2;&lt;br /&gt;
    end&lt;br /&gt;
    table.sort( result_lines, comp );&lt;br /&gt;
&lt;br /&gt;
    local result_lines2 = {};&lt;br /&gt;
    local row;&lt;br /&gt;
    for k, tt in ipairs( result_lines ) do&lt;br /&gt;
        if exc then&lt;br /&gt;
            local excerpt = tt[#tt];&lt;br /&gt;
            table.remove( tt );&lt;br /&gt;
            row = table.concat( tt, &amp;#039;||&amp;#039; );&lt;br /&gt;
            table.insert( result_lines2, row );&lt;br /&gt;
            table.insert( result_lines2, &lt;br /&gt;
                &amp;#039; colspan=6 style=&amp;quot;padding-left:2em; padding-top:0.5em; padding-bottom:0.5em;&amp;quot; | &amp;lt;span style=&amp;quot;font-size:90%&amp;quot;&amp;gt;&amp;#039; ..excerpt .. &amp;#039;&amp;lt;/span&amp;gt;&amp;#039; );&lt;br /&gt;
        else&lt;br /&gt;
            row = table.concat( tt, &amp;#039;||&amp;#039; );&lt;br /&gt;
            table.insert( result_lines2, row );&lt;br /&gt;
        end            &lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    result = result .. table.concat( result_lines2, &amp;#039;\n|-\n|&amp;#039; ) .. &amp;quot;\n|}&amp;quot;;&lt;br /&gt;
        &lt;br /&gt;
    return result;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
function p._formatTimeDiff( tv, rt, ot )&lt;br /&gt;
    local tv_string;&lt;br /&gt;
    tv_string = &amp;#039;&amp;lt;span style=&amp;quot;display:none&amp;quot;&amp;gt;&amp;#039; .. tostring(tv) .. &amp;#039;_&amp;lt;/span&amp;gt;&amp;#039; .. mw.ustring.gsub( pp.formatDateDiff(tv), &amp;#039; &amp;#039;, &amp;#039;&amp;amp;nbsp;&amp;#039; );&lt;br /&gt;
    if tv &amp;lt; rt then&lt;br /&gt;
        tv_string = &amp;#039; style=&amp;quot;background:#EFE&amp;quot; | &amp;#039; .. tv_string; --green cell&lt;br /&gt;
    elseif tv &amp;gt; ot then&lt;br /&gt;
        tv_string = &amp;#039; style=&amp;quot;background:#FEE&amp;quot; | &amp;#039; .. tv_string; --red cell&lt;br /&gt;
    end&lt;br /&gt;
    return tv_string;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p;&lt;/div&gt;</summary>
		<author><name>imported&gt;Smalljim</name></author>
	</entry>
</feed>