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

Add support for hosting at sub URL. #67

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

GrahamDumpleton
Copy link

This includes changes to adjust how URLs are generated when performing redirects so that the URLs generated are correct when the application is hosted at a URL.

For URL generation, the change is to swap from hard coded absolute URL paths, to calculating the URL path from the controller/action specified for the route, which is the recommended practice anyway. This is needed in the redirects in the controllers, but also where generating the URL path for embedding images.

To allow hosting at a sub URL a Rack middleware is also required to fix up the Rack request environment so that the Rails application is able to work when it is mounted at a sub URL. This is needed specifically because Rack is used to wrap Rails and is in addition to setting various Rails environment variables.

To host at a sub URL, one would set the environment variables:

    export RAILS_RELATIVE_URL_ROOT=/suburl
    export RAILS_ASSETS_PATH=/suburl/public

cc @jorgemoralespou

@GrahamDumpleton
Copy link
Author

Should note that right now this doesn't address getting the web socket stuff which works at /cable working. I don't understand what that is actually for at this point, so haven't made changes so that the handler for that special URL is re-hosted with sub URL as additional prefix.

@GrahamDumpleton
Copy link
Author

Will also need to fix up lib/workshopper/lab.rb so markdown image inclusion works. Specifically the render() methods for ModulePath and ImagePath.

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.

None yet

1 participant