Compare commits

...

6 Commits

Author SHA1 Message Date
7569ff6930 技術スタックを追加 2025-11-17 17:38:25 +09:00
3b1792df01 README.md を更新 2025-11-17 08:34:49 +00:00
fc1f04fa12 \URL追加,旧ディレクトリ名修正 2025-11-17 17:33:33 +09:00
7c58848869 README.mdを追加し,index.htmlではTwitterをx.comに変更 2025-11-17 17:30:11 +09:00
2a2b24d11a Merge remote-tracking branch 'origin/main' 2025-11-17 11:00:03 +09:00
0d9f8070da initial commit 2025-11-17 10:45:52 +09:00
7 changed files with 260 additions and 1 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
node_modules/
npm-debug.log
package-lock.json

View File

@@ -1,2 +1,56 @@
# WB-ToonTools
渡辺橋のJSON → TOON 変換ツール
## 概要
このツールは、JSON形式のデータをTOON形式に変換するためのウェブアプリケーションです。
すべての変換はブラウザ内で完結し、入力されたデータがサーバーに送信されることはありません。
## 主な機能
- **JSONからTOONへの変換**: 入力されたJSONデータをTOON形式に変換します。
- **クライアントサイド処理**: サーバーにデータを送信することなく、ブラウザ上で安全に変換処理を行います。
- **クリップボードへのコピー**: 変換結果を簡単にコピーできます。
- **UIのクリア**: 入力と出力エリアを一度にクリアできます。
## 技術スタック
- HTML, CSS, JavaScript
- CSSフレームワークはBootstrapを使用
- JSONからTOONへの変換で公式の[@toon-format/toon](https://github.com/toon-format/toon)ライブラリを使用
## 使い方
1. Webページを開きます。
2. 左側の「JSON入力エリア」に、変換したいJSONデータを貼り付けます。
3. 「変換」ボタンをクリックします。
4. 右側の「TOON出力エリア」に変換結果が表示されます。
5. 「コピー」ボタンで結果をクリップボードにコピーできます。
## ローカルでの実行方法
1. リポジトリをクローンします。
```bash
git clone https://git.watanabebashi.net/Watanabebashi/WB-ToonTools
cd WB-ToonTools
```
2. 依存関係をインストールします。
```bash
npm install
```
3. 開発用サーバーを起動します。
```bash
npx http-server
```
4. ブラウザで `http://127.0.0.1:8080` にアクセスします。
## 開発予定の機能
- TOON形式からJSON形式への逆変換
- 入力されたJSON/TOONの構文ハイライト
- CSV等の形式への対応
- 節約トークン数の表示
## ライセンス
このプロジェクトは [AGPLv3](https://www.gnu.org/licenses/agpl-3.0.html) の下でライセンスされています。
© 2025 Watanabebashi Alpha

79
app.js Normal file
View File

@@ -0,0 +1,79 @@
/*
* Copyright (C) 2025 Watanabebashi Alpha
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
import { encode } from './node_modules/@toon-format/toon/dist/index.js';
const jsonInEl = document.getElementById('jsonIn');
const toonOutEl = document.getElementById('toonOut');
const convertBtn = document.getElementById('convertBtn');
const clearBtn = document.getElementById('clearBtn');
const copyBtn = document.getElementById('copyBtn');
let isError = false;
const resetCopyButton = () => {
copyBtn.textContent = 'コピー';
copyBtn.classList.remove('btn-success');
copyBtn.classList.add('btn-outline-secondary');
};
convertBtn.addEventListener('click', () => {
const text = jsonInEl.value.trim();
if (!text) {
toonOutEl.textContent = '';
isError = false;
return;
}
resetCopyButton();
try {
const parsedJson = JSON.parse(text);
const toonData = encode(parsedJson);
toonOutEl.value = toonData;
isError = false;
} catch (e) {
isError = true;
if (e instanceof SyntaxError) {
toonOutEl.value = `JSONの形式が正しくありません`;
} else {
toonOutEl.value = `変換エラー`;
}
}
});
clearBtn.addEventListener('click', () => {
jsonInEl.value = '';
toonOutEl.value = '';
isError = false;
resetCopyButton();
});
copyBtn.addEventListener('click', () => {
const textToCopy = toonOutEl.value;
if (isError || !textToCopy) {
return;
}
navigator.clipboard.writeText(textToCopy).then(() => {
copyBtn.textContent = 'コピーしました!';
copyBtn.classList.remove('btn-outline-secondary');
copyBtn.classList.add('btn-success');
}).catch(err => {
console.error('クリップボードへのコピーに失敗しました: ', err);
});
});

6
css/bootstrap.min.css vendored Normal file

File diff suppressed because one or more lines are too long

102
index.html Normal file
View File

@@ -0,0 +1,102 @@
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>渡辺橋のJSON → TOON 変換ツール</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<style>
.io-box {
height: 400px;
overflow-y: auto;
}
</style>
</head>
<body>
<div class="container mt-4">
<div class="row">
<div class="col-md-10 mx-auto">
<h1 class="mb-4">渡辺橋のJSON → TOON 変換ツール</h1>
<div class="alert alert-info" role="alert">
入力内容はブラウザ内で変換され、サーバーには一切送信されません。
</div>
<div class="mb-3">
<button id="convertBtn" class="btn btn-primary">変換</button>
<button id="clearBtn" class="btn btn-secondary">クリア</button>
</div>
<div class="row">
<div class="col-md-6">
<h3>JSON入力エリア</h3>
<textarea id="jsonIn" class="form-control io-box" placeholder="ここにJSONを入力してください"></textarea>
</div>
<div class="col-md-6">
<div class="position-relative">
<h3 class="d-inline-block">TOON出力エリア</h3>
<button id="copyBtn" class="btn btn-sm btn-outline-secondary position-absolute top-0 end-0" style="margin-top: 0.5rem;">コピー</button>
<textarea id="toonOut" class="form-control io-box" readonly></textarea>
</div>
</div>
</div>
<div class="mt-4 text-center">
<h5 class="mb-3">気に入っていただけたらぜひシェアお願いします!!</h5>
<a id="shareTwitter" href="#" class="btn btn-dark" target="_blank" rel="noopener noreferrer">X(Twitter)</a>
<a id="shareFacebook" href="#" class="btn btn-primary" target="_blank" rel="noopener noreferrer">Facebook</a>
<a id="shareLine" href="#" class="btn text-white" style="background-color: #06C755; border-color: #06C755;" target="_blank" rel="noopener noreferrer">LINE</a>
</div>
<div class="mt-5">
<p>
<a class="btn btn-outline-secondary" data-bs-toggle="collapse" href="#futureFeatures" role="button" aria-expanded="false" aria-controls="futureFeatures">
開発予定の機能
</a>
</p>
<div class="collapse" id="futureFeatures">
<div class="card card-body">
<ul class="mb-0">
<li>TOON形式からJSON形式への逆変換</li>
<li>入力されたJSON/TOONの構文ハイライト</li>
<li>CSV等の形式への対応</li>
<li>節約トークン数の表示</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer mt-5 py-3 bg-light border-top">
<div class="container text-center">
<span class="text-muted"><a href="https://git.watanabebashi.net/Watanabebashi/WB-TOONTools">source code</a> | <a href="https://policy.watanabebashi.net/privacy.html">privacy policy</a></span>
<br>
<span class="text-muted">Proudly running on <a href="https://yodogawa.watanabebashi.net">yodogawa</a></span>
<br>
<span class="text-muted">&copy; 2025 Watanabebashi Alpha, Licensed under AGPLv3</span>
</div>
</footer>
<script type="module" src="app.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const pageUrl = encodeURIComponent(window.location.href);
const pageTitle = encodeURIComponent(document.title);
const twitterShare = document.getElementById('shareTwitter');
twitterShare.href = `https://x.com/intent/post?url=${pageUrl}&text=${pageTitle}`;
const facebookShare = document.getElementById('shareFacebook');
facebookShare.href = `https://www.facebook.com/sharer/sharer.php?u=${pageUrl}`;
const lineShare = document.getElementById('shareLine');
lineShare.href = `https://social-plugins.line.me/lineit/share?url=${pageUrl}`;
});
</script>
</body>
</html>

7
js/bootstrap.bundle.min.js vendored Normal file

File diff suppressed because one or more lines are too long

8
package.json Normal file
View File

@@ -0,0 +1,8 @@
{
"dependencies": {
"@toon-format/toon": "^1.0.0"
},
"devDependencies": {
"http-server": "^14.1.1"
}
}