diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-09-23 23:23:39 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-09-23 23:23:39 +0900 |
| commit | 2e18021e015e472b72610f2e1af080914c053ccb (patch) | |
| tree | fb9ad662d60103d1c4a300596cefba268bd74e9b /scripts/make-flow-simple.py | |
| parent | d534b20bb948a7b5d16220954d1886473c38d3ea (diff) | |
make-flow-simple.py ほか: 版と更新日を入れ、課題欄なしの簡易版を追加
図の右上に「第1版(令和8年9月23日)」を入れ、改訂したら版と日付を更新することをページに書いた。どの版が最新かを誰でも確認できるようにするため。
下部の課題欄と、フロー上の「課題N」バッジ、その説明(※6)を外した簡易版を用意した。教育委員会の内部資料など、課題欄が不要な用途でAIに作り直させずに済むようにするため。
簡易版にも出典・ライセンス・版は入れており、課題の内容はこのサイトに掲載している旨の注記を置いた。
簡易版の生成は scripts/make-flow-simple.py(make-flow-pdfs.py より先に実行)。
Diffstat (limited to 'scripts/make-flow-simple.py')
| -rw-r--r-- | scripts/make-flow-simple.py | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/scripts/make-flow-simple.py b/scripts/make-flow-simple.py new file mode 100644 index 0000000..1e0b566 --- /dev/null +++ b/scripts/make-flow-simple.py @@ -0,0 +1,80 @@ +"""公立学校版のSVGから、下部の【課題・論点】を省いた「簡易版」を作る。 + +- 課題欄(枠・見出し・12項目)と、フロー上の赤い「課題N」バッジを削除 +- 「課題N」を説明していた ※6 の注記も削除 +- 課題欄より下の要素(参考欄・注記・下部バー)を上へ寄せ、SVGの高さを縮める +- 課題欄があった位置に、課題はこのサイトに載っている旨の注記を入れる + + +このスクリプトは make-flow-pdfs.py より先に実行すること(PDFはSVGから作るため)。 + +使い方: python scripts/make-flow-simple.py +""" +import re +import sys +from pathlib import Path + +sys.stdout.reconfigure(encoding="utf-8") + +SRC = Path("public/ijime-judai-jitai/images/ijime-judai-flow.svg") +DST = Path("public/ijime-judai-jitai/images/ijime-judai-flow-simple.svg") +FF = "'Noto Sans JP','Yu Gothic','Hiragino Kaku Gothic ProN',Meiryo,sans-serif" +SHIFT = 525 # 課題欄を外したぶん、下の要素を上へ +GAP_Y = 2941 # ここより下の y をずらす + +text = SRC.read_text(encoding="utf-8") + +# 1) 課題欄(枠・見出し・注記・12項目)を削除 +start = text.index('<rect x="164" y="2941"') +end = text.index('<rect x="8" y="336"') +text = text[:start] + text[end:] + +# 2) フロー上の赤い「課題N」バッジを削除 +text, n_badge = re.subn(r'<a href="#issue\d+" style="cursor:pointer">.*?</a>\n', "", + text, flags=re.S) + +# 3) 「課題N」の説明(※6)を削除 +text, n_note = re.subn(r'<text x="20" y="\d+"[^>]*>※6[^<]*</text>\n', "", text) + +# 4) 出典の行から「課題欄」の語を外す +# 簡易版には課題欄がないので、ライセンス行の但し書きも外す +text = text.replace("課題欄のリンク先:yasutakeyohei.com", + "各課題の詳細:yasutakeyohei.com/ijime-judai-jitai/flow/") +text = text.replace("内容を変えず(下部の【課題・論点】を省くのは可)、", "内容を変えず、") + +# 5) 課題欄より下の要素を上へ寄せる +def _shift(m): + v = float(m.group(2)) + v = v - SHIFT if v >= GAP_Y else v + return f'{m.group(1)}="{int(v) if v == int(v) else v:g}"' + + +text = re.sub(r'\b(y|y1|y2)="([0-9.]+)"', _shift, text) + +# 6) SVGの高さを縮める +text = text.replace('height="3954"', f'height="{3954 - SHIFT}"') +text = text.replace('width="1820" height="4164" viewBox="0 0 1820 4164"', + f'width="1820" height="{4164 - SHIFT}" viewBox="0 0 1820 {4164 - SHIFT}"') + +# 7) タイトルに簡易版と分かるようにする +text = text.replace(">いじめの重大事態の対応フロー(ロール別)<", + ">いじめの重大事態の対応フロー(ロール別)簡易版<") + +# 8) 課題欄があった位置に、課題はこのサイトにある旨の注記を入れる +note = ( + f'<rect x="164" y="2925" width="1640" height="36" rx="6" fill="#FFFDE7" ' + f'stroke="#F9A825" stroke-width="1.6"/>\n' + f'<text x="180" y="2949" font-family="{FF}" font-size="12.5" fill="#E65100">' + f'※この図は、下部の【課題・論点】を省いた簡易版です。各課題の内容は、' + f'この図の解説ページ(yasutakeyohei.com/ijime-judai-jitai/flow/)に掲載しています。</text>\n' +) +text = text.replace('<rect x="8" y="336"', note + '<rect x="8" y="336"', 1) + +if "課題" in text.replace("【課題・論点】", "").replace("各課題", ""): + left = [ln for ln in text.splitlines() if "課題" in ln + and "【課題・論点】" not in ln and "各課題" not in ln] + raise SystemExit("「課題」の語が残っています:\n" + "\n".join(left[:5])) + +DST.write_text(text, encoding="utf-8") +print(f"作成しました: {DST}") +print(f" バッジ {n_badge}個 / ※6 {n_note}行 を削除、下の要素を {SHIFT}px 上へ") |
