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

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

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

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

Makoto Shiga

January 28, 2017
Tweet

More Decks by Makoto Shiga

Other Decks in Programming

Transcript

  1. هࣄσʔλΛࢀর͢Δ 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; هࣄσʔλͷςʔϒϧ
  2. هࣄσʔλΛࢀর͢Δ 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.-͕ͦͷ·· ͸͍ͬͯΔ
  3. هࣄσʔλΛࢀর͢Δ 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; هࣄσʔλͷςʔϒϧ ΧςΰϦʔ͕
 ̏ͭೖΔ
  4. هࣄσʔλΛࢀর͢Δ هࣄʹؔ࿈͢ΔΧςΰϦʔ͕͸͍Δςʔϒϧ͕·ͩ͋ͬͨ 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;
  5. هࣄσʔλΛࢀর͢Δ CREATE TABLE `category` ( `id` int(11) NOT NULL, `name`

    varchar(30) NOT NULL, PRIMARY KEY (`id`), ) ENGINE=MyISAM DEFAULT CHARSET=utf8;
  6. ςʔϒϧߏ଄ͷมߋ 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;
  7. 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; ςʔϒϧߏ଄ͷมߋ
  8. [ { "type": "headline", "value": “title dayo" }, { "type":

    "image", "value": “https://…” }, { "type": "link", "value": “https://…” },
 … ]
  9. ݹ͍ϝσΟΞ͋Δ͋Δ <b><span class="txt_blue">title</span></b> 
 <span class="txt_blue">title</span> 
 <font color="blue">title</font> 


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


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

  12. ,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" }
  13. ,SBNEPXOͰύʔε w Bλά w JNHλά w ZPVUVCF w UXJUUFS w

    খݟग़͠ w ৭෇͖ݟग़͠ w ͦͷଞ͸ͨͩͷจࣈྻ ࡞ͬͨओͳ෼ྨΘ͚ͷఆٛ