SlideShare ist ein Scribd-Unternehmen logo
1 von 16
HTML::Mason 使用Mason进行高性能Web站点的开发 Yujie / Maxthon
目录 1/ 四个网站 2/ Mason的定义 3/ 为什么选择Mason 4/ 了解Mason 5/ 网站演示 6/ 从哪儿开始 本演讲的目的不是深入探讨Mason的原理和运作机制, 而是展示什么是Mason, 它有什么特点, 能够实现什么样的功能.
1/ 四个网站
2/ Mason的定义 Perl模块High-Performance, dyamic web site authoring system. -- CPAN 模板工具 	Mason is a powerful text templating tool for embedding Perl in text. It offers many features to help you create dynamic web sites from re-usable components. -- Mason Book Web站点开发引擎 	Mason is a powerful Perl-based web site development engine. With Mason you can embed Perl code in your HTML and construct pages from shared, reusable components. -- www.masonhq.com Web框架/Perl Web开发解决方案…
3/ 为什么选择Mason 书写方便、开发快速直接在HTML页面里书写Perl代码, VS Template::Toolkit 可重用组件 组件的概念, 只需更改一次, 关注不同的地方 统一的参数处理 	Post和Get方式 内建缓存机制 强大的文本过滤 高性能与mod_perl紧密结合: Apache内置Perl解释器、代码缓冲 	Mason自身的机制: 代码缓存、对象文件…
4/ 了解Mason Apache配置 <VirtualHost www.yujie.com> 	DocumentRoot "/var/www/www.yujie.com" 	PerlRequire "/var/www/www.yujie.com/startup.pl" 	PerlSetVar MasonCompRoot "/var/www/www.yujie.com" PerlSetVarMasonDataDir "/var/www/www.yujie.com/data" PerlSetVarMasonAllowGlobals $User <Directory "/var/www/www.yujie.com"> 	SetHandler perl-script 	PerlHandler HTML::Mason::ApacheHandler </Directory> <LocationMatch "(gif|jpg|png|ico|css|js|swf)$"> SetHandler default </LocationMatch> </VirtualHost>
4/ 了解Mason Perl嵌入 Perl代码嵌入HTML页面的三种方式 <%perl>  my $planet; </%perl> % $planet = “World”;  Hello, <% $planet %>! <div style=“display: <% $display ? ‘block’ : ‘none’ %>” >  <input type=“text” value=“<% $ARGS{account} || $User->{account} %>” name=“account” /> </div>
4/ 了解Mason %ARGS send.html <form action="example.html?user=Yujie" method="post">  <input type="text" value="Today is Saturday." name="word" /><br />  <input type="submit" value="submit" /> </form> example.html <% $ARGS{user} %>:<% $ARGS{word} %>
4/ 了解Mason 标签 Perl标签: 嵌入HTML页面的一段Perl代码 Init标签: 初始化Perl块, 在HTML页面之前执行 Attr标签: 声明组件的属性 Flags标签: 标志标签, 可用于声明组件继承关系 Args标签: 参数标签, 用于声明页面所需参数 Once标签: 一次性加载 Docs标签: 文档标签 Filter标签: 过滤标签 Mason is a powerful Perl-based web site development and delivery engine. <%filter>  s/(+)/$1/g # s/href="([^"])+"/add_session_id($1)/eg;  # s/action="([^"])+"/add_session_id($1)/eg; </%filter>
4/ 了解Mason autohandler autohandler 逻辑处理 视图处理 请求 数据封装 header 输出 用户认证 $m->call_next 输出过滤 footer <& footer &> index.html example.html …
4/ 了解Mason autohandler ,[object Object],<%perl>  print “Hello";  $m->call_next; </%perl> example.html % print “ friends!“; ,[object Object],<& template/header.mas &> <& template/sidebar.mas &> % $m->call_next; <& template/footer.mas &>
4/ 了解Mason dhandler dhandler return 404 分发请求 逻辑处理 404请求 数据获取 输出生成 返回404 url跳转 输出
4/ 了解Mason dhandler dhandler my $request_uri = $m->dhandler_arg; if($request_uri =~ m#old/(.*?)$#) {  $m->redirect(“/new/$1”); } 0_23.png 获得请求地址 类型:0 userid:23 获得参数 用户性别、昵称等 取得用户数据 生成图片 GD、Imagemagick
4/ 了解Mason 实践 数据库操作从DBI到Rose, 从SQL到ORM 模块 提高重用性, 提高性能 Tools.pm package Tools; sub trim {  # code here  }  startup.pl use lib “/var/www/www.yujie.com/_modules”; use Tools; example.html % print Tools::trim($data);
5/ 网站演示 常用模块  Apache2::Cookie   Apache2::Upload   Apache::DBI  GD  GD::SecurityImage  URI::Escape  LWP::UserAgent  JSON  DateTime  Cache::Memcached  Encode   Net::SMTP   Mail::Sender Digest::SHA  Crypt::DES  Rose
6/ 从哪儿开始 Mason BookEmbedding Perl in HTML with Mason 	www.masonbook.com www.masonhq.com 	maillist

Weitere ähnliche Inhalte

Empfohlen

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
 

Empfohlen (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...
 

Mason

  • 2. 目录 1/ 四个网站 2/ Mason的定义 3/ 为什么选择Mason 4/ 了解Mason 5/ 网站演示 6/ 从哪儿开始 本演讲的目的不是深入探讨Mason的原理和运作机制, 而是展示什么是Mason, 它有什么特点, 能够实现什么样的功能.
  • 4. 2/ Mason的定义 Perl模块High-Performance, dyamic web site authoring system. -- CPAN 模板工具 Mason is a powerful text templating tool for embedding Perl in text. It offers many features to help you create dynamic web sites from re-usable components. -- Mason Book Web站点开发引擎 Mason is a powerful Perl-based web site development engine. With Mason you can embed Perl code in your HTML and construct pages from shared, reusable components. -- www.masonhq.com Web框架/Perl Web开发解决方案…
  • 5. 3/ 为什么选择Mason 书写方便、开发快速直接在HTML页面里书写Perl代码, VS Template::Toolkit 可重用组件 组件的概念, 只需更改一次, 关注不同的地方 统一的参数处理 Post和Get方式 内建缓存机制 强大的文本过滤 高性能与mod_perl紧密结合: Apache内置Perl解释器、代码缓冲 Mason自身的机制: 代码缓存、对象文件…
  • 6. 4/ 了解Mason Apache配置 <VirtualHost www.yujie.com> DocumentRoot "/var/www/www.yujie.com" PerlRequire "/var/www/www.yujie.com/startup.pl" PerlSetVar MasonCompRoot "/var/www/www.yujie.com" PerlSetVarMasonDataDir "/var/www/www.yujie.com/data" PerlSetVarMasonAllowGlobals $User <Directory "/var/www/www.yujie.com"> SetHandler perl-script PerlHandler HTML::Mason::ApacheHandler </Directory> <LocationMatch "(gif|jpg|png|ico|css|js|swf)$"> SetHandler default </LocationMatch> </VirtualHost>
  • 7. 4/ 了解Mason Perl嵌入 Perl代码嵌入HTML页面的三种方式 <%perl> my $planet; </%perl> % $planet = “World”; Hello, <% $planet %>! <div style=“display: <% $display ? ‘block’ : ‘none’ %>” > <input type=“text” value=“<% $ARGS{account} || $User->{account} %>” name=“account” /> </div>
  • 8. 4/ 了解Mason %ARGS send.html <form action="example.html?user=Yujie" method="post"> <input type="text" value="Today is Saturday." name="word" /><br /> <input type="submit" value="submit" /> </form> example.html <% $ARGS{user} %>:<% $ARGS{word} %>
  • 9. 4/ 了解Mason 标签 Perl标签: 嵌入HTML页面的一段Perl代码 Init标签: 初始化Perl块, 在HTML页面之前执行 Attr标签: 声明组件的属性 Flags标签: 标志标签, 可用于声明组件继承关系 Args标签: 参数标签, 用于声明页面所需参数 Once标签: 一次性加载 Docs标签: 文档标签 Filter标签: 过滤标签 Mason is a powerful Perl-based web site development and delivery engine. <%filter> s/(+)/$1/g # s/href="([^"])+"/add_session_id($1)/eg; # s/action="([^"])+"/add_session_id($1)/eg; </%filter>
  • 10. 4/ 了解Mason autohandler autohandler 逻辑处理 视图处理 请求 数据封装 header 输出 用户认证 $m->call_next 输出过滤 footer <& footer &> index.html example.html …
  • 11.
  • 12. 4/ 了解Mason dhandler dhandler return 404 分发请求 逻辑处理 404请求 数据获取 输出生成 返回404 url跳转 输出
  • 13. 4/ 了解Mason dhandler dhandler my $request_uri = $m->dhandler_arg; if($request_uri =~ m#old/(.*?)$#) { $m->redirect(“/new/$1”); } 0_23.png 获得请求地址 类型:0 userid:23 获得参数 用户性别、昵称等 取得用户数据 生成图片 GD、Imagemagick
  • 14. 4/ 了解Mason 实践 数据库操作从DBI到Rose, 从SQL到ORM 模块 提高重用性, 提高性能 Tools.pm package Tools; sub trim { # code here } startup.pl use lib “/var/www/www.yujie.com/_modules”; use Tools; example.html % print Tools::trim($data);
  • 15. 5/ 网站演示 常用模块 Apache2::Cookie Apache2::Upload Apache::DBI GD GD::SecurityImage URI::Escape LWP::UserAgent JSON DateTime Cache::Memcached Encode Net::SMTP Mail::Sender Digest::SHA Crypt::DES Rose
  • 16. 6/ 从哪儿开始 Mason BookEmbedding Perl in HTML with Mason www.masonbook.com www.masonhq.com maillist