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

WebRebuild

 WebRebuild

2010 于北京讲「建立前端开发团队」

Joseph Chiang

July 18, 2010
Tweet

More Decks by Joseph Chiang

Other Decks in Programming

Transcript

  1. ۃɓ΅ʈЪί • 2.5 ϋj ۃ၌ʈ೻师 • 0.5 ϋj ඩډ开发٫໊ٟ传઺ɻ •

    1 ϋj ඩډȭΤʃ१ʈ೻师 ුlҢ݊ਧෞ / 蒋֛ρ ܘ开ː来Ց̏ԯl
  2. ൺӉ环岛 ίҢ 29 ๋ 2008 ϋ 5 ˜ࣛ ڀə 27

    ˂ ൺə ɞϵεʮԢ ༺ϓൺӉᐑࢥٙྫྷซ 没Ϟʔ̙ঐ
  3. ۃ၌开发环ྤ - ʕːܠซ • 减ˇ环ྤࢨ៦ ˾码ʔк断环ྤe设֛档̥Ϟɓ΅ • ᅼ块ʷ开发 ʔ၍ HTMLeCSSeJS

    ே˸ᅼ块开发 • 让͕错变੻Ѣ难 Nicholas Zakas Ⴍ “Make it difficult to make mistakes.“
  4. 问题 1 : ӊࡈᐑྤٙ Host Name ேʔɓᅵ Development Alpha Staging

    Production devm1.corp.muchiii.com:5002* devm1.corp.muchiii.com:50029 devm1.corp.muchiii.com static.devm1.corp.muchiii.com img[n].staging.bar.tw1.corp.muchiii.com w[n].staging.bar.tw1.corp.muchiii.com www.muchiii.com a.mimgs.com ɭ݊ც Commit Їو͉છ၍ٙ˾码 仅ɓ΅组态档e˲̥写͍ό环ྤ
  5. Fiddler 还ঐਂʡɯ Fiddler 这类ٙ软ᠧ还ঐίਂܘεٙ应͜dԷνj 1. 协п AJAX ٙৰЏf 2. 协п开发时͉ή၌ʲ图eʔცɪ传Ї؂务ኜf

    3. τౢІʉ惯ٙ͜ʈՈf 4. ҷ变浏览᠒१ʔ顺଻ٙή˙f 5. ᅼ拟஺ܓ࿔ٙ环ྤf Ԓ为ɓ个ۃ၌ʈ೻师dFiddler ॆٙ݊̀备ٙʈՈl
  6. CSS ˖档内ٙߠ౻图档༩径写ج #mod .bd { background: url(bg_empty.png); } #mod .bd

    { background: url(/home/bg_empty.png); } #mod .bd { background: url(http://a.mimgs.com/home/bg_empty.png); } 实际༩径ίj/var/www/muchiii/static/home/style.css HTTP 请Ӌ༩径ίjhttp://a.mimgs.com/home/style.css ɧ᮱ே̙БdЫ͜ԟɓ᮱k
  7. CSS ˖档内ٙߠ౻图档༩径写ج #mod .bd { background: url(bg_empty.png); } #mod .bd

    { background: url(/home/bg_empty.png); } #mod .bd { background: url(http://a.mimgs.com/home/bg_empty.png); } Ϊ为ࠅਂ׌ঐាʷeც将ε个 CSS 档ࣩ௰ʃʷ˲Υϊ 届时 CSS 将会ί᠒१࣬ͦ录ɨ͛ϓ ୋɓ᮱޴对༩径ٙ˙ό会ிϓ图档༩径错误 ୋɧ᮱̙БdШ过ɲ᪜杂e࢙׸͂错ο ה˸Ң们ɓܛ规֛Դ͜ୋɚ᮱˙όeࡒ࢙׌௰λf
  8. ᅼ块ʷٙѢ难点 • HTMLjܘλ༆决d̥ࠅ͜ include ٙ˙όఱ̙ ˸ਂՑ€Performance ᅂ响ʔɽ • CSS :

    ͜ id 当 namespace ̙˸ਂՑfШν؈ ӊ个ᅼ组݊ɓ个档ࣩdɓ页 30 个ᅼ组ఱ会Ϟ 30 个 requestsd对׌ঐᅂ响ܘɽl • JavaScript : ༧ CSS ɓ样会Ϟ request ிϓٙ ׌ঐ问题f̤̮ცࠅɓ个ݖᦻਂ༨ᅼ组ٙ沟ஷf
  9. $key - PHP Module Τ称 or 页ࠦΤ称 is_top: ׳ί </head>

    ۃא </body> ۃ ̤̮还Ϟ is_noscript, media ഃ属׌̙˸设֛ static.php 设֛ʔΝ页ࠦהࠅˏٙ͜ CSS/JS
  10. Mini ٙ XML 设֛档dҪ刚ʑٙ设֛୅ֻ这Ԣ 寻Ҭ档ࣩٙЗໄd̙֛义ε个f $DEV_ROOT ݊ί设֛ Apache VirtualHost ٙ环ྤ变数

    ӊ个 module 会ϞІʉٙ CSS ᝺ JS 档 module ̙˸̘̋ɝՉ˼ٙ moduledɰ̙˸ exclude ݔ个档ࣩ index ٙ CSS/JS ᅼ块档ࣩ
  11. ͜户点选 window.mods[“photo-show”] = { showPhoto : function (src) { ....

    } } window.mods[“photo-list”] = { init : function () { ... $(“img”).on(“click”, function(e) { window.mods[“photo-show”].showPhoto(this.src); } } ɘϓٙɛ会͜Ό҅变ඎ༆决问题 当๫˪显ͪᅼ块没ϞɓৎπίΝɓ页 时dΐڌᅼ块ఱ̈现ə Bug!
  12. ΎՓЪᅼ块ٙ API ʧࠦ Core • oAPI.listen() : 让ͦۃٙᅼ块ഃܙɓ个ڦࢹ • oAPI.broadcast()

    让ͦۃٙᅼ块发̈ɓ个ڦࢹ • oAPI.getNode() : ՟੻ͦۃᅼ块ٙ DOM ي΁参Ͻ API mod mod mod
  13. _photo_list.js ΐڌᅼ块ٙ JavaScript Y.Core.register("photo-list", { // Ϥᅼ块ڋ֐ʷ init: function (api)

    { // 这个ᅼ块Ϟ兴ሳѠ՟ٙ两᮱讯ࢹ api.listen("photo-filter-submit"); api.listen("photo-filter-response"); this.api = api; }, // Ϥᅼ块ί页ࠦɪ ContentReady onload: function () { // ѓ诉 Core ๫˪ΐڌҁ毕dϊҪୋɓ张图˪༩径ɓৎ౤Զ this.api.broadcast("photo-list-rendered", img.src); }, // Ϥᅼ块ϗՑ讯ࢹ onmessage: function (eventType, callerName, data) { switch (eventType) { case "photo-filter-response" : // ෬满ΐڌ break; case "photo-filter-submit" : // ૶٤ΐڌ break; } }, _updateUI: function (data) { // ѓ诉 Core ๫˪ΐڌҁ毕dϊҪୋɓ张图˪༩径ɓৎ౤Զ this.api.broadcast("photo-list-rendered", img.src); } }); ც૶٤ΐڌ ც෬满ΐڌ ՟੻资ࣘ ͜户౤ʹڌ单 显ͪୋɓ张图˪ ΐڌҁ毕
  14. Ъج • ӊϣ Commit 会ਂٙ检ݟd没ஷ过ఱʔঐ过关 • 执Б JSLint : JavaScript

    Good Partsf • 执Б PHP CodeSniffer : ̙˸І订˾码标ࡘ检 ݟ PHPdɰ˕౪ JavaScript ᝺ CSSl • ӊϣ Packaging 会ਂٙʈЪ • 执Б Image Optimization (Smush.it) d౤ ፴图˪ცࠅ௰Գʷf • 没Ϟ压缩过ٙ JavaScript ᝺ CSS ʔ会஗͂ ̍f
  15. Ң们ٙ Visual Designer ̥负责͛ϓ PSD 档ࣩ F2E ੻Іʉ处ଣ图档௰Գʷٙ问题 PNG8 ݊ͦۃʮ认ί

    Web ௰λٙࣸό Ш̥݊Ϟ Fireworks ˕౪转换ϓ Alpha Transparency
  16. ͂̍ pkg_create & ɪ线 pkg_deploy Υϊ JS/CSS 档ࣩ᝺௰ʃʷ 档ࣩΥϊΧe档Τɰ会ҷ变€ʔΎԴ͜ Mini

    ʈՈ ࡌҷ˾码ʕٙ host Τ称 (www.muchiii.com -> devm1.corp.muchiii.com) pkg_create