From 5b11574bb5acdbca2da1bc951a25d4e21f75cfb8 Mon Sep 17 00:00:00 2001 From: "Sebastian J. Bronner" Date: Tue, 20 Nov 2018 02:08:40 +0100 Subject: [PATCH] Allow mounting application at a location other than '/' when started with rackup. --- config.ru | 6 +++++- lib/taskwarrior-web/app.rb | 2 +- lib/taskwarrior-web/config/navigation.rb | 14 +++++++------- lib/taskwarrior-web/helpers.rb | 6 +++--- lib/taskwarrior-web/views/404.erb | 2 +- lib/taskwarrior-web/views/partials/_topbar.erb | 4 ++-- .../views/tasks/_annotation_form.erb | 2 +- lib/taskwarrior-web/views/tasks/_form.erb | 2 +- lib/taskwarrior-web/views/tasks/index.erb | 4 ++-- lib/taskwarrior-web/views/tasks/new.erb | 2 +- 10 files changed, 24 insertions(+), 20 deletions(-) diff --git a/config.ru b/config.ru index c3050c6..04e6889 100644 --- a/config.ru +++ b/config.ru @@ -1,5 +1,9 @@ require File.join(File.dirname(__FILE__), 'lib', 'taskwarrior-web') +require 'sinatra' disable :run TaskwarriorWeb::App.set({ :environment => :production }) -run TaskwarriorWeb::App + +map '/' do + run TaskwarriorWeb::App +end diff --git a/lib/taskwarrior-web/app.rb b/lib/taskwarrior-web/app.rb index 7d38494..0a9d3bf 100644 --- a/lib/taskwarrior-web/app.rb +++ b/lib/taskwarrior-web/app.rb @@ -11,7 +11,7 @@ class TaskwarriorWeb::App < Sinatra::Base autoload :Helpers, 'taskwarrior-web/helpers' - @@root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..')) + @@root = File.dirname(__FILE__) set :root, @@root set :app_file, __FILE__ set :public_folder, File.dirname(__FILE__) + '/public' diff --git a/lib/taskwarrior-web/config/navigation.rb b/lib/taskwarrior-web/config/navigation.rb index 9965298..993b232 100644 --- a/lib/taskwarrior-web/config/navigation.rb +++ b/lib/taskwarrior-web/config/navigation.rb @@ -3,16 +3,16 @@ navigation.items do |primary| primary.dom_class = 'nav' - primary.item :tasks, 'Tasks', '/tasks' do |tasks| + primary.item :tasks, 'Tasks', url('/tasks') do |tasks| tasks.dom_class = 'nav nav-pills' - tasks.item :pending, "Pending #{task_count}", '/tasks/pending' - tasks.item :waiting, 'Waiting', '/tasks/waiting' - tasks.item :completed, 'Completed', '/tasks/completed' - tasks.item :deleted, 'Deleted', '/tasks/deleted' + tasks.item :pending, "Pending #{task_count}", url('/tasks/pending') + tasks.item :waiting, 'Waiting', url('/tasks/waiting') + tasks.item :completed, 'Completed', url('/tasks/completed') + tasks.item :deleted, 'Deleted', url('/tasks/deleted') end - primary.item :projects, 'Projects', '/projects', { :highlights_on => %r{/projects/?.+?} } do |projects| + primary.item :projects, 'Projects', url('/projects'), { :highlights_on => %r{/projects/?.+?} } do |projects| projects.dom_class = 'nav nav-pills' - projects.item :overview, 'Overview', '/projects/overview' + projects.item :overview, 'Overview', url('/projects/overview') end end end diff --git a/lib/taskwarrior-web/helpers.rb b/lib/taskwarrior-web/helpers.rb index 212aed7..6528468 100644 --- a/lib/taskwarrior-web/helpers.rb +++ b/lib/taskwarrior-web/helpers.rb @@ -67,11 +67,11 @@ def progress_bar(tasks) def crud_links(task) string = %() - string << %() + string << %() string << %( | ) - string << %() + string << %() string << %( | ) - string << %() + string << %() string << %() string end diff --git a/lib/taskwarrior-web/views/404.erb b/lib/taskwarrior-web/views/404.erb index 7b0fec0..64a99ce 100644 --- a/lib/taskwarrior-web/views/404.erb +++ b/lib/taskwarrior-web/views/404.erb @@ -1,2 +1,2 @@

Aww bummer. Taskwarrior doesn't know what to do with <%= @current_page %>.

-

Go back or to the main task page.

+

Go back or to the main task page.

diff --git a/lib/taskwarrior-web/views/partials/_topbar.erb b/lib/taskwarrior-web/views/partials/_topbar.erb index 2230dab..d992647 100644 --- a/lib/taskwarrior-web/views/partials/_topbar.erb +++ b/lib/taskwarrior-web/views/partials/_topbar.erb @@ -1,10 +1,10 @@