Changeset 1591
- Timestamp:
- 07/05/08 18:55:15 (3 months ago)
- Files:
-
- agitator/TODO (modified) (2 diffs)
- agitator/app/controllers/reminder_controller.rb (modified) (2 diffs)
- agitator/app/helpers/application_helper.rb (modified) (1 diff)
- agitator/app/views/widgets/_home_guts.rhtml (modified) (1 diff)
- agitator/config/environment.rb (modified) (1 diff)
- agitator/public/javascripts/application.js (modified) (1 diff)
- agitator/public/stylesheets/screen.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
agitator/TODO
r1590 r1591 1 1 2 NEXT 2 sort tags by usage3 print list of tags in browser 3 4 everything next is in reminder controller (persistence for reminders) 4 print list of tags in browser5 5 6 6 NICETOHAVE … … 9 9 10 10 DONE 11 get basic login and logout working 12 set up db alias 13 hide login form if already logged in 11 DONE sort tags by usage 12 DONE get basic login and logout working 13 DONE set up db alias 14 DONE hide login form if already logged in 15 agitator/app/controllers/reminder_controller.rb
r1590 r1591 21 21 @message = "Ordinarily you would see your (cached) #{BOOKMARKING_NAME} tags here but Rails is being a bitch about it." 22 22 end 23 24 session[:sort_tags_by] = (params[:sort_tags_by] == "alpha") ? "alpha" : "usage" 23 25 24 26 # FIXME: sort the tags by most prevalent and show the top ten … … 41 43 logger.debug( "..................................." ) 42 44 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 } 45 46 # hashify them briefly so we can sort them by usage: 47 tag_hash = Hash.new 48 tags.each{ |t| tag_hash[ t.attributes['tag']] = t.attributes['count'].to_i } 49 sorted_tags = tag_hash.sort {|a,b| a[1] <=> b[1]}.reverse 50 51 #sorted_tags.each{ |t| logger.debug( t[0].to_s + ":" + t[1].to_s ) } 52 #return sorted_tags 54 53 end 55 54 agitator/app/helpers/application_helper.rb
r1590 r1591 5 5 end 6 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>' 7 def get_tag_as_html( tag, user ) 8 if user == nil or tag == nil 9 return "" 10 end 11 return '<a href="http://' + BOOKMARKING_NAME + '/' + user + '/' + tag[0] + '">' + tag[0] + '(' + tag[1].to_s + ')</a>' 9 12 end 10 13 agitator/app/views/widgets/_home_guts.rhtml
r1590 r1591 1 <h2>HOME</h2>2 1 <% 3 if u and u != "" and @tags 2 if u and u != "" and @tags and @tags != nil and @tags.length > 0 3 sort = session[:sort_tags_by] 4 4 %> 5 5 6 Hi, <%= u %>! 6 7 7 Hi, <%= u %>, 8 <form name="sneaky_form" id="sneaky_form" action="/i/have/no/fucking/idea"> 9 <input type="hidden" name="reminder_tags" value="<%= DEFAULT_REMINDER_TAGS %>" /> 10 </form> 8 11 9 your most-used tag is <%= get_tag_as_html @tags[0], u %>. 12 <h3> 13 Your personal email will include links that are tagged: 14 </h3> 15 16 <div id="reminder_tags_preview"> 17 </div> 18 19 <h3> 20 Here are <%= @tags.length > 50 ? "your top 50" : "all your" %> <%= BOOKMARKING_NAME %> tags,<br /> 21 sorted 22 <%= sort== "alpha" ? "alphabetically" : "from most-used to least-used" %>. 23 </h3> 24 <p> 25 To include a tag in your personal reminder email, click it! 26 </p> 27 <form> 28 29 <div id="tags_by_usage" style="<%= sort == 'alpha' ? 'display: none;' : '' %>"> 30 <div class="tag_sort_toggle"> 31 <a href="javascript:sort_tags_by_alpha();">sort alphabetically?</a> 32 </div> 33 <% 34 c = 0 35 @tags.each{ |t| 36 if c < 50 37 -%> 38 <label> <input type="checkbox" name="tag_<%= t[0] %>" value="<%= t[0] %>" onClick="toggle_tag(this);" /> <%= t[0] %> </label> 39 <% 40 end 41 c += 1 42 } 43 %> 44 </div> 45 </form> 46 47 <div id="tags_by_alpha" style="<%= sort == 'alpha' ? '' : 'display: none;' %>"> 48 <div class="tag_sort_toggle"> 49 <a href="javascript: sort_tags_by_usage();">sort by most-frequently used?</a> 50 </div> 51 <% 52 c = 0 53 @tags = @tags.sort{ |a,b| a[0].downcase <=> b[0].downcase } 54 @tags.each{ |t| 55 if c < 50 56 -%> 57 <label> <input type="checkbox" name="tag_<%= t[0] %>" value="<%= t[0] %>" onClick="toggle_tag(this);" /> <%= t[0] %> </label> 58 <% 59 end 60 c += 1 61 } 62 %> 63 </div> 64 10 65 11 66 <p> agitator/config/environment.rb
r1585 r1591 14 14 BOOKMARKING_API_USERNAME = "agitator_test" 15 15 BOOKMARKING_API_PASSWORD = "6f1482c1e50d0de7763a5bcd858006e3" 16 DEFAULT_REMINDER_TAGS = "todo" 16 17 17 18 BOOKMARKING_API_CREDS_URL = "/v1/posts/update" agitator/public/javascripts/application.js
r1575 r1591 1 1 // Place your application-specific JavaScript functions and classes here 2 2 // This file is automatically included by javascript_include_tag :defaults 3 4 function sort_tags_by_alpha() { 5 $('tags_by_usage').setStyle('display', 'none'); 6 $('tags_by_alpha').setStyle('display', 'block'); 7 } 8 9 function sort_tags_by_usage() { 10 $('tags_by_usage').setStyle('display', 'block'); 11 $('tags_by_alpha').setStyle('display', 'none'); 12 } 13 14 function toggle_tag( checkbox ) { 15 if( checkbox.checked ) 16 alert( checkbox.value ); 17 } 3 18 4 19 // form validation: agitator/public/stylesheets/screen.css
r1581 r1591 159 159 display: inline; 160 160 } 161 162 div#reminder_tags_preview { 163 border: 1px solid gray; 164 padding: 2.0em; 165 width: 20em; 166 text-align: center; 167 font-size: 1.6em; 168 }