ユーザ用ツール

サイト用ツール


hist

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
次のリビジョン
前のリビジョン
hist [2026/04/24 23:02] Tokyo Adminhist [2026/05/03 00:19] (現在) Tokyo Admin
行 1: 行 1:
 ====== 過去履歴 ====== ====== 過去履歴 ======
  
-<php> +過去から現在までの掲載記事を年別にまとめています。
-$targetYear = '2025'; +
-$baseDir = '/home/usausa2web/web/www_jarltokyo.com'; +
-$blogDir = $baseDir . '/data/pages/blog';+
  
-$items = [];+^ 年 ^ 
 +[[hist2026|2026年]] | 
 +| [[hist2025|2025年]] | 
 +| [[hist2024|2024年]] | 
 +| [[hist2023|2023年]] | 
 +| [[hist2022|2022年]] | 
 +| [[hist2021|2021年]] | 
 +| [[hist2020|2020年]] | 
 +| [[hist2019|2019年]] | 
 +| [[hist2018|2018年]|
  
-foreach (glob($blogDir . '/*.txt') as $file) { 
-    $basename = basename($file, '.txt'); 
  
-    if (!preg_match('/^(' . preg_quote($targetYear, '/') . ')(\d{2})(\d{2})_(.+)$/', $basename, $m)) { 
-        continue; 
-    } 
  
-    $year = $m[1]; +----
-    $month = $m[2]; +
-    $day = $m[3];+
  
-    $content = file_get_contents($file); 
-    if ($content === false) { 
-        continue; 
-    } 
  
-    $title = $basename; 
-    if (preg_match('/^======\s*(.+?)\s*======\s*$/m', $content, $tm)) { 
-        $title = trim($tm[1]); 
-    } 
  
-    $items[] = [ +----
-        'datekey' => $year . $month . $day, +
-        'year' => $year, +
-        'month' => $month, +
-        'day' => $day, +
-        'id' => $basename, +
-        'title' => $title, +
-    ]; +
-}+
  
-usort($items, function ($a, $b) { 
-    return strcmp($b['datekey'], $a['datekey']); 
-}); 
- 
-echo '<div class="archive-list">'; 
-echo '<h2>' . htmlspecialchars((int)$targetYear . '年の過去履歴', ENT_QUOTES, 'UTF-8') . '</h2>'; 
- 
-$currentMonth = ''; 
- 
-foreach ($items as $item) { 
-    if ($item['month'] !== $currentMonth) { 
-        if ($currentMonth !== '') { 
-            echo '</ul>'; 
-        } 
- 
-        $currentMonth = $item['month']; 
-        echo '<h3>' . htmlspecialchars((int)$currentMonth . '月', ENT_QUOTES, 'UTF-8') . '</h3>'; 
-        echo '<ul>'; 
-    } 
- 
-    $dateLabel = (int)$item['year'] . '年' . (int)$item['month'] . '月' . (int)$item['day'] . '日'; 
-    $url = '/blog/' . rawurlencode($item['id']); 
- 
-    echo '<li>'; 
-    echo '<span class="archive-date">' . htmlspecialchars($dateLabel, ENT_QUOTES, 'UTF-8') . '</span> '; 
-    echo '<a href="' . htmlspecialchars($url, ENT_QUOTES, 'UTF-8') . '">'; 
-    echo htmlspecialchars($item['title'], ENT_QUOTES, 'UTF-8'); 
-    echo '</a>'; 
-    echo '</li>'; 
-} 
- 
-if ($currentMonth !== '') { 
-    echo '</ul>'; 
-} 
- 
-if (empty($items)) { 
-    echo '<p>記事はありません。</p>'; 
-} 
- 
-echo '</div>'; 
-</php> 
hist.1777039358.txt.gz · 最終更新: by Tokyo Admin

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki