Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GitHub Pages を Web API として使う

Kite
June 11, 2016

GitHub Pages を Web API として使う

GitHub の API ではなく、GitHub のサービスの一つである GitHub Pagesを使って、サーバなしで Web API を提供

Kite

June 11, 2016
Tweet

More Decks by Kite

Other Decks in Programming

Transcript

  1. Use GitHub Pages as a Web API GitHub Pages Λ

    Web API ͱͯ͠࢖͏ Kansai Front-end users group 2016.06.11 ϑϩϯτΤϯυͷਓ͕Web APIΛޠΔձ
  2. WordPress core contributor Ruby on Rails contributor Wocker developer Bathe

    developer Frasco developer Web & graphic designer Programmer Kite KITERETZ inc. CEO & Funder ! kite.koga " ixkaito # ixkaito WHO AM I?
  3. Jekyll Pages API ͱ͸ • Jekyll ͷϓϥάΠϯ • Jekyll αΠτ಺ͷ͢΂ͯͷϖʔδɺ౤ߘɺυΩϡϝϯτɺ੩త

    ϑΝΠϧͷσʔλΛجʹ JSON ϑΝΠϧΛੜ੒͢Δ • API ͸ http://example.com/api/v1/pages.json ͷΑ͏ͳURL ͰऔಘՄೳ
  4. GitHub Pages ΍ Jekyll Λ࢖͏ ϝϦοτ • GitHub Pages Λ࢖͏͜ͱͰɺΠϯϑϥͷϝϯςφϯε͕ෆཁ

    • Git ʹΑΔιʔε؅ཧ • API ͷΧελϚΠζ͕ࣗ༝ • ελςΟοΫͳϑΝΠϧͷ഑৴ͳͷͰɺηΩϡϦςΟϦεΫ͕௿͍ • ύϒϦοΫϦϙδτϦͰ͔ͭಠࣗυϝΠϯΛ࢖༻͠ͳ͍৔߹͸ແ ྉ • ଞͷαʔϏε΁ͷҠߦ΋༰қ
  5. ໰୊఺ GitHub Pages ͸ 
 GitHub Pages dependencies ʹ͋Δ
 ϓϥάΠϯҎ֎͸αϙʔτ͍ͯ͠ͳ͍

    ͦͷ·· gh-pages ϒϥϯνͳͲʹϓογϡͯ͠΋ɺJSON ϑΝ Πϧ͸ੜ੒͞Εͳ͍
  6. Travis CI ͳͲʹΑΔσϓϩΠ ϝϦοτ • ௨ৗͷ GitHub Pages/Jekyll ͷӡ༻ͱશ͘ಉ͡ σϝϦοτ

    • Travis CI ͳͲͷֶशίετ͕͔͔Δ • GitHub Pages ʹެ։͞ΕΔ·Ͱ͕͔͔࣌ؒΔ
  7. Rakefile ͳͲʹΑΔσϓϩΠ ϝϦοτ • ֎෦αʔϏεʹཔΔඞཁ͕ͳ͘ɺσϓϩΠͷखؒ΋͔͔Βͳ͍ • GitHub Pages ʹ͙͢ʹެ։͞ΕΔ •

    Travis CI ͳͲΑΓ͸ֶशίετ͕௿͍ σϝϦοτ • Rakefile Λ࡞Δඞཁ͕͋Δ • `git push` Ҏ֎ʹɺσϓϩΠ༻ͷίϚϯυΛ࣮ߦ͢Δඞཁ͕͋Δ
  8. ࢖͍ํ 1. Jekyll API Boilerplate ΛϑΥʔΫ 2. ϑΥʔΫͨ͠ϦϙδτϦΛΫϩʔϯ 3. Ϋϩʔϯͨ͠σΟϨΫτϦ಺ͰԼهΛ࣮ߦ


    $ bundle install --path vendor/bundle
 $ bundle exec jekyll serve --baseurl /jekyll-api-boilerplate 4. http://localhost:4000/jekyll-api-boilerplate/api/v1/ pages.json ʹΞΫηε͢Δ͜ͱͰ JSON API Λ֬ೝͰ͖Δ
  9. GitHub Pages ʹσϓϩΠ 1. `_config.yml` ಺ͷ `url` Λࣗ͝਎ͷ΋ͷʹมߋ 2. σΟϨΫτϦ಺ͰԼهΛ࣮ߦ


    $ bundle exec rake deploy 3. http://username.github.io/jekyll-api-boilerplate/api/v1/ pages.json ͷΑ͏ͳ URL ʹɺJSON API ͕ެ։͞Ε·͢