Changeset 1590
- Timestamp:
- 07/05/08 17:26:50 (2 months ago)
- Files:
-
- agitator/TODO (modified) (1 diff)
- agitator/app/controllers/reminder_controller.rb (modified) (3 diffs)
- agitator/app/helpers/application_helper.rb (modified) (1 diff)
- agitator/app/helpers/notifier_helper.rb (modified) (1 diff)
- agitator/app/models/tag.rb (added)
- agitator/app/models/user.rb (modified) (1 diff)
- agitator/app/views/notifier/daily_notification.rhtml (modified) (2 diffs)
- agitator/app/views/reminder/home.rhtml (modified) (1 diff)
- agitator/app/views/reminder/send_daily.rhtml (modified) (1 diff)
- agitator/app/views/widgets/_home_guts.rhtml (added)
- agitator/app/views/widgets/_link_list.rhtml (modified) (2 diffs)
- agitator/app/views/widgets/_login_form.rhtml (modified) (2 diffs)
- agitator/config/routes.rb (modified) (2 diffs)
- agitator/db/migrate/003_create_tags.rb (added)
- agitator/db/schema.rb (modified) (1 diff)
- agitator/test/fixtures/tags.yml (added)
- agitator/test/unit/tag_test.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
agitator/TODO
r1578 r1590 1 * everything next is in reminder controller (persistence for reminders) 1 NEXT 2 sort tags by usage 3 everything next is in reminder controller (persistence for reminders) 4 print list of tags in browser 5 6 NICETOHAVE 7 make app.post '/login', { :bookmarking_username => 'jm3', :bookmarking_password => '****' } work despite the rails form forgery stuff 8 get an inspectable session of the app going (ie. call the controll with the del login creds and then inspect the data structure 9 10 DONE 11 get basic login and logout working 12 set up db alias 13 hide login form if already logged in agitator/app/controllers/reminder_controller.rb
r1586 r1590 7 7 # FIXME: need persistence here for the tags + email address... 8 8 def send_daily 9 Notifier.deliver_daily_notification( "jm3@jm3.net", ["work", "todo"] )9 #Notifier.deliver_daily_notification( "jm3@jm3.net", ["work", "todo"] ) 10 10 end 11 11 … … 17 17 tags = get_tags_for_user( session[:bookmarking_username], session[:bookmarking_password] ) 18 18 if tags != nil 19 @tags = tags .length.to_s + " tags found"19 @tags = tags 20 20 else 21 21 @message = "Ordinarily you would see your (cached) #{BOOKMARKING_NAME} tags here but Rails is being a bitch about it." … … 32 32 def get_tags_for_user( u, p ) 33 33 tags_file = get_tags_file( u ) 34 if ! File.exist ?(tags_file)34 if ! File.exists?(tags_file) 35 35 refresh_cached_tags( u, p ) 36 36 end 37 37 xml_obj = Document.new(File.new(tags_file)) 38 38 tags = xml_obj.elements.to_a( "/tags/tag" ) 39 return tags 39 40 # tags come back in the form: <tag tag='tumblr' count='1'/> 41 logger.debug( "..................................." ) 42 logger.debug( "* found " + tags.length.to_s + " tags") 43 sorted_tags = [tags.length] 44 c = 0 45 tags.each{ |t| 46 sorted_tags[c] = t.attributes['count'] + " " + t.attributes['tag'] 47 sorted_tags.sort!.reverse! 48 logger.debug( t.to_s ) 49 c += 1 50 } 51 sorted_tags.each{ |t| 52 logger.debug( t ) 53 } 40 54 end 41 55 agitator/app/helpers/application_helper.rb
r1565 r1590 4 4 `svn info #{RAILS_ROOT} | grep Revision`.gsub( /Revision: /, "" ).chop + " at " + Time.now.to_s 5 5 end 6 7 def get_tag_as_html( tag_string, user ) 8 return '<a href="http://' + BOOKMARKING_NAME + '/' + user + '/' + tag_string.split[1] + '">' + tag_string.split[1] + '(' + tag_string.split[0] + ')</a>' 9 end 10 11 def get_tag_picker( tags, user ) 12 return 'a list with checkboxes' 13 end 6 14 end agitator/app/helpers/notifier_helper.rb
r1574 r1590 4 4 5 5 def get_links_for_tag( u, tag ) 6 file = File.new(RAILS_ROOT + "/tmp/API_cache/" + u + "/" + tag + ".xml") 7 doc = Document.new(file) 8 links = doc.elements.to_a( "/posts/post" ) 6 if u and tag 7 fname = RAILS_ROOT + "/tmp/API_cache/" + u + "/" + tag + ".xml" 8 fname = "/tmp/write.txt" 9 else 10 return [] 11 end 12 if File.exists?( fname ) 13 file = File.new(fname, "w+") 14 return [] 15 doc = Document.new(file) 16 links = doc.elements.to_a( "/posts/post" ) 17 else 18 [] 19 end 9 20 end 10 21 agitator/app/models/user.rb
r1577 r1590 1 1 class User < ActiveRecord::Base 2 has_many :tags 2 3 end agitator/app/views/notifier/daily_notification.rhtml
r1574 r1590 10 10 <% 11 11 @tags.each{ |tag| 12 links = get_links_for_tag( BOOKMARKING_API_USERNAME, tag )12 links = get_links_for_tag( BOOKMARKING_API_USERNAME, tag ) 13 13 %> 14 14 … … 19 19 20 20 <% } %> 21 21 22 <br /> 22 23 agitator/app/views/reminder/home.rhtml
r1582 r1590 1 < h2>HOME</h2>1 <%= render :partial => "widgets/home_guts", :locals => {:u => session[:bookmarking_username], :p => session[:bookmarking_password]} %> 2 2 3 Welcome, <%= @u %>.4 5 <p>6 <%= @message %>7 </p>8 9 <p>10 Coming soon:11 <li>pick from any of your <%= BOOKMARKING_NAME %> tags.</li>12 <li>configurable, persistent mail reminders.</li>13 <li>choose what email address gets which reminder.</li>14 </p>15 16 Currently we can dynamically download your list of tags,<br />17 but since sorting's not done yet, you'll have to wait. :-(18 <p>19 <h1><%= @tags %></h1>20 </p>agitator/app/views/reminder/send_daily.rhtml
r1551 r1590 1 sent, bitch! 1 SENDING DISABLED WHILE IN DEBUG MODE 2 <% # sent, bitch! %> agitator/app/views/widgets/_link_list.rhtml
r1554 r1590 1 <% 2 if links and links.length > 0 3 %> 1 4 <h1> 2 5 <%= NUM_LINKS_FOR_ALL_TAGS %> <%= random ? kooky_random_string : "most recent" %> links tagged “<%= tag %>”: … … 16 19 </ul> 17 20 </big> 21 <% 22 else 23 # FIXME throw exception here 24 end 25 %> agitator/app/views/widgets/_login_form.rhtml
r1575 r1590 1 <% 2 if session[:bookmarking_username] 3 %> 4 5 <small> 6 <%= render :partial => "widgets/home_guts", :locals => {:u => session[:bookmarking_username], :p => session[:bookmarking_password]} %> 7 </small> 8 9 <% 10 else 11 %> 12 1 13 <%= form_tag('/login', :method => :post, :onsubmit => "return validate_login(this);", :id => "login" ) %> 2 14 <h1>Log in:</h1> … … 16 28 17 29 </form> 30 <% 31 end 32 %> agitator/config/routes.rb
r1569 r1590 1 1 ActionController::Routing::Routes.draw do |map| 2 # The priority is based upon order of creation: first created -> highest priority.3 4 # Sample of regular route:5 # map.connect 'products/:id', :controller => 'catalog', :action => 'view'6 # Keep in mind you can assign values other than :controller and :action7 8 # named routes:9 # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'10 # This route can be invoked with purchase_url(:id => product.id)11 2 12 map.notifier 'send',:controller => 'reminder', :action => 'send_daily'3 map.notifier 'send', :controller => 'reminder', :action => 'send_daily' 13 4 14 5 map.login 'login', :controller => 'access', :action => 'login' … … 16 7 map.apply_for_beta 'apply_for_beta', :controller => 'access', :action => 'apply_for_beta' 17 8 18 # You can have the root of your site routed with map.root -- just remember to delete public/index.html.19 9 map.root :controller => "reminder" 20 10 21 11 # See how all your routes lay out with "rake routes" 22 12 23 # Install the default routes as the lowest priority.24 13 map.connect ':controller/:action/:id' 25 14 map.connect ':controller/:action/:id.:format' agitator/db/schema.rb
r1577 r1590 10 10 # It's strongly recommended to check this file into your version control system. 11 11 12 ActiveRecord::Schema.define(:version => 2) do12 ActiveRecord::Schema.define(:version => 3) do 13 13 14 14 create_table "reminders", :force => true do |t| 15 t.string "tag" 16 t.string "email" 17 t.integer "frequency" 18 t.datetime "created_at" 19 t.datetime "updated_at" 20 end 21 22 create_table "tags", :force => true do |t| 23 t.string "name" 24 t.integer "num_links" 15 25 t.datetime "created_at" 16 26 t.datetime "updated_at"