HTMLを綺麗に
諏訪子 <suwako@076.moe>、2025-11-08 18:12
コミット 8513c530f56deb2e1008518c462e0d99f907cacf
・親 adaf762
・ファイルを見る
7個のファイル、+112 -101
| @@ -42,7 +42,7 @@ | ||
| 42 | 42 | */ |
| 43 | 43 | public function addCss(string $name): void { |
| 44 | 44 | $this->custCss[] = |
| 45 | - '<link rel="stylesheet" type="text/css" href="/static/style-'.$name.'.css" />'; | |
| 45 | + "<link rel=\"stylesheet\" type=\"text/css\" href=\"/static/style-{$name}.css\" />\n"; | |
| 46 | 46 | $this->assign('custCss', $this->custCss); |
| 47 | 47 | } |
| 48 | 48 |
| @@ -1,16 +1,27 @@ | ||
| 1 | 1 | {@ include(common/header) @} |
| 2 | +{@ include(common/search) @} | |
| 3 | + | |
| 2 | 4 | <div class="news-article"> |
| 3 | - {@ if (isset($meta->thumbnail) && $meta->thumbnail != '') @} | |
| 5 | +{@ if (isset($meta->thumbnail) && $meta->thumbnail != '') @} | |
| 4 | 6 | <div class="thumbnail{{ isset($meta->thumborient) && $meta->thumborient != 'center' ? ' '.$meta->thumborient : '' }}"> |
| 5 | 7 | <img src="/static/article/{{ $meta->thumbnail }}" alt="" /> |
| 6 | 8 | </div> |
| 7 | - {@ endif @} | |
| 9 | +{@ endif @} | |
| 8 | 10 | <div class="meta"> |
| 9 | 11 | <div class="meta-date">{{ $meta->date }}</div> |
| 10 | 12 | <div class="meta-author">{{ $meta->author }}</div> |
| 13 | +{@ if (isset($meta->category) && !empty($meta->category) && $meta->category[0] !== '') @} | |
| 14 | +{@ foreach ($meta->category as $cat) @} | |
| 15 | + <div class="meta-category"> | |
| 16 | + {{ $cat }} | |
| 17 | + | |
| 18 | + </div> | |
| 19 | +{@ endforeach @} | |
| 20 | +{@ endif @} | |
| 11 | 21 | </div> |
| 12 | 22 | |
| 13 | 23 | <h1 class="title">{{{ $meta->title }}}</h1> |
| 14 | - {{{ $article }}} | |
| 24 | +{{{ $article }}} | |
| 25 | + | |
| 15 | 26 | </div> |
| 16 | 27 | {@ include(common/footer) @} |
| @@ -7,16 +7,16 @@ | ||
| 7 | 7 | <title>{{ SITEINFO['title'] }}: {{ $pagetit }}</title> |
| 8 | 8 | <link rel="stylesheet" type="text/css" href="/static/style.css" /> |
| 9 | 9 | {@ if (isset($custCss) && !empty($custCss) && !is_bool($custCss)) @} |
| 10 | - {@ foreach ($custCss as $css) @} | |
| 10 | +{@ foreach ($custCss as $css) @} | |
| 11 | 11 | {{{ $css }}} |
| 12 | - {@ endforeach @} | |
| 12 | +{@ endforeach @} | |
| 13 | 13 | {@ endif @} |
| 14 | 14 | {@ if (isset($meta)) @} |
| 15 | 15 | <meta name="author" content="{{ $meta->author }}" /> |
| 16 | - {@ if (isset($meta->thumbnail)) @} | |
| 16 | +{@ if (isset($meta->thumbnail)) @} | |
| 17 | 17 | <meta name="thumbnail" content="/static/{{ $meta->thumbnail }}" /> |
| 18 | - {@ endif @} | |
| 19 | 18 | {@ endif @} |
| 19 | +{@ endif @} | |
| 20 | 20 | <meta name="description" content="{{ $description }}" /> |
| 21 | 21 | <meta name="keywords" content="{{ SITEINFO['tags'].',' }}{@ if (isset($meta)) @}{@ foreach ($meta->category as $cat) @}{{ $cat.',' }}{@ endforeach @}{@ endif @}" /> |
| 22 | 22 | |
| @@ -24,23 +24,23 @@ | ||
| 24 | 24 | <meta property="og:description" content="{{ $description }}" /> |
| 25 | 25 | <meta property="og:type" content="{{ isset($meta) && isset($meta->thumbnail) ? 'article' : 'website' }}" /> |
| 26 | 26 | <meta property="og:url" content="{{ isset($_SERVER['REQUEST_URI']) ? 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] : 'https://'.$_SERVER['HTTP_HOST'] }}" /> |
| 27 | - {@ if (isset($meta) && isset($meta->thumbnail)) @} | |
| 27 | +{@ if (isset($meta) && isset($meta->thumbnail)) @} | |
| 28 | 28 | <meta property="og:image" content="https://{{ $_SERVER['HTTP_HOST'] }}/static/article/{{ $meta->thumbnail }}" /> |
| 29 | - {@ endif @} | |
| 29 | +{@ endif @} | |
| 30 | 30 | |
| 31 | - {@ if (TWITTER_HANDLE != '') @} | |
| 31 | +{@ if (TWITTER_HANDLE != '') @} | |
| 32 | 32 | <meta name="twitter:card" content="summary_large_image" /> |
| 33 | 33 | <meta name="twitter:card" content="{{ TWITTER_HANDLE }}" /> |
| 34 | 34 | <meta name="twitter:title" content="{{ SITEINFO['title'] }}: {{ $pagetit }}" /> |
| 35 | 35 | <meta name="twitter:url" content="{{ isset($_SERVER['REQUEST_URI']) ? 'https://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] : 'https://'.$_SERVER['HTTP_HOST'] }}" /> |
| 36 | 36 | <meta name="twitter:description" content="{{ $description }}" /> |
| 37 | - {@ if (isset($meta) && isset($meta->thumbnail)) @} | |
| 37 | +{@ if (isset($meta) && isset($meta->thumbnail)) @} | |
| 38 | 38 | <meta name="twitter:image:src" content="https://{{ $_SERVER['HTTP_HOST'] }}/static/article/{{ $meta->thumbnail }}" /> |
| 39 | - {@ endif @} | |
| 40 | - {@ endif @} | |
| 41 | - {@ if (ATOM_ENABLED) @} | |
| 39 | +{@ endif @} | |
| 40 | +{@ endif @} | |
| 41 | +{@ if (ATOM_ENABLED) @} | |
| 42 | 42 | <link rel="alternate" type="application/atom+xml" title="{{ SITEINFO['title'] }} feed" href="/blog.atom" /> |
| 43 | - {@ endif @} | |
| 43 | +{@ endif @} | |
| 44 | 44 | </head> |
| 45 | 45 | <body> |
| 46 | 46 | <div class="container"> |
| @@ -50,9 +50,9 @@ | ||
| 50 | 50 | </div> |
| 51 | 51 | <nav> |
| 52 | 52 | {@ foreach ($menu as $m) @} |
| 53 | - {@ if ($m['show']) @} | |
| 53 | +{@ if ($m['show']) @} | |
| 54 | 54 | <a class="{{ $m['class'] }}{{ $curPage == $m['page'] ? ' active' : '' }}" href="{{ $m['href'] }}">{{ $m['text'] }}</a> |
| 55 | - {@ endif @} | |
| 55 | +{@ endif @} | |
| 56 | 56 | {@ endforeach @} |
| 57 | 57 | </nav> |
| 58 | 58 | </header> |
| @@ -1,23 +1,21 @@ | ||
| 1 | - <article class="news-card"> | |
| 2 | - {@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @} | |
| 3 | - <div class="news-image"> | |
| 4 | - <a href="/{{ $section }}/{{ $post['slug'] }}"> | |
| 5 | - <img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" /> | |
| 6 | - </a> | |
| 1 | + <article class="news-card"> | |
| 2 | +{@ if (isset($post['thumbnail']) && $post['thumbnail'] != '') @} | |
| 3 | + <div class="news-image"> | |
| 4 | + <a href="/{{ $section }}/{{ $post['slug'] }}"> | |
| 5 | + <img src="/static/article/{{ $post['thumbnail'] }}" alt="{{ $post['title'] }}" loading="lazy" /> | |
| 6 | + </a> | |
| 7 | + </div> | |
| 8 | +{@ endif @} | |
| 9 | + <div class="news-content"> | |
| 10 | + <div class="news-meta"> | |
| 11 | + <span class="news-date">{{ $post['date'] }}</span> | |
| 12 | +{@ foreach ($post['category'] as $cat) @} | |
| 13 | + <span class="news-category">{{ $cat }}</span> | |
| 14 | +{@ endforeach @} | |
| 7 | 15 | </div> |
| 8 | - {@ endif @} | |
| 9 | - <div class="news-content"> | |
| 10 | - <div class="news-meta"> | |
| 11 | - <span class="news-date">{{ $post['date'] }}</span> | |
| 12 | - {# {@ if (isset($post['category']) && is_array($post['category'])) @} #} | |
| 13 | - {@ foreach ($post['category'] as $cat) @} | |
| 14 | - <span class="news-category">{{ $cat }}</span> | |
| 15 | - {@ endforeach @} | |
| 16 | - {# {@ endif @} #} | |
| 17 | - </div> | |
| 18 | - <h2 class="news-title"> | |
| 19 | - <a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a> | |
| 20 | - </h2> | |
| 21 | - <p class="news-preview">{{{ $post['preview'] }}}</p> | |
| 22 | - </div> | |
| 23 | - </article> | |
| 16 | + <h2 class="news-title"> | |
| 17 | + <a href="/{{ $section }}/{{ $post['slug'] }}{{{ isset($_GET['q']) ? '?q='.urlencode($_GET['q']) : '' }}}">{{{ $post['title'] }}}</a> | |
| 18 | + </h2> | |
| 19 | + <p class="news-preview">{{{ $post['preview'] }}}</p> | |
| 20 | + </div> | |
| 21 | + </article> |
| @@ -1,71 +1,71 @@ | ||
| 1 | - {@ if (isset($totalPages) && $totalPages > 1) @} | |
| 1 | +{@ if (isset($totalPages) && $totalPages > 1) @} | |
| 2 | 2 | <div class="pagination"> |
| 3 | - {# 検索クエリがある場合はページネーションリンクに含める #} | |
| 4 | - {$ $queryParams = [] $} | |
| 5 | - {@ if (isset($_GET['q']) && !empty($_GET['q'])) @} | |
| 6 | - {$ $queryParams['q'] = $_GET['q'] $} | |
| 7 | - {@ endif @} | |
| 3 | +{# 検索クエリがある場合はページネーションリンクに含める #} | |
| 4 | +{$ $queryParams = [] $} | |
| 5 | +{@ if (isset($_GET['q']) && !empty($_GET['q'])) @} | |
| 6 | +{$ $queryParams['q'] = $_GET['q'] $} | |
| 7 | +{@ endif @} | |
| 8 | 8 | |
| 9 | - {# 前のページへのリンク #} | |
| 10 | - {@ if (isset($currentPage) && $currentPage > 1) @} | |
| 11 | - {$ $prevParams = $queryParams $} | |
| 12 | - {$ $prevParams['page'] = $currentPage - 1 $} | |
| 13 | - {$ $prevQueryString = http_build_query($prevParams) $} | |
| 9 | +{# 前のページへのリンク #} | |
| 10 | +{@ if (isset($currentPage) && $currentPage > 1) @} | |
| 11 | +{$ $prevParams = $queryParams $} | |
| 12 | +{$ $prevParams['page'] = $currentPage - 1 $} | |
| 13 | +{$ $prevQueryString = http_build_query($prevParams) $} | |
| 14 | 14 | <a href="?{{ $prevQueryString }}" class="page-link">« 前</a> |
| 15 | - {@ endif @} | |
| 15 | +{@ endif @} | |
| 16 | 16 | |
| 17 | - {# 表示するページ番号の範囲を計算(モバイル対応の為) #} | |
| 18 | - {# 最大表示ページ数 #} | |
| 19 | - {$ $rangeSize = 2 $} | |
| 20 | - {$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $} | |
| 21 | - {$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $} | |
| 17 | +{# 表示するページ番号の範囲を計算(モバイル対応の為) #} | |
| 18 | +{# 最大表示ページ数 #} | |
| 19 | +{$ $rangeSize = 2 $} | |
| 20 | +{$ $startPage = max(1, $currentPage - floor($rangeSize / 2)) $} | |
| 21 | +{$ $endPage = min($totalPages, $startPage + $rangeSize - 1) $} | |
| 22 | 22 | |
| 23 | - {# 範囲の調整 #} | |
| 24 | - {@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @} | |
| 25 | - {$ $startPage = max(1, $endPage - $rangeSize + 1) $} | |
| 26 | - {@ endif @} | |
| 23 | +{# 範囲の調整 #} | |
| 24 | +{@ if ($endPage - $startPage + 1 < $rangeSize && $startPage > 1) @} | |
| 25 | +{$ $startPage = max(1, $endPage - $rangeSize + 1) $} | |
| 26 | +{@ endif @} | |
| 27 | 27 | |
| 28 | - {# 最初のページへのリンク(多数のページがある場合) #} | |
| 29 | - {@ if ($startPage > 1) @} | |
| 30 | - {$ $firstParams = $queryParams $} | |
| 31 | - {$ $firstParams['page'] = 1 $} | |
| 32 | - {$ $firstQueryString = http_build_query($firstParams) $} | |
| 28 | +{# 最初のページへのリンク(多数のページがある場合) #} | |
| 29 | +{@ if ($startPage > 1) @} | |
| 30 | +{$ $firstParams = $queryParams $} | |
| 31 | +{$ $firstParams['page'] = 1 $} | |
| 32 | +{$ $firstQueryString = http_build_query($firstParams) $} | |
| 33 | 33 | |
| 34 | 34 | <a href="?{{ $firstQueryString }}" class="page-link">1</a> |
| 35 | - {@ if ($startPage > 2) @} | |
| 35 | +{@ if ($startPage > 2) @} | |
| 36 | 36 | <span class="page-ellipsis">...</span> |
| 37 | - {@ endif @} | |
| 38 | - {@ endif @} | |
| 37 | +{@ endif @} | |
| 38 | +{@ endif @} | |
| 39 | 39 | |
| 40 | - {@ for ($i = $startPage; $i <= $endPage; $i++) @} | |
| 41 | - {$ $pageParams = $queryParams $} | |
| 42 | - {$ $pageParams['page'] = $i $} | |
| 43 | - {$ $pageQueryString = http_build_query($pageParams) $} | |
| 40 | +{@ for ($i = $startPage; $i <= $endPage; $i++) @} | |
| 41 | +{$ $pageParams = $queryParams $} | |
| 42 | +{$ $pageParams['page'] = $i $} | |
| 43 | +{$ $pageQueryString = http_build_query($pageParams) $} | |
| 44 | 44 | |
| 45 | - {@ if ($i == $currentPage) @} | |
| 46 | - <span class="page-current" aria-current="page">{{ $i }}</span> | |
| 47 | - {@ else @} | |
| 48 | - <a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a> | |
| 49 | - {@ endif @} | |
| 50 | - {@ endfor @} | |
| 45 | +{@ if ($i == $currentPage) @} | |
| 46 | + <span class="page-current" aria-current="page">{{ $i }}</span> | |
| 47 | +{@ else @} | |
| 48 | + <a href="?{{ $pageQueryString }}" class="page-link">{{ $i }}</a> | |
| 49 | +{@ endif @} | |
| 50 | +{@ endfor @} | |
| 51 | 51 | |
| 52 | - {@ if ($endPage < $totalPages) @} | |
| 53 | - {# 最後のページへのリンク(多数のページがある場合) #} | |
| 54 | - {$ $lastParams = $queryParams $} | |
| 55 | - {$ $lastParams['page'] = $totalPages $} | |
| 56 | - {$ $lastQueryString = http_build_query($lastParams) $} | |
| 57 | - {@ if ($endPage < $totalPages - 1) @} | |
| 58 | - <span class="page-ellipsis">...</span> | |
| 59 | - {@ endif @} | |
| 60 | - <a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a> | |
| 61 | - {@ endif @} | |
| 52 | +{@ if ($endPage < $totalPages) @} | |
| 53 | +{# 最後のページへのリンク(多数のページがある場合) #} | |
| 54 | +{$ $lastParams = $queryParams $} | |
| 55 | +{$ $lastParams['page'] = $totalPages $} | |
| 56 | +{$ $lastQueryString = http_build_query($lastParams) $} | |
| 57 | +{@ if ($endPage < $totalPages - 1) @} | |
| 58 | + <span class="page-ellipsis">...</span> | |
| 59 | +{@ endif @} | |
| 60 | + <a href="?{{ $lastQueryString }}" class="page-link">{{ $totalPages }}</a> | |
| 61 | +{@ endif @} | |
| 62 | 62 | |
| 63 | - {# 次のページへのリンク #} | |
| 64 | - {@ if (isset($currentPage) && $currentPage < $totalPages) @} | |
| 65 | - {$ $nextParams = $queryParams $} | |
| 66 | - {$ $nextParams['page'] = $currentPage + 1 $} | |
| 67 | - {$ $nextQueryString = http_build_query($nextParams) $} | |
| 68 | - <a href="?{{ $nextQueryString }}" class="page-link">次 »</a> | |
| 69 | - {@ endif @} | |
| 63 | +{# 次のページへのリンク #} | |
| 64 | +{@ if (isset($currentPage) && $currentPage < $totalPages) @} | |
| 65 | +{$ $nextParams = $queryParams $} | |
| 66 | +{$ $nextParams['page'] = $currentPage + 1 $} | |
| 67 | +{$ $nextQueryString = http_build_query($nextParams) $} | |
| 68 | + <a href="?{{ $nextQueryString }}" class="page-link">次 »</a> | |
| 69 | +{@ endif @} | |
| 70 | 70 | </div> |
| 71 | - {@ endif @} | |
| 71 | +{@ endif @} |
| @@ -1,9 +1,11 @@ | ||
| 1 | 1 | {@ include(common/header) @} |
| 2 | 2 | {@ include(common/search) @} |
| 3 | + | |
| 3 | 4 | <div class="news-grid"> |
| 4 | - {@ foreach ($posts as $post) @} | |
| 5 | - {@ include(common/newscard) @} | |
| 6 | - {@ endforeach @} | |
| 5 | +{@ foreach ($posts as $post) @} | |
| 6 | +{@ include(common/newscard) @} | |
| 7 | +{@ endforeach @} | |
| 7 | 8 | </div> |
| 8 | - {@ include(common/pagination) @} | |
| 9 | + | |
| 10 | +{@ include(common/pagination) @} | |
| 9 | 11 | {@ include(common/footer) @} |