theunraveler / taskwarrior-web

A web interface for the Taskwarrior todo application. Because being a neckbeard is only fun sometimes.
http://theunraveler.github.com/taskwarrior-web
MIT License
526 stars 63 forks source link

Absolute links for CSS and Java #132

Open hymie0 opened 4 years ago

hymie0 commented 4 years ago

Greetings. It doesn't look like any work is happening here anymore, but I thought I would ask anyway.

Most of the links generated by taskwarrior-web are relative links... but some of them -specifically, the CSS and the JavaScript links -- are absolute.

This creates a problem for me. I have an oddball setup, where I have an SSL frontend on my firewall/bastion host, but the internal servers are all running HTTP.

So what this means is that, when I take my browser to https://host.domain.name:5678/ , my firewall goes internally to my http site, and all of the CSS and JS links are returned to my browser as http://host.domain.name:5678/css/ ... and those don't work.

All of the other links are (or, at least, appear to be) relative links, and my browser interprets them correctly.

I tried to find where this was happening, but I don't speak Ruby and I couldn't find it.

Anyway, I'd really like these CSS and JS links to be relative instead of absolute.

cilynx commented 4 years ago

As you say, this project isn't strongly maintained at this point. That said, I think this might be a quick fix. The CSS and JS asset links are defined here:

https://github.com/theunraveler/taskwarrior-web/blob/bf7f91eca7e27ab09cbfbf20033a8785819d9fcf/lib/taskwarrior-web/views/layout.erb#L8-L13

I'm honestly not sure how the url() function is supposed to act as it's not what I've seen used in other projects. I've created a new branch where I replaced url() with url_for(). In my experience, url_for() has :only_path set to True by default, so it should return relative paths.

Give that branch a try and let us know how it goes.

hymie0 commented 4 years ago

Thank you for the tip. I ended up with something simpler (I don't know if it will work properly for everybody, but it works for me). I took out the url() entirely and ended up with

<% %w(bootstrap.min datepicker styles).each do |file| %>
  <link rel="stylesheet" href="/css/<%=file%>.css">
<% end %>

(It's happening somewhere else too, but I can't figure out exactly where yet.)

cilynx commented 4 years ago

Check the commit I linked above -- the diff includes the other locations of the absolute url() function.

hymie0 commented 4 years ago

Something in the 302 redirection is doing the same thing.

$ curl -i https://lactose.homelinux.net:5678/
HTTP/1.1 302 Found
Content-Type: text/html;charset=utf-8
Location: http://lactose.homelinux.net:5678/tasks/pending

I think I found the redirect calls in lib/taskwarrior-web/app.rb ... but I haven't traced it past there yet...

cilynx commented 4 years ago

Losing HTTPS on 302 with SSL proxies is a known issue that a few folks have gotten around. Check out: #20, #56, and this wiki page.