shoesrb.com icon indicating copy to clipboard operation
shoesrb.com copied to clipboard

No dynamically redirecting URLs anymore for downloads

Open PragTob opened this issue 11 years ago • 10 comments

Hi everyone,

since the move to github pages we don't have dynamically redirecting URLs anymore.

The question is: can we fix that somehow?

Shoes on! Tobi

PragTob avatar May 24 '13 19:05 PragTob

Jekyll doesn't have support for this, I don't think.

steveklabnik avatar May 24 '13 20:05 steveklabnik

What about using JS routing like in Backbone.js? Davis.js?

jamesaanderson avatar May 24 '13 22:05 jamesaanderson

That doesn't help.

We need shoesrb.com/download/mac to redirect to s3. JS can't do that, that I know of.

steveklabnik avatar May 24 '13 22:05 steveklabnik

I haven't used Davis.js but by looking at their example wouldn't the following work?

var app = Davis(function () {
  this.get('/download/:os', function (req) {
    if (req.params['os'] == 'mac') {
      window.location.replace(...)
    }
    else {
      ...
    }
  })
})

app.start()

jamesaanderson avatar May 24 '13 22:05 jamesaanderson

I haven't used Davis.js before but looking at their example wouldn't the following work?

var app = Davis(function () { this.get('/download/mac', function (req) { window.location.replace(...) }) })

app.start()

It would work for clients that evaluate javascript, I think. Has anyone used this technique before? (meta tag with refresh of 0)

http://www.w3.org/TR/WCAG20-TECHS/H76.html

Seems what we want, though I don't know if all clients would follow it.

wasnotrice avatar May 25 '13 00:05 wasnotrice

See http://en.wikipedia.org/wiki/Meta_refresh#Usability. It does seem like the best option though.

jamesaanderson avatar May 25 '13 01:05 jamesaanderson

if we do it/try it we would still have to make that it works without JavaScript. I'm a noscript user and I want the basic functionality of shoesrb.com to be available without JS :-)

PragTob avatar May 25 '13 07:05 PragTob

Uses for these download URLs:

  • folks browsing the shoes site for a shoes download
  • other sites wanting to promote shoes, by linking to downloads
  • shoes itself, so that it can download and/or update itself

This last one has always been the trickiest one. In Shoes 3, there is an option to package a Shoes app without Shoes. It comes with a small stub that only knows how to download and install the latest version of Shoes. It does not know how to navigate links or javascript. Actually, if I remember correctly, the stub hits a particular URL, which returns a text/plain string. That string is the URL for the download. I don't know if Shoes 4 will have this same kind of stub installer, but it seems prudent to think about this use case. We want to have a stable URL that can (somehow) direct clients to the real current URL.

wasnotrice avatar May 25 '13 13:05 wasnotrice

Idea! GitHub has a releases API. So we could implement it several ways. None of which, unfortunately, will work outside of the browser.

The Meta Refresh/JavaScript Way

<!DOCTYPE html>
<html>
  <head>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script>
    $.getJSON('https://api.github.com/repos/shoes/shoes/releases', function(data) {
      release = data[0].tarball_url;
      $('head').append('<META http-equiv="refresh" content="0;URL=' + release + '">');
    });
    </script>
    <title>Latest Shoes Release</title>
  </head>
  <body>

  </body>
</html>

This will have jQuery append a meta refresh/redirect to the head, which will in turn download the tarball.

The JavaScript Only Way Just pretend this is in the head of the same document.

$.getJSON('https://api.github.com/repos/shoes/shoes/releases', function(data) {
  release = data[0].tarball_url;
  window.location.href = release;
});

Let me know what you think.

JesseHerrick avatar Aug 18 '14 01:08 JesseHerrick

As for OS specific downloads, it really depends on how Shoes releases will released. But I'm sure I can make it work.

JesseHerrick avatar Aug 18 '14 01:08 JesseHerrick