Changeset 1415

Show
Ignore:
Timestamp:
03/15/08 17:22:02
Author:
rsz
Message:

cleanup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HTTP/WikiRevisionService.lua

    r1414 r1415  
    2626local FormatDateTime = WikiService.FormatDateTime 
    2727local Path = WikiService.Path 
     28local Today = WikiService.Today 
     29local Yesterday = WikiService.Yesterday 
     30local ThisWeek = WikiService.ThisWeek 
    2831 
    2932local math = require( 'math' ) 
     
    104107end 
    105108 
     109local function TimeTitle( aTime ) 
     110    local aTitle = FormatDate( aTime ) 
     111 
     112    if Today( aTime ) then 
     113        aTitle = ( 'Today — %s' ):format( aTitle ) 
     114    elseif Yesterday( aTime ) then 
     115        aTitle = ( 'Yesterday — %s' ):format( aTitle ) 
     116    elseif ThisWeek( aTime ) then 
     117        aTitle = ( 'Last few days — %s' ):format( aTitle ) 
     118    end  
     119     
     120    return aTitle 
     121end 
     122 
    106123local function Variation( aContent ) 
    107124    local aPreviousVersion = aContent.previousVersion 
     
    115132        local aDescription = ( '%d%%' ):format( aVariation, aPreviousSize, aSize, aDifference ) 
    116133         
    117         if math.abs( aVariation ) == 0 then 
     134        if aVariation > 0 then 
     135            aDescription = ( '+%s' ):format( aDescription ) 
     136        elseif aVariation == 0 then 
    118137            aDescription = ( '±%s' ):format( aDescription ) 
    119138        end 
     
    148167    for _, anEntry in ipairs( someEntries ) do 
    149168        local anEntryTemplate = aTemplate[ 'entries' ] 
    150         local aTime = anEntry.time 
    151         local aDate = os.date( '!*t', aTime ) 
    152         local aTitle = FormatDate( aTime ) 
    153169         
    154170        anEntryTemplate[ 'description' ] = Encode( Description( #anEntry.items ) ) 
    155         anEntryTemplate[ 'title' ] = Encode( aTitle
     171        anEntryTemplate[ 'title' ] = Encode( TimeTitle( anEntry.time )
    156172         
    157173        for _, aContent in ipairs( anEntry.items ) do