老舗15年のwebメディアをAPIサーバー化した話

 老舗15年のwebメディアをAPIサーバー化した話

DevLOVE199 越境CON の30min セッショントークの内容です。

B9a64a1c5873755ce9df629f05e3e12d?s=128

Makoto Shiga

January 28, 2017
Tweet

Transcript

  1. ࿝ฮ೥ͷXFCϝσΟΞΛ
 "1*αʔόʔԽͨ͠࿩ %FW-07&
 ӽڥ$0/
 !NBDPUBTV

  2. ࣗݾ঺հ

  3.  !NBDPUBTV
 HJUIVC.BDP5BTV
 UXJUUFSIUUQTUXJUUFSDPN.BDP@5BTV
 
 DIJFGFOHJOFFS


  4. BOJNBUF5JNFT ೥͔Β৘ใΛൃ৴͍ͯ͠ΔXFCϝσΟΞ ੠༏Ξχϝχϡʔε Ξχϝಈը ੠༏ϥδΦ 17഑৴ νέοτ FUDʜ Ξχϝ৘ใΛຖ೔ൃ৴ɺಡऀʹ͓ಧ͚͍ͯ͠Δ

  5. IUUQXXXBOJNBUFUJNFTDPN

  6. ࡢ೥݄ʹΞϓϦΛϦϦʔε

  7. ຊ୊ "1*Խ͢ΔͨΊͷΞϓϩʔν

  8. ࡢ೥݄̓ʹ্͔Β͓ୡ͕͋͠Γ·ͨ͠ ΞϓϦԽͷܦҢ

  9. ЊʮΞχϝΠτλΠϜζͷΞϓϦΛ࡞ͬͯ ΄͍͠ɻ݄຤ϦϦʔε໨ඪͰ΍ͬͯΈͯʯ ΞϓϦԽͷܦҢ

  10. ЊЊЊͳɺͳΜͩͬͯʔʂʁ ΞϓϦԽͷܦҢ

  11. ݱঢ়ͷαΠτΑΓշదʹ࢖͑Δ ΞϓϦԽͰͷϛογϣϯ

  12. w XFCWJFXͩͱαΠτΛεϚϗͷϒϥ΢βͰΈΔͷͱมΘΒͳ͍ w ΞϓϦͰͷදࣔ଎౓͕XFCWJFXͷ࣌ͱ"1*ͰKTPOͰΛฦͨ͠৔ ߹Ͱഒ଎౓͕ҧͬͨ
 IUUQEFWFMPQFSBOJNBUFMBCDPNFOUSZ  ΑΓշదʹ ΍ͬͺΓXFCWJFX͡Όͳͯ͘"1*͡Όͳ͖Όշదʹ ͸ͳΒͳ͍Ͷ

  13. ೥͔Βಈ͍͍ͯΔͷͰΘΓͱʁϨΨγʔ ΞχϝΠτλΠϜζͷݱঢ় w Ṗͳίʔυ͕ͨ͘͞Μ w /P'SBNFXPSLͰࢄΒ͹͍ͬͯΔQIQϑΝΠϧ w ࿝ٺԽͨ͠αʔόʔ w ։ൃ؀ڥ͕ͳ͍ʹ౳͍͠

    w FUD
  14. ͜ͷ؀ڥʹ࡞Ζ͏ͱ͢Δͱ
 ຤ʹऴΘΒͳ͍ͷͰ͸ʁ

  15. ࡞ઓ XFCϝσΟΞຊମͱ"1*͸ผΞϓϦͱͯ͠ੈքΛ෼͚Δ

  16. ੈքΛ෼͚ΔϝϦοτσϝϦοτ w ຊମ؀ڥͷঢ়ଶΛؾʹͤͣʹ࣮૷Ͱ͖Δ w ΞΫηε͕૿͑ͨ࣌ʹ྆ܥ͕ࢮ͵ͷΛආ͚Δ w Ұ͔Β࡞ΔͷͰɺṖͷଟ͍ίʔυͷղੳʹ࣌ؒΛ࢖ Θͣɺ"1*Λ࡞Δ͜ͱʹઐ೦Ͱ͖Δ ϝϦοτ σϝϦοτ

    w ͪΐͬͱ͓͔͔ۚΔ w ӡ༻ίετ΋૿͑Δ
  17. "1*αʔόʔͷಈ࡞؀ڥ w MBOHVBHF3VCZ w TFSWFSQVNB w GSBNFXPSLHSBQF

  18. w ϝσΟΞຊମ͔Βੜ੒͞ΕͨσʔλΛࢀর͢Δ
 w औಘͨ͠هࣄσʔλΛKTPOʹͯ͠ฦ͢
 "1*Խʹඞཁͳ͜ͱ

  19. "1*Խʹඞཁͳ͜ͱ w ϝσΟΞຊମ͔Βੜ੒͞ΕͨσʔλΛࢀর͢Δ
 w औಘͨ͠هࣄσʔλΛKTPOʹͯ͠ฦ͢


  20. "1*Խʹඞཁͳ͜ͱ w ϝσΟΞຊମ͔Βੜ੒͞ΕͨσʔλΛࢀর͢Δ
 w औಘͨ͠هࣄσʔλΛKTPOʹͯ͠ฦ͢


  21. هࣄσʔλΛࢀর͢Δ

  22. هࣄσʔλΛࢀর͢Δ CREATE TABLE `article` ( `id` int(10) NOT NULL, `body_1`

    text NOT NULL, `body_2` longtext, `public_flag` int(1) NOT NULL DEFAULT '0', `start_at` datetime NOT NULL, `end_at` datetime NOT NULL, `category_a` int(10) NOT NULL, `category_b` int(10) NOT NULL, `category_c` int(10) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8; هࣄσʔλͷςʔϒϧ
  23. هࣄσʔλΛࢀর͢Δ CREATE TABLE `article` ( `id` int(10) NOT NULL, `body_1`

    text NOT NULL, `body_2` longtext, `public_flag` int(1) NOT NULL DEFAULT '0', `start_at` datetime NOT NULL, `end_at` datetime NOT NULL, `category_a` int(10) NOT NULL, `category_b` int(10) NOT NULL, `category_c` int(10) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8; هࣄσʔλͷςʔϒϧ )5.-͕ͦͷ·· ͸͍ͬͯΔ
  24. هࣄσʔλΛࢀর͢Δ CREATE TABLE `article` ( `id` int(10) NOT NULL, `body_1`

    text NOT NULL, `body_2` longtext, `public_flag` int(1) NOT NULL DEFAULT '0', `start_at` datetime NOT NULL, `end_at` datetime NOT NULL, `category_a` int(10) NOT NULL, `category_b` int(10) NOT NULL, `category_c` int(10) NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8; هࣄσʔλͷςʔϒϧ ΧςΰϦʔ͕
 ̏ͭೖΔ
  25. ͱ͋ΔهࣄͷΧςΰϦʔ

  26. ΧϥϜ͕̏ͭͳͷʹͭҎ্ΧςΰϦʔ ͕͋Δͧʁ

  27. هࣄσʔλΛࢀর͢Δ هࣄʹؔ࿈͢ΔΧςΰϦʔ͕͸͍Δςʔϒϧ͕·ͩ͋ͬͨ CREATE TABLE `article_attribute` ( `id` int(11) NOT NULL

    COMMENT 'article id', `key` varchar(30) NOT NULL COMMENT 'category', `key_int` int(11) NOT NULL COMMENT ‘category id', KEY (`id`,`key`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  28. هࣄσʔλΛࢀর͢Δ CREATE TABLE `category` ( `id` int(11) NOT NULL, `name`

    varchar(30) NOT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  29. "1*ଆͰςʔϒϧߏ଄Λมߋ͢Δ

  30. "1*ଆͰςʔϒϧߏ଄Λมߋ͢Δ ຊମଆ͔ΒσʔλΛࢀর͠ɺਖ਼نԽͯ͠Ω ϨΠʹͨ͠ঢ়ଶͰผͷ%#ʹೖΕΔ

  31. ςʔϒϧߏ଄ͷมߋ CREATE TABLE `article` ( `id` int(10) NOT NULL, `headline`

    text NOT NULL, `body` longtext, `public_flag` int(1) NOT NULL DEFAULT '0', `start_at` datetime NOT NULL, `end_at` datetime NOT NULL, `created_at` datetime NOT NULL, `updated_at` datetime DEFAULT NULL, PRIMARY KEY (`id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  32. CREATE TABLE `article_categories` ( `article_id` int(11) NOT NULL, `category_id` int(11)

    NOT NULL, PRIMARY KEY (`category_id`,`article_id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8; ςʔϒϧߏ଄ͷมߋ
  33. ෛ࠴Λͭড়Խͨͧ͠

  34. "1*Ͱͷهࣄύʔε

  35. هࣄσʔλΛύʔε͢Δ

  36. ύʔε࣌ʹٻΊΒΕΔ͜ͱ w ෆཁͳλά৘ใ͸ফ͢
 CςΩετCςΩετ w ඞཁͳଐੑΛ͚ͭͯฦ͢
 ˙λΠτϧখݟग़͠จࣈ
 ZPVUVCFϦϯΫಈը
 JNHը૾ w

    )5.-Λ+40/ʹ͢Δ
  37. [ { "type": "headline", "value": “title dayo" }, { "type":

    "image", "value": “https://…” }, { "type": "link", "value": “https://…” },
 … ]
  38. 1BSTFS
 HFUUBMPOHLSBNEPXO

  39. 1BSTFS ਤࢀরIUUQTLSBNEPXOHFUUBMPOHPSH

  40. LSBNEPXO w ,SBNEPXO1BSTFS#BTF  ,SBNEPXO$POWFSUFS#BTFΛܧঝ͢Δ͜ͱͰ ύʔε΍ɺग़ྗͷ֦ு͕Ͱ͖Δ w ந৅ߏจ໦Λग़ྗͰ͖Δ
 LSBNEPXOUP+40/ͷॲཧ͕Ͱ͖ͦ͏

  41. ݹ͍ϝσΟΞ͋Δ͋Δ <b><span class="txt_blue">title</span></b> ྫ খݟग़͠ w $.4ͷೖྗαϙʔτػೳ͕ऑ͘ɺਓʹΑͬͯඍົ ʹIUNMͷॻ͖ํ͕ҧ͏

  42. ݹ͍ϝσΟΞ͋Δ͋Δ w $.4ͷೖྗαϙʔτػೳ͕ऑ͘ɺਓʹΑͬͯඍົ ʹIUNMͷॻ͖ํ͕ҧ͏ <b><span class="txt_blue">title</span></b> 
 <span class="txt_blue">title</span> ྫ

    খݟग़͠
  43. ݹ͍ϝσΟΞ͋Δ͋Δ <b><span class="txt_blue">title</span></b> 
 <span class="txt_blue">title</span> 
 <font color="blue">title</font> ྫ

    খݟग़͠ w $.4ͷೖྗαϙʔτػೳ͕ऑ͘ɺਓʹΑͬͯඍົ ʹIUNMͷॻ͖ํ͕ҧ͏
  44. ݹ͍ϝσΟΞ͋Δ͋Δ <b><span class="txt_blue">title</span></b> 
 <span class="txt_blue">title</span> 
 <font color="blue">title</font> 


    title:
 ྫ খݟग़͠ w $.4ͷೖྗαϙʔτػೳ͕ऑ͘ɺਓʹΑͬͯඍົ ʹIUNMͷॻ͖ํ͕ҧ͏
  45. ݹ͍ϝσΟΞ͋Δ͋Δ <b><span class="txt_blue">title</span></b> 
 <span class="txt_blue">title</span> 
 <font color="blue">title</font> 


    title:
 
 etc… ྫ খݟग़͠ w $.4ͷೖྗαϙʔτػೳ͕ऑ͘ɺਓʹΑͬͯඍົ ʹIUNMͷॻ͖ํ͕ҧ͏
  46. 808

  47. ϑΥʔϚοτ౷Ұ͠Α͏

  48. ϑΥʔϚοτ౷Ұ ಡऀʹͱͬͯѹ౗తʹಡΈ΍͘͢ͳΔͷͰ΍ͬͯଛ͸ ͳ͍

  49. ϑΥʔϚοτ౷Ұͷํ๏ w ϥΠλʔ͞Μʹࠓޙͷೖྗํ๏ͷมߋͷप஌
 ࠓޙখݟग़͠͸TQBODMBTTlUYU@CMVFzUJUMFTQBO ʹͯ͘͠Ε·ͤΜ͔ʜ  w աڈهࣄʹ͍ͭͯ΋ϑΟʔϚοτἧ͍͑ͨͳʜ
 Ұهࣄͣͭͳ͓ͯ͠௖͚·ͤΜ͔ʜ 


  50. ϑΥʔϚοτ౷Ұͷํ๏ w ϥΠλʔ͞Μʹࠓޙͷೖྗํ๏ͷมߋͷप஌
 ࠓޙ͸TQBODMBTTlUYU@CMVFzUJUMFTQBOʹͯ͘͠ Ε·ͤΜ͔ʜ  w աڈهࣄʹ͍ͭͯ΋ϑΟʔϚοτἧ͍͑ͨͳʜ
 Ұهࣄͣͭͳ͓ͯ͠௖͚·ͤΜ͔ʜ 


    օʹͱ݈ͬͯશͳํ๏͡Όͳ͍
  51. ϑΥʔϚοτ౷Ұͷํ๏ w ϥΠλʔ͞Μʹࠓޙͷೖྗํ๏ͷมߋͷप஌
 $.4ػೳͰೖྗαϙʔτͷڧԽ w աڈهࣄʹ͍ͭͯ΋ϑΥʔϚοτἧ͍͑ͨͳʜ
 ύʔεͰ͕Μ͹Δ ٕज़Ͱղܾ͢Δ

  52. ϑΥʔϚοτ౷Ұͷํ๏ w ϥΠλʔ͞Μʹࠓޙͷೖྗํ๏ͷมߋͷप஌
 $.4ػೳͰೖྗαϙʔτͷڧԽ w աڈهࣄʹ͍ͭͯ΋ϑΟʔϚοτἧ͍͑ͨͳʜ
 ύʔεͰ͕Μ͹Δ ٕज़Ͱղܾ͢Δ

  53. ύʔεͰ͕Μ͹Δ෼ྨ෼͚͢Δ <b><span class="txt_blue">title</span></b>
 <span class="txt_blue">title</span> 
 
 
 
 


    <font color="blue">title</font>
 title:
 etc… খݟग़͠ ࠇจࣈςΩετ
  54. ,SBNEPXOͰύʔε ਖ਼نදݱͰখݟग़͠Λ൑ผ BOLD_HEADLINE_START # When this matches, type=headline = /^(?:<b>)?<span\s+class=(?<quote>["']?)txt_blue\k<quote+0>>/i


    BOLD_HEADLINE_MATCH # select text = %r{^(?:<b>)?(?<text><span\s+class=(? <quote>["']?)txt_blue\k<quote+0>>((?:.|\n)+?)</span>)(?:</b>)?\n}i { "type": "headline", "value": "title" }
  55. ,SBNEPXOͰύʔε ਖ਼نදݱͰԿʹ΋Ϛον͠ͳ͍IUNMλά
 ͸௨ৗͷςΩετʹ͢Δ { "type": "text", "value": "title" } 3"8@)5.-@5"(@45"35

    UBH@OBNF aT 
  56. ,SBNEPXOͰύʔε w Bλά w JNHλά w ZPVUVCF w UXJUUFS w

    খݟग़͠ w ৭෇͖ݟग़͠ w ͦͷଞ͸ͨͩͷจࣈྻ ࡞ͬͨओͳ෼ྨΘ͚ͷఆٛ
  57. ࢥͬͨΑΓҧ࿨ײ͕ͳ͍
 ݟͨ໨ͷهࣄʹͳͬͨ

  58. ݁Ռ͸ΞϓϦͰΈͯΈͶ

  59. "1*αʔόʔԽͨ͠Ըܙ w ൚༻"1*αʔόʔͱͯ͠࡞ͬͨͷͰ৭ʑͳ͜ͱʹ࢖ ͑Δ༨஍͕Ͱ͖ͨ
 ࠓ·Ͱຊମͷѻ͍ʹ͍͘σʔλͷ͍ͤͰɺͰ͖ͳ ͔ͬͨ͜ͱ΋"1*αʔόʔ࢖͏͜ͱͰ࣮ݱ͠΍͘͢ ͳͬͨ ࣮ࡍʹԣͷαʔϏεͰ͔ͭ͏࿩΋Ͱ͍ͯΔ

  60. ·ͱΊ w ຊମͱ"1*ͰੈքΛ෼͚Δ͜ͱͰɺݱঢ়ҡ࣋ͭͭ͠ ৽͍͜͠ͱ͕͠΍͘͢ͳͬͨ w "1*αʔόʔΛ࡞͓͔ͬͨ͛ͰαʔϏεʹ͍Ζ͍Ζ ͳՄೳੑ͕Ͱ͖ͨ w "1*αʔόʔԽͷաఔͰɺٕज़తෛ࠴ɾӡ༻໘ͷෛ ࠴ͳͲ੔ཧ͠޲͖߹͍ɺαʔϏεͷ඼࣭޲্ʹ΋ͭ

    ͳ͕ͬͨ
  61. -FU`T"1*Խ

  62. ͝੩ௌ͋Γ͕ͱ͏͍͟͝·ͨ͠