paths starting with / #22

Closed
humanitiesNerd opened this Issue May 2, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@humanitiesNerd

why must paths start with a slash ?

@magnars

This comment has been minimized.

Show comment Hide comment
@magnars

magnars May 2, 2014

Owner

Which paths where?

Owner

magnars commented May 2, 2014

Which paths where?

@humanitiesNerd

This comment has been minimized.

Show comment Hide comment
@humanitiesNerd

humanitiesNerd May 3, 2014

Sorry for being unclear.

I'm experimenting with Optimus and Stasis.

I have a couple of pages and they are working on my local web server.

Not so on github pages, because the resources managed through Optimus have paths as "/stylesheets/style.css" or "/img/background.jpg"

Because on github pages the URL is like

https://blah/blah/index.html

resources are not reached as they are not at https://blah/stylesheets/style.css and https://blah/img/background.jpg but rather at https://blah/blah/stylesheets... etc

I tried to change the paths to

"stylesheest/style.css" and "img/background.jpg"

that is, without the starting slash, that is with relative paths

but an exception gets thrown. I explored the code and there's a "guard-path" function that does exactly this: it checks that paths start with a slash, if they don't it throws an exception.

Enforcing the slash in the beginning cuts out the use case where your site has not its own domain name.

I was wondering what's the reasoning behind this.

My aim is to create a blog made with static files and have it hosted on simple free setups.

That's all

Sorry for being unclear.

I'm experimenting with Optimus and Stasis.

I have a couple of pages and they are working on my local web server.

Not so on github pages, because the resources managed through Optimus have paths as "/stylesheets/style.css" or "/img/background.jpg"

Because on github pages the URL is like

https://blah/blah/index.html

resources are not reached as they are not at https://blah/stylesheets/style.css and https://blah/img/background.jpg but rather at https://blah/blah/stylesheets... etc

I tried to change the paths to

"stylesheest/style.css" and "img/background.jpg"

that is, without the starting slash, that is with relative paths

but an exception gets thrown. I explored the code and there's a "guard-path" function that does exactly this: it checks that paths start with a slash, if they don't it throws an exception.

Enforcing the slash in the beginning cuts out the use case where your site has not its own domain name.

I was wondering what's the reasoning behind this.

My aim is to create a blog made with static files and have it hosted on simple free setups.

That's all

@magnars

This comment has been minimized.

Show comment Hide comment
@magnars

magnars May 3, 2014

Owner

Hi! Thanks for elaborating. I'll give it some thought, but have you looked at Optimus' :base-dir option? Sounds like it could solve your issue.

  • Magnar

Den 3. mai 2014 kl. 12:16 skrev humanitiesNerd notifications@github.com:

Sorry for being unclear.

I'm experimenting with Optimus and Stasis.

I have a couple of pages and they are working on my local web server.

Not so on github pages, because the resources managed through Optimus have paths as "/stylesheets/style.css" or "/img/background.jpg"

Because on github pages the URL is like

https://blah/blah/index.html

resources are not reached as they are not at https://blah/stylesheets/style.css and https://blah/img/background.jpg but rather at https://blah/blah/stylesheets... etc

I tried to change the paths to

"stylesheest/style.css" and "img/background.jpg"

that is, without the starting slash, that is with relative paths

but an exception gets thrown. I explored the code and there's a "guard-path" function that does exactly this: it checks that paths start with a slash, if they don't it throws an exception.

Enforcing the slash in the beginning cuts out the use case where your site has not its own domain name.

I was wondering what's the reasoning behind this.

My aim is to create a blog made with static files and have it hosted on simple free setups.

That's all


Reply to this email directly or view it on GitHub.

Owner

magnars commented May 3, 2014

Hi! Thanks for elaborating. I'll give it some thought, but have you looked at Optimus' :base-dir option? Sounds like it could solve your issue.

  • Magnar

Den 3. mai 2014 kl. 12:16 skrev humanitiesNerd notifications@github.com:

Sorry for being unclear.

I'm experimenting with Optimus and Stasis.

I have a couple of pages and they are working on my local web server.

Not so on github pages, because the resources managed through Optimus have paths as "/stylesheets/style.css" or "/img/background.jpg"

Because on github pages the URL is like

https://blah/blah/index.html

resources are not reached as they are not at https://blah/stylesheets/style.css and https://blah/img/background.jpg but rather at https://blah/blah/stylesheets... etc

I tried to change the paths to

"stylesheest/style.css" and "img/background.jpg"

that is, without the starting slash, that is with relative paths

but an exception gets thrown. I explored the code and there's a "guard-path" function that does exactly this: it checks that paths start with a slash, if they don't it throws an exception.

Enforcing the slash in the beginning cuts out the use case where your site has not its own domain name.

I was wondering what's the reasoning behind this.

My aim is to create a blog made with static files and have it hosted on simple free setups.

That's all


Reply to this email directly or view it on GitHub.

@humanitiesNerd

This comment has been minimized.

Show comment Hide comment
@humanitiesNerd

humanitiesNerd May 4, 2014

Magnars,

it worked. Thanks

But I'd still be interested in knowing your reasons for absolute paths.

Magnars,

it worked. Thanks

But I'd still be interested in knowing your reasons for absolute paths.

@magnars

This comment has been minimized.

Show comment Hide comment
@magnars

magnars May 5, 2014

Owner

Good to hear. Some reasons:

The absolute paths are unique identifiers for assets and pages, that are
used to look up what to serve when a request comes in. Those requests come
with absolute URLs.

Absolute paths are simpler than relative paths, in the non-complex sense.
This makes the code easier to reason about - by quite a bit, since both the
parent and child assets may change their place in the directory tree as
part of transformations.

It is certainly possible to add an asset transformation middleware that
could be added to the very end, that rewrites all references to relative,
tho.

  • Magnar

On Sun, May 4, 2014 at 11:09 AM, humanitiesNerd notifications@github.comwrote:

Magnars,

it worked. Thanks

But I'd still be interested in knowing your reasons for absolute paths.


Reply to this email directly or view it on GitHubhttps://github.com/magnars/optimus/issues/22#issuecomment-42128200
.

Owner

magnars commented May 5, 2014

Good to hear. Some reasons:

The absolute paths are unique identifiers for assets and pages, that are
used to look up what to serve when a request comes in. Those requests come
with absolute URLs.

Absolute paths are simpler than relative paths, in the non-complex sense.
This makes the code easier to reason about - by quite a bit, since both the
parent and child assets may change their place in the directory tree as
part of transformations.

It is certainly possible to add an asset transformation middleware that
could be added to the very end, that rewrites all references to relative,
tho.

  • Magnar

On Sun, May 4, 2014 at 11:09 AM, humanitiesNerd notifications@github.comwrote:

Magnars,

it worked. Thanks

But I'd still be interested in knowing your reasons for absolute paths.


Reply to this email directly or view it on GitHubhttps://github.com/magnars/optimus/issues/22#issuecomment-42128200
.

@magnars magnars closed this Nov 6, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment