Changeset 1590

Show
Ignore:
Timestamp:
07/05/08 17:26:50 (2 months ago)
Author:
jm3
Message:

yeah, digging out / digging deeper

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • agitator/TODO

    r1578 r1590  
    1  * everything next is in reminder controller (persistence for reminders) 
     1NEXT 
     2  sort tags by usage 
     3  everything next is in reminder controller (persistence for reminders) 
     4  print list of tags in browser 
     5 
     6NICETOHAVE 
     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 
     10DONE 
     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  
    77  # FIXME: need persistence here for the tags + email address... 
    88  def send_daily 
    9     Notifier.deliver_daily_notification( "jm3@jm3.net", ["work", "todo"] ) 
     9    #Notifier.deliver_daily_notification( "jm3@jm3.net", ["work", "todo"] ) 
    1010  end 
    1111   
     
    1717    tags = get_tags_for_user( session[:bookmarking_username], session[:bookmarking_password] ) 
    1818    if tags != nil 
    19       @tags = tags.length.to_s + " tags found" 
     19      @tags = tags 
    2020    else 
    2121      @message = "Ordinarily you would see your (cached) #{BOOKMARKING_NAME} tags here but Rails is being a bitch about it." 
     
    3232  def get_tags_for_user( u, p ) 
    3333    tags_file = get_tags_file( u ) 
    34     if ! File.exist?(tags_file) 
     34    if ! File.exists?(tags_file) 
    3535      refresh_cached_tags( u, p ) 
    3636    end 
    3737    xml_obj = Document.new(File.new(tags_file)) 
    3838    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    } 
    4054  end 
    4155 
  • agitator/app/helpers/application_helper.rb

    r1565 r1590  
    44    `svn info  #{RAILS_ROOT} | grep Revision`.gsub( /Revision: /, "" ).chop + " at " + Time.now.to_s 
    55  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 
    614end 
  • agitator/app/helpers/notifier_helper.rb

    r1574 r1590  
    44 
    55  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 
    920  end 
    1021 
  • agitator/app/models/user.rb

    r1577 r1590  
    11class User < ActiveRecord::Base 
     2  has_many :tags 
    23end 
  • agitator/app/views/notifier/daily_notification.rhtml

    r1574 r1590  
    1010<% 
    1111  @tags.each{ |tag| 
    12     links = get_links_for_tag( BOOKMARKING_API_USERNAME, tag ) 
     12  links = get_links_for_tag( BOOKMARKING_API_USERNAME, tag ) 
    1313%> 
    1414 
     
    1919 
    2020<% } %> 
     21 
    2122<br /> 
    2223 
  • 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]} %
    22 
    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! 
     1SENDING 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%> 
    14<h1> 
    25  <%= NUM_LINKS_FOR_ALL_TAGS %> <%= random ? kooky_random_string : "most recent" %> links tagged &ldquo;<%= tag %>&rdquo;: 
     
    1619  </ul> 
    1720</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 
    113<%= form_tag('/login', :method => :post, :onsubmit => "return validate_login(this);", :id => "login" ) %> 
    214        <h1>Log in:</h1> 
     
    1628         
    1729</form> 
     30<% 
     31  end 
     32%> 
  • agitator/config/routes.rb

    r1569 r1590  
    11ActionController::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 :action 
    7  
    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) 
    112   
    12   map.notifier 'send',   :controller => 'reminder', :action => 'send_daily'   
     3  map.notifier       'send',           :controller => 'reminder', :action => 'send_daily'   
    134   
    145  map.login          'login',          :controller => 'access',   :action => 'login' 
     
    167  map.apply_for_beta 'apply_for_beta', :controller => 'access',   :action => 'apply_for_beta' 
    178 
    18   # You can have the root of your site routed with map.root -- just remember to delete public/index.html. 
    199  map.root :controller => "reminder" 
    2010 
    2111  # See how all your routes lay out with "rake routes" 
    2212 
    23   # Install the default routes as the lowest priority. 
    2413  map.connect ':controller/:action/:id' 
    2514  map.connect ':controller/:action/:id.:format' 
  • agitator/db/schema.rb

    r1577 r1590  
    1010# It's strongly recommended to check this file into your version control system. 
    1111 
    12 ActiveRecord::Schema.define(:version => 2) do 
     12ActiveRecord::Schema.define(:version => 3) do 
    1313 
    1414  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" 
    1525    t.datetime "created_at" 
    1626    t.datetime "updated_at"