SlideShare a Scribd company logo
1 of 30
Download to read offline
Asset Pipeline
              天龍國 Developer 的 Assets 管理法




                          1
星期日, 4月 15,                                1
Xdite Cheng


              github.com/xdite

              xdite




                                 2
星期日, 4月 15,                          2
小蟹
              PIXNET
              github.com/wildjcrt
              wildjcrt

              Ruby Taiwan
              RailsTuesday



                               3
星期日, 4月 15,                         3
Assets

              ▪ CSS
              ▪ JavaScript
              ▪ Image


                               4
星期日, 4月 15,                           4
Asset = 次等公民



                   5
星期日, 4月 15,                  5
public/
              •   icon-01.png          •   reset.css

              •   icon-02.png          •   tinymce/

              •   jquery.js            •   ....

              •   logo.png

              •   main.css




                                   6
星期日, 4月 15,                                            6
Asset 管理上需要面對的問題


              ▪ Optimization Issue
              ▪ Outdate
              ▪ Hard to write maintainable code


                                  7
星期日, 4月 15,                                       7
Optimization Issue

              ▪ Compress / Trim
              ▪ CSS Sprite
              ▪ Development / Deploy
              ▪ CDN / clear cache

                                 8
星期日, 4月 15,                            8
Outdate
              ▪ jQuery
              ▪ jQuery UI
              ▪ Bootstrap
              ▪ TinyMCE
              ▪ ....

                               9
星期日, 4月 15,                           9
Maintain Issue
              #header{ ... }
              #header nav.main{ ... }
              #header nav.main a{ ...}
              #header nav.main a:hover{...}


                           不覺得這樣寫很囉嗦的請舉手


                                  10
星期日, 4月 15,                                   10
Maintain Issue




              ▪ JavaScript
                             11
星期日, 4月 15,                       11
Asset Pipeline
                 Since Rails 3.1




                        12
星期日, 4月 15,                        12
以一個全新的角度去管理 Asset




                      13
星期日, 4月 15,                       13
Asset Pipeline 提供

              ▪ Optimization Mechanism
              ▪ Organization Rules
              ▪ Asset Version Control
              ▪ Write assets in other language

                                   14
星期日, 4月 15,                                      14
這麼神?



               15
星期日, 4月 15,          15
Optimization

              ▪ Compress / Trim
              ▪ CSS Sprite
              ▪ Development / Deploy
              ▪ CDN / clear cache
                      內建 Best Practices,Deploy 時自動完成


                                 16
星期日, 4月 15,                                            16
Organization Rules
              ▪ vendor/assets/
               ▫ jQuery, TinyMCE, Bootstrap...
              ▪ lib/assets/
               ▫ utility
              ▪ app/assets
               ▫ main, sidebar, font,
                                  17
星期日, 4月 15,                                      17
Organization Rules
              /*
               *= require bootstrap
               *= require sidebar
               *= require common
               *= require_self
               *= require_tree .
              */

                               一律視為 /assets 下檔案掛起來

                                      18
星期日, 4月 15,                                          18
Asset Version Control
              ▪ Bundler => Asset As Gem
               ▫ Gemfile
              gem "jquery-rails"
              gem "tinymce-rails"
              gem "bootstrap", "1.4.1"


              ○ application.js
              //= require jquery
              //= require jquery_ujs
              //= require bootstrap
              //= require tinymce



                                         19
星期日, 4月 15,                                   19
Front-end Meta Languages

              ▪ CoffeeScript
              ▪ Sass / SCSS
               ▫ Compass


                               20
星期日, 4月 15,                              20
CoffeeScript
              class Animal
               constructor: (@name) ->

               move: (meters) ->
                alert @name + " moved #{meters}m."

              class Snake extends Animal
               move: ->
                 alert "Slithering..."
                 super 5




                                            21
星期日, 4月 15,                                          21
CoffeeScript

              ▪ avoid the“bad parts”
               ▫ avoid global variable / function
               ▫ 使用 -> 和 indent (縮排)
               ▫ 容易偵測 syntax error

                                    22
星期日, 4月 15,                                         22
Sass / SCSS
              #header{ ... }
              #header nav.main{ ... }
              #header nav.main a{ ...}
              #header nav.main a:hover{...}




                                    23
星期日, 4月 15,                                   23
Sass / SCSS
              #header{
                 nav.main{
                    a{
              ▪   We&:hover{do this way
                       should }
                  }
                }
              }



                                   24
星期日, 4月 15,                               24
Compass
              ▪ CSS Authoring Framework
               ▫ Blueprint
               ▫ 960
               ▫ fancy buttons
               ▫ CSS3 Pie

                                25
星期日, 4月 15,                               25
Compass
              ▪ Features
               ▫ replace-text
               ▫ border-radius
               ▫ gradient
               ▫ sprite

                                 26
星期日, 4月 15,                           26
Organize SCSS
              ▪ by default block ( header / footer / sidebar )
              ▪ by special block
              ▪ by feature
              ▪ by (Rails) controller
              ▪ by page specific

                                    27
星期日, 4月 15,                                                      27
Compass and bootstrap
                @import "bootstrap";

                // config variables first and import compass
                $base-font-size: 16px;
                $base-line-height: 24px;
                $relative-font-sizing: false;
                @import "compass";

                @import "module/mixins";
                @import "module/box";
                @import "module/modal"; // override bootstrap modal effect

                @import "partial/header";
                @import "partial/sidebar-items";
                @import "partial/sidebar-tools";
                @import "partial/sidebar";                              ▪ main.css
                                             28
星期日, 4月 15,                                                                          28
Reference
              ▪ http://upgrade2rails31.com/asset-pipeline
              ▪ http://upgrade2rails31.com/sass-scss
              ▪ http://upgrade2rails31.com/coffee-script
              ▪ http://blog.xdite.net/posts/2012/02/06/
                extend-bootstrap-in-compass/

              ▪ https://github.com/anjlab/bootstrap-rails
                                    29
星期日, 4月 15,                                                 29
Thanks



                30
星期日, 4月 15,            30

More Related Content

Recently uploaded

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusZilliz
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...apidays
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 

Recently uploaded (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Asset pipeline osdc

  • 1. Asset Pipeline 天龍國 Developer 的 Assets 管理法 1 星期日, 4月 15, 1
  • 2. Xdite Cheng github.com/xdite xdite 2 星期日, 4月 15, 2
  • 3. 小蟹 PIXNET github.com/wildjcrt wildjcrt Ruby Taiwan RailsTuesday 3 星期日, 4月 15, 3
  • 4. Assets ▪ CSS ▪ JavaScript ▪ Image 4 星期日, 4月 15, 4
  • 5. Asset = 次等公民 5 星期日, 4月 15, 5
  • 6. public/ • icon-01.png • reset.css • icon-02.png • tinymce/ • jquery.js • .... • logo.png • main.css 6 星期日, 4月 15, 6
  • 7. Asset 管理上需要面對的問題 ▪ Optimization Issue ▪ Outdate ▪ Hard to write maintainable code 7 星期日, 4月 15, 7
  • 8. Optimization Issue ▪ Compress / Trim ▪ CSS Sprite ▪ Development / Deploy ▪ CDN / clear cache 8 星期日, 4月 15, 8
  • 9. Outdate ▪ jQuery ▪ jQuery UI ▪ Bootstrap ▪ TinyMCE ▪ .... 9 星期日, 4月 15, 9
  • 10. Maintain Issue #header{ ... } #header nav.main{ ... } #header nav.main a{ ...} #header nav.main a:hover{...} 不覺得這樣寫很囉嗦的請舉手 10 星期日, 4月 15, 10
  • 11. Maintain Issue ▪ JavaScript 11 星期日, 4月 15, 11
  • 12. Asset Pipeline Since Rails 3.1 12 星期日, 4月 15, 12
  • 13. 以一個全新的角度去管理 Asset 13 星期日, 4月 15, 13
  • 14. Asset Pipeline 提供 ▪ Optimization Mechanism ▪ Organization Rules ▪ Asset Version Control ▪ Write assets in other language 14 星期日, 4月 15, 14
  • 15. 這麼神? 15 星期日, 4月 15, 15
  • 16. Optimization ▪ Compress / Trim ▪ CSS Sprite ▪ Development / Deploy ▪ CDN / clear cache 內建 Best Practices,Deploy 時自動完成 16 星期日, 4月 15, 16
  • 17. Organization Rules ▪ vendor/assets/ ▫ jQuery, TinyMCE, Bootstrap... ▪ lib/assets/ ▫ utility ▪ app/assets ▫ main, sidebar, font, 17 星期日, 4月 15, 17
  • 18. Organization Rules /* *= require bootstrap *= require sidebar *= require common *= require_self *= require_tree . */ 一律視為 /assets 下檔案掛起來 18 星期日, 4月 15, 18
  • 19. Asset Version Control ▪ Bundler => Asset As Gem ▫ Gemfile gem "jquery-rails" gem "tinymce-rails" gem "bootstrap", "1.4.1" ○ application.js //= require jquery //= require jquery_ujs //= require bootstrap //= require tinymce 19 星期日, 4月 15, 19
  • 20. Front-end Meta Languages ▪ CoffeeScript ▪ Sass / SCSS ▫ Compass 20 星期日, 4月 15, 20
  • 21. CoffeeScript class Animal constructor: (@name) -> move: (meters) -> alert @name + " moved #{meters}m." class Snake extends Animal move: -> alert "Slithering..." super 5 21 星期日, 4月 15, 21
  • 22. CoffeeScript ▪ avoid the“bad parts” ▫ avoid global variable / function ▫ 使用 -> 和 indent (縮排) ▫ 容易偵測 syntax error 22 星期日, 4月 15, 22
  • 23. Sass / SCSS #header{ ... } #header nav.main{ ... } #header nav.main a{ ...} #header nav.main a:hover{...} 23 星期日, 4月 15, 23
  • 24. Sass / SCSS #header{ nav.main{ a{ ▪ We&:hover{do this way should } } } } 24 星期日, 4月 15, 24
  • 25. Compass ▪ CSS Authoring Framework ▫ Blueprint ▫ 960 ▫ fancy buttons ▫ CSS3 Pie 25 星期日, 4月 15, 25
  • 26. Compass ▪ Features ▫ replace-text ▫ border-radius ▫ gradient ▫ sprite 26 星期日, 4月 15, 26
  • 27. Organize SCSS ▪ by default block ( header / footer / sidebar ) ▪ by special block ▪ by feature ▪ by (Rails) controller ▪ by page specific 27 星期日, 4月 15, 27
  • 28. Compass and bootstrap @import "bootstrap"; // config variables first and import compass $base-font-size: 16px; $base-line-height: 24px; $relative-font-sizing: false; @import "compass"; @import "module/mixins"; @import "module/box"; @import "module/modal"; // override bootstrap modal effect @import "partial/header"; @import "partial/sidebar-items"; @import "partial/sidebar-tools"; @import "partial/sidebar"; ▪ main.css 28 星期日, 4月 15, 28
  • 29. Reference ▪ http://upgrade2rails31.com/asset-pipeline ▪ http://upgrade2rails31.com/sass-scss ▪ http://upgrade2rails31.com/coffee-script ▪ http://blog.xdite.net/posts/2012/02/06/ extend-bootstrap-in-compass/ ▪ https://github.com/anjlab/bootstrap-rails 29 星期日, 4月 15, 29
  • 30. Thanks 30 星期日, 4月 15, 30