Skip to content

Commit bc270ef

Browse files
authored
Add 'Days' column and cleanups (#97)
* Remove unused TranslateCritical. * Normalize header colors on translator's table. * There is no CSS class 'blue'. * Remove unused styles. * Another undeclared style. * Simplify ws. * Show how many days since last en/ commit. * Don't color empty days.
1 parent 855a373 commit bc270ef

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

scripts/revcheck.php

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class FileStatusEnum
8484
const TranslatedWip = 'TranslatedWip';
8585
const TranslatedOk = 'TranslatedOk';
8686
const TranslatedOld = 'TranslatedOld';
87-
const TranslatedCritial = 'TranslatedCritial';
8887
const NotInEnTree = 'NotInEnTree';
8988
}
9089

@@ -95,6 +94,7 @@ class FileStatusInfo
9594
public $size;
9695
public $hash;
9796
public $skip;
97+
public $days;
9898
public $adds;
9999
public $dels;
100100
public $syncStatus;
@@ -133,7 +133,6 @@ public static function getKey( $fileStatus ) {
133133
switch ( $fileStatus ) {
134134
case FileStatusEnum::RevTagProblem:
135135
case FileStatusEnum::TranslatedOld:
136-
case FileStatusEnum::TranslatedCritial:
137136
return "files_outdated";
138137
break;
139138
case FileStatusEnum::TranslatedWip:
@@ -356,7 +355,6 @@ function computeSyncStatus( $enFiles , $trFiles , $gitData , $lang )
356355

357356
// TranslatedOk
358357
// TranslatedOld
359-
// TranslatedCritial
360358
if ( strlen( $trFile->hash ) == 40 )
361359
{
362360
if ( $enFile->hash == $trFile->hash )
@@ -366,16 +364,20 @@ function computeSyncStatus( $enFiles , $trFiles , $gitData , $lang )
366364
$trFile->syncStatus = FileStatusEnum::TranslatedOld;
367365

368366
$cwd = getcwd();
369-
370367
chdir( 'en' );
368+
//adds,dels
371369
$subject = `git diff --numstat $trFile->hash -- {$filename}`;
372-
chdir( $cwd );
373370
if ( $subject )
374371
{
375372
preg_match('/(\d+)\s+(\d+)/', $subject, $matches);
376373
if ($matches)
377374
[, $enFile->adds, $enFile->dels] = $matches;
378375
}
376+
//days
377+
$days = `git show --no-patch --format='%ct' $enFile->hash -- {$filename}`;
378+
if ( $days != "" )
379+
$enFile->days = floor( ( time() - $days ) / 86400 );
380+
chdir( $cwd );
379381

380382
if ( $enFile->skip )
381383
{
@@ -495,22 +497,15 @@ function print_html_header( $lang )
495497
table { margin-left: auto; margin-right: auto; text-align: left; border-spacing: 2px; }
496498
th { color: white; background-color: #666699; padding: 0.2em; text-align: center; vertical-align: middle; }
497499
td { padding: 0.2em 0.3em; }
498-
.oc { white-space: nowrap; overflow: hidden; max-width: 7em; }
499500
.copy { margin:0; padding: 0; font-size:small; }
500501
.copy:hover { text-transform: uppercase; }
501502
.copy:active { background: aqua; font-weight: bold; }
502-
.o { white-space: nowrap; overflow: hidden; max-width: 5em; }
503-
.c { text-align: center; }
504-
.r { text-align: right; }
505503
.b { font-weight: bold; }
506-
.white { color: white; }
507-
.black { color: black; }
508-
.bgblue { background-color: #666699;}
504+
.c { text-align: center; }
505+
.o { white-space: nowrap; overflow: hidden; max-width: 5em; }
506+
.oc { white-space: nowrap; overflow: hidden; max-width: 7em; }
509507
.bggray { background-color: #dcdcdc;}
510-
.bggreen { background-color: #68d888;}
511508
.bgorange { background-color: #f4a460;}
512-
.bgred { background-color: #ff6347;}
513-
.bgyellow { background-color: #eee8aa;}
514509
</style>
515510
</head>
516511
<body>
@@ -551,18 +546,18 @@ function print_html_translators( $translators , $enFiles, $trFiles )
551546
</table>
552547
<p/>
553548
<table class="c">
554-
<tr class=blue>
549+
<tr>
555550
<th rowspan=2>Translator's name</th>
556551
<th rowspan=2>Contact email</th>
557552
<th rowspan=2>Nick</th>
558553
<th rowspan=2>V<br>C<br>S</th>
559554
<th colspan=4>Files maintained</th>
560555
</tr>
561556
<tr>
562-
<th style="color:#000000">upto-<br>date</th>
563-
<th style="color:#000000">old</th>
564-
<th style="color:#000000">wip</th>
565-
<th class="blue">sum</th>
557+
<th>upto-<br>date</th>
558+
<th>old</th>
559+
<th>wip</th>
560+
<th>sum</th>
566561
</tr>
567562
HTML;
568563
$files_uptodate = 0;
@@ -748,7 +743,7 @@ function print_html_untranslated($enFiles)
748743
{
749744
$path = $en->path;
750745
$path2 = $path == '' ? '/' : $path;
751-
print " <tr><th class='blue' colspan='3'>$path2</th></tr>";
746+
print " <tr><th colspan='3'>$path2</th></tr>";
752747
}
753748
$size = $en->size < 1024 ? 1 : floor( $en->size / 1024 );
754749

@@ -795,6 +790,7 @@ function print_html_files( $enFiles , $trFiles , $lang )
795790
<th colspan="2">Hash</th>
796791
<th rowspan="2">Maintainer</th>
797792
<th rowspan="2">Status</th>
793+
<th rowspan="2">Days</th>
798794
</tr>
799795
<tr>
800796
<th>en</th>
@@ -822,7 +818,7 @@ function print_html_files( $enFiles , $trFiles , $lang )
822818
{
823819
$path = $en->path;
824820
$path2 = $path == '' ? '/' : $path;
825-
print " <tr><th colspan='6' class='blue c'>$path2</th></tr>";
821+
print " <tr><th colspan='7' class='c'>$path2</th></tr>";
826822
}
827823
$ll = strtolower( $lang );
828824
$kh = hash( 'sha256' , $key );
@@ -834,6 +830,10 @@ function print_html_files( $enFiles , $trFiles , $lang )
834830
$h1 = "<a href='https://github.com/php/doc-en/blob/{$en->hash}/$key'>{$en->hash}</a>";
835831
$h2 = "<a href='https://github.com/php/doc-en/blob/{$tr->hash}/$key'>{$tr->hash}</a>";
836832

833+
$bgdays = '';
834+
if ($en->days != null && $en->days > 90)
835+
$bgdays = 'bgorange';
836+
837837
if ($en->adds != null)
838838
$ch = "<span style='color: darkgreen;'>+{$en->adds}</span> <span style='color: firebrick;'>-{$en->dels}</span>";
839839
else
@@ -843,17 +843,15 @@ function print_html_files( $enFiles , $trFiles , $lang )
843843
$st = $tr->completion;
844844
print <<<HTML
845845
<tr class="bggray">
846-
<td class="l">$nm</td>
846+
<td>$nm</td>
847847
<td class="c">$ch</td>
848848
<td class="oc">
849-
<button class="btn copy" data-clipboard-text="{$en->hash}">
850-
Copy
851-
</button>
852-
$h1
849+
<button class="btn copy" data-clipboard-text="{$en->hash}">Copy</button> $h1
853850
</td>
854851
<td class="o">$h2</td>
855852
<td class="c">$ma</td>
856853
<td class="c">$st</td>
854+
<td class="c {$bgdays}">{$en->days}</td>
857855
</tr>
858856
HTML;
859857
}
@@ -882,7 +880,7 @@ function print_html_notinen()
882880
if ( $path !== $en->path )
883881
{
884882
$path = $en->path;
885-
print " <tr><th class='blue' colspan='2'>/$path</th></tr>";
883+
print " <tr><th colspan='2'>/$path</th></tr>";
886884
}
887885
print <<<HTML
888886
<tr class=bggray>

0 commit comments

Comments
 (0)