-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# ssj | ||
超簡易静的サイトジェネレーター | ||
|
||
// 超簡易静的サイトジェネレーター | ||
// index.htmlの<!-- {***} -->~<!-- /{***} -->で囲まれた部分を | ||
// 他のHTMLにコピーする。 | ||
// ***に入る文字列は header, sidebar, footer のいずれか。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- {header} --> | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>タイトル</title> | ||
<link rel="stylesheet" href="main.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1><!-- {s1} -->トップページ<!-- /{s1} --></h1> | ||
<a href="./">トップページ</a> | ||
<a href="company.html">会社概要</a> | ||
<a href="contact.html">お問い合わせ</a> | ||
</header> | ||
<!-- /{header} --> | ||
<div id="container"> | ||
<!-- {sidebar} --> | ||
<aside> | ||
サイドバー | ||
</aside> | ||
<!-- /{sidebar} --> | ||
<article> | ||
会社概要 | ||
</article> | ||
</div> | ||
<!-- {footer} --> | ||
<footer> | ||
<!-- {s2} -->フッタ<!-- /{s2} --> | ||
</footer> | ||
</body> | ||
</html> | ||
<!-- /{footer} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- {header} --> | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>タイトル</title> | ||
<link rel="stylesheet" href="main.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1><!-- {s1} -->トップページ<!-- /{s1} --></h1> | ||
<a href="./">トップページ</a> | ||
<a href="company.html">会社概要</a> | ||
<a href="contact.html">お問い合わせ</a> | ||
</header> | ||
<!-- /{header} --> | ||
<div id="container"> | ||
<!-- {sidebar} --> | ||
<aside> | ||
サイドバー | ||
</aside> | ||
<!-- /{sidebar} --> | ||
<article> | ||
お問い合わせ | ||
</article> | ||
</div> | ||
<!-- {footer} --> | ||
<footer> | ||
<!-- {s2} -->フッタ<!-- /{s2} --> | ||
</footer> | ||
</body> | ||
</html> | ||
<!-- /{footer} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!-- {header} --> | ||
<!DOCTYPE html> | ||
<html lang="ja"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>タイトル</title> | ||
<link rel="stylesheet" href="main.css"> | ||
</head> | ||
<body> | ||
<header> | ||
<h1><!-- {s1} -->トップページ<!-- /{s1} --></h1> | ||
<a href="./">トップページ</a> | ||
<a href="company.html">会社概要</a> | ||
<a href="contact.html">お問い合わせ</a> | ||
</header> | ||
<!-- /{header} --> | ||
<div id="container"> | ||
<!-- {sidebar} --> | ||
<aside> | ||
サイドバー | ||
</aside> | ||
<!-- /{sidebar} --> | ||
<article> | ||
トップページ | ||
</article> | ||
</div> | ||
<!-- {footer} --> | ||
<footer> | ||
<!-- {s2} -->フッタ<!-- /{s2} --> | ||
</footer> | ||
</body> | ||
</html> | ||
<!-- /{footer} --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
header, footer { | ||
background: #ffc; | ||
text-align: center; | ||
padding: 20px 0; | ||
} | ||
#container { | ||
display: flex; | ||
height: 300px; | ||
} | ||
aside { | ||
flex: 1; | ||
background: #fcc; | ||
} | ||
article { | ||
flex: 2; | ||
background: #cff; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
// Seiteki Saito Jenereetaa | ||
|
||
// 反映元 | ||
$src = 'index.html'; | ||
|
||
// 反映先 | ||
$dists = ['company.html', 'contact.html']; | ||
|
||
// セクション | ||
$sections = ['header', 'sidebar', 'footer']; | ||
|
||
$parts = []; | ||
$html = file_get_contents($src); | ||
foreach ($sections as $section) { | ||
preg_match('|<!-- {' . $section . '} -->(.*?)<!-- /{' . $section . '} -->|s', $html, $ms); | ||
$parts[$section] = $ms[1]; | ||
} | ||
preg_match_all('|<!-- {s(\d+?)} -->(.*?)<!-- /{s\d+?} -->|s', $html, $mss, PREG_SET_ORDER); | ||
$slots = []; | ||
foreach ($mss as $ms) $slots[$ms[1]] = $ms[2]; | ||
foreach ($dists as $dist) { | ||
$html = file_get_contents($dist); | ||
foreach ($parts as $section => $part) { | ||
$html = preg_replace('|(<!-- {' . $section . '} -->)(.*?)(<!-- /{' . $section . '} -->)|s', "$1$part$3", $html); | ||
} | ||
file_put_contents($dist, $html); | ||
echo "$dist OK<br>"; | ||
} |