Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support the use of a URL root path #609

Merged
merged 2 commits into from
Oct 11, 2015
Merged

Conversation

geeklain
Copy link
Contributor

It adds support to run ungit under a specific URL root path like http://host:port/root/path .
This fixes #313

On the server side, the basic idea is to add a top level middleware in express that rewrites URLs to remove the root path and then moves forward to other middlewares (that do not need any change).
The socket io version had to be bumped up to better support the root path starting with a slash (http://socket.io/docs/migrating-from-0-9/#configuration-differences)

On the client side, there was quite a few changes to support the concept of a root path.

All the tests are succeeding.

@@ -11,6 +11,10 @@ var defaultConfig = {

// The base URL ungit will be accessible from.
urlBase: "http://localhost",

// The URL root path under which ungit will be accesible.
// Either blank or starting with a slash and no trailing slash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this constraint enforced anywhere in the code? Seems like a user could easily violate this constraint without realizing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked for other config params and there does not seem to be any validation for those.
Is there a good place to validate the config?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we can use url.resolve()? Not sure if we need additional validation though...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm just saying that, from a UX perspective, it would be nice if ungit automatically appended a slash to the start of the config variable if needed, and removed any trailing slash. Just one less thing for the user to worry about.

Alternately, if taking care of this constraint automatically would take too much development effort, that requirement for the formatting of that setting should definitely be documented somewhere other than just a comment in the source code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into adding a validation for the complete url: urlBase+port+rootPath

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if I have explained correctly, if we do something like url.resolve(urlBase + ':' + port, rootPath) at the later part of this file, we don't need validation for checking prefix, postfix slashes within rootPath or port as it is handled via url package.

What I mean by additional validation is the character encoding and non alphabet characters and such....

@FredrikNoren
Copy link
Owner

@codingtwinky yeah exactly, and that's awesome that if it works now! We should remove the holdback code in the gruntfile

@geeklain this is looking awesome. only thing I'm missing is a clicktest for this as well (see how for instance the authentication test works), so that this doesn't break in the future

@geeklain
Copy link
Contributor Author

geeklain commented Sep 3, 2015

@FredrikNoren OK I'll look closer at the clicktest

@geeklain
Copy link
Contributor Author

geeklain commented Sep 4, 2015

@FredrikNoren I modified the generic clicktest to test different rootPaths.

I also added a rootPath clean up routine in config.js to cleanup leading and trainling slashes. I think that would help the users.

@geeklain geeklain force-pushed the master branch 2 times, most recently from b857107 to c88ec00 Compare September 4, 2015 02:26
@FredrikNoren
Copy link
Owner

@geeklain Ok awesome, looks ready to merge. Can you update the PR to solve merge conflicts and I'll merge it?

@geeklain
Copy link
Contributor Author

geeklain commented Oct 8, 2015

@FredrikNoren All clear - rebased and tests passed - ready to merge

@geeklain geeklain force-pushed the master branch 4 times, most recently from 919649f to 870afcf Compare October 10, 2015 17:14
@geeklain
Copy link
Contributor Author

oh man! Tests keep failing because at least one of them encounters a weird error... Transient errors. It's driving me nuts

@jung-kim
Copy link
Collaborator

Right, I have been having some issues with it as well. I have fixed some of them in #626 but as with any intermittent issues, it is hard to verify.

@geeklain
Copy link
Contributor Author

Hurray! Tests passed without a hiccup after re-rebasing.
@codingtwinky @FredrikNoren ready to merge.

jung-kim added a commit that referenced this pull request Oct 11, 2015
Support the use of a URL root path
@jung-kim jung-kim merged commit c36b9e7 into FredrikNoren:master Oct 11, 2015
@FredrikNoren
Copy link
Owner

@geeklain Nice!

@sebastianmay
Copy link

We're going to use ungit on a shared environment, so we set up ungit for a few users, each with an own instance, through a reverse proxy. Everythings seems to work fine, except the favorite repositories on the home screen. I'm not quite sure, if we have set it up wrong or made some bad configurations, but we've a small fix in the home.js, which helps with this problem.
The list of favorite repositories, doesn't care about the rootPath configuration.
So we edited line 15 in components/home/home.js from
this.link = '/#/repository?path=' + encodeURIComponent(path);
to this.link = ungit.config.rootPath + '/#/repository?path=' + encodeURIComponent(path);
So far it is working nice and we can use the favorites over the reverse proxy.
Can anyone confirm this behaviour or give us a hint, what we set up wrong?
Or is this the right solution?
Thanks a lot for your help.

@Ajedi32
Copy link
Contributor

Ajedi32 commented May 11, 2016

@sebastianmay You might want to file a new issue or submit a pull request for that. It'd be easy for a comment like that in an already-merged PR to simply go unnoticed.

@jung-kim
Copy link
Collaborator

@sebastianmay Yes, I do believe this is a valid issue and your fix is needed. If you would like, please do send us a pull request if you don't mind. Thanks!

@sebastianmay
Copy link

Somehow, I'm not able create a pull request from my fork.
The only change necessary is in the file components/home/home.js line 15:
add "ungit.config.rootPath + " befor the '/#/repository'
This worked for us.

@Ajedi32
Copy link
Contributor

Ajedi32 commented May 13, 2016

Huh. Yeah, that's weird. I was going to just send the PR for you since you've already got the commit in your fork, but GitHub's throwing a 500 error right now: FredrikNoren:master...sebastianmay:patch-1

The relevant commit is here: sebastianmay@2962d72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow hosting under a path
6 participants