Rails ã®ãã³ãããªã¹ãã®ãªã¹ã¹ã¡ãæãã¦ãã ãã
èæ¯
ãã³ãããªã¹ãã¨ããã®ãç¨æãã¦ã¿ãã¨ãããã»ã³ã¹ããªããããã¯èªåã§ãããã®ã§ãªãã¦ã©ã¤ãã©ãªã§ãã£ãã»ããããã¨æãã¾ããã
è¦ä»¶
ã¤ããããããè¦ãç®ããã¾ãããµããªããããã¤ãã¤ããããã¾ãããµããªããã¨ãããã®ãããã§ãã
èªåãè¦ä»ãããããã®
ruby-toolbox.com ã§ããã£ã¨è¦ã¦ã¿ãã¨ããã以ä¸ã®5ã¤ãããããããªãã¨æãã¾ããã
- Breadcrumbs On Rails
- Crummy
- Breadcrumble
- Loaf
- Gretel
Breadcrumbs On Rails
å®çªã®ããã§ãä¸çªäººæ°ã£ã½ããã³ã³ããã¼ã©ã§ãªã³ã¯åã¨ãã¹ãé åã«è©°ãã¦ããããã¥ã¼ã§ããã表示ããã¿ã¤ã
- ActionController::Base#add_breadcrumb ã«ãªã³ã¯åã¨ãã¹ã渡ããªã¹ããä½ããååã®ã¯ã©ã¹ã¡ã½ããããããbefore_filter ã使ããã¯ãçã«å®ç¾©ããæ©è½ãæä¾ãã
- 表示ã®ããã®ãã«ããå®ç¾©ãã¦ããããã³ãããªã¹ãã®ã»ãã¬ã¼ã¿(» ãããã©ã«ã)ããspan ãã li ãªã©ã®ã¿ã°æå®ãã§ããããã
- 幾種é¡ãã®ãªã³ã¯åããã¹ã®æå®ãå¯è½ã§ãããã·ã³ãã«ã Proc ãªãã¸ã§ã¯ãããããã°ã³ã³ããã¼ã©ã®ã¤ã³ã¹ã¿ã³ã¹ã®ã³ã³ããã¹ãã§è©ä¾¡ããã
Crummy
Breadcrumbs On Rails ã¨ã¢ããã¼ãã¯åãã§ä½ããã ãããåãããã¯ãçã« before_filter ã宣è¨ããã¯ã©ã¹ã¡ã½ããã®ã¤ãããã¡ãã£ã¨éãã
- ActionController::Base#add_crumb ã«ãªã³ã¯åã¨ãã¹ã渡ããªã¹ããã¤ãããActionController::Base.add_crumb ãã¤ã³ã¹ã¿ã³ã¹ã®ã³ã³ããã¹ããæã«ãããã®ããããã¸ããããªå°è±¡
- 表示ã®ããã®ãã«ãã¯ã表示ç¨ã®ã¯ã©ã¹(Crummy::StandardRenderer ã¨ããã¬ã³ãã©)ã«å¦çãããæ¹å¼ã§ãwill_paginate ã£ã½ã
Breadcrumble
ã·ã³ãã«ãª Breadcrumbs On Railsãæ¥æ¬ã®æ¹ãä½ã£ã¦ãæ§åã
- ActionController::Base#add_breadcrumb ã§(以ä¸ç¥)ããã¯ãçã¯ã©ã¹ã¡ã½ãããã·ã³ãã«ããããããããªããcollection 㪠URL ã® named_path ã®æå®ã¯ã§ãããæ°ããã
- 表示ã®ããã®ãã«ãã¯ã表示ç¨ã®ãã¼ã·ã£ã«ã使ãæ¹å¼ã§ãkaminari ã£ã½ããä»ã¯ã§ããªãããkaminari ã¿ããã« theme ãªãã·ã§ã³ãåãä»ãããã§ããã
Loaf
ãªã³ã¯ããã¹ãé¨åã I18n ã«å¯¾å¿ãã Breadcrumbs On Rails ã¨ããæã(ãã以ä¸ã®å°è±¡ããªã)ã
Gretel
config/initializers 以ä¸ã« Ruby ã®ãã¡ã¤ã«ãç½®ãè¨å®ãã¡ã¤ã«æ¹å¼ã
- config/initializers/breadcrumbs.rb ã«ããã³ãããªã¹ãã®ããã¹ãã¨ãªã³ã¯ãååãã¤ãã¦è¨å®ãã¦ãããè¨å®ã¯ parent ã®è¨å®ãæå®ãããã¨ãå¯è½ã§ãããã§é層ã表ç¾ããã
- 表示ã®ããã®ãã«ãã«ãè¨å®ãã¡ã¤ã«ã§ã¤ããååã§è¨å®ãå¼ã¶(
<% breadcrumb :issue, @issue %>
ã®ããã«ãè¨å®ã§ã¯è¡¨ç¤ºãããªã³ã¯ã®ãªã½ã¼ã¹ãæå®ãããã¨ãå¯è½) - æ¨æºã§ã¯ãã«ãã content_tag ãªã©ã®ã¡ã½ãã㧠HTML ãçæãããããªã¹ãã«ã¢ã¯ã»ã¹ããã¡ã½ãããããã®ã§ããªãã·ã§ã³æå®ã§ã©ãã«ããªããªãã¨ã㯠ERB ãªã©ã§è¡¨ç¤ºã®å¤æ´ãå¯è½
çµè«
Gretel ãä¸çªããããªã¨ããæ°ãããããã³ãããªã¹ãã®è¡¨ç¤ºã¨ããããã¾ãã¡ã¤ã³ã®å¦çã¨é¢ä¿ãªã(é¢ä¿ãªããã¨ã¯ãªãã)å¦çã®ãã¨ãèããªãã¦ããã®ã¯ãããããã
ãªãã¨ãªãäºæ³ãã¦ããã©ãGretel ã§ã¯ãã㨠view ã§è¡¨ç¤ºãå¶å¾¡ããå½¢ã«ãªãã®ã§(ã©ãããã¹ãããã¯å¤æãããã)åã view ãã¤ããã¾ãããããªç»é¢ãå¤ãã¨ãã¤ããã¥ãããããããªã(helper ã§ã©ããããã°ããããã§ã¯ãã)ãã¾ããã³ã³ããã¼ã©ã§ãã³ãããªã¹ãã«ã¤ãã¦ãã¾ãæèããªãã¦æ¸ãã¨ã¯ãããå ¨ãæèããªãã¦ããããã§ã¯ãªããã¨ã¯ããã³ã³ããã¼ã©ã® before_filter ã§ãªããããããã¤ãã¦ãã®ãã©ããªãã ããã¨ãã¤ãæãã®ã§ Gretel ã§ãã°ããçãã¦ããã¾ãã
Gretel ã§ä¸é½åãããã° Breadcrumbs On Rails ã Breadcrumble ã使ããã¨ãããã
ä½ããªã¹ã¹ã¡ããã£ãã誰ããããã¦ãã ããã