ç§ã¯ããªãã«èŠåããŸãããããã®ããã€ãã¯å®å šã«ãã£ããã³ã®ãã®ã§ãããããã€ãã¯VKontakteãŸãã¯Dangaãšããé¢ä¿ããããŸãããäžè¬ã«ãç§ã責ããªãã§ãã ãã
ã«ããã®äžïŒ
- django-vkontakte-iframeããã³vkontakte
- ã¢ããªã±ãŒã·ã§ã³ãå£ã«ããŠã³ããŒããã
- ãã©ãã·ã¥ãããŒ
- ææã®IEã§ã®ã»ãã·ã§ã³
- ãã¹ãŠã®ãflashVarsãã¯GETãªã¯ãšã¹ãã«ãã£ãŠéä¿¡ãããŸã
- ãã¬ãŒã ã¯ãŒã¯
- ãŠãŒã¶ãŒæ å ±ãžã®ã¢ã¯ã»ã¹
- ã¬ã€ã¢ãŠãã®æ€èšŒ
- JSLintã¯ããªãã®å人ã§ããåå¿ã§ã
- ãµã ãã€ã«çæ
- ãããã·ã¢ãã«ã«ããã¢ãã¬ãŒã·ã§ã³
- ã€ã³ããŒãèšå®
- æé©å
åºåãšããŠïŒã¢ããªã±ãŒã·ã§ã³ã¯ãã³ã¬ã¯ã¿ãŒããšåŒã°ããã³ã€ã³ãåæãã«ãŒãããã®ä»ã®ã¢ã€ãã ã®åéã«é¢ãã人ã ã察象ãšããŠããŸãã çŸåšãMTGãããã«ã¿ãã°ã®ã¿ãå ¥åãããŠããŸãããä»åŸãä»ã®ã¢ã€ãã ã®ã«ã¿ãã°ãäœæãããŠå ¥åãããŸãã ãã¡ãããç§ãã¡ã¯ããªãã®ææ¡ã建èšçãªæ¹å€ããã¹ãŠåãã§èããŸãã
django-vkontakte-iframeããã³vkontakte
ãããã®ã¢ãžã¥ãŒã«ã«ãããããã¥ã¡ã³ãVKontakte APIãç解ããããšãªããããã«æçšãªæ©èœã®éçºãéå§ã§ããŸãã
æåã®ãã®ã¯ãŠãŒã¶ãŒã®æ¿èªãåŒãç¶ããéåžžã®dzhangovskihãŠãŒã¶ãŒãæäœã§ããããã«ããŸããã圌ã¯ãã§ã«èè èªèº«ã«ãã£ãŠããã§èšåãããŠããŸãã
ãããããã°ããããŠãã¢ããªã±ãŒã·ã§ã³ã¯ãŠãŒã¶ãŒã®èå¥ãæåŠãå§ããŸããã åé¡ã¯reffererãã£ãŒã«ãã«çŸããvk_iframe / forms.pyã§æ¬¡ã®ããã«æžãããŠããŸãïŒ
referrer = forms.ChoiceFieldïŒREFERRER_CHOICESãå¿ é = FalseïŒ
ããã¥ã¡ã³ããããã¢ãžã¥ãŒã«ã§èŠå®ãããŠããREFERRER_CHOICESã¯å€ããããã«ãad_ {AD_ID}ã®ããã«åºå®ãªã¹ãã¯é©åã§ã¯ãªããšçµè«ä»ããããšãã§ããŸãã ãããã£ãŠãè«ççãªçœ®æã¯åé¡ã解決ããŸãã
referrer = forms.CharFieldïŒå¿ é = FalseïŒ
ãã¡ãããREFERRER_CHOICESã¯äžèŠã«ãªããå®å šã«åé€ã§ããŸãã
2çªç®ã®ã¢ãžã¥ãŒã«ã¯APIã®ã©ãããŒãæäŸããŸããããŸãããµãŒããŒãããã¹ãŠã®ã¡ãœããã䜿çšã§ããããã§ã¯ãããŸããã2çªç®ã«ãç§ã®æèŠã§ã¯ãã»ãšãã©ã®å ŽåããŠãŒã¶ãŒã®ããŒãžããjavascriptã䜿çšããŠAPIã«ã¢ã¯ã»ã¹ããæ¹ã䟿å©ã§æé©ã§ã éçºäžã®ã¢ããªã±ãŒã·ã§ã³ã§ã¯ããã®ã¢ãžã¥ãŒã«ãå°ããªããã«ãŠã§ã¢ã§äœ¿çšããŠãdjango-vkontakte-iframeã«ãã£ãŠäœæããããŠãŒã¶ãŒãããã£ãŒã«ãå®æçã«æŽæ°ãããŠãŒã¶ãŒã®åéã«ãèªåãšåéã ãã«è¡šç€ºãã衚瀺ãããŠãŒã¶ãŒã«å±ããããŒãžã衚瀺ããæš©éããããã©ãããå€æãããŸããã
åæã«ããããããç¬éã«æ³šç®ãã䟡å€ããããŸãã6æ16æ¥ãããŒãžã«å ¥ãããšãããšãã¢ããªã±ãŒã·ã§ã³ãçªç¶è¡šç€ºããå§ããŸãã...äœããããŸããã èŠæ±ã衚瀺ãããšã1åã®èŠæ±ã§500çªç®ã®ãšã©ãŒãè¿ãããããšã瀺ãããŸããã ã€ãŸã è¿ãããã®ã¯ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãªããVKontakteèªäœã§ããã çã調æ»ã®çµæããã®åé¡ã¯APIãžã®æåã®ãªã¯ãšã¹ãã«å«ãŸããŠããŸãããããã°ãããããšç¶æ³ã¯æ£åžžã«æ»ããŸããã
ã¢ããªã±ãŒã·ã§ã³ãå£ã«ããŠã³ããŒããã
ã¢ããªã±ãŒã·ã§ã³ã®ããã¢ãŒã·ã§ã³ã®ããã«ããŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ã«ãã£ãŠçæãããã¡ãã»ãŒãžãå人ã®å£ã«æçš¿ããæ©èœããŠãŒã¶ãŒã«è¿œå ãããšãå€ãã®å Žåãã¯ãªãã¯ãããšãŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ã«å ¥ããŸãã ç§ãã¡ã®å Žåãããã¯ãŠãŒã¶ãŒã®ã³ã¬ã¯ã·ã§ã³å ã®ãèªæ ¢ã®ãã¢ã€ãã ã§ããã
å ¬éã·ãŒã±ã³ã¹ã¯ç°¡åã§ãã
- æçš¿ãè¡ãããå£ã®ãŠãŒã¶ãŒIDãååŸããŸã
- wall.getPhotoUploadServerã䜿çšããŠåçãã¢ããããŒãããããã®ãµãŒããŒã¢ãã¬ã¹ãååŸãã
- æå®ããPOSTã¢ãã¬ã¹ãžã®ç®çã®åçãå«ãåçãã£ãŒã«ãã§ãªã¯ãšã¹ããäœæããŸã
- åä¿¡ããåçããŒã¿ã䜿çšããŠwall.savePostãåŒã³åºã ãåä¿¡è ã«ã¡ãã»ãŒãžãæå®ããŸã
- JS API saveWallPostã¡ãœããã䜿çšããŠããŠãŒã¶ãŒã«ç¢ºèªãŠã£ã³ããŠã衚瀺ããŸã
äž»ã«ç§èªèº«ã®äžæ³šæã«ãããåçã®ã¢ããããŒãã«èŠåŽããªããã°ãªããŸããã§ããã ããã¥ã¡ã³ãã¯ãã¢ããªã±ãŒã·ã§ã³ããŠãŒã¶ãŒã®å£ã«ããŠã³ããŒãããããšããæ瀺ã«åŸãå¿ èŠããããç§ã¯ããŠãŒã¶ãŒã®å£ã«åçãã¢ããããŒããããã«åŸãç¶ããŸããã
POSTãªã¯ãšã¹ãã䜿çšããŠåçãèªã¿èŸŒããšãåçã§ã¯ãªãåçãã£ãŒã«ããæã€ãªããžã§ã¯ããèªã¿èŸŒãŸããŸããããã«å¿ããŠãæ瀺ã®äžæ£ç¢ºãã«æ³šæããããšããå§ãããŸãã ããã«ãVKontakteã¯åçã®ãµã€ãºã75ãã¯ã»ã«ã«å€æŽãããããéåžžã«å€§ããªç»åãéä¿¡ããŠãæå³ããªãããšã«æ³šæããŠãã ããã
ãããŠæåŸã«ããã®åãPOSTèŠæ±ãçæããæ¹æ³ã çè«çã«ã¯ãããã¯javascriptã䜿çšããŠè¡ãããšãã§ããŸãããç§ã¯èŠåŽããã«éä¿¡ãµãŒããŒãè¡ããŸããã ããã«ããªãã·ã§ã³ãããã ãã³ã§ãªã¯ãšã¹ããäœæããããæ¢è£œã®ã¢ãžã¥ãŒã«ã䜿çšã§ããŸã ã å人çã«ã¯ã2çªç®ã®ãªãã·ã§ã³ã«æ±ºããŸããã
ãããŠãã¯ããwall.savePostãåŒã³åºããšãã«post_idãæå®ããããšãå¿ããªãã§ãã ãããããã«ãããwallã®ã¡ãã»ãŒãžãéããŠã¢ããªã±ãŒã·ã§ã³ãå ¥åãããŠãŒã¶ãŒã«äœã衚瀺ãããã決å®ã§ããŸãã
æ°ã«ãã人ã¯ã ããã§èª¬æããã¢ã«ãŽãªãºã ãå®è£ ããJavaScriptã®ãããã«åŸ®èª¿æŽããããŒãžã§ã³ã§ãã
ãã©ãã·ã¥ãããŒ
ãããããã¡ããã1滎ã®ã¿ãŒã«ãªãã§ã¯ã§ããŸããã§ããã ãŠãŒã¶ãŒãäžèšã®æ¹æ³ã䜿çšããŠã¡ãã»ãŒãžãéä¿¡ããåä¿¡è ã®ãŠã©ãŒã«ã«ã¢ã¯ã»ã¹ããŠã¯ãªãã¯ãããšã空ã®ãŠã£ã³ããŠãéããŸãã
ããã¯ãVKontakteããŠãŒã¶ãŒã«ãã©ãã·ã¥ãã¡ã€ã«ã衚瀺ããããšããŠããããŠãŒã¶ãŒãå®éã«iframeãæã£ãŠãããã©ãããæ°ã«ããŠããªãããã«çºçããŸãã ããããªããããªã®ããèããªãã§ãã ãããæãèå³æ·±ãã
ããã§ã 607x412ã¹ã¿ããäœæããŠãã©ãã·ã¥ãæ°ã«ããå¿ èŠããããŸãïŒãŸãã¯å人ã«å€æ³šããã»ããããïŒãå°ãªããšããæ°ããã¿ãã§å£ã«ã¡ãã»ãŒãžãéãå¿ èŠãããããšããŠãŒã¶ãŒã«éç¥ããå¿ èŠããããŸãã post_idã ã¹ã¿ããåããã«ã¯ãèšå®ã§ã¢ããªã±ãŒã·ã§ã³ã®ã¿ã€ããFlashã«å€æŽãããã¡ã€ã«ãåããŠãã¿ã€ããå ã«æ»ããŸãã
ãã®æ å ±ã¯ãã§ã«å€ããªã£ãŠããå¯èœæ§ããããŸãããã¢ããªã±ãŒã·ã§ã³ã®æ¿èªãã§ãŒãºã§ã¯ãã¹ã¿ããåŒãç¶ã圹ç«ã€å ŽåããããŸãã 管çè ã¯ããã©ã«ãã§ãã©ãã·ã¥ã衚瀺ããŸããã€ãŸããäœæããããã®ã衚瀺ãããªãã ãã§ãã
ææã®IEã§ã®ã»ãã·ã§ã³
ãã¡ãããããã¯ç®ç«ããã«ã¯ããããŸããã§ãããã ãããããªãã¯åœŒã®ããã«äœãåãããªããã°ãªããŸããã
P3Pããªã·ãŒã«ã¯åé¡ããããŸããããã¯ãã¢ããªã±ãŒã·ã§ã³ãCookieãèšå®ã§ããªãããã§ããããã«ãããèªèšŒãã¡ã€ã«ãäœæãããŸãã 幞ããªããšã«ãããã¯æ¬¡ã®å 容ã®P3Pãã£ãŒã«ããåçã«è¿œå ããã ãã§ä¿®æ£ã§ããŸããCP = "IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"
ã¢ããªã±ãŒã·ã§ã³ã§ã¯ãå¥ã®ããã«ãŠã§ã¢ã§åé¡ã解決ããŸããã
UPDïŒãã®èšäºã§ã¯ãiframe Cookieã®åé¡ã«ã€ããŠè©³çŽ°ã«èª¬æããä»ã®ãã©ãŠã¶ãŒã§çºçããå¯èœæ§ã®ããåé¡ã®è§£æ±ºçãæäŸããŸãã
ãã¹ãŠã®ãflashVarsãã¯GETãªã¯ãšã¹ãã«ãã£ãŠéä¿¡ãããŸã
ãŠãŒã¶ãŒãã¢ããªã±ãŒã·ã§ã³ã«å ¥ããšãæçšãªæ å ±ãéä¿¡ãããŸãã ãããã£ãŠããããã¯ãã¹ãŠãã¡ã€ã³ã®èŠæ±ãå ¥åãããšãã«éåžžã®GETèŠæ±ã§éä¿¡ãããŸãã ãããã£ãŠãããå€ãã®ã€ã³ã¿ã©ã¯ãã£ãæ©èœãå¿ èŠãªå Žåã¯ã䜿çšããã®ãæ ããªãã§ãã ããã
æãäžè¬çãªã®ã¯ãrequest.GET ['post_id']ã«åºã¥ããŠã誰ãã®ãŠã©ãŒã«ããã¢ããªã±ãŒã·ã§ã³ã«ã¢ã¯ã»ã¹ãããŠãŒã¶ãŒãã¡ã€ã³ã®ããŒãžããç®çã®ããŒãžã«ãªãã€ã¬ã¯ãããããšã§ãã
ãã¬ãŒã ã¯ãŒã¯
éåžžã®ãµã€ããäœæããã®ã§ã¯ãªãããã¬ãŒã å ã§äœæ¥ããŠããããšãå¿ããªãã§ãã ããã ãããŠãããã¯ããŠã£ã³ããŠã®æå€§å¹ ã827ãã¯ã»ã«ïŒã€ã³ãã³ããšã³ã³ãããŒã«ãå«ã807ïŒã§ããäžæ¹ã§ã resizeWindowã䜿çšããŠãŠã£ã³ããŠã®ãµã€ãºãå€æŽããå¿ èŠãããããšãæå³ããŸãïŒããã£ãŸãã¯ã©ãããŒdivã®é«ããååŸããŸãïŒ VKontakteã€ã³ã¿ãŒãã§ãŒã¹ã䌞ã³å§ããŸãã
ããã«ããŠãŒã¶ãŒããã©ãŠã¶ã®ãã¿ã³ãååŸã«åããã«ã¯ã setLocationã䜿çšãã setTitleã䜿çšããŠèŠªããŒãžã®ååãå€æŽããå¿ èŠããããŸãã
ããã«ããµãŒãããŒãã£ã®ããã³ããšã³ãã¢ããªã±ãŒã·ã§ã³ãæ£åžžã«åäœããªããªããšããäºå®ã«ééããå¯èœæ§ããããŸããããšãã°ããã¬ãŒã å ã§lyteboxãæ£åžžã«éãã«ã¯å°ãçµäºããªããã°ãªããŸããã§ãã ã
ãŠãŒã¶ãŒæ å ±ãžã®ã¢ã¯ã»ã¹
ãŠãŒã¶ãŒããåŸã ã«æš©éãååŸã§ããããã«ã¢ããªã±ãŒã·ã§ã³ãèšèšããã¢ããªã±ãŒã·ã§ã³ãã€ã³ã¹ããŒã«ããã«ã¢ããªã±ãŒã·ã§ã³ã®å¯èœãªéã倧ããªéšåã«ã¢ã¯ã»ã¹ã§ããããã«ããããšããå§ãããŸãã
ãã®ãããåãŠãŒã¶ãŒã«ãŠã£ã³ããŠã衚瀺ãããã ãã§ãªããããã¹ãŠã®æ å ±ãåãåºããŠããéãããã¢ããŒãã®éµãå¿ããªãã§ãã ãããã ãã§ãªããåŸã ã«æš©å©ãæ¡å€§ããããšãææ¡ããŸãããå®éã«ãããã®æš©å©ãå¿ èŠãªçç±ã説æããããšããå§ãããŸãã getUserSettingsãšshowSettingsBoxãããã«åœ¹ç«ã¡ãŸãã
ãããããå人ã®æåŸ ãã¿ã³ãç®ç«ã€å Žæã«çœ®ãããšãå¿ããªãã§ãã ãããããã¯showInviteBoxã§åäœããŸã ã
ã¬ã€ã¢ãŠãã®æ€èšŒ
å®å šã«æå¹ãªã¬ã€ã¢ãŠãã§ã®ã¿äœæ¥ããããšã匷ããå§ãããŸãã ããã«ããæéãå€§å¹ ã«ç¯çŽã§ããäœæ¥ã«å¯©çŸçãªæºè¶³æãããããããšãã§ããŸããããšãã°ããã¬ãŒã ãäžé©åã«ãµã€ãºå€æŽãããçç±ãçŽ1æéãããŠèª¿ã¹ããšãããçã£ãdivã§ããã
æ€èšŒããã»ã¹ãç°¡çŽ åããããã«ãããã¿ãŒã«ãªã³ã¯ãé 眮ãã次ã®JavaScriptããã®äžã«æããŸããã ã¬ã€ã¢ãŠãã®æå¹æ§ãç£èŠã§ããã ãã§ãªããã¬ã€ã¢ãŠãã«ã€ããŠèªæ ¢ããããšãã§ããŸãã W3Cããã®äžçš®ã®ãããŒã§ãããèŠèŠçãªãã®ã§ãã ãã¡ããããã©ãŠã¶ã«çµã¿èŸŒãŸããŠããããŒã«ããã£ã³ã»ã«ãã人ã¯ããŸããïŒããšãã°ãOperaã®ã³ã³ããã¹ãã¡ãã¥ãŒé ç®ãWebæšæºã«æºæ ããŠããŸããïŒãããããç§ã®æèŠã§ã¯ãã¯ãªãã¯ã§ãããªã³ã¯ã¯ãã©ãŠã¶éã®äºææ§ã¯èšããŸã§ããªã䟿å©ã§ãã
<thinking_aloud>ããããããŒãžã芪ããŒãžã«ããŒãããæ©èœã¯ãå®è³ªçã«ããŒã«å®è£ ã§ãã iframeã¢ããªã±ãŒã·ã§ã³ããvkontaktã®ããã«èŠããå¥ã®ãµã€ããããŒãããŠããã芪æã§è¡šç€ºããããšãã§ããŸãã</ thinking_aloud>
ãããŸã§ã®éãhtml5ã®æ°ããã¿ã°ã䜿çšããããšããããããªãã§ãã ãããIEã§ã¹ã¿ã€ã«ãé©çšããã«ã¯ãJavaScriptã䜿çšããŠå¿ èŠãªã¿ã°ãäœæãããhtml5ä¿®æ£ãã ãã§æ§æãããç°¡åãªãœãªã¥ãŒã·ã§ã³ããããŸãã å人çã«ãç§ã¯ãã®ãã©ãã€ã ã«åºå·ããããšããŠããŸãïŒãæ代é ãã®ããŸãã¯ä»£ããã«æèœã®ãããã©ãŠã¶ã®ãŠãŒã¶ãŒã¯ããŒãžãèŠãããããåå§çã§ããã
JSLintã¯ããªãã®å人ã§ããåå¿ã§ã
ã¢ããªã±ãŒã·ã§ã³ãéçºããå Žåãå¿ èŠã§ã¯ãããŸããããjavascriptãèšè¿°ããå¿ èŠããããŸãã ãããŠãããã¯éåžžããžã£ã³ãžã£ã€ã¹ãã«ãšã£ãŠæŽ»åã®äž»èŠãªåéã§ã¯ãªãããšãèãããšãééããç¯ãå¯èœæ§ãé«ããªããŸãã JSLintã䜿çšãããšãæããªãšã©ãŒãããã«ãã£ããã§ããã ãã§ãªããã³ãŒããéåžžã«ããããªåœ¢åŒã«ä¿ã€ããšãã§ããŸãã ããããhabrã«ã€ããŠã¯æ¢ã«ååã«è©³çŽ°ã«æžããŠããŸãã
ãµã ãã€ã«çæ
ç§ã®æèŠã§ã¯ãäŸãã°ãåºãç¥ãããŠããsorl-thumbnailãaino-convertãªã©ãéåžžã«å å®ãªãœãªã¥ãŒã·ã§ã³ãããã«ããããããããããã¯éãããŸãã
ãããã£ãŠãç§ã¯django-thumbsãæ¡çšããŸããã 幞ããªããšã«ãæšæºã®ImageFieldã®æ¡åŒµåãæäŸãã1ã€ã®ãã¡ã€ã«ã®ã¿ã§æ§æãããŠããŸãã ãããç解ããæãŸããç¶æ ã«ä»äžããããšã¯é£ãããããŸããã ããšãã°ãã¢ããªã±ãŒã·ã§ã³ã®å Žåãéãããè¿œå ããŸããïŒãã ãããããã«ã¯å察ã§ããããããã¯èŠä»¶ã§ããïŒãå ã®ç»åãå¥ã®ãã©ã«ããŒã«ä¿åããèšå®ãå€æŽããå Žåã«ãµã ãã€ã«ãåçæããŸãã
ãããã·ã¢ãã«ã«ããã¢ãã¬ãŒã·ã§ã³
ãŠãŒã¶ãŒãè¿œå ããã¿ã°ã«ã¢ãã¬ãŒããè¿œå ããæ¹æ³ãæ¢ããŠãããšãã«ãããªãèå³æ·±ããã¯ããã¯ãåŸãŸããïŒæ®å¿µãªããããã°ãžã®ãªã³ã¯ãèŠã€ããæ¹æ³ã¯ãããŸããïŒ .mptt-adminã¯ç®¡çããã«ã§ãã§ã«äœ¿çšãããŠãããããéåžžã®ãã£ã«ã¿ãŒã䜿çšããå¿ èŠã¯ãããŸããã§ãã ãã®æ¬è³ªã¯ãå·ŠåŽã®ã¢ããªã±ãŒã·ã§ã³ïŒããšãã°ããModeratingãïŒãäœæããŠãããã·ã¢ãã«ãäœæããadmin.pyã§querysetã¡ãœãããå®çŸ©ããããšã«ããã衚瀺ããå¿ èŠã®ãããã®ïŒã€ãŸããã¢ãã¬ãŒããããŠããªãã¿ã°ã®ã¿ïŒãæã§èšå®ãããšããäºå®ã«ãããŸãããã¥ã¡ã³ãå ã®äœããæ¬ èœããŠããŸãïŒã å¿ èŠã«å¿ããŠããããã§ã¿ã°ãã¢ãã¬ãŒãããã¡ãœãããè¿œå ã§ããŸãã
çµæã¯ãã®ãããªãã®ã§ãã ãããã·ã¢ãã«ã®äœ¿çšã«ã€ããŠã¯ããããã«ç°ãªãç®çã®ããã«ã ããã§èªãããšãã§ããŸã ã
ã€ã³ããŒãèšå®
ã»ãšãã©ã®åå¿è ãèããããã«ãæåã¯ããã®èšå®ã®ã€ã³ããŒããåžžã«äœ¿çšããŠããŸããã
from settings import foo
ãã ãã次ã®ããã«æ£ããã€ã³ããŒãããŸãã
from django.conf import settings
ãªããããªã®ãã ããã¥ã¡ã³ããèªãã»ããè¯ãã§ãããã
æé©å
ã¯ãããææå°æ©ãªæé©åã¯ãã¹ãŠã®æªã®æ ¹æºãã§ããã第äžã«ãèè ã«ãããšãã®ãã¬ãŒãºã¯ïŒèè ã§ã¯ãªããåé¡ã§ã¯ãªãïŒ97ïŒ ã®ã±ãŒã¹ã§ã®ã¿çå®ã§ããã第äºã«ãããã«ä»¥äžã®å¯Ÿçãè¬ããããšãæãŸããéçºäžã
éåžžããã¹ãŠã®Webã¢ããªã±ãŒã·ã§ã³ãç¹ã«Djangoã«åºã¥ããWebã¢ããªã±ãŒã·ã§ã³ã®ããã«ããã¯ã¯ããŒã¿ããŒã¹ã¯ãšãªã§ãããéåžžã¯ORMãããŸãæ£ãã䜿çšããªããšæªåããŸãã ãã ããããã¥ã¡ã³ãã§ãã®åé¡ãååã«è©³çŽ°ã«é瀺ãããŠãããããããªãŒã«åºããããšã¯ããŸãæå³ããããŸããã ããŒã¿ããŒã¹ã«å¯ŸããŠè¡ãããã¯ãšãªãšãã®å®è¡æéã衚瀺ããã«ã¯ã django-debug-toolbarãŸãã¯ããæšè£œã®ãœãªã¥ãŒã·ã§ã³ã䜿çšã§ããŸãã
ãããäžæ¹ã§ããŠãŒã¶ãŒã¯ããŒãžã®è¡šç€ºé床ã«é¢å¿ãããããµãŒããŒãã©ãã ããããã§ã¯ãªããè² è·èªäœãæé©åããå¿ èŠããããŸãã ã¡ãªã¿ã«ãäžèšã®ããŠãŒã¶ãŒã®ããŒãžããjavascriptãä»ããŠAPIã«ã¢ã¯ã»ã¹ããæ¹ãæé©ã§ãããšæžããçç±ã¯ã VKontakteãµãŒããŒã®å¿çã®é 延ã¯å€§ããç°ãªãå¯èœæ§ããããããããŒãžãèªã¿èŸŒãŸããŠãŠãŒã¶ãŒã«è¡šç€ºãããåŸãã§ããã ãæ©ããã¹ãŠã®èŠæ±ãè¡ãããšããå§ãããŸãã
æé©åã§éåžžã«åœ¹ç«ã€ãã«ããŒã¯Page Speedã§ãã ã»ãšãã©ã®å ŽåããŸã第äžã«ããã¹ãŠãçž®å°ããå¿ èŠããããŸãã
htmlã®å Žåã質åã¯ãã³ãã¬ãŒãã¿ã°{ïŒ spacelessïŒ } {ïŒ endspacelessïŒ }ã«ãã£ãŠè§£æ±ºãããŸãããã¿ã°ã¯ã¿ã°éã®ã¹ããŒã¹ã®ã¿ãåé€ãããããã¿ã°å ã®ãã¹ãŠã®ããã¹ããã©ããããå¿ èŠããããŸãïŒãã³ãã¬ãŒãã¿ã°éã§ãããŸãã¯ããã®ãããªå Žæã«ãã¹ãŠ1è¡ã§æžã蟌ã¿ãã¿ã°å±æ§ãå¥ã ã®è¡ã«æžã蟌ããšããæªã倢ã®ããã«å¿ããŸãã ããã«ãã¿ã°éã®ç©ºçœã€ã³ãã³ãã«äŸåããŠããå Žåããããä¿®æ£ããã¹ã¿ã€ã«ãå®å šã«äœ¿çšããå¿ èŠããããŸãã ãã¡ããããã®ãããªçž®å°ã¯å®ç§ã®é«ãã§ã¯ãããŸããããåŒçšç¬Šããã®ä»ã®åé¯ã®é€å»ããåŸããã5ã10ïŒ ã¯å®å šã«ç¡èŠã§ãããšæããŸãã ããã«ãgzipå§çž®ã¯ç¡èŠããªãã§ãã ããã察å¿ããããã«ãŠã§ã¢ãæäŸãããŠããŸãã
ä»ãCSSãšJSã«ã€ããŠã å人çã«ã¯ã django-compressã䜿çšããŸããã æãããªå©ç¹ã¯æ¬¡ã®ãšããã§ãã
- æ¥çãã¡ã€ã«ã®ããŒãžã§ã³ç®¡çïŒå€æŽã衚瀺ããããã«ãã£ãã·ã¥ãå¿é ããå¿ èŠããªãããšãæå³ããŸãïŒ
- ããŸããŸãªã³ã³ãã¬ããµãŒã䜿çšããæ©èœïŒãµãŒããŒãCSSTidyãã€ããªãèµ·åã§ããªãã£ãããã YUI Compressorã䜿çšãããããéåžžã«äŸ¿å©ã§ãïŒ
- å€éšãã¡ã€ã«ã®ãµããŒããããã«ãããCDNãç°¡åã«æ·»ä»ã§ããŸãïŒCDNã®ç®çãšç®çã¯ã ãã¡ãã§ç¢ºèªã§ããŸã ïŒã
ãã¡ããããã®ã¢ãžã¥ãŒã«ã¯æ¬è³ªçã«MVCã«éåããŠããŸãããèŽåœçã§ã¯ãªããéåžžã«äŸ¿å©ã§ãã
ããã«ã django-media-bundlerã«æ³šç®ãã䟡å€ããããŸãã cssãšjsã®å§çž®ã«å ããŠãpngcrushã䜿çšããŠCSSã¹ãã©ã€ããããã«çž®å°ããªãããèªåçã«CSSã¹ãã©ã€ããäœæããããšãã§ããŸãããæ®å¿µãªããdjango-compressã®ãããªããŒãžã§ã³ç®¡çã¯ãããŸããã ã¢ããªã±ãŒã·ã§ã³å ã®ã¢ã€ã³ã³ã®æ°ãå°ãªããããå°æ¥ã®ãããžã§ã¯ãã®ããã«æ®ãããšã«ããŸããã
ããã«ãåjsãã¡ã€ã«ã®æåŸã«ã»ãã³ãã³ã眮ããšéåžžã«äŸ¿å©ã§ãã ååšããªããšãå§çž®åŸã«ãããã³ãŒããçºçããå¯èœæ§ããããŸãã
ãããŠæåŸã«ã補åã®åŒ·åºŠããã¹ããã䟡å€ããããŸãã è² è·ã®åœ±é¿ã¯ããã®åé¡ã§éåžžã«åœ¹ç«ã¡ãŸãã èå³ã®ããæ¹ã¯ãããã«ã€ããŠããå°ã詳ãã説æããèšäºãã芧ãã ããã ãã¡ããç¡æã®ãã¹ããå©çšã§ããŸãïŒæ倧50ãŠãŒã¶ãŒïŒãããã¡ããã§ã¯ãªããå°ãªããšã9ãã«çžåœã®åºæ¬ããã±ãŒãžïŒæ倧250ãŠãŒã¶ãŒïŒãè³Œå ¥ããããšããå§ãããŸãã
ã¢ããªã±ãŒã·ã§ã³ãã¹ãã®çµæã¯æ¬¡ã®ãšããã§ãã
ã¢ããªã±ãŒã·ã§ã³ã¯è² è·ã«éåžžã«ããŸã察åŠã§ããããšãããããŸãããããã«ããããããã70人ã®ãŠãŒã¶ãŒã®åŸã§ã¯ããã¹ãŠãæäŸããããã£ãã«ã®å¹ ã«äŸåããŸãã ãã®ãããæçµåæã§ã¯ãhtmlãcssãjsã®çž®å°åã䌎ããžã§ã¹ãã£ãŒãããã³CDNã®äœ¿çšãéåžžã«åœ¹ç«ã¡ãŸããã
PSïŒç§ã®åŸãå¥ã®äººãã¬ã€ã¢ãŠãã«åãçµãã ãããã¢ããªã±ãŒã·ã§ã³ã®ãã³ãã®äžéšãå®è¡ãããªãå ŽåããããŸãã