Permalink
Browse files

Merge pull request #10 from shoes/download

Add downloads page
  • Loading branch information...
steveklabnik committed Feb 4, 2013
2 parents 40e2c76 + 7ae40db commit e151380f242ab5d511523acc1d52a42691828ace
Showing with 63 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +2 −0 config.ru
  3. +33 −0 resources/download_resource.rb
  4. +5 −0 resources/downloads_page.rb
  5. +19 −0 views/downloads.html.haml
  6. +2 −0 views/layout.html.haml
View
@@ -1,3 +1,5 @@
# IDEs
/.idea
+.rvmrc
+
View
@@ -15,6 +15,8 @@ Shoes = Webmachine::Application.new do |app|
add ["blog"], BlogResource
add ["blog", :slug], BlogResource
add ["contribute"], ContributePage
+ add ["downloads"], DownloadsPage
+ add ["downloads", :filename], DownloadResource
add ['*'], StaticResource, :root => "public"
end
app.configure do |config|
@@ -0,0 +1,33 @@
+# Manager for downloads hosted elsewhere. Handles redirects from shoesrb.com
+# URLs to the URLs where resources actually live.
+#
+# Request downloads by filename like this:
+#
+# GET /downloads/filename.zip HTTP/1.1
+#
+# Manage redirects to actual resources by adding to the DOWNLOADS hash:
+#
+# "filename.zip" => "http://url/for/actual/filename.zip"
+#
+class DownloadResource < Webmachine::Resource
+ DOWNLOADS = {
+ "shoes-app-template-0.0.1.zip" => "https://s3.amazonaws.com/net.wasnotrice.shoes/wrappers/shoes-app-template-0.0.1.zip"
+ }
+
+ # shows up in the URL like so: http://shoesrb.com/downloads/:filename
+ def filename
+ @request.path_info[:filename]
+ end
+
+ def resource_exists?
+ false
+ end
+
+ def previously_existed?
+ DOWNLOADS.has_key?(filename)
+ end
+
+ def moved_permanently?
+ previously_existed? && DOWNLOADS[filename]
+ end
+end
@@ -0,0 +1,5 @@
+class DownloadsPage < Webmachine::Resource
+ def to_html
+ Template.new(:downloads).render
+ end
+end
View
@@ -0,0 +1,19 @@
+.hero-unit
+ .downloads
+ %h1 Downloads
+ %p Get your Shoes and Shoes Accessories Here.
+
+.row
+ .span5
+ %h2 Shoes
+ #shoes
+
+ .span5
+ %h2 Shoes Accessories
+ #accessories
+
+ %h3 App Wrappers
+ %ul
+ %li
+ %a{:href => "/downloads/shoes-app-template-0.0.1.zip"} OS X .app wrapper
+
View
@@ -35,6 +35,8 @@
%ul.nav
%li.active
%a{:href => "/"} Home
+ %li
+ %a{:href => "/downloads"} Downloads
%li
%a{:href => "/tutorials"} Tutorials
%li

0 comments on commit e151380

Please sign in to comment.