{"action":"created","issue":{"url":"https://api.github.com/repos/rrthomas/nancy/issues/9","repository_url":"https://api.github.com/repos/rrthomas/nancy","labels_url":"https://api.github.com/repos/rrthomas/nancy/issues/9/labels{/name}","comments_url":"https://api.github.com/repos/rrthomas/nancy/issues/9/comments","events_url":"https://api.github.com/repos/rrthomas/nancy/issues/9/events","html_url":"https://github.com/rrthomas/nancy/issues/9","id":182940411,"number":9,"title":"Feature request: $unpath","user":{"login":"apt1002","id":2067837,"avatar_url":"https://avatars.githubusercontent.com/u/2067837?v=3","gravatar_id":"","url":"https://api.github.com/users/apt1002","html_url":"https://github.com/apt1002","followers_url":"https://api.github.com/users/apt1002/followers","following_url":"https://api.github.com/users/apt1002/following{/other_user}","gists_url":"https://api.github.com/users/apt1002/gists{/gist_id}","starred_url":"https://api.github.com/users/apt1002/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apt1002/subscriptions","organizations_url":"https://api.github.com/users/apt1002/orgs","repos_url":"https://api.github.com/users/apt1002/repos","events_url":"https://api.github.com/users/apt1002/events{/privacy}","received_events_url":"https://api.github.com/users/apt1002/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-14T01:04:16Z","updated_at":"2016-10-14T10:32:21Z","closed_at":null,"body":"A common use-case of Nancy is building HTML files that link to each other using relative URLs. It is difficult to get the relative URLs right. For example, suppose we have a file \"template.html\" which contains:\r\n\r\n    $include{menu.html}\r\n\r\nWe generate two output files \"index.html\" and \"some_dir/some_file.html\":\r\n\r\n    nancy template.html index --output build/index.html\r\n    nancy template.html some_dir/some_file --output build/some_dir/some_file.html\r\n\r\nSuppose \"menu.html\" includes a link:\r\n\r\n    <a href=\"some_dir/some_file.html\">\r\n\r\nThen we have a problem. When the menu gets included in \"index.html\", the link works, but when the menu gets included in \"some_dir/some_file.html\" the link is broken.\r\n\r\nA possible work-around is only to use absolute URLs. But that means I've lost flexibility in the URL where the site is hosted. In particular, I can't point my browser at \"file://build\", because none of the links begin with \"/path/to/build/\".\r\n\r\nA better work-around is to place all output files in the same directory, i.e. to flatten the directory hierarchy inside \"build\". This is unsatisfactory because the correspondence of source to build files is confusing and a potential maintenance problem.\r\n\r\nA better work-around is to make a file \"path_to_root.txt\" in every source directory, containing \".\" or \"..\" or \"../..\" as appropriate, and then to write the link as follows:\r\n\r\n    <a href=\"$paste{path_to_root.txt}/some_dir/some_file.html\">\r\n\r\nHowever, it is annoying to have to do this in every link, and it is easy to forget to do so.\r\n\r\nA better better work-around, using the same \"path_to_root.txt\" files, is to leave the links unchanged, but put the following in \"template.html\" (so that it appears in every HTML file):\r\n\r\n    <base href=\"$paste{path_to_root.txt}\">\r\n\r\nHowever, this is still far from ideal. The \"path_to_root.txt\" files are confusing and distracting. When reorganising the directory tree, they become a maintenance problem.\r\n\r\nTherefore, please introduce a Nancy command \"$unpath\" (or something) which expands to:\r\n\r\n- \".\" if $PATH is empty.\r\n- \"..\" if $PATH is depth 1.\r\n- \"../..\" if $PATH is depth 2.\r\n- \"../../..\" if $PATH is depth 3.\r\n- Etc."},"comment":{"url":"https://api.github.com/repos/rrthomas/nancy/issues/comments/253765720","html_url":"https://github.com/rrthomas/nancy/issues/9#issuecomment-253765720","issue_url":"https://api.github.com/repos/rrthomas/nancy/issues/9","id":253765720,"user":{"login":"rrthomas","id":17382,"avatar_url":"https://avatars.githubusercontent.com/u/17382?v=3","gravatar_id":"","url":"https://api.github.com/users/rrthomas","html_url":"https://github.com/rrthomas","followers_url":"https://api.github.com/users/rrthomas/followers","following_url":"https://api.github.com/users/rrthomas/following{/other_user}","gists_url":"https://api.github.com/users/rrthomas/gists{/gist_id}","starred_url":"https://api.github.com/users/rrthomas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rrthomas/subscriptions","organizations_url":"https://api.github.com/users/rrthomas/orgs","repos_url":"https://api.github.com/users/rrthomas/repos","events_url":"https://api.github.com/users/rrthomas/events{/privacy}","received_events_url":"https://api.github.com/users/rrthomas/received_events","type":"User","site_admin":false},"created_at":"2016-10-14T10:32:21Z","updated_at":"2016-10-14T10:32:21Z","body":"​You may want to look at how this used to be implemented (confusingly, also called `$root`). Sorry to make you reinvent the past.​ The most recent commit that had this was fd34ede9.\r\n\r\nI removed it as part of making Nancy not web-specific; I'd rather not have such a feature in the core (unless perhaps it's useful for something else?)."}}
{"actor":{"display_login":"rrthomas"}}