diff --git a/website/www/Gemfile.lock b/website/www/Gemfile.lock index 112d0d72d..946a40701 100644 --- a/website/www/Gemfile.lock +++ b/website/www/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - activesupport (3.2.21) + activesupport (3.2.22) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) builder (3.2.2) @@ -9,7 +9,7 @@ GEM coffee-script (2.2.0) coffee-script-source execjs - coffee-script-source (1.9.1) + coffee-script-source (1.9.1.1) commonjs (0.2.7) compass (1.0.3) chunky_png (~> 1.2) @@ -23,20 +23,20 @@ GEM sass (>= 3.3.0, < 3.5) compass-import-once (1.0.5) sass (>= 3.2, < 3.5) - daemons (1.1.9) - eventmachine (1.0.7) + daemons (1.2.3) + eventmachine (1.0.8) execjs (1.4.1) multi_json (~> 1.0) - ffi (1.9.6) - haml (4.0.6) + ffi (1.9.10) + haml (4.0.7) tilt highline (1.6.21) hike (1.2.3) i18n (0.6.11) - kramdown (1.5.0) + kramdown (1.9.0) less (2.2.2) commonjs (~> 0.2.6) - libv8 (3.16.14.7) + libv8 (3.16.14.13) listen (1.3.1) rb-fsevent (>= 0.9.3) rb-inotify (>= 0.9) @@ -75,25 +75,25 @@ GEM sprockets-helpers (~> 1.0.0) sprockets-sass (~> 1.0.0) mini_portile (0.6.2) - multi_json (1.10.1) + multi_json (1.11.2) nokogiri (1.6.6.2) mini_portile (~> 0.6.0) - rack (1.6.0) + rack (1.6.4) rack-contrib (1.1.0) rack (>= 0.9.1) rack-protection (1.5.3) rack rack-test (0.6.3) rack (>= 1.0) - rb-fsevent (0.9.4) + rb-fsevent (0.9.6) rb-inotify (0.9.5) ffi (>= 0.5.0) - rb-kqueue (0.2.3) + rb-kqueue (0.2.4) ffi (>= 0.5.0) redcarpet (3.0.0) - ref (1.0.5) - sass (3.4.13) - sprockets (2.12.3) + ref (2.0.0) + sass (3.4.19) + sprockets (2.12.4) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) @@ -103,7 +103,7 @@ GEM sprockets-sass (1.0.3) sprockets (~> 2.0) tilt (~> 1.1) - therubyracer (0.12.1) + therubyracer (0.12.2) libv8 (~> 3.16.14.0) ref thin (1.5.1) @@ -112,7 +112,7 @@ GEM rack (>= 1.0.0) thor (0.19.1) tilt (1.3.7) - tzinfo (0.3.43) + tzinfo (0.3.45) uglifier (2.1.2) execjs (>= 0.3.0) multi_json (~> 1.0, >= 1.0.2) diff --git a/website/www/config.rb b/website/www/config.rb index d30b7bd51..a5b2fa61a 100644 --- a/website/www/config.rb +++ b/website/www/config.rb @@ -1,13 +1,10 @@ -require File.expand_path("../helpers/download_helpers", __FILE__) +require_relative "helpers/middleman_hashicorp_shim" +helpers MiddlemanHashiCorpHelpers page "/blog_feed.xml", layout: false -ignore "/download-archive-single.html" -# Archived download pages -$vagrant_versions.each do |version| - proxy "/download-archive/v#{version}.html", "/download-archive-single.html", - locals: { version: version }, ignore: true -end +# The version of Vagrant - update this to update the downloads page +set :latest_version, '1.7.4' set :css_dir, 'stylesheets' set :js_dir, 'javascripts' diff --git a/website/www/config.ru b/website/www/config.ru index 2cef78935..49f749c15 100644 --- a/website/www/config.ru +++ b/website/www/config.ru @@ -6,6 +6,7 @@ require "rack/contrib/try_static" require "rack/protection" require File.expand_path("../lib/legacy_redirect", __FILE__) +require File.expand_path("../lib/redirect_to_releases", __FILE__) # Protect against various bad things use Rack::Protection::JsonCsrf @@ -23,6 +24,9 @@ use Rack::Deflater # Redirect the legacy URLs that point to www.vagrantup.com use HashiCorp::Rack::LegacyRedirect +# Redirect the archive page to releases +use HashiCorp::Rack::RedirectToReleases + # Set the "forever expire" cache headers for these static assets. Since # we hash the contents of the assets to determine filenames, this is safe # to do. diff --git a/website/www/helpers/download_helpers.rb b/website/www/helpers/download_helpers.rb deleted file mode 100644 index 9244d9af4..000000000 --- a/website/www/helpers/download_helpers.rb +++ /dev/null @@ -1,85 +0,0 @@ -require "json" -require "net/http" -require "net/https" - -$vagrant_files = {} -$vagrant_os = [] - -$vagrant_os_mappings = { - ".deb" => "debian", - ".dmg" => "darwin", - ".msi" => "windows", - ".rpm" => "rpm", -} - -$vagrant_os_order = ["darwin", "windows", "debian", "rpm"] -$vagrant_downloads = {} -$vagrant_versions = [] - -if ENV["VAGRANT_VERSION"] - puts "Finding downloads for Vagrant" - raise "BINTRAY_API_KEY must be set." if !ENV["BINTRAY_API_KEY"] - http = Net::HTTP.new("bintray.com", 443) - http.use_ssl = true - req = Net::HTTP::Get.new("/api/v1/packages/mitchellh/vagrant/vagrant/files") - req.basic_auth "mitchellh", ENV["BINTRAY_API_KEY"] - response = http.request(req) - data = JSON.parse(response.body) - - data.each do |file| - filename = file["name"] - - # Ignore any files that don't appear to have a version in it - next if filename !~ /[-_]?(\d+\.\d+\.\d+[^-_.]*)/ - version = Gem::Version.new($1.to_s) - $vagrant_downloads[version] ||= {} - - $vagrant_os_mappings.each do |suffix, os| - if filename.end_with?(suffix) - $vagrant_downloads[version][os] ||= [] - $vagrant_downloads[version][os] << filename - end - end - end - - $vagrant_versions = $vagrant_downloads.keys.sort.reverse - $vagrant_versions.each do |v| - puts "- Version #{v} found" - end -else - puts "Not generating downloads." -end - -module DownloadHelpers - def download_arch(file) - if file.include?("i686") - return "32-bit" - elsif file.include?("x86_64") - return "64-bit" - else - return "Universal (32 and 64-bit)" - end - end - - def download_os_human(os) - if os == "darwin" - return "Mac OS X" - elsif os == "debian" - return "Linux (Deb)" - elsif os == "rpm" - return "Linux (RPM)" - elsif os == "windows" - return "Windows" - else - return os - end - end - - def download_url(file) - "https://dl.bintray.com/mitchellh/vagrant/#{file}" - end - - def latest_version - $vagrant_versions.first - end -end diff --git a/website/www/helpers/middleman_hashicorp_shim.rb b/website/www/helpers/middleman_hashicorp_shim.rb new file mode 100644 index 000000000..9ac10b4d0 --- /dev/null +++ b/website/www/helpers/middleman_hashicorp_shim.rb @@ -0,0 +1,103 @@ +# This file is a shim that mirrors the behavior or middleman-hashicorp without +# fully importing it. Vagrant is somewhat of a beast and cannot be easily +# updated due to older versions of bootstrap and javascript and whatnot. + +require "open-uri" + +class MiddlemanHashiCorpReleases + RELEASES_URL = "https://releases.hashicorp.com".freeze + + class Build < Struct.new(:name, :version, :os, :arch, :url); end + + def self.fetch(product, version) + url = "#{RELEASES_URL}/#{product}/#{version}/index.json" + r = JSON.parse(open(url).string, + create_additions: false, + symbolize_names: true, + ) + + # Convert the builds into the following format: + # + # { + # "os" => { + # "arch" => "https://download.url" + # } + # } + # + {}.tap do |h| + r[:builds].each do |b| + build = Build.new(*b.values_at(*Build.members)) + + h[build.os] ||= {} + h[build.os][build.arch] = build.url + end + end + end +end + +module MiddlemanHashiCorpHelpers + # + # Output an image that corresponds to the given operating system using the + # vendored image icons. + # + # @return [String] (html) + # + def system_icon(name) + image_tag("icons/icon_#{name.to_s.downcase}.png") + end + + # + # The formatted operating system name. + # + # @return [String] + # + def pretty_os(os) + case os + when /darwin/ + "Mac OS X" + when /freebsd/ + "FreeBSD" + when /openbsd/ + "OpenBSD" + when /linux/ + "Linux" + when /windows/ + "Windows" + else + os.capitalize + end + end + + # + # The formatted architecture name. + # + # @return [String] + # + def pretty_arch(arch) + case arch + when /all/ + "Universal (32 and 64-bit)" + when /686/, /386/ + "32-bit" + when /86_64/, /amd64/ + "64-bit" + else + parts = arch.split("_") + + if parts.empty? + raise "Could not determine pretty arch `#{arch}'!" + end + + parts.last.capitalize + end + end + + # + # Query the Bintray API to get the real product download versions. + # + # @return [Hash] + # + def product_versions + MiddlemanHashiCorpReleases.fetch("vagrant", latest_version) + end +end diff --git a/website/www/lib/redirect_to_releases.rb b/website/www/lib/redirect_to_releases.rb new file mode 100644 index 000000000..655c58d2e --- /dev/null +++ b/website/www/lib/redirect_to_releases.rb @@ -0,0 +1,37 @@ +module HashiCorp + module Rack + # This redirects to releases.hashicorp.com when a user tries to download + # an old version of Vagrant. + class RedirectToReleases + def initialize(app) + @app = app + end + + def call(env) + if env["PATH_INFO"] =~ /^\/downloads-archive/ + headers = { + "Content-Type" => "text/html", + "Location" => "https://releases.hashicorp.com/vagrant", + } + + message = "Redirecting to releases archive..." + + return [301, headers, [message]] + end + + if env["PATH_INFO"] =~ /^\/download-archive\/v(.+)\.html/ + headers = { + "Content-Type" => "text/html", + "Location" => "https://releases.hashicorp.com/vagrant/#{$1}", + } + + message = "Redirecting to releases archive..." + + return [301, headers, [message]] + end + + @app.call(env) + end + end + end +end diff --git a/website/www/source/_sidebar_downloads.erb b/website/www/source/_sidebar_downloads.erb index faf7b8f3b..939cd078a 100644 --- a/website/www/source/_sidebar_downloads.erb +++ b/website/www/source/_sidebar_downloads.erb @@ -1,4 +1,4 @@
-You can find the SHA256 checksums for this version of Vagrant -here. -
--This webpage lists the older versions of Vagrant that are available for -download. Some even older versions are available from the -legacy downloads page. -
- --The latest version of Vagrant can be found on the -main downloads page. -
- -<% if $vagrant_versions.length > 1 %> --No old Vagrant versions could be found. -
-<% end %> diff --git a/website/www/source/downloads.html.erb b/website/www/source/downloads.html.erb index 252b325a2..55b10484e 100644 --- a/website/www/source/downloads.html.erb +++ b/website/www/source/downloads.html.erb @@ -9,41 +9,47 @@ page_title: "Download Vagrant"-Below are all available downloads for the latest version of Vagrant -(<%= latest_version %>). Please download the proper package for your -operating system and architecture. You can find SHA256 checksums -for packages here, -and you can find the version changelog here. -
-+ Below are the available downloads for the latest version of Vagrant + (<%= latest_version %>). Please download the proper package for your + operating system and architecture. +
++ You can find the + + SHA256 checksums for Vagrant <%= latest_version %> + + online and you can + + verify the checksums signature file + + which has been signed using HashiCorp's GPG key. + You can also download older versions of Vagrant from the releases service. +
+