Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix text feeds

  • Loading branch information...
commit 436cc862d6c43ab5050de6422c0046702cd480b9 1 parent f513e66
Reinier Balt authored May 20, 2012
48  Gemfile.lock
@@ -2,7 +2,7 @@ GEM
2 2
   remote: https://rubygems.org/
3 3
   specs:
4 4
     RedCloth (4.2.9)
5  
-    aasm (3.0.5)
  5
+    aasm (3.0.6)
6 6
       activerecord
7 7
     actionmailer (3.2.3)
8 8
       actionpack (= 3.2.3)
@@ -32,7 +32,7 @@ GEM
32 32
       i18n (~> 0.6)
33 33
       multi_json (~> 1.0)
34 34
     acts_as_list (0.1.6)
35  
-    addressable (2.2.7)
  35
+    addressable (2.2.8)
36 36
     arel (3.0.2)
37 37
     aruba (0.4.11)
38 38
       childprocess (>= 0.2.3)
@@ -57,13 +57,12 @@ GEM
57 57
     coffee-script (2.2.0)
58 58
       coffee-script-source
59 59
       execjs
60  
-    coffee-script-source (1.3.1)
61  
-    cucumber (1.1.9)
  60
+    coffee-script-source (1.3.3)
  61
+    cucumber (1.2.0)
62 62
       builder (>= 2.1.2)
63  
-      diff-lcs (>= 1.1.2)
64  
-      gherkin (~> 2.9.0)
  63
+      diff-lcs (>= 1.1.3)
  64
+      gherkin (~> 2.10.0)
65 65
       json (>= 1.4.6)
66  
-      term-ansicolor (>= 1.0.6)
67 66
     cucumber-rails (1.3.0)
68 67
       capybara (>= 1.1.2)
69 68
       cucumber (>= 1.1.8)
@@ -72,12 +71,12 @@ GEM
72 71
     database_cleaner (0.7.2)
73 72
     diff-lcs (1.1.3)
74 73
     erubis (2.7.0)
75  
-    execjs (1.3.1)
  74
+    execjs (1.3.2)
76 75
       multi_json (~> 1.0)
77  
-    factory_girl (3.2.0)
  76
+    factory_girl (3.3.0)
78 77
       activesupport (>= 3.0.0)
79  
-    factory_girl_rails (3.2.0)
80  
-      factory_girl (~> 3.2.0)
  78
+    factory_girl_rails (3.3.0)
  79
+      factory_girl (~> 3.3.0)
81 80
       railties (>= 3.0.0)
82 81
     ffi (1.0.11)
83 82
     formatize (1.1.0)
@@ -85,7 +84,7 @@ GEM
85 84
       actionpack (~> 3.0)
86 85
       bluecloth (~> 2.2)
87 86
     gem_plugin (0.2.3)
88  
-    gherkin (2.9.3)
  87
+    gherkin (2.10.0)
89 88
       json (>= 1.4.6)
90 89
     hike (1.2.1)
91 90
     htmlentities (4.3.1)
@@ -94,7 +93,7 @@ GEM
94 93
     jquery-rails (2.0.2)
95 94
       railties (>= 3.2.0, < 5.0)
96 95
       thor (~> 0.14)
97  
-    json (1.6.6)
  96
+    json (1.7.3)
98 97
     libwebsocket (0.1.3)
99 98
       addressable
100 99
     mail (2.4.4)
@@ -105,7 +104,7 @@ GEM
105 104
     mongrel (1.2.0.pre2)
106 105
       daemons (~> 1.0.10)
107 106
       gem_plugin (~> 0.2.3)
108  
-    multi_json (1.3.2)
  107
+    multi_json (1.3.5)
109 108
     mysql2 (0.3.11)
110 109
     nokogiri (1.5.2)
111 110
     polyglot (0.3.3)
@@ -124,7 +123,7 @@ GEM
124 123
       activesupport (= 3.2.3)
125 124
       bundler (~> 1.0)
126 125
       railties (= 3.2.3)
127  
-    rails_autolink (1.0.6)
  126
+    rails_autolink (1.0.7)
128 127
       rails (~> 3.1)
129 128
     railties (3.2.3)
130 129
       actionpack (= 3.2.3)
@@ -136,18 +135,18 @@ GEM
136 135
     rake (0.9.2.2)
137 136
     rdoc (3.12)
138 137
       json (~> 1.4)
139  
-    rspec (2.9.0)
140  
-      rspec-core (~> 2.9.0)
141  
-      rspec-expectations (~> 2.9.0)
142  
-      rspec-mocks (~> 2.9.0)
143  
-    rspec-core (2.9.0)
144  
-    rspec-expectations (2.9.1)
  138
+    rspec (2.10.0)
  139
+      rspec-core (~> 2.10.0)
  140
+      rspec-expectations (~> 2.10.0)
  141
+      rspec-mocks (~> 2.10.0)
  142
+    rspec-core (2.10.0)
  143
+    rspec-expectations (2.10.0)
145 144
       diff-lcs (~> 1.1.3)
146  
-    rspec-mocks (2.9.0)
  145
+    rspec-mocks (2.10.1)
147 146
     rubyzip (0.9.8)
148 147
     sanitize (2.0.3)
149 148
       nokogiri (>= 1.4.4, < 1.6)
150  
-    sass (3.1.16)
  149
+    sass (3.1.18)
151 150
     sass-rails (3.2.5)
152 151
       railties (~> 3.2.0)
153 152
       sass (>= 3.1.10)
@@ -166,7 +165,6 @@ GEM
166 165
     swf_fu (2.0.2)
167 166
       coffee-script
168 167
       rails (>= 3.1)
169  
-    term-ansicolor (1.0.7)
170 168
     thor (0.14.6)
171 169
     tilt (1.3.3)
172 170
     treetop (1.4.10)
@@ -179,7 +177,7 @@ GEM
179 177
     will_paginate (3.0.3)
180 178
     xpath (0.1.4)
181 179
       nokogiri (~> 1.3)
182  
-    yard (0.7.5)
  180
+    yard (0.8.1)
183 181
 
184 182
 PLATFORMS
185 183
   ruby
2  app/controllers/contexts_controller.rb
@@ -31,6 +31,8 @@ def index
31 31
         @feed_description = "Lists all the contexts for #{current_user.display_name}"
32 32
       end
33 33
       format.text do
  34
+        # somehow passing Mime::TEXT using content_type to render does not work
  35
+        headers['Content-Type']=Mime::TEXT.to_s
34 36
         render :action => 'index', :layout => false, :content_type => Mime::TEXT
35 37
       end
36 38
       format.autocomplete &render_autocomplete
92  app/controllers/projects_controller.rb
@@ -21,10 +21,24 @@ def index
21 21
         @projects = current_user.projects.all
22 22
       end
23 23
       @new_project = current_user.projects.build
  24
+      @active_projects = current_user.projects.active
  25
+      @hidden_projects = current_user.projects.hidden
24 26
       respond_to do |format|
25  
-        format.html  &render_projects_html
26  
-        format.m     &render_projects_mobile
27  
-        format.xml   { render :xml => @projects.to_xml( :except => :user_id )  }
  27
+        format.html  do
  28
+          @page_title = t('projects.list_projects')
  29
+          @count = current_user.projects.count
  30
+          @completed_projects = current_user.projects.completed.limit(10)
  31
+          @completed_count = current_user.projects.completed.count
  32
+          @no_projects = current_user.projects.empty?
  33
+          current_user.projects.cache_note_counts
  34
+          @new_project = current_user.projects.build
  35
+        end
  36
+        format.m     do
  37
+          @completed_projects = current_user.projects.completed
  38
+          @down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size
  39
+          cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
  40
+        end
  41
+        format.xml   { render :xml => @projects.all.to_xml( :except => :user_id )  }
28 42
         format.rss   do
29 43
           @feed_title = I18n.t('models.project.feed_title')
30 44
           @feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
@@ -33,8 +47,14 @@ def index
33 47
           @feed_title = I18n.t('models.project.feed_title')
34 48
           @feed_description = I18n.t('models.project.feed_description', :username => current_user.display_name)
35 49
         end
36  
-        format.text
37  
-        format.autocomplete &render_autocomplete
  50
+        format.text do
  51
+          # somehow passing Mime::TEXT using content_type to render does not work
  52
+          headers['Content-Type']=Mime::TEXT.to_s
  53
+        end
  54
+        format.autocomplete do
  55
+          projects = current_user.projects.active + current_user.projects.hidden
  56
+          render :text => for_autocomplete(projects, params[:term])
  57
+        end
38 58
       end
39 59
     end
40 60
   end
@@ -97,6 +117,8 @@ def projects_and_actions
97 117
     @projects = current_user.projects.active
98 118
     respond_to do |format|
99 119
       format.text  {
  120
+        # somehow passing Mime::TEXT using content_type to render does not work
  121
+        headers['Content-Type']=Mime::TEXT.to_s
100 122
         render :action => 'index_text_projects_and_actions', :layout => false, :content_type => Mime::TEXT
101 123
       }
102 124
     end
@@ -127,15 +149,23 @@ def show
127 149
     @contexts = current_user.contexts
128 150
     respond_to do |format|
129 151
       format.html
130  
-      format.m     &render_project_mobile
131  
-      format.xml   {
  152
+      format.m     do
  153
+        if @project.default_context.nil?
  154
+          @project_default_context = t('projects.no_default_context')
  155
+        else
  156
+          @project_default_context = t('projects.default_context', :context => @project.default_context.name)
  157
+        end
  158
+        cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
  159
+        @mobile_from_project = @project.id
  160
+      end
  161
+      format.xml   do
132 162
         render :xml => @project.to_xml(:except => :user_id) { |xml|
133 163
           xml.not_done { @not_done.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
134 164
           xml.deferred { @deferred.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
135 165
           xml.pending { @pending.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
136 166
           xml.done { @done.each { |child| child.to_xml(:builder => xml, :skip_instruct => true) } }
137 167
         }
138  
-      }
  168
+      end
139 169
     end
140 170
   end
141 171
 
@@ -302,53 +332,7 @@ def update_state_counts
302 332
     @show_hidden_projects = @hidden_projects_count > 0
303 333
     @show_completed_projects = @completed_projects_count > 0
304 334
   end
305  
-
306  
-  def render_projects_html
307  
-    lambda do
308  
-      @page_title = t('projects.list_projects')
309  
-      @count = current_user.projects.count
310  
-      @active_projects = current_user.projects.active
311  
-      @hidden_projects = current_user.projects.hidden
312  
-      @completed_projects = current_user.projects.completed.limit(10)
313  
-      @completed_count = current_user.projects.completed.count
314  
-      @no_projects = current_user.projects.empty?
315  
-      current_user.projects.cache_note_counts
316  
-      @new_project = current_user.projects.build
317  
-      render
318  
-    end
319  
-  end
320  
-
321  
-  def render_projects_mobile
322  
-    lambda do
323  
-      @active_projects = current_user.projects.active
324  
-      @hidden_projects = current_user.projects.hidden
325  
-      @completed_projects = current_user.projects.completed
326  
-      @down_count = @active_projects.size + @hidden_projects.size + @completed_projects.size
327  
-      cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
328  
-      render
329  
-    end
330  
-  end
331  
-
332  
-  def render_project_mobile
333  
-    lambda do
334  
-      if @project.default_context.nil?
335  
-        @project_default_context = t('projects.no_default_context')
336  
-      else
337  
-        @project_default_context = t('projects.default_context', :context => @project.default_context.name)
338  
-      end
339  
-      cookies[:mobile_url]= {:value => request.fullpath, :secure => SITE_CONFIG['secure_cookies']}
340  
-      @mobile_from_project = @project.id
341  
-      render
342  
-    end
343  
-  end
344 335
   
345  
-  def render_autocomplete
346  
-    lambda do
347  
-      projects = current_user.projects.active + current_user.projects.hidden
348  
-      render :text => for_autocomplete(projects, params[:term])
349  
-    end
350  
-  end
351  
-
352 336
   def set_project_from_params
353 337
     @project = current_user.projects.find_by_params(params)
354 338
   end
112  app/controllers/todos_controller.rb
@@ -11,55 +11,6 @@ class TodosController < ApplicationController
11 11
 
12 12
   protect_from_forgery :except => :check_deferred
13 13
 
14  
-  def with_feed_query_scope(&block)
15  
-    unless TodosController.is_feed_request(request)
16  
-      Todo.send(:where, ['todos.state = ?', 'active']) do
17  
-        yield
18  
-        return
19  
-      end
20  
-    end
21  
-    condition_builder = FindConditionBuilder.new
22  
-
23  
-    if params.key?('done')
24  
-      condition_builder.add 'todos.state = ?', 'completed'
25  
-    else
26  
-      condition_builder.add 'todos.state = ?', 'active'
27  
-    end
28  
-
29  
-    @title = t('todos.next_actions_title')
30  
-    @description = t('todos.next_actions_description')
31  
-
32  
-    if params.key?('due')
33  
-      due_within = params['due'].to_i
34  
-      due_within_when = Time.zone.now + due_within.days
35  
-      condition_builder.add('todos.due <= ?', due_within_when)
36  
-      due_within_date_s = due_within_when.strftime("%Y-%m-%d")
37  
-      @title << t('todos.next_actions_title_additions.due_today') if (due_within == 0)
38  
-      @title << t('todos.next_actions_title_additions.due_within_a_week') if (due_within == 6)
39  
-      @description << t('todos.next_actions_description_additions.due_date', :due_date => due_within_date_s)
40  
-    end
41  
-
42  
-    if params.key?('done')
43  
-      done_in_last = params['done'].to_i
44  
-      condition_builder.add('todos.completed_at >= ?', Time.zone.now - done_in_last.days)
45  
-      @title << t('todos.next_actions_title_additions.completed')
46  
-      @description << t('todos.next_actions_description_additions.completed', :count => done_in_last.to_s)
47  
-    end
48  
-
49  
-    if params.key?('tag')
50  
-      tag = Tag.find_by_name(params['tag'])
51  
-      if tag.nil?
52  
-        tag = Tag.new(:name => params['tag'])
53  
-      end
54  
-      condition_builder.add('taggings.tag_id = ?', tag.id)
55  
-    end
56  
-
57  
-    Todo.send :where, condition_builder.to_conditions do
58  
-      yield
59  
-    end
60  
-
61  
-  end
62  
-
63 14
   def with_parent_resource_scope(&block)
64 15
     @feed_title = t('common.actions')
65 16
     if (params[:context_id])
@@ -79,38 +30,43 @@ def with_parent_resource_scope(&block)
79 30
       yield
80 31
     end
81 32
   end
82  
-
83  
-  def with_limit_scope(&block)
84  
-    if params.key?('limit')
85  
-      Todo.send :with_scope, :find => { :limit => params['limit'] } do
86  
-        yield
87  
-      end
88  
-      if TodosController.is_feed_request(request) && @description
89  
-        if params.key?('limit')
90  
-          @description << t('todos.list_incomplete_next_actions_with_limit', :count => params['limit'])
91  
-        else
92  
-          @description << t('todos.list_incomplete_next_actions')
93  
-        end
94  
-      end
95  
-    else
96  
-      yield
97  
-    end
98  
-  end
99 33
   
100 34
   def index
101 35
     @source_view = params['_source_view'] || 'todo'
102 36
     init_data_for_sidebar unless mobile?
103 37
     
104  
-    if mobile?
105  
-      @not_done_todos = current_user.todos.
106  
-        where('todos.state = ? AND contexts.hide = ? AND (projects.state = ? OR todos.project_id IS NULL)', 'active', false, 'active').
107  
-        reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").
108  
-        includes(:project, :context, :tags)
  38
+    @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES)
  39
+    
  40
+    # TODO: refactor text feed for done todos to todos/done.text, not /todos.text?done=true
  41
+    if params[:done]
  42
+      @not_done_todos = current_user.todos.completed.completed_after(Time.zone.now - params[:done].to_i.days)
109 43
     else
110  
-      @todos = current_user.todos.includes(Todo::DEFAULT_INCLUDES)
111  
-      @not_done_todos = current_user.todos.active.not_hidden.
112  
-        reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").
113  
-        includes(Todo::DEFAULT_INCLUDES)
  44
+      @not_done_todos = current_user.todos.active.not_hidden
  45
+    end
  46
+    
  47
+    @not_done_todos = @not_done_todos.
  48
+      reorder("todos.due IS NULL, todos.due ASC, todos.created_at ASC").
  49
+      includes(Todo::DEFAULT_INCLUDES)
  50
+    @not_done_todos = @not_done_todos.limit(sanitize(params[:limit])) if params[:limit]
  51
+    
  52
+    if params[:due]
  53
+      due_within_when = Time.zone.now + params['due'].to_i.days
  54
+      @not_done_todos = @not_done_todos.where('todos.due <= ?', due_within_when)
  55
+    end
  56
+    
  57
+    if params[:tag]
  58
+      tag = Tag.find_by_name(params['tag'])
  59
+      @not_done_todos = @not_done_todos.where('taggings.tag_id = ?', tag.id)
  60
+    end
  61
+    
  62
+    if params[:context_id]
  63
+      context = current_user.contexts.find(params[:context_id])
  64
+      @not_done_todos = @not_done_todos.where('context_id' => context.id)
  65
+    end
  66
+    
  67
+    if params[:project_id]
  68
+      project = current_user.projects.find(params[:project_id])
  69
+      @not_done_todos = @not_done_todos.where('project_id' => project)
114 70
     end
115 71
     
116 72
     @projects = current_user.projects.includes(:default_context)
@@ -137,10 +93,14 @@ def index
137 93
   
138 94
         render :action => 'index'
139 95
       end
  96
+      format.text  do
  97
+        # somehow passing Mime::TEXT using content_type to render does not work
  98
+        headers['Content-Type']=Mime::TEXT.to_s
  99
+        render :content_type => Mime::TEXT
  100
+      end
140 101
       format.xml   { render :xml => @todos.to_xml( *to_xml_params ) }
141 102
       format.rss   { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
142 103
       format.atom  { @feed_title, @feed_description = 'Tracks Actions', "Actions for #{current_user.display_name}" }
143  
-      format.text
144 104
       format.ics
145 105
     end
146 106
   end
4  app/helpers/feedlist_helper.rb
@@ -8,12 +8,12 @@ def rss_formatted_link(options = {})
8 8
 
9 9
   def text_formatted_link(options = {})
10 10
     linkoptions = merge_hashes( {:format => 'txt'}, user_token_hash, options)
11  
-    link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}, linkoptions))
  11
+    link_to(content_tag(:span, 'TXT', {:class => 'feed', :title => "Plain text feed"}), linkoptions)
12 12
   end
13 13
   
14 14
   def ical_formatted_link(options = {})
15 15
     linkoptions = merge_hashes( {:format => 'ics'}, user_token_hash, options)
16  
-    link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}, linkoptions))
  16
+    link_to(content_tag(:span, 'iCal', {:class=>"feed", :title => "iCal feed"}), linkoptions)
17 17
   end
18 18
 
19 19
   def feed_links(feeds, link_options, title)
5  app/views/projects/index_text_projects_and_actions.rhtml
... ...
@@ -1,5 +0,0 @@
1  
-<% @projects.each do |p| -%>
2  
-<%= p.name.upcase -%>
3  
-<% actions = p.todos.select { |t| t.active? } -%>  
4  
-<%= render :partial => "todos/text_todo", :collection => actions -%>
5  
-<% end -%>
5  app/views/projects/index_text_projects_and_actions.text.erb
... ...
@@ -0,0 +1,5 @@
  1
+<% @projects.each do |p| -%>
  2
+<%= p.name.upcase -%>
  3
+<% actions = p.todos.select { |t| t.active? } -%>
  4
+<%= render :partial => actions -%>
  5
+<% end -%>
35  config/initializers/tracks.rb
... ...
@@ -1,38 +1,3 @@
1  
-#require 'name_part_finder'
2  
-#require 'tracks/todo_list'
3  
-#require 'tracks/config'
4  
-#require 'tagging_extensions' # Needed for tagging-specific extensions
5  
-# require 'digest/sha1' #Needed to support 'rake db:fixtures:load' on some ruby installs: http://dev.rousette.org.uk/ticket/557
6  
-
7  
-# TODO: move to devise for authentication which handles ldap, cas and openid
8  
-if ( SITE_CONFIG['authentication_schemes'].include? 'ldap')
9  
-  require 'net/ldap' #requires ruby-net-ldap gem be installed
10  
-  require 'simple_ldap_authenticator'
11  
-  ldap =  SITE_CONFIG['ldap']
12  
-  SimpleLdapAuthenticator.ldap_library = ldap['library']
13  
-  SimpleLdapAuthenticator.servers = ldap['servers']
14  
-  SimpleLdapAuthenticator.use_ssl = ldap['ssl']
15  
-  SimpleLdapAuthenticator.login_format = ldap['login_format']
16  
-end
17  
-
18  
-# OpenID is not supported currently!
19  
-#
20  
-# if ( SITE_CONFIG['authentication_schemes'].include? 'open_id')
21  
-#   #requires ruby-openid gem to be installed
22  
-#   OpenID::Util.logger = RAILS_DEFAULT_LOGGER
23  
-# end
24  
-
25  
-if ( SITE_CONFIG['authentication_schemes'].include? 'cas')
26  
-  #requires rubycas-client gem to be installed
27  
-  if defined? CASClient
28  
-    require 'casclient/frameworks/rails/filter'
29  
-    CASClient::Frameworks::Rails::Filter.configure(
30  
-        :cas_base_url => SITE_CONFIG['cas_server'] ,
31  
-        :cas_server_logout => SITE_CONFIG['cas_server_logout']
32  
-      )
33  
-  end
34  
-end
35  
-
36 1
 # changed in development.rb to show under_construction bar
37 2
 NOTIFY_BAR = "" unless defined?(NOTIFY_BAR)
38 3
 

0 notes on commit 436cc86

Please sign in to comment.
Something went wrong with that request. Please try again.