Skip to content

災害情報を配信するための実験的なプロジェクトです。

License

Notifications You must be signed in to change notification settings

c4w/disaster-information

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHubページを使った災害情報配信用のJSON API

Build Status

このプロジェクトは災害情報を配信するための実験的なプロジェクトです。

このプロジェクトは以下のことを目的としています。

  • 強固なインフラであること。
  • 災害情報はAPIとして配信できること。複数のフロントエンドで再利用が可能であること。
  • 導入に際してなるべく学習コストが低いこと。
  • 災害時に即座に導入することが可能であること。
  • オープンであり汎用性が高いテクノロジーを使用していること。
  • 自動化がしやすいこと。

もちろんこの方法がベストだとは思っていませんが、災害時に自治体等のサイトがダウンしてしまうという最悪の状態を防ぐための手段の一つとしてどうかなと考えてみました。

この方法のメリット

  • メインのサイトにCDNを適用してキャッシュされても、災害情報がAPI経由であればキャッシュの問題が解消される。
  • 複数のフロントエンドをあらかじめ用意すればトラフィックの集中を防げる。
  • 他言語対応が容易。
  • GitHubの巨大なバックボーンを使用可能。AWSのS3等にバックボーンを変更することもわずかなコードの修正で可能。
  • スタティックなファイルの配信なので安全。
  • いちど構築してしまえば学習コストが低い。(と思う。笑)
  • インフラのメンテナンスが不要。
  • オペレーションミスがあってもGitで戻せて履歴も残せる。
  • 無料。(ただし独自ドメインを割り当てた方がポータビリティが高くGitHubへの依存度も低い。。。と思う。)

APIのエンドポイント

APIの出力例

{
  "entries": [
    {
      "title": "Welcome to Jekyll!",
      "date": "2016-04-17 07:56:11 +0000",
      "url": "/2016/04/17/welcome-to-jekyll.html",
      "tags": [
        "避難情報",
        "避難所情報"
      ],
      "lang": "ja",
      "body": "You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run jekyll serve, which launches a web server and auto-regenerates your site when a file is updated. To add new posts, simply add a file in the _posts directory that follows the convention YYYY-MM-DD-name-of-post.ext and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works."
    }
  ]
}

導入方法

  1. このリポジトリをフォークしてください。
  2. Travis CIにサインアップ。
  3. Travis CIでリポジトリを有効化。
  4. アクセストークンを取得
  5. アクセストークンを暗号化
  6. .travis.ymlを書き換え。
  7. GitHubにプッシュ。

記事の投稿方法

  1. masterブランチの_postsディレクトリ内にJekyllの記事と同じフォーマット(.md)のファイルをpushしてください。またはGitHubの [New file] ボタンをクリックして_posts内に記事を作成してください。
  2. masterブランチに変更が加わるとTravis CIによって自動的にAPIとして利用可能なJSONファイルが生成されます。(ただし生成されるまでに数分かかります。)

仕組み

  • GitHubにマークダウンファイルを投稿すると、Travis CIが発火して自動的にJSON APIがgh-pagesブランチに生成されます。
  • JSONを生成するには、Jekyllと、アメリカ政府内の機関18Fが開発したjekyll_pages_apiというJekyllプラグインを使用しています。

マークダウンフォーマットの例

---
title:  "Welcome to Jekyll!"
date:   2016-04-17 16:56:11 +0900
tags: 避難情報, 避難所情報
lang: ja
---
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.

To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.

問題点

  • Travis CIによってJSONが生成されるまでに数分かかる。
    • デスクトップで生成してgh-pagesにpushすることも可能
  • マークダウンの学習コストが高いかも。
  • そもそもGitの学習コストが高いかも。
    • 和歌山県や国土地理院などGitHubアカウントを持っている政府機関や自治体はすでにある。
    • GitHub上であればブラウザ上の操作だけで情報の追加が可能
  • GitHubに依存することにネガティブな意見があるかもしれない。
    • オープンな技術を使っているので、他にも代替可能なサービスや手段はあり、必要以上に依存してるわけではない。

その他、いろいろあるかもですが、ご意見やご感想はIssueでどうぞ。

開発

$ git clone git@github.com:c4w/disaster-information.git
$ cd disaster-information
$ bundle install --path vendor/bundle

Then:

$ bundle exec jekyll serve

Or

$ bundle exec jekyll build

ライセンス

MIT

About

災害情報を配信するための実験的なプロジェクトです。

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages