mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-21 21:40:48 +02:00
commit
33f4963a02
14 changed files with 132 additions and 179 deletions
71
Gemfile
71
Gemfile
|
@ -1,55 +1,41 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'actionpack-xml_parser', '~> 2.0'
|
||||
gem 'activemodel-serializers-xml', '~> 1.0.1'
|
||||
|
||||
gem 'coffee-rails', '~> 5.0.0'
|
||||
|
||||
gem 'jquery-rails', '~> 4.4'
|
||||
gem 'jquery-ui-rails', '~>6.0.1'
|
||||
|
||||
gem 'rails', '~> 6.0.3'
|
||||
gem 'sassc-rails', '~> 2.1.2'
|
||||
gem 'coffee-rails', '~> 5.0.0'
|
||||
|
||||
#gem 'json'
|
||||
gem 'bootstrap-sass', '3.4.1'
|
||||
gem 'font-awesome-sass', '~> 5.15.1'
|
||||
|
||||
# todo: remove xml api
|
||||
gem 'actionpack-xml_parser', '~> 2.0'
|
||||
gem 'activemodel-serializers-xml', '~> 1.0.1'
|
||||
gem 'uglifier', '>=1.3.0'
|
||||
|
||||
gem 'aasm', '~> 5.1.1'
|
||||
gem 'acts_as_list'
|
||||
gem 'bcrypt', '~> 3.1.16'
|
||||
gem 'chartjs-ror', :git => 'git://github.com/ZeiP/chartjs-ror.git'
|
||||
gem 'htmlentities'
|
||||
gem 'paperclip'
|
||||
gem 'puma', '~> 5.0'
|
||||
gem 'rails_autolink'
|
||||
gem 'RedCloth'
|
||||
gem 'sanitize', '~> 5.2'
|
||||
gem 'will_paginate'
|
||||
|
||||
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
|
||||
gem 'therubyracer', group: :therubyracer
|
||||
|
||||
gem 'uglifier', '>=1.3.0'
|
||||
|
||||
gem 'jquery-rails' , '~> 4.4'
|
||||
gem 'jquery-ui-rails' , '~>6.0.1'
|
||||
|
||||
# you may comment out the database driver(s) you will not be using.
|
||||
# This will prevent a native build of the driver. Building native drivers is not
|
||||
# always possible on all platforms
|
||||
# Alternatively use --without <group> arguments to bundler to not install that group
|
||||
# Use --without <group> argument to skip unnecessary drivers
|
||||
gem 'sqlite3', group: :sqlite
|
||||
gem 'mysql2', '~> 0.5.3', group: :mysql
|
||||
gem 'pg', '~> 1.2.3', group: :postgresql
|
||||
|
||||
gem 'RedCloth'
|
||||
gem 'sanitize', '~> 5.2'
|
||||
gem 'will_paginate'
|
||||
gem 'acts_as_list'
|
||||
gem 'aasm', '~> 5.1.1'
|
||||
gem 'htmlentities'
|
||||
gem 'rails_autolink'
|
||||
gem 'puma', '~> 5.0'
|
||||
gem 'paperclip'
|
||||
|
||||
# To use ActiveModel has_secure_password
|
||||
gem 'bcrypt', '~> 3.1.16'
|
||||
|
||||
gem 'chartjs-ror', :git => 'git://github.com/ZeiP/chartjs-ror.git'
|
||||
|
||||
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
|
||||
# gem 'turbolinks'
|
||||
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
# gem 'jbuilder', '~> 1.2'
|
||||
|
||||
gem 'bootstrap-sass', '3.4.1'
|
||||
gem 'font-awesome-sass', '~> 5.15.1'
|
||||
|
||||
group :development do
|
||||
gem 'spring'
|
||||
gem 'yard'
|
||||
|
@ -79,15 +65,6 @@ group :test do
|
|||
gem 'mocha', :require => false
|
||||
gem 'minitest-stub-const'
|
||||
|
||||
gem 'selenium-webdriver', '~> 3.142'
|
||||
|
||||
# uncomment to use the webkit option. This depends on Qt being installed
|
||||
# gem 'capybara-webkit'
|
||||
|
||||
# uncomment to be able to make screenshots from scenarios
|
||||
#gem 'capybara-screenshot'
|
||||
#gem 'launchy'
|
||||
|
||||
gem 'simplecov'
|
||||
# get test coverage info on codeclimate
|
||||
gem 'codeclimate-test-reporter', '1.0.7', group: :test, require: nil
|
||||
|
|
|
@ -89,7 +89,6 @@ GEM
|
|||
activesupport (>= 3.0.0)
|
||||
uniform_notifier (~> 1.11)
|
||||
byebug (11.1.3)
|
||||
childprocess (3.0.0)
|
||||
climate_control (0.2.0)
|
||||
codeclimate-test-reporter (1.0.7)
|
||||
simplecov
|
||||
|
@ -245,7 +244,6 @@ GEM
|
|||
rubocop-ast (0.8.0)
|
||||
parser (>= 2.7.1.5)
|
||||
ruby-progressbar (1.10.1)
|
||||
rubyzip (2.3.0)
|
||||
safe_yaml (1.0.5)
|
||||
sanitize (5.2.1)
|
||||
crass (~> 1.0.2)
|
||||
|
@ -259,9 +257,6 @@ GEM
|
|||
sprockets (> 3.0)
|
||||
sprockets-rails
|
||||
tilt
|
||||
selenium-webdriver (3.142.7)
|
||||
childprocess (>= 0.5, < 4.0)
|
||||
rubyzip (>= 1.2.2)
|
||||
simplecov (0.19.1)
|
||||
docile (~> 1.1)
|
||||
simplecov-html (~> 0.11)
|
||||
|
@ -355,7 +350,6 @@ DEPENDENCIES
|
|||
rubocop (~> 0.93)
|
||||
sanitize (~> 5.2)
|
||||
sassc-rails (~> 2.1.2)
|
||||
selenium-webdriver (~> 3.142)
|
||||
simplecov
|
||||
solargraph
|
||||
spring
|
||||
|
|
|
@ -24,8 +24,8 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
def set_locale
|
||||
locale = params[:locale] # specifying a locale in the request takes precedence
|
||||
locale = locale || prefs.locale unless current_user.nil? # otherwise, the locale of the currently logged in user takes over
|
||||
locale = locale || request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']
|
||||
locale ||= prefs.locale unless current_user.nil? # otherwise, the locale of the currently logged in user takes over
|
||||
locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].scan(/^[a-z]{2}/).first if request.env['HTTP_ACCEPT_LANGUAGE']
|
||||
|
||||
if locale && I18n::available_locales.map(&:to_s).include?(locale.to_s)
|
||||
I18n.locale = locale
|
||||
|
@ -43,13 +43,14 @@ class ApplicationController < ActionController::Base
|
|||
|
||||
# Get expiry time (allow ten seconds window for the case where we have
|
||||
# none)
|
||||
expiry_time = session['expiry_time'] || Time.now + 10
|
||||
if expiry_time < Time.now
|
||||
now = Time.zone.now
|
||||
expiry_time = session['expiry_time'] || now + 10
|
||||
if expiry_time < now
|
||||
# Too late, matey... bang goes your session!
|
||||
reset_session
|
||||
else
|
||||
# Okay, you get another hour
|
||||
session['expiry_time'] = Time.now + (60*60)
|
||||
session['expiry_time'] = now + (60*60)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -109,7 +110,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def format_dependencies_as_json_for_auto_complete(entries)
|
||||
json_elems = Array[*entries.map{ |e| { :value => e.id.to_s, :label => e.specification } }].to_json
|
||||
json_elems = Array[*entries.map { |e| { :value => e.id.to_s, :label => e.specification } }].to_json
|
||||
return json_elems
|
||||
end
|
||||
|
||||
|
|
|
@ -13,15 +13,9 @@ class CalendarController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.m {
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
}
|
||||
format.ics {
|
||||
render :action => 'show', :layout => false, :content_type => Mime[:ics]
|
||||
}
|
||||
format.xml {
|
||||
render :xml => @due_all.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
}
|
||||
format.m { cookies[:mobile_url] = { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] } }
|
||||
format.ics { render :action => 'show', :layout => false, :content_type => Mime[:ics] }
|
||||
format.xml { render :xml => @due_all.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] ) }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -40,7 +40,7 @@ class ContextsController < ApplicationController
|
|||
@max_completed = current_user.prefs.show_number_completed
|
||||
@done = @context.todos.completed.limit(@max_completed).reorder(Arel.sql("todos.completed_at DESC, todos.created_at DESC")).includes(Todo::DEFAULT_INCLUDES)
|
||||
@not_done_todos = @context.todos.active_or_hidden.not_project_hidden.reorder(Arel.sql('todos.due IS NULL, todos.due ASC, todos.created_at ASC')).includes(Todo::DEFAULT_INCLUDES)
|
||||
@todos_without_project = @not_done_todos.select{ |t| t.project.nil? }
|
||||
@todos_without_project = @not_done_todos.select { |t| t.project.nil? }
|
||||
|
||||
@deferred_todos = @context.todos.deferred.includes(Todo::DEFAULT_INCLUDES)
|
||||
@pending_todos = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES)
|
||||
|
@ -110,13 +110,13 @@ class ContextsController < ApplicationController
|
|||
|
||||
respond_to do |format|
|
||||
format.js
|
||||
format.xml {
|
||||
format.xml do
|
||||
if @saved
|
||||
render :xml => @context.to_xml(:except => :user_id)
|
||||
else
|
||||
render :body => "Error on update: #{@context.errors.full_messages.inject("") { |v, e| v + e + " " }}", :status => 409
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -202,17 +202,17 @@ class ContextsController < ApplicationController
|
|||
@active_contexts = current_user.contexts.active
|
||||
@hidden_contexts = current_user.contexts.hidden
|
||||
@down_count = @active_contexts.size + @hidden_contexts.size
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
cookies[:mobile_url] = { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
render
|
||||
end
|
||||
end
|
||||
|
||||
def render_context_mobile
|
||||
lambda do
|
||||
@page_title = "TRACKS::List actions in "+@context.name
|
||||
@not_done = @not_done_todos.select {|t| t.context_id == @context.id }
|
||||
@page_title = "TRACKS::List actions in " + @context.name
|
||||
@not_done = @not_done_todos.select { |t| t.context_id == @context.id }
|
||||
@down_count = @not_done.size
|
||||
cookies[:mobile_url]= { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
cookies[:mobile_url] = { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
@mobile_from_context = @context.id
|
||||
render
|
||||
end
|
||||
|
|
|
@ -34,7 +34,7 @@ class ProjectsController < ApplicationController
|
|||
format.m do
|
||||
@completed_projects = current_user.projects.completed
|
||||
@down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size
|
||||
cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
|
||||
cookies[:mobile_url] = { :value => request.fullpath, :secure => SITE_CONFIG['secure_cookies'] }
|
||||
end
|
||||
format.xml { render :xml => @projects.to_xml(:root => :projects, :except => :user_id) }
|
||||
format.any(:rss, :atom) do
|
||||
|
@ -43,7 +43,7 @@ class ProjectsController < ApplicationController
|
|||
end
|
||||
format.text do
|
||||
# somehow passing Mime[:text] using content_type to render does not work
|
||||
headers['Content-Type']=Mime[:text].to_s
|
||||
headers['Content-Type'] = Mime[:text].to_s
|
||||
end
|
||||
format.autocomplete do
|
||||
projects = current_user.projects.active + current_user.projects.hidden
|
||||
|
@ -60,7 +60,7 @@ class ProjectsController < ApplicationController
|
|||
@projects_to_review = projects.select { |p| p.needs_review?(current_user) }
|
||||
@stalled_projects = projects.select { |p| p.stalled? }
|
||||
@blocked_projects = projects.select { |p| p.blocked? }
|
||||
@current_projects = projects.uncompleted.select { |p| not (p.needs_review?(current_user)) }.sort_by { |p| p.last_reviewed || Time.zone.at(0) }
|
||||
@current_projects = projects.uncompleted.select { |p| not p.needs_review?(current_user) }.sort_by { |p| p.last_reviewed || Time.zone.at(0) }
|
||||
|
||||
init_not_done_counts(['project'])
|
||||
init_hidden_todo_counts(['project'])
|
||||
|
@ -112,11 +112,11 @@ class ProjectsController < ApplicationController
|
|||
def projects_and_actions
|
||||
@projects = current_user.projects.active
|
||||
respond_to do |format|
|
||||
format.text {
|
||||
format.text do
|
||||
# somehow passing Mime[:text] using content_type to render does not work
|
||||
headers['Content-Type'] = Mime[:text].to_s
|
||||
render :action => 'index_text_projects_and_actions', :layout => false, :content_type => Mime[:text]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -246,15 +246,14 @@ class ProjectsController < ApplicationController
|
|||
respond_to do |format|
|
||||
format.js { render :template => template }
|
||||
format.html { redirect_to :action => 'index'}
|
||||
format.xml {
|
||||
format.xml do
|
||||
if @saved
|
||||
render :xml => @project.to_xml( :except => :user_id )
|
||||
render :xml => @project.to_xml(:except => :user_id)
|
||||
else
|
||||
render :body => "Error on update: #{@project.errors.full_messages.inject("") { |v, e| v + e + " " }}", :status => 409
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -268,10 +267,10 @@ class ProjectsController < ApplicationController
|
|||
@project.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.js {
|
||||
format.js do
|
||||
@down_count = current_user.projects.size
|
||||
update_state_counts
|
||||
}
|
||||
end
|
||||
format.xml { render :body => "Deleted project #{@project.name}" }
|
||||
end
|
||||
end
|
||||
|
|
|
@ -703,7 +703,7 @@ class TodosController < ApplicationController
|
|||
def tags
|
||||
tags_beginning = current_user.tags.where(Tag.arel_table[:name].matches("#{params[:term]}%"))
|
||||
tags_all = current_user.tags.where(Tag.arel_table[:name].matches("%#{params[:term]}%"))
|
||||
tags_all = tags_all - tags_beginning
|
||||
tags_all -= tags_beginning
|
||||
|
||||
respond_to do |format|
|
||||
format.autocomplete { render :body => for_autocomplete(tags_beginning+tags_all, params[:term]) }
|
||||
|
@ -731,30 +731,26 @@ class TodosController < ApplicationController
|
|||
determine_down_count
|
||||
determine_remaining_in_container_count(@todo)
|
||||
source_view do |page|
|
||||
page.project {
|
||||
page.project do
|
||||
@remaining_undone_in_project = current_user.projects.find(@todo.project_id).todos.not_completed.count
|
||||
}
|
||||
page.tag {
|
||||
determine_deferred_tag_count(params['_tag_name'])
|
||||
}
|
||||
end
|
||||
page.tag { determine_deferred_tag_count(params['_tag_name']) }
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js { render :action => 'update' }
|
||||
format.m {
|
||||
format.m do
|
||||
notify(:notice, t("todos.action_deferred", :description => @todo.description))
|
||||
do_mobile_todo_redirection
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def list_hidden
|
||||
@hidden = current_user.todos.hidden
|
||||
respond_to do |format|
|
||||
format.xml {
|
||||
render :xml => @hidden.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] )
|
||||
}
|
||||
format.xml { render :xml => @hidden.to_xml( *[todo_xml_params[0].merge({ :root => :todos })] ) }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -801,12 +797,8 @@ class TodosController < ApplicationController
|
|||
@todo = current_user.todos.find(params['id'])
|
||||
@return_path = cookies[:mobile_url] ? cookies[:mobile_url] : mobile_path
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
redirect_to home_path, "Viewing note of todo is not implemented"
|
||||
}
|
||||
format.m {
|
||||
render :action => "show_notes"
|
||||
}
|
||||
format.html { redirect_to home_path, "Viewing note of todo is not implemented" }
|
||||
format.m { render :action => "show_notes" }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -866,9 +858,9 @@ class TodosController < ApplicationController
|
|||
# Additional tag condition(s) handled as AND.
|
||||
@tag_expr << params[:and].split(',') if params[:and]
|
||||
i = 1
|
||||
while params['and'+i.to_s]
|
||||
@tag_expr << params['and'+i.to_s].split(',')
|
||||
i=i+1
|
||||
while params['and' + i.to_s]
|
||||
@tag_expr << params['and' + i.to_s].split(',')
|
||||
i += 1
|
||||
end
|
||||
|
||||
@single_tag = @tag_expr.size == 1 && @tag_expr[0].size == 1
|
||||
|
@ -986,17 +978,17 @@ end
|
|||
|
||||
def determine_remaining_in_container_count(todo = @todo)
|
||||
source_view do |from|
|
||||
from.deferred {
|
||||
from.deferred do
|
||||
todos_in_container, todos_in_target_container = find_todos_in_container_and_target_container(todo, @todo)
|
||||
@remaining_in_context = todos_in_container.deferred_or_blocked.count
|
||||
@target_context_count = todos_in_target_container.deferred_or_blocked.count
|
||||
}
|
||||
from.todo {
|
||||
end
|
||||
from.todo do
|
||||
todos_in_container, todos_in_target_container = find_todos_in_container_and_target_container(todo, @todo)
|
||||
@remaining_in_context = todos_in_container.active.not_hidden.count
|
||||
@target_context_count = todos_in_target_container.active.not_hidden.count
|
||||
}
|
||||
from.tag {
|
||||
end
|
||||
from.tag do
|
||||
tag = Tag.where(:name => params['_tag_name']).first
|
||||
tag = Tag.new(:name => params['tag']) if tag.nil?
|
||||
|
||||
|
@ -1006,8 +998,8 @@ end
|
|||
@target_context_count = todos_in_target_container.active.not_hidden.with_tag(tag.id).count
|
||||
@remaining_hidden_count = current_user.todos.hidden.with_tag(tag.id).count
|
||||
@remaining_deferred_or_pending_count = current_user.todos.with_tag(tag.id).deferred_or_blocked.count
|
||||
}
|
||||
from.project {
|
||||
end
|
||||
from.project do
|
||||
project_id = @project_changed ? @original_item.project_id : @todo.project_id
|
||||
@remaining_deferred_or_pending_count = current_user.projects.find(project_id).todos.deferred_or_blocked.count
|
||||
|
||||
|
@ -1018,11 +1010,11 @@ end
|
|||
end
|
||||
|
||||
@target_context_count = current_user.projects.find(project_id).todos.active.count
|
||||
}
|
||||
from.calendar {
|
||||
end
|
||||
from.calendar do
|
||||
@target_context_count = @new_due_id.blank? ? 0 : count_old_due_empty(@new_due_id)
|
||||
}
|
||||
from.context {
|
||||
end
|
||||
from.context do
|
||||
context = current_user.contexts.find(todo.context_id)
|
||||
@remaining_deferred_or_pending_count = context.todos.deferred_or_blocked.count
|
||||
|
||||
|
@ -1037,13 +1029,11 @@ end
|
|||
actions_in_target = @todo.context.todos.deferred_or_blocked
|
||||
end
|
||||
@target_context_count = actions_in_target.count
|
||||
}
|
||||
from.done {
|
||||
end
|
||||
from.done do
|
||||
@remaining_in_context = DoneTodos.remaining_in_container(current_user.todos, @original_completed_period)
|
||||
}
|
||||
from.all_done {
|
||||
@remaining_in_context = current_user.todos.completed.count
|
||||
}
|
||||
end
|
||||
from.all_done { @remaining_in_context = current_user.todos.completed.count }
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ class UsersController < ApplicationController
|
|||
user.is_admin = true if first_user_signing_up
|
||||
if user.save
|
||||
@user = User.authenticate(user.login, params['user']['password'])
|
||||
@user.create_preference({:locale => I18n.locale})
|
||||
@user.create_preference({ :locale => I18n.locale })
|
||||
@user.save
|
||||
session['user_id'] = @user.id unless signup_by_admin
|
||||
notify :notice, t('users.signup_successful', :username => @user.login)
|
||||
|
|
|
@ -3,12 +3,12 @@ class RichMessageExtractor
|
|||
include ActionView::Helpers::SanitizeHelper
|
||||
extend ActionView::Helpers::SanitizeHelper::ClassMethods
|
||||
|
||||
PROJECT_MARKER = '~'
|
||||
CONTEXT_MARKER = '@'
|
||||
TICKLER_MARKER = '>'
|
||||
DUE_MARKER = '<'
|
||||
TAG_MARKER = '#'
|
||||
STAR_MARKER = '*'
|
||||
PROJECT_MARKER = '~'.freeze
|
||||
CONTEXT_MARKER = '@'.freeze
|
||||
TICKLER_MARKER = '>'.freeze
|
||||
DUE_MARKER = '<'.freeze
|
||||
TAG_MARKER = '#'.freeze
|
||||
STAR_MARKER = '*'.freeze
|
||||
|
||||
ALL_MARKERS = [
|
||||
PROJECT_MARKER,
|
||||
|
|
|
@ -33,12 +33,12 @@
|
|||
# Simple test file. Remove the '# ' string at the beginning.
|
||||
# token [A]
|
||||
# token [BB]
|
||||
#
|
||||
#
|
||||
# to [A] after [BB]
|
||||
# .task 1 in [A], [BB]|computer|starred,blue|my notes here
|
||||
# ^task 1.1 dependent on [A]|||only a note
|
||||
# .task 2
|
||||
#
|
||||
#
|
||||
# project 2 with [A]
|
||||
# .task in project 2
|
||||
|
||||
|
@ -73,18 +73,17 @@ require 'readline'
|
|||
require File.expand_path(File.dirname(__FILE__) + '/tracks_cli/tracks_api')
|
||||
|
||||
class TemplateParser
|
||||
|
||||
def initialize
|
||||
@keywords = {}
|
||||
end
|
||||
|
||||
def parse_keyword(token)
|
||||
print "Input required for "+token+": "
|
||||
@keywords[token]=gets.chomp
|
||||
print "Input required for " + token + ": "
|
||||
@keywords[token] = gets.chomp
|
||||
end
|
||||
|
||||
def replace_tokens_in(line)
|
||||
@keywords.each{ |key,val| line=line.sub(key,val) }
|
||||
@keywords.each { |key, val| line = line.sub(key, val) }
|
||||
line
|
||||
end
|
||||
|
||||
|
@ -92,27 +91,27 @@ class TemplateParser
|
|||
options = {}
|
||||
|
||||
# first char is . or ^ the latter meaning this todo is dependent on the previous one
|
||||
options[:depend]= line[0].chr == "^" ? true : false;
|
||||
options[:depend] = line[0].chr == "^"
|
||||
line = line[1..line.length] # remove first char
|
||||
|
||||
tmp= line.split("|")
|
||||
tmp = line.split("|")
|
||||
if tmp.length > 5
|
||||
puts "Formatting error: found too many |"
|
||||
exit 1
|
||||
end
|
||||
|
||||
tmp[0].chomp!
|
||||
options[:description]=tmp[0]
|
||||
options[:description] = tmp[0]
|
||||
|
||||
tmp.each_with_index do |t,idx|
|
||||
t=t.strip.chomp
|
||||
t=nil if t.empty?
|
||||
tmp[idx]=t
|
||||
tmp.each_with_index do |t, idx|
|
||||
t = t.strip.chomp
|
||||
t = nil if t.empty?
|
||||
tmp[idx] = t
|
||||
end
|
||||
|
||||
options[:context]=tmp[1]
|
||||
options[:taglist]=tmp[2]
|
||||
options[:notes] =tmp[3]
|
||||
options[:context] = tmp[1]
|
||||
options[:taglist] = tmp[2]
|
||||
options[:notes] = tmp[3]
|
||||
options
|
||||
end
|
||||
|
||||
|
@ -124,8 +123,8 @@ class TemplateParser
|
|||
next if (line.empty? || line[0].chr == "#")
|
||||
|
||||
# check if line defines a token
|
||||
if (line.split(' ')[0] == "token")
|
||||
parse_keyword line.split(' ')[1]
|
||||
if (line.split(' ')[0] == "token")
|
||||
parse_keyword line.split(' ')[1]
|
||||
next
|
||||
end
|
||||
|
||||
|
@ -136,18 +135,16 @@ class TemplateParser
|
|||
if (line[0].chr == "." ) || (line[0].chr == "^")
|
||||
if @last_project_id.nil?
|
||||
puts "Warning: no project specified for task \"#{line}\". Using default project."
|
||||
end
|
||||
end
|
||||
poster.postTodo(parse_todo(line), @last_project_id)
|
||||
else
|
||||
@last_project_id = poster.postProject(line)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class TemplatePoster
|
||||
|
||||
def initialize(options)
|
||||
@options = options
|
||||
@tracks = TracksCli::TracksAPI.new({
|
||||
|
@ -163,10 +160,10 @@ class TemplatePoster
|
|||
|
||||
def postTodo(parsed_todo, project_id)
|
||||
resp = @tracks.post_todo(
|
||||
description: CGI.escapeHTML(parsed_todo[:description]),
|
||||
context_name: parsed_todo[:context],
|
||||
context_id: @context_id,
|
||||
project_id: project_id || @project_id,
|
||||
description: CGI.escapeHTML(parsed_todo[:description]),
|
||||
context_name: parsed_todo[:context],
|
||||
context_id: @context_id,
|
||||
project_id: project_id || @project_id,
|
||||
show_from: parsed_todo[:show_from],
|
||||
notes: parsed_todo[:notes],
|
||||
is_dependend: parsed_todo[:depend],
|
||||
|
@ -174,7 +171,7 @@ class TemplatePoster
|
|||
|
||||
if resp.code == '302' || resp.code == '201'
|
||||
puts resp['location'] if @options[:verbose]
|
||||
|
||||
|
||||
# return the todo id
|
||||
@last_posted_todo_id = resp['location'].split("/").last
|
||||
return @last_posted_todo_id
|
||||
|
@ -209,11 +206,13 @@ class TemplatePoster
|
|||
|
||||
return resp.code == '200'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Error < StandardError; end
|
||||
class InvalidParser < StandardError; end
|
||||
class Error < StandardError
|
||||
end
|
||||
|
||||
class InvalidParser < StandardError
|
||||
end
|
||||
|
||||
class ConsoleOptionsForTemplate
|
||||
attr_reader :parser, :options, :keywords
|
||||
|
@ -275,14 +274,14 @@ class ConsoleOptionsForTemplate
|
|||
puts "ERROR: no GTD_LOGIN environment variable set"
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
if ENV['GTD_PASSWORD'] == nil
|
||||
puts "ERROR: no GTD_PASSWORD environment variable set"
|
||||
exit 1
|
||||
end
|
||||
|
||||
|
||||
file = @filename.nil? ? STDIN : File.open(@filename)
|
||||
|
||||
|
||||
## check for existence of the context
|
||||
if @options[:context_id].nil?
|
||||
puts "ERROR: need to specify a context_id with -c option."
|
||||
|
|
|
@ -12,11 +12,11 @@ module LoginSystem
|
|||
# Logout the {#current_user} and redirect to login page
|
||||
#
|
||||
# @param [String] message notification to display
|
||||
def logout_user message=t('login.logged_out')
|
||||
def logout_user(message=t('login.logged_out'))
|
||||
@user.forget_me if logged_in?
|
||||
cookies.delete :auth_token
|
||||
session['user_id'] = nil
|
||||
if ( SITE_CONFIG['authentication_schemes'].include? 'cas') && session[:cas_user]
|
||||
if SITE_CONFIG['authentication_schemes'].include?('cas') && session[:cas_user]
|
||||
CASClient::Frameworks::Rails::Filter.logout(self)
|
||||
else
|
||||
reset_session
|
||||
|
@ -36,7 +36,7 @@ module LoginSystem
|
|||
# user.login != "bob"
|
||||
# end
|
||||
def authorize?(user)
|
||||
true
|
||||
true
|
||||
end
|
||||
|
||||
# overwrite this method if you only want to protect certain actions of the controller
|
||||
|
@ -78,7 +78,7 @@ module LoginSystem
|
|||
end
|
||||
# Allow also login based on auth data
|
||||
auth = get_basic_auth_data
|
||||
if user = User.where(:login => auth[:user], :token => auth[:pass]).first
|
||||
if (user = User.where(:login => auth[:user], :token => auth[:pass]).first)
|
||||
set_current_user(user)
|
||||
return true
|
||||
end
|
||||
|
@ -102,12 +102,12 @@ module LoginSystem
|
|||
|
||||
login_from_cookie
|
||||
|
||||
if session['user_id'] and authorize?(get_current_user)
|
||||
if session['user_id'] && authorize?(get_current_user)
|
||||
return true
|
||||
end
|
||||
|
||||
auth = get_basic_auth_data
|
||||
if user = User.authenticate(auth[:user], auth[:pass])
|
||||
if (user = User.authenticate(auth[:user], auth[:pass]))
|
||||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
return true
|
||||
|
@ -125,12 +125,12 @@ module LoginSystem
|
|||
def login_optional
|
||||
login_from_cookie
|
||||
|
||||
if session['user_id'] and authorize?(get_current_user)
|
||||
if session['user_id'] && authorize?(get_current_user)
|
||||
return true
|
||||
end
|
||||
|
||||
auth = get_basic_auth_data
|
||||
if user = User.authenticate(auth[:user], auth[:pass])
|
||||
if (user = User.authenticate(auth[:user], auth[:pass]))
|
||||
session['user_id'] = user.id
|
||||
set_current_user(user)
|
||||
return true
|
||||
|
@ -197,7 +197,7 @@ module LoginSystem
|
|||
authdata = request.env[location].to_s.split
|
||||
end
|
||||
end
|
||||
if authdata and authdata[0] == 'Basic'
|
||||
if authdata && authdata[0] == 'Basic'
|
||||
data = Base64.decode64(authdata[1]).split(':')[0..1]
|
||||
{
|
||||
user: data[0],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
namespace :ci do
|
||||
desc 'Continuous integration tests, without features'
|
||||
task :lite do
|
||||
ENV['RAILS_ENV'] ||= "test"
|
||||
ENV['RAILS_ENV'] ||= "test"
|
||||
|
||||
puts 'Running "lite" test suite'
|
||||
|
||||
|
|
|
@ -2,20 +2,20 @@ namespace :tracks do
|
|||
desc 'Replace the password of USER with a new one.'
|
||||
task :password => :environment do
|
||||
require "io/console"
|
||||
|
||||
|
||||
user = User.find_by_login(ENV['USER'])
|
||||
if user.nil?
|
||||
puts "Sorry, we couldn't find user '#{ENV['USER']}'. To specify a different user, pass USER=username to this task."
|
||||
exit 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
puts "Changing Tracks password for #{ENV['USER']}."
|
||||
print "New password: "
|
||||
password = STDIN.noecho(&:gets).chomp
|
||||
print "\nRetype new password: "
|
||||
password_confirmation = STDIN.noecho(&:gets).chomp
|
||||
puts
|
||||
|
||||
|
||||
begin
|
||||
user.change_password(password, password_confirmation)
|
||||
puts "Password changed."
|
||||
|
@ -25,4 +25,3 @@ namespace :tracks do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ module Tracks
|
|||
module SourceViewSwitching
|
||||
class Responder
|
||||
def initialize(source_view)
|
||||
@source_view = source_view.underscore.gsub(/\s+/,'_').to_sym rescue nil
|
||||
@source_view = source_view.underscore.gsub(/\s+/, '_').to_sym rescue nil
|
||||
end
|
||||
|
||||
def nil?
|
||||
|
@ -41,7 +41,7 @@ module Tracks
|
|||
|
||||
module Helper
|
||||
def source_view_tag(name)
|
||||
hidden_field_tag :_source_view, name.underscore.gsub(/\s+/,'_')
|
||||
hidden_field_tag :_source_view, name.underscore.gsub(/\s+/, '_')
|
||||
end
|
||||
|
||||
def source_view_is(s)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue