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

Allow mounting application at a location other than '/' when started with rackup. #118

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion config.ru
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lib/taskwarrior-web/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
14 changes: 7 additions & 7 deletions lib/taskwarrior-web/config/navigation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span class=\"badge\">#{task_count}</span>", '/tasks/pending'
tasks.item :waiting, 'Waiting', '/tasks/waiting'
tasks.item :completed, 'Completed', '/tasks/completed'
tasks.item :deleted, 'Deleted', '/tasks/deleted'
tasks.item :pending, "Pending <span class=\"badge\">#{task_count}</span>", 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
6 changes: 3 additions & 3 deletions lib/taskwarrior-web/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ def progress_bar(tasks)

def crud_links(task)
string = %(<span class="crud-links">)
string << %(<a class="annotation-add" href="/tasks/#{task.uuid}/annotations/new"><i class="icon-comment"></i></a>)
string << %(<a class="annotation-add" href="#{url("/tasks/#{task.uuid}/annotations/new")}"><i class="icon-comment"></i></a>)
string << %(&nbsp;|&nbsp;)
string << %(<a href="/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}"><i class="icon-pencil"></i></a>)
string << %(<a href="#{url("/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}")}"><i class="icon-pencil"></i></a>)
string << %(&nbsp;|&nbsp;)
string << %(<a href="/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}" data-method="DELETE" data-confirm="Are you sure you want to delete this task?"><i class="icon-trash"></i></a>)
string << %(<a href="#{url("/tasks/#{task.uuid}?destination=#{ERB::Util.u(request.path_info)}")}" data-method="DELETE" data-confirm="Are you sure you want to delete this task?"><i class="icon-trash"></i></a>)
string << %(</span>)
string
end
Expand Down
2 changes: 1 addition & 1 deletion lib/taskwarrior-web/views/404.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
<p>Aww bummer. Taskwarrior doesn't know what to do with <%= @current_page %>.</p>
<p>Go <a href="<%= back %>">back</a> or <a href="/tasks">to the main task page</a>.</p>
<p>Go <a href="<%= back %>">back</a> or <a href="<%= url('/tasks') %>">to the main task page</a>.</p>
4 changes: 2 additions & 2 deletions lib/taskwarrior-web/views/partials/_topbar.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<div class="navbar navbar-fixed-top">
<div class="navbar-inner"><div class="container">
<a href="/" class="brand">TaskwarriorWeb</a>
<a href="<%= url('/') %>" class="brand">TaskwarriorWeb</a>
<%= render_navigation :level => 1 %>
<ul class="nav pull-right">
<li<% if @current_page =~ %r(^/tasks/new/?) %> class="active"<% end %>>
<a href="/tasks/new?destination=<%= ERB::Util.u(request.path_info) %>">
<a href="<%= url("/tasks/new?destination=#{ERB::Util.u(request.path_info)}") %>">
<i class="icon-plus"></i>&nbsp;Add a Task
</a>
</li>
Expand Down
2 changes: 1 addition & 1 deletion lib/taskwarrior-web/views/tasks/_annotation_form.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<form action="/tasks/<%= @task.uuid %>/annotations" method="POST" class="modal-form">
<form action="<%= url("/tasks/#{@task.uuid}/annotations") %>" method="POST" class="modal-form">
<div class="modal-header">
<% if @json %>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
Expand Down
2 changes: 1 addition & 1 deletion lib/taskwarrior-web/views/tasks/_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<label for="task-wait" class="control-label">Hide until</label>
<div class="controls">
<input class="date-picker" type="text" id="task-wait" name="task[wait]" value="<%= format_date(@task.wait) unless @task.nil? || @task.wait.blank? %>" data-date-format="<%= @date_format %>" />
<span class="help-block">If specified, the task will appear in the <a href="/tasks/waiting">Waiting</a> list until the given date.</span>
<span class="help-block">If specified, the task will appear in the <a href="<%= url('/tasks/waiting') %>">Waiting</a> list until the given date.</span>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions lib/taskwarrior-web/views/tasks/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<%= auto_link(annotation.description) %>
</td>
<td>
<a href="/tasks/<%= task.uuid %>/annotations/<%= ERB::Util.u(annotation.description) %>"
<a href="<%= url("/tasks/#{task.uuid}/annotations/#{ERB::Util.u(annotation.description)}") %>"
data-method="DELETE"
data-confirm="Are you sure you want to delete this annotation?">
<i class="icon-trash"></i>
Expand All @@ -54,7 +54,7 @@
</table>
<% end %>
</td>
<td><a href="/projects/<%= linkify(task.project) %>"><%= task.project %></a></td>
<td><a href="<%= url("/projects/#{linkify(task.project)}") %>"><%= task.project %></a></td>
<td><%= format_date(task.due) unless task.due.nil? %></td>
<%=
case params[:status]
Expand Down
2 changes: 1 addition & 1 deletion lib/taskwarrior-web/views/tasks/new.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
});
</script>

<form id="new-task-form" class="form-horizontal" action="/tasks<%= '?destination='+ERB::Util.u(params[:destination]) if params[:destination] %>" method="post">
<form id="new-task-form" class="form-horizontal" action="<%= url('/tasks') %><%= '?destination='+ERB::Util.u(params[:destination]) if params[:destination] %>" method="post">

<%= erb :'tasks/_form' %>

Expand Down