ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Communications Lab :: Web Lecture 6: More advanced examples
Announcements JavaScript assignment #5 due today. Office hours by appointment?only?this week.
Final Projects Final Project Ideas - User Experience Presentations
Sending an Email from Sinatra require 'pony' post '/contact' do ?  Pony.mail  :to => 'you@example.com', ? ? ? ? ? ?  :from => 'me@example.com', ? ? ? ? ? ?  :subject => 'Hello email!' end
Sending an Email from Sinatra require 'pony' post '/send_email' do? ? ?  Pony.mail ( ? ? ?  :from  => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;</slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; + params[:email] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ?  :to  => 'my_email@gmail.com', ? ? ?  :subject  => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; has sent you an email/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ?  :body  => params[:message], ? ? ?  ......) ? ?  redirect '/success'? end
Sending an Email from Sinatra require 'pony' post '/send_email' do? ? ?  Pony.mail( ? ? ?  :from  => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;</slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; + params[:email] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ?  :to  => 'my_email@gmail.com', ? ? ?  :subject  => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; has sent you an email/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ?  :body  => params[:message], ? ? ?  :port  => '587', ? ? ?  :via  => :smtp, ? ? ?  :via_options  => {? ? ? ? ?  :address ? ? ? ? ? ? ?=> 'smtp.gmail.com',? ? ? ? ?  :port ? ? ? ? ? ? ? ? => '587',? ? ? ? ?  :enable_starttls_auto => true,? ? ? ? ?  :user_name ? ? ? ? ? ?=> 'my_email',? ? ? ? ?  :password ? ? ? ? ? ? => 'p@55w0rd',? ? ? ? ?  :authentication ? ? ? => :plain,? ? ? ? ?  :domain ? ? ? ? ? ? ? => 'example.com' ? ? ?  }) ? ?  redirect '/success'? end
Email Resources http://www.sinatrarb.com/faq.html#email http://ididitmyway.heroku.com/past/2010/12/4/ an_email_contact_form_in_sinatra/ https://github.com/adamwiggins/pony
Embedding a Video in HTML 1. Go to youtube.com 2. Click on /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;Share/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; 3. Click on /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;embed/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; 4. Copy the HTML and paste it in your HTML file
Embedding Fonts Sometimes you may want to use a  font that's not web safe If you use a font face the user doesn't have on their computer, the browser will find the closest installed font and use it instead The solution? Embedded fonts! ?Downsides: Use sparingly, since  fonts take a long time to download . This will significantly slow down your web pages. Different browsers accept different types of fonts.
Embedding Fonts First, download a font. A good source:?http://www.dafont.com/ ? ?  <style type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;text/css/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ?  @font-face  { ? ? ? ?  font-family:  deadends ; ? ? ? ?  src: url(/slideshow/lecture-6-comm-lab-web-itp/9864023/&); ? ? ?  } ? ? ?  .deadend-font  { ? ? ? ?  font-family:  deadends ; ? ? ? ?  font-size: 3.2em; ? ? ?  } ? ?  </style> ? ?  <body>? ?? ??? ? <h2 class=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;deadend-font/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Today's News</h2>? ?? ? </body>
Embedding Fonts An alternative is to use  typekit , compatible with all browsers https://typekit.com/ Hundreds of free web-safe fonts on  Google web fonts : http://www.google.com/webfonts
Creating a Navigation Menu Navigation menus can actually be lists: < ul  id=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;nav/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; class=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;menu/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ?? ? < li ><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;index.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Home</a></ li > ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;syllabus.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Syllabus</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;schedule.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Schedule</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;resources.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Resources</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;contact.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Contact</a></li> </ ul >
Creating a Navigation Menu Adding CSS: ?  ? ?  ul.menu, ul.menu li, ul.menu ul  { ? ? ? ?  list-style: none; ? ? ?  } ? ? ?  ul.menu li  { ? ? ? ?  padding: 7px 10px; ? ? ? ?  border-style: solid; ? ? ? ?  border-width: 1px 1px 1px 0; ? ? ? ?  border-color: #fff #d9d9d9 #d9d9d9; ? ? ? ?  background-color: #f6f6f6; ? ? ? ?  float: left; ? ? ?  }
Creating a Navigation Menu Some more ideas: http://www.hongkiat.com/blog/drop-down-menu-30-free-scripts-to-enhance-header-navigation/
A Simple Image Gallery Download Galleria:?http://galleria.aino.se/download/ Unzip Galleria in your directory. In your html file, include the following two JavaScript files: ? ?  <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;></script> ? ?  <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; galleria/galleria-1.2.5.min.js /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;></script>
A Simple Image Gallery 4. Define a div with a /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; id (required) and list all the images you want inside of it. ? ? <div id=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ?  <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo1.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ?  <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo2.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ?  <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo3.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ?  </div>
A Simple Image Gallery 5. At the end of your file, right before the body tag, add the following piece of JavaScript to define the width, height and theme of your gallery. ? ? ?  <script>? ?? ? ? ? ?  Galleria.loadTheme('galleria/themes/classic/ galleria.classic.min.js'); ? ? ? ?  $(/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;#gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;).galleria({ ? ? ? ? ? ?  width: 900, ? ? ? ? ? ?  height: 700 ? ? ? ?  }); ? ?  </script>
Uploading Files with Sinatra get '/' do ?  form = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ?  form += '<form action=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;http://itp.nyu.edu/~irs221/sinatra/upload /upload_file /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; method=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; POST /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;  enctype=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;multipart/form-data/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; >' ?  form += '<p><label>File:</label> <input  type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;file/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;  name=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;file/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; /></p>' ?  form += '<p><input type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;submit/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; value=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;Upload/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; /></p>' ?  form += '</form>' ?  form end
Uploading Files with Sinatra require 'dm-core' DataMapper::setup(:default, {:adapter => 'yaml', :path => 'db'}) class  Image ?  include DataMapper::Resource ?  property :id, ? ? ? ? ? ? ? ? Serial ?  property :filename, ? ? ? ? ? String end
Uploading Files with Sinatra post ' /upload_file ' do ?  tmpfile =  params[:file][:tempfile] ?  name =  params[:file][:filename] ?  while  blk = tmpfile.read(65536) ? ? ?  File.open(File.join(Dir.pwd,/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;public/uploads/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, name), /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;ab/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;) { |f| f.write(blk) } ?  end ?  image = Image.new ?  image.filename = params[:file][:filename]; ?  image.save ? /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;success <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& end Don't forget to create the directory /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;uploads/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; in public first!
Uploading Files with Sinatra get '/images' do ?  output = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; <!DOCTYPE html> ?  <html> ? ?  <head> ? ? ? ? ?  <meta charset=utf-8 /> ? ? ? ? ?  <title>Images</title> ? ?  </head> ? ?  <body> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ?  for i in Image.all ? ?  output +=  <<-HTML <p>#{i.filename}<img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& HTML ?  end ?  output += /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; </body></html> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ?  output end
Adding Image Gallery in Sinatra get '/images' do ?  output = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;<!DOCTYPE html> ?  <html><head> ? ? ? <meta charset=utf-8 /><title>Images</title> ?? ?? <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& ? ? ? <script src='/~irs221/sinatra/upload/public/galleria/galleria-1.2.5.min.js'></script> ? ?  </head><body> <div id='gallery'> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ?  for i in Image.all ? ?  output += <<-HTML <img src='http://itp.nyu.edu/~irs221/sinatra/upload/public/uploads/#{i.filename}'/> HTML ?  end ??
Adding Image Gallery in Sinatra output +=?/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; </div><script> ? ? ? ?  Galleria.loadTheme('/~irs221/sinatra/upload/public/galleria/themes/classic/galleria.classic.min.js'); ? ? ? ?  $('#gallery').galleria({ ? ? ? ? ? ?  width: 700, ? ? ? ? ? ?  height: 500 ? ? ? ?  }); ? ?  </script> </body></html>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ?  output end ??
Sinatra Resources Sinatra Google Group:?https://groups.google.com/group/sinatrarb?pli=1 DataMapper Google Group:?http://groups.google.com/group/datamapper Reference for Sinatra Syntax and Examples:?http://rubydoc.info/gems/sinatra/1.3.1/file/ README.rdoc
Next time... Final Project Presentations!

More Related Content

What's hot (14)

Jabber Bot
Jabber BotJabber Bot
Jabber Bot
Aizat Faiz
?
The page and the desktop
The page and the desktopThe page and the desktop
The page and the desktop
Glenn Jones
?
Facebook Social Plugins
Facebook Social PluginsFacebook Social Plugins
Facebook Social Plugins
Aizat Faiz
?
merb.intro
merb.intromerb.intro
merb.intro
pjb3
?
Html5 accessibility
Html5 accessibilityHtml5 accessibility
Html5 accessibility
Virginia DeBolt
?
You and Your Stylesheet
You and Your StylesheetYou and Your Stylesheet
You and Your Stylesheet
Virginia DeBolt
?
Html in a box
Html in a boxHtml in a box
Html in a box
bdubuque
?
Xhtml Part1
Xhtml Part1Xhtml Part1
Xhtml Part1
nleesite
?
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
Aizat Faiz
?
ARTDM 170, Week 16: Publishing
ARTDM 170, Week 16: PublishingARTDM 170, Week 16: Publishing
ARTDM 170, Week 16: Publishing
Gilbert Guerrero
?
CSS Best practices
CSS Best practicesCSS Best practices
CSS Best practices
Jos¨¦ Teixid¨®
?
Vanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums Theme Guide
Vanilla Forums Theme Guide
Vanilla Forums
?
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
tom altman
?
Mobile library on drupal cil2011
Mobile library on drupal   cil2011Mobile library on drupal   cil2011
Mobile library on drupal cil2011
sc20866
?
The page and the desktop
The page and the desktopThe page and the desktop
The page and the desktop
Glenn Jones
?
Facebook Social Plugins
Facebook Social PluginsFacebook Social Plugins
Facebook Social Plugins
Aizat Faiz
?
merb.intro
merb.intromerb.intro
merb.intro
pjb3
?
Html in a box
Html in a boxHtml in a box
Html in a box
bdubuque
?
Beginning WordPress Plugin Development
Beginning WordPress Plugin DevelopmentBeginning WordPress Plugin Development
Beginning WordPress Plugin Development
Aizat Faiz
?
ARTDM 170, Week 16: Publishing
ARTDM 170, Week 16: PublishingARTDM 170, Week 16: Publishing
ARTDM 170, Week 16: Publishing
Gilbert Guerrero
?
Vanilla Forums Theme Guide
Vanilla Forums Theme GuideVanilla Forums Theme Guide
Vanilla Forums Theme Guide
Vanilla Forums
?
Learning Wordpress - the internal guide
Learning Wordpress - the internal guideLearning Wordpress - the internal guide
Learning Wordpress - the internal guide
tom altman
?
Mobile library on drupal cil2011
Mobile library on drupal   cil2011Mobile library on drupal   cil2011
Mobile library on drupal cil2011
sc20866
?

Similar to Lecture 6 - Comm Lab: Web @ ITP (20)

YL Intro html
YL Intro htmlYL Intro html
YL Intro html
dilom1986
?
Intro Html
Intro HtmlIntro Html
Intro Html
Chidanand Byahatti
?
Lecture1 B Frames&Forms
Lecture1 B  Frames&FormsLecture1 B  Frames&Forms
Lecture1 B Frames&Forms
Sur College of Applied Sciences
?
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
reybango
?
Iml 140 web_week_2_html_basics_
Iml 140 web_week_2_html_basics_Iml 140 web_week_2_html_basics_
Iml 140 web_week_2_html_basics_
Evan Hughes
?
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
Nikhil Jain
?
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
phuphax
?
Grails and Dojo
Grails and DojoGrails and Dojo
Grails and Dojo
Sven Haiges
?
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Final
ematrix
?
PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
Ankush Jain
?
Developing Gadgets
Developing GadgetsDeveloping Gadgets
Developing Gadgets
Quirk
?
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
brynary
?
Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITP
yucefmerhi
?
Schenker - DSL for quickly creating web applications in Perl
Schenker - DSL for quickly creating web applications in PerlSchenker - DSL for quickly creating web applications in Perl
Schenker - DSL for quickly creating web applications in Perl
Jiro Nishiguchi
?
Illuminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 TutorialIlluminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 Tutorial
mikel_maron
?
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Alfresco Software
?
DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8DevDays09 Internet Explorer 8
DevDays09 Internet Explorer 8
Konstantinos Pantos
?
HTML5: 5 Quick Wins
HTML5:  5 Quick WinsHTML5:  5 Quick Wins
HTML5: 5 Quick Wins
Jeff Leombruno
?
How To Create Personal Web Pages On My Web
How To Create Personal Web Pages On My WebHow To Create Personal Web Pages On My Web
How To Create Personal Web Pages On My Web
sritikumar
?
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
?
HTML5 Overview
HTML5 OverviewHTML5 Overview
HTML5 Overview
reybango
?
Iml 140 web_week_2_html_basics_
Iml 140 web_week_2_html_basics_Iml 140 web_week_2_html_basics_
Iml 140 web_week_2_html_basics_
Evan Hughes
?
KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7KMUTNB - Internet Programming 3/7
KMUTNB - Internet Programming 3/7
phuphax
?
Flex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 FinalFlex For Flash Developers Ff 2006 Final
Flex For Flash Developers Ff 2006 Final
ematrix
?
Developing Gadgets
Developing GadgetsDeveloping Gadgets
Developing Gadgets
Quirk
?
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
brynary
?
Lecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITPLecture 1 - Comm Lab: Web @ ITP
Lecture 1 - Comm Lab: Web @ ITP
yucefmerhi
?
Schenker - DSL for quickly creating web applications in Perl
Schenker - DSL for quickly creating web applications in PerlSchenker - DSL for quickly creating web applications in Perl
Schenker - DSL for quickly creating web applications in Perl
Jiro Nishiguchi
?
Illuminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 TutorialIlluminated Hacks -- Where 2.0 101 Tutorial
Illuminated Hacks -- Where 2.0 101 Tutorial
mikel_maron
?
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Enterprise Google Gadgets Integrated with Alfresco - Open Source ECM
Alfresco Software
?
How To Create Personal Web Pages On My Web
How To Create Personal Web Pages On My WebHow To Create Personal Web Pages On My Web
How To Create Personal Web Pages On My Web
sritikumar
?
Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)Phing - A PHP Build Tool (An Introduction)
Phing - A PHP Build Tool (An Introduction)
Michiel Rook
?

Recently uploaded (20)

BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
?
Endpoint Backup: 3 Reasons MSPs Ignore It
Endpoint Backup: 3 Reasons MSPs Ignore ItEndpoint Backup: 3 Reasons MSPs Ignore It
Endpoint Backup: 3 Reasons MSPs Ignore It
MSP360
?
The Future of Repair: Transparent and Incremental by Botond De?nes
The Future of Repair: Transparent and Incremental by Botond De?nesThe Future of Repair: Transparent and Incremental by Botond De?nes
The Future of Repair: Transparent and Incremental by Botond De?nes
ScyllaDB
?
Future-Proof Your Career with AI Options
Future-Proof Your  Career with AI OptionsFuture-Proof Your  Career with AI Options
Future-Proof Your Career with AI Options
DianaGray10
?
Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025
kherorpacca00126
?
UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1
DianaGray10
?
Gojek Clone Multi-Service Super App.pptx
Gojek Clone Multi-Service Super App.pptxGojek Clone Multi-Service Super App.pptx
Gojek Clone Multi-Service Super App.pptx
V3cube
?
Technology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptxTechnology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptx
kaylagaze
?
A Framework for Model-Driven Digital Twin Engineering
A Framework for Model-Driven Digital Twin EngineeringA Framework for Model-Driven Digital Twin Engineering
A Framework for Model-Driven Digital Twin Engineering
Daniel Lehner
?
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
Tsuyoshi Hirayama
?
FinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptxFinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptx
Tracxn
?
Computational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the WorldComputational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the World
HusseinMalikMammadli
?
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-StoryRevolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
ssuser52ad5e
?
Backstage Software Templates for Java Developers
Backstage Software Templates for Java DevelopersBackstage Software Templates for Java Developers
Backstage Software Templates for Java Developers
Markus Eisele
?
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarterQ4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
MariaBarbaraPaglinaw
?
Field Device Management Market Report 2030 - TechSci Research
Field Device Management Market Report 2030 - TechSci ResearchField Device Management Market Report 2030 - TechSci Research
Field Device Management Market Report 2030 - TechSci Research
Vipin Mishra
?
DealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures CapitalDealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures Capital
Yevgen Sysoyev
?
Cloud of everything Tech of the 21 century in Aviation
Cloud of everything Tech of the 21 century in AviationCloud of everything Tech of the 21 century in Aviation
Cloud of everything Tech of the 21 century in Aviation
Assem mousa
?
Transform Your Future with Front-End Development Training
Transform Your Future with Front-End Development TrainingTransform Your Future with Front-End Development Training
Transform Your Future with Front-End Development Training
Vtechlabs
?
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog GavraReplacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
ScyllaDB
?
BoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is DynamicBoxLang JVM Language : The Future is Dynamic
BoxLang JVM Language : The Future is Dynamic
Ortus Solutions, Corp
?
Endpoint Backup: 3 Reasons MSPs Ignore It
Endpoint Backup: 3 Reasons MSPs Ignore ItEndpoint Backup: 3 Reasons MSPs Ignore It
Endpoint Backup: 3 Reasons MSPs Ignore It
MSP360
?
The Future of Repair: Transparent and Incremental by Botond De?nes
The Future of Repair: Transparent and Incremental by Botond De?nesThe Future of Repair: Transparent and Incremental by Botond De?nes
The Future of Repair: Transparent and Incremental by Botond De?nes
ScyllaDB
?
Future-Proof Your Career with AI Options
Future-Proof Your  Career with AI OptionsFuture-Proof Your  Career with AI Options
Future-Proof Your Career with AI Options
DianaGray10
?
Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025Brave Browser Crack 1.45.133 Activated 2025
Brave Browser Crack 1.45.133 Activated 2025
kherorpacca00126
?
UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1UiPath Automation Developer Associate Training Series 2025 - Session 1
UiPath Automation Developer Associate Training Series 2025 - Session 1
DianaGray10
?
Gojek Clone Multi-Service Super App.pptx
Gojek Clone Multi-Service Super App.pptxGojek Clone Multi-Service Super App.pptx
Gojek Clone Multi-Service Super App.pptx
V3cube
?
Technology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptxTechnology use over time and its impact on consumers and businesses.pptx
Technology use over time and its impact on consumers and businesses.pptx
kaylagaze
?
A Framework for Model-Driven Digital Twin Engineering
A Framework for Model-Driven Digital Twin EngineeringA Framework for Model-Driven Digital Twin Engineering
A Framework for Model-Driven Digital Twin Engineering
Daniel Lehner
?
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
DAO UTokyo 2025 DLT mass adoption case studies IBM Tsuyoshi Hirayama (ƽɽÒã)
Tsuyoshi Hirayama
?
FinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptxFinTech - US Annual Funding Report - 2024.pptx
FinTech - US Annual Funding Report - 2024.pptx
Tracxn
?
Computational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the WorldComputational Photography: How Technology is Changing Way We Capture the World
Computational Photography: How Technology is Changing Way We Capture the World
HusseinMalikMammadli
?
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-StoryRevolutionizing-Government-Communication-The-OSWAN-Success-Story
Revolutionizing-Government-Communication-The-OSWAN-Success-Story
ssuser52ad5e
?
Backstage Software Templates for Java Developers
Backstage Software Templates for Java DevelopersBackstage Software Templates for Java Developers
Backstage Software Templates for Java Developers
Markus Eisele
?
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarterQ4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
Q4_TLE-7-Lesson-6-Week-6.pptx 4th quarter
MariaBarbaraPaglinaw
?
Field Device Management Market Report 2030 - TechSci Research
Field Device Management Market Report 2030 - TechSci ResearchField Device Management Market Report 2030 - TechSci Research
Field Device Management Market Report 2030 - TechSci Research
Vipin Mishra
?
DealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures CapitalDealBook of Ukraine: 2025 edition | AVentures Capital
DealBook of Ukraine: 2025 edition | AVentures Capital
Yevgen Sysoyev
?
Cloud of everything Tech of the 21 century in Aviation
Cloud of everything Tech of the 21 century in AviationCloud of everything Tech of the 21 century in Aviation
Cloud of everything Tech of the 21 century in Aviation
Assem mousa
?
Transform Your Future with Front-End Development Training
Transform Your Future with Front-End Development TrainingTransform Your Future with Front-End Development Training
Transform Your Future with Front-End Development Training
Vtechlabs
?
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog GavraReplacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
Replacing RocksDB with ScyllaDB in Kafka Streams by Almog Gavra
ScyllaDB
?

Lecture 6 - Comm Lab: Web @ ITP

  • 1. Communications Lab :: Web Lecture 6: More advanced examples
  • 2. Announcements JavaScript assignment #5 due today. Office hours by appointment?only?this week.
  • 3. Final Projects Final Project Ideas - User Experience Presentations
  • 4. Sending an Email from Sinatra require 'pony' post '/contact' do ? Pony.mail :to => 'you@example.com', ? ? ? ? ? ? :from => 'me@example.com', ? ? ? ? ? ? :subject => 'Hello email!' end
  • 5. Sending an Email from Sinatra require 'pony' post '/send_email' do? ? ? Pony.mail ( ? ? ? :from => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;</slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; + params[:email] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ? :to => 'my_email@gmail.com', ? ? ? :subject => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; has sent you an email/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ? :body => params[:message], ? ? ? ......) ? ? redirect '/success'? end
  • 6. Sending an Email from Sinatra require 'pony' post '/send_email' do? ? ? Pony.mail( ? ? ? :from => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;</slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; + params[:email] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ? :to => 'my_email@gmail.com', ? ? ? :subject => params[:name] + /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; has sent you an email/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, ? ? ? :body => params[:message], ? ? ? :port => '587', ? ? ? :via => :smtp, ? ? ? :via_options => {? ? ? ? ? :address ? ? ? ? ? ? ?=> 'smtp.gmail.com',? ? ? ? ? :port ? ? ? ? ? ? ? ? => '587',? ? ? ? ? :enable_starttls_auto => true,? ? ? ? ? :user_name ? ? ? ? ? ?=> 'my_email',? ? ? ? ? :password ? ? ? ? ? ? => 'p@55w0rd',? ? ? ? ? :authentication ? ? ? => :plain,? ? ? ? ? :domain ? ? ? ? ? ? ? => 'example.com' ? ? ? }) ? ? redirect '/success'? end
  • 7. Email Resources http://www.sinatrarb.com/faq.html#email http://ididitmyway.heroku.com/past/2010/12/4/ an_email_contact_form_in_sinatra/ https://github.com/adamwiggins/pony
  • 8. Embedding a Video in HTML 1. Go to youtube.com 2. Click on /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;Share/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; 3. Click on /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;embed/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; 4. Copy the HTML and paste it in your HTML file
  • 9. Embedding Fonts Sometimes you may want to use a font that's not web safe If you use a font face the user doesn't have on their computer, the browser will find the closest installed font and use it instead The solution? Embedded fonts! ?Downsides: Use sparingly, since fonts take a long time to download . This will significantly slow down your web pages. Different browsers accept different types of fonts.
  • 10. Embedding Fonts First, download a font. A good source:?http://www.dafont.com/ ? ? <style type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;text/css/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ? @font-face { ? ? ? ? font-family: deadends ; ? ? ? ? src: url(/slideshow/lecture-6-comm-lab-web-itp/9864023/&); ? ? ? } ? ? ? .deadend-font { ? ? ? ? font-family: deadends ; ? ? ? ? font-size: 3.2em; ? ? ? } ? ? </style> ? ? <body>? ?? ??? ? <h2 class=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;deadend-font/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Today's News</h2>? ?? ? </body>
  • 11. Embedding Fonts An alternative is to use typekit , compatible with all browsers https://typekit.com/ Hundreds of free web-safe fonts on Google web fonts : http://www.google.com/webfonts
  • 12. Creating a Navigation Menu Navigation menus can actually be lists: < ul id=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;nav/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; class=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;menu/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ?? ? < li ><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;index.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Home</a></ li > ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;syllabus.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Syllabus</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;schedule.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Schedule</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;resources.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Resources</a></li> ?? ? <li><a href=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;contact.html/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;>Contact</a></li> </ ul >
  • 13. Creating a Navigation Menu Adding CSS: ? ? ? ul.menu, ul.menu li, ul.menu ul { ? ? ? ? list-style: none; ? ? ? } ? ? ? ul.menu li { ? ? ? ? padding: 7px 10px; ? ? ? ? border-style: solid; ? ? ? ? border-width: 1px 1px 1px 0; ? ? ? ? border-color: #fff #d9d9d9 #d9d9d9; ? ? ? ? background-color: #f6f6f6; ? ? ? ? float: left; ? ? ? }
  • 14. Creating a Navigation Menu Some more ideas: http://www.hongkiat.com/blog/drop-down-menu-30-free-scripts-to-enhance-header-navigation/
  • 15. A Simple Image Gallery Download Galleria:?http://galleria.aino.se/download/ Unzip Galleria in your directory. In your html file, include the following two JavaScript files: ? ? <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.js /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;></script> ? ? <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; galleria/galleria-1.2.5.min.js /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;></script>
  • 16. A Simple Image Gallery 4. Define a div with a /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; id (required) and list all the images you want inside of it. ? ? <div id=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ? <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo1.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ? <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo2.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? ? <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;photo3.jpg/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;> ? ? </div>
  • 17. A Simple Image Gallery 5. At the end of your file, right before the body tag, add the following piece of JavaScript to define the width, height and theme of your gallery. ? ? ? <script>? ?? ? ? ? ? Galleria.loadTheme('galleria/themes/classic/ galleria.classic.min.js'); ? ? ? ? $(/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;#gallery/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;).galleria({ ? ? ? ? ? ? width: 900, ? ? ? ? ? ? height: 700 ? ? ? ? }); ? ? </script>
  • 18. Uploading Files with Sinatra get '/' do ? form = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ? form += '<form action=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;http://itp.nyu.edu/~irs221/sinatra/upload /upload_file /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; method=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; POST /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; enctype=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;multipart/form-data/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; >' ? form += '<p><label>File:</label> <input type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;file/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; name=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;file/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; /></p>' ? form += '<p><input type=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;submit/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; value=/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;Upload/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; /></p>' ? form += '</form>' ? form end
  • 19. Uploading Files with Sinatra require 'dm-core' DataMapper::setup(:default, {:adapter => 'yaml', :path => 'db'}) class Image ? include DataMapper::Resource ? property :id, ? ? ? ? ? ? ? ? Serial ? property :filename, ? ? ? ? ? String end
  • 20. Uploading Files with Sinatra post ' /upload_file ' do ? tmpfile = params[:file][:tempfile] ? name = params[:file][:filename] ? while blk = tmpfile.read(65536) ? ? ? File.open(File.join(Dir.pwd,/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;public/uploads/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;, name), /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;ab/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;) { |f| f.write(blk) } ? end ? image = Image.new ? image.filename = params[:file][:filename]; ? image.save ? /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;success <img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& end Don't forget to create the directory /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;uploads/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; in public first!
  • 21. Uploading Files with Sinatra get '/images' do ? output = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; <!DOCTYPE html> ? <html> ? ? <head> ? ? ? ? ? <meta charset=utf-8 /> ? ? ? ? ? <title>Images</title> ? ? </head> ? ? <body> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ? for i in Image.all ? ? output += <<-HTML <p>#{i.filename}<img src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& HTML ? end ? output += /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; </body></html> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ? output end
  • 22. Adding Image Gallery in Sinatra get '/images' do ? output = /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot;<!DOCTYPE html> ? <html><head> ? ? ? <meta charset=utf-8 /><title>Images</title> ?? ?? <script src=/slideshow/lecture-6-comm-lab-web-itp/9864023/& ? ? ? <script src='/~irs221/sinatra/upload/public/galleria/galleria-1.2.5.min.js'></script> ? ? </head><body> <div id='gallery'> /slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ? for i in Image.all ? ? output += <<-HTML <img src='http://itp.nyu.edu/~irs221/sinatra/upload/public/uploads/#{i.filename}'/> HTML ? end ??
  • 23. Adding Image Gallery in Sinatra output +=?/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; </div><script> ? ? ? ? Galleria.loadTheme('/~irs221/sinatra/upload/public/galleria/themes/classic/galleria.classic.min.js'); ? ? ? ? $('#gallery').galleria({ ? ? ? ? ? ? width: 700, ? ? ? ? ? ? height: 500 ? ? ? ? }); ? ? </script> </body></html>/slideshow/lecture-6-comm-lab-web-itp/9864023/&quot; ? output end ??
  • 24. Sinatra Resources Sinatra Google Group:?https://groups.google.com/group/sinatrarb?pli=1 DataMapper Google Group:?http://groups.google.com/group/datamapper Reference for Sinatra Syntax and Examples:?http://rubydoc.info/gems/sinatra/1.3.1/file/ README.rdoc
  • 25. Next time... Final Project Presentations!