Skip to content

Commit 882dcfa

Browse files
authored
Merge pull request #28 from 01397/dev
ドメイン変更とCI更新
2 parents e659f5a + df35fab commit 882dcfa

10 files changed

Lines changed: 66 additions & 27 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ jobs:
1616
cache: 'npm'
1717
- run: npm install
1818
- run: npm run build
19+
env:
20+
VITE_APP_VERSION: ${{ github.ref_name }}
1921
- name: Publish to Cloudflare Pages
2022
uses: cloudflare/wrangler-action@v3
2123
with:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ OuDiaファイル(.oud), OuDiaSecondファイル(.oud2)を開くことができ
99
Chromeを推奨しています。おそらく、Edge, Firefox, Safariの最新版でも動作すると思います。Internet Explorerはサポートしていません。
1010

1111
## 試す
12-
[http://onemu.starfree.jp/clouddia/](http://onemu.starfree.jp/clouddia/)で公開しています。
12+
[https://clouddia.01397.dev/clouddia/](https://clouddia.01397.dev/clouddia/)で公開しています。
1313

1414
## DiagramParser.js
1515
[DiagramParser.js](dist/js/DiagramParser.js) を用いてOudia, OudiaSecondのファイルをロードするのに使うことができます。DiagramParser.jsは[Util.js](dist/js/Util.js)に依存しているのでDiagramParser.jsとUtil.jsは同じディレクトリに含める必要があります。もちろん[Typescript版](src)もあります。

index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
<meta charset="utf-8">
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8-
<meta property="og:image" content="http://onemu.starfree.jp/clouddia/img/logo.png" />
8+
<meta property="og:image" content="https://clouddia.01397.dev/clouddia/img/logo.png" />
99
<meta property="og:locale" content="ja_JP" />
1010
<meta property="og:site_name" content="CloudDia" />
1111
<meta property="og:title" content="CloudDia" />
1212
<meta property="og:type" content="website" />
13-
<meta property="og:url" content="http://onemeu.starfree.jp/clouddia/" />
13+
<meta property="og:url" content="https://clouddia.01397.dev/clouddia/" />
1414
<meta property="og:description" content="oudiaファイルをブラウザで!" />
1515
<meta name="twitter:card" content="summary" />
1616
<meta name="twitter:site" content="@01397dev" />
@@ -28,7 +28,6 @@
2828
</script>
2929
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+JP:300,500&display=swap&subset=japanese"
3030
rel="stylesheet">
31-
<link rel="stylesheet" href="/style.css?v0.4.4">
3231
<script src="src/main.ts" type="module"></script>
3332
</head>
3433

package-lock.json

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
22
"name": "clouddia",
3-
"version": "0.4.4",
43
"description": "Online Diagram Editor",
5-
"homepage": "http://onemu.starfree.jp/clouddia/",
4+
"homepage": "https://clouddia.01397.dev/clouddia/",
65
"main": "src/main.ts",
76
"repository": "git@github.com:01397/clouddia.git",
87
"author": "01397 <41501869+01397@users.noreply.github.com>",

src/App.ts

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ import TrainTypeSettingView from './components/TrainTypeSettingView.js';
1313
import View, { viewTypeString } from './components/View.js';
1414
import DiagramParser, { DiagramFile, Train } from './DiagramParser.js';
1515
import Encoding from 'encoding-japanese';
16-
import { h, Menu } from './Util.js';
16+
import { Dialog, h, Menu } from './Util.js';
17+
import './styles/app.css';
1718

1819
export interface SelectionObject {
1920
train?: Train;
@@ -94,7 +95,9 @@ export default class App {
9495
private menu: MenuItem[];
9596

9697
constructor(root: Element) {
97-
this.version = '0.4.4';
98+
this.version = import.meta.env.PROD
99+
? import.meta.env.VITE_APP_VERSION
100+
: 'dev-build';
98101
this.sidebarElm = h('aside', { id: 'sidebar' }, null);
99102
this.toolbarElm = h('div', { id: 'toolbar' }, null);
100103
this.tabbarElm = h('div', { id: 'tabbar' }, null);
@@ -221,7 +224,7 @@ export default class App {
221224
public save() {
222225
//const bom = new Uint8Array([0xef, 0xbb, 0xbf]);
223226
const unicodeArray: number[] = [];
224-
const oudiaString = this.data.saveAsOud('CloudDia v' + this.version);
227+
const oudiaString = this.data.saveAsOud('CloudDia ' + this.version);
225228
for (let i = 0; i < oudiaString.length; i++) {
226229
unicodeArray.push(oudiaString.charCodeAt(i));
227230
}
@@ -248,6 +251,12 @@ export default class App {
248251
.catch((e: Error) => {
249252
// tslint:disable-next-line: no-console
250253
console.error('parse error.', e);
254+
const dialog = new Dialog({
255+
title: 'ファイル読み込みエラー',
256+
message: '時刻表ファイルとして認識できませんでした。',
257+
buttons: ['OK'],
258+
});
259+
dialog.show();
251260
});
252261
}
253262
public initialize(diagram: DiagramFile) {
@@ -260,19 +269,40 @@ export default class App {
260269
this.showTrainTimetableView(0, 0);
261270
}
262271
public loadOnlineFile(fileURL: string) {
263-
const url = 'http://soasa.starfree.jp/fileRequest.php?url=' + fileURL;
264-
fetch(url, { mode: 'cors' })
265-
.then((response) => response.blob())
266-
.then(
267-
(blob) =>
268-
new Promise(() => {
269-
const reader = new FileReader();
270-
reader.onload = () =>
271-
this.loadOudia(reader.result as string, 'Web上のファイル');
272-
reader.readAsText(blob, 'shift-jis');
273-
})
274-
)
272+
fetch(fileURL, { mode: 'cors' })
273+
.then((response) => {
274+
if (!response.ok) {
275+
throw new Error(`HTTPステータスコード: ${response.status}`);
276+
}
277+
return response.blob();
278+
})
279+
.then((blob) => {
280+
const reader = new FileReader();
281+
reader.onload = () =>
282+
this.loadOudia(reader.result as string, 'Web上のファイル');
283+
reader.onerror = (e) => {
284+
const dialog = new Dialog({
285+
title: 'ファイル読み込みエラー',
286+
message: 'ファイルの読み取りに失敗しました。',
287+
buttons: ['OK'],
288+
});
289+
dialog.show();
290+
};
291+
reader.readAsText(blob, 'shift-jis');
292+
})
275293
.catch((err) => {
294+
const message =
295+
err instanceof TypeError
296+
? 'CORSポリシーにより、読み込みがブロックされている可能性があります。'
297+
: err instanceof Error
298+
? err.message
299+
: '';
300+
const dialog = new Dialog({
301+
title: 'ファイル読み込みエラー',
302+
message: '指定のURLからファイルを読み込めませんでした。' + message,
303+
buttons: ['OK'],
304+
});
305+
dialog.show();
276306
throw err;
277307
});
278308
}

src/components/StartView.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export default class StartView extends View {
112112
h(
113113
'p',
114114
{ class: 'start-readme-paragraph' },
115-
'ブラウザ上で時刻表ファイルを見れたらいいなぁ〜という気持ちを込めて開発中の作品。OuDia, OuDiaSecondのファイルを表示することが多分できます。web上のファイルは"http://onemu.starfree.jp/clouddia/?url=[時刻表ファイルのURL]"で開くこともできます。'
115+
'ブラウザ上で時刻表ファイルを見れたらいいなぁ〜という気持ちを込めて開発中の作品。OuDia, OuDiaSecondのファイルを表示することが多分できます。web上のファイルは"https://clouddia.01397.dev/clouddia/?url=[時刻表ファイルのURL]"で開くこともできます。'
116116
),
117117
h('h1', { class: 'start-readme-heading' }, '注意事項'),
118118
h(
@@ -148,7 +148,7 @@ export default class StartView extends View {
148148
h('a', { href: 'https://github.com/01397/clouddia' }, 'GitHub'),
149149
]),
150150
h('p', { class: 'start-readme-paragraph' }, [
151-
document.createTextNode('バージョン: v' + this.app.version + ' '),
151+
document.createTextNode('バージョン: ' + this.app.version + ' '),
152152
h(
153153
'a',
154154
{

src/main.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ document.addEventListener('DOMContentLoaded', () => {
2020
// tslint:disable-next-line: no-console
2121
console.log(
2222
'%c %cWelcome To\n%c %cCloud %cDia',
23-
'padding:0px 32px;background-image:url(http://onemu.starfree.jp/clouddia/img/logo_icon_dark.svg);background-size:cover;background-position:0 -10px;',
23+
'padding:0px 32px;background-image:url(https://clouddia.01397.dev/clouddia/img/logo_icon_dark.svg);background-size:cover;background-position:0 -10px;',
2424
'font-size:14px;font-style:italic;',
25-
'padding:16px 32px;background-image:url(http://onemu.starfree.jp/clouddia/img/logo_icon_dark.svg);background-size:cover;background-position:0 -24px;',
25+
'padding:16px 32px;background-image:url(https://clouddia.01397.dev/clouddia/img/logo_icon_dark.svg);background-size:cover;background-position:0 -24px;',
2626
'padding:4px 0 4px 8px;color: #888888;font-size:24px;background-color:#1f1a24;background-image:linear-gradient(to right, #52a8ff00, #52a8ffaa );background-size: 100% 2px;background-position:0 calc(100% - 4px); background-repeat: no-repeat;border-radius:4px 0 0 4px',
2727
'padding:4px 8px 4px 0;color:#a852ff;font-size:24px;background-color:#1f1a24;background-image:linear-gradient(to right, #52a8ffaa, #52a8ff 90%);background-size: 100% 2px;background-position:0 calc(100% - 4px); background-repeat: no-repeat;border-radius:0 4px 4px 0'
2828
);
File renamed without changes.

src/vite-env.d.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/// <reference types="vite/client" />
2+
3+
interface ImportMetaEnv {
4+
// VITE_APP_VERSIONは、GitHub Actionsによるビルド時にGit tagから取得したバージョン番号を設定する
5+
// 例: "v0.1.0"
6+
VITE_APP_VERSION: string;
7+
}
8+
9+
interface ImportMeta {
10+
readonly env: ImportMetaEnv;
11+
}

0 commit comments

Comments
 (0)