tbranyen / github-viewer

GitHub Viewer.
MIT License
366 stars 59 forks source link

Relative path setup #19

Closed pinksy closed 11 years ago

pinksy commented 11 years ago

I've installed github-viewer to a sub-directory on my Apache server (i.e., not through the provided node server) at http://www.pinksy.co.uk/backbone/github-viewer/. It works, but the URL contains repeated sub-paths when the buttons are clicked.

I followed the notes at https://github.com/tbranyen/backbone-boilerplate/wiki/Relative-path-setup-notes to tweak it for relative paths, with the following changes:

i. Change index.html to use relative paths instead of absolute paths:

<link rel="stylesheet" href="app/styles/index.css">

...and ...

<script data-main="app/config" src="vendor/js/libs/require.js"></script>

ii. Change the routes.

from:

routes: {
  "": "index",
  "org/:name": "org",
  "org/:org/user/:name": "user",
  "org/:org/user/:user/repo/:name": "repo"
},

to:

routes: {
  "backbone/github-viewer/": "index",
  "backbone/github-viewer/org/:name": "org",
  "backbone/github-viewer/org/:org/user/:name": "user",
  "backbone/github-viewer/org/:org/user/:user/repo/:name": "repo"
},

iii. Change the root property in the Backbone.history.start call in main.js.

from: 

Backbone.history.start({ pushState: true, root: app.root });

to:

Backbone.history.start({ pushState: true, root: "backbone/github-viewer/" });

iv. Change the path for the $.get call in the fetch function of Backbone.LayoutManager.configure in app.js.

from:

$.get(app.root + path, function(contents) {

to:

$.get(location.protocol + "//" + location.host+ '/' + app.root + path, function(contents) {

I also seemed to need to make the following additional changes:

v. Convert app.styl to app.css using the stylus tool, and change the @import in index.css accordingly

vi. Change the prefix field of Backbone.LayoutManager.configure in app.js.

from:

prefix: "app/templates/",

to:

prefix: "backbone/github-viewer/app/templates/",

vii. Change the router calls in repo.js and user.js.

from:

app.router.go("org"...

to:

app.router.go("backbone/github-viewer/org"....

viii. Change the img src in repo.js and user.js.

from:

src='/app/img...

to:

src='/backbone/github-viewer/app/img

I did note issue 1, which suggests that only the root property in the Backbone.history.start call in main.js needs to change, and the routes don't need to change, but that didn't seem to work.

So the page renders fine, but when you click on the search button for example, the URL changes to:

http://www.pinksy.co.uk/backbone/github-viewer/backbone/github-viewer/org/matchbox

instead of the expected:

http://www.pinksy.co.uk/backbone/github-viewer/org/matchbox

Have I done something wrong? I've copied it up uncompiled, so you're welcome to dig down into the scripts and have a look at my changes!

Thanks

tbranyen commented 11 years ago

Did you see? https://github.com/tbranyen/backbone-boilerplate/wiki/Apache

tbranyen commented 11 years ago

Also check out the new targeted build stuff I wrote in. That might help a lot.

pinksy commented 11 years ago

Ok, thanks Tim. I haven't had chance to try out the Apache config suggestions (been busy with some amqp stuff), but will give it a go. Oh, and happy Christmas!