Skip to content
This repository
Browse code

Added initial Rails app

  • Loading branch information...
commit b3d85637d8799e6125dcb97d7e00edac27c84961 0 parents
David Shettler authored

Showing 302 changed files with 21,031 additions and 0 deletions. Show diff stats Hide diff stats

  1. 46  CREDITS
  2. 3  Capfile
  3. 340  LICENSE
  4. 70  README
  5. 10  Rakefile
  6. 86  app/controllers/about_controller.rb
  7. 452  app/controllers/account_controller.rb
  8. 11  app/controllers/activity_controller.rb
  9. 81  app/controllers/admin/articles_controller.rb
  10. 155  app/controllers/admin/bill_summaries_controller.rb
  11. 176  app/controllers/admin/commentary_controller.rb
  12. 110  app/controllers/admin/comments_controller.rb
  13. 53  app/controllers/admin/featured_people_controller.rb
  14. 33  app/controllers/admin/hot_bills_controller.rb
  15. 8  app/controllers/admin/index_controller.rb
  16. 78  app/controllers/admin/sidebar_items_controller.rb
  17. 52  app/controllers/admin/sidebars_controller.rb
  18. 64  app/controllers/admin/site_text_controller.rb
  19. 100  app/controllers/admin/site_text_pages_controller.rb
  20. 251  app/controllers/admin/stats_controller.rb
  21. 47  app/controllers/admin/tags_controller.rb
  22. 14  app/controllers/admin/thunderdome_controller.rb
  23. 53  app/controllers/admin/upcoming_bills_controller.rb
  24. 3  app/controllers/admin/user_roles_controller.rb
  25. 14  app/controllers/admin/user_warnings_controller.rb
  26. 87  app/controllers/admin/users_controller.rb
  27. 370  app/controllers/api_controller.rb
  28. 199  app/controllers/application_controller.rb
  29. 109  app/controllers/articles_controller.rb
  30. 261  app/controllers/battle_royale_controller.rb
  31. 696  app/controllers/bill_controller.rb
  32. 16  app/controllers/cache_controller.rb
  33. 26  app/controllers/commentary_controller.rb
  34. 190  app/controllers/comments_controller.rb
  35. 125  app/controllers/committee_controller.rb
  36. 10  app/controllers/contact_controller.rb
  37. 21  app/controllers/districts_controller.rb
  38. 134  app/controllers/facebook_controller.rb
  39. 408  app/controllers/friends_controller.rb
  40. 83  app/controllers/gossip_controller.rb
  41. 47  app/controllers/index_controller.rb
  42. 201  app/controllers/issue_controller.rb
  43. 98  app/controllers/mailing_list_items_controller.rb
  44. 10  app/controllers/meta_controller.rb
  45. 75  app/controllers/money_trail_controller.rb
  46. 36  app/controllers/notebook_files_controller.rb
  47. 87  app/controllers/notebook_items_controller.rb
  48. 117  app/controllers/notebook_links_controller.rb
  49. 2  app/controllers/notebook_notes_controller.rb
  50. 2  app/controllers/notebook_videos_controller.rb
  51. 744  app/controllers/people_controller.rb
  52. 131  app/controllers/political_notebooks_controller.rb
  53. 525  app/controllers/profile_controller.rb
  54. 504  app/controllers/resources_controller.rb
  55. 294  app/controllers/roll_call_controller.rb
  56. 39  app/controllers/scrape_tools_controller.rb
  57. 177  app/controllers/search_controller.rb
  58. 30  app/controllers/states_controller.rb
  59. 11  app/controllers/thunderdome_controller.rb
  60. 82  app/controllers/twitter_configs_controller.rb
  61. 56  app/controllers/twitter_controller.rb
  62. 183  app/controllers/user_feeds_controller.rb
  63. 84  app/controllers/user_mailing_lists_controller.rb
  64. 23  app/controllers/video_controller.rb
  65. 88  app/controllers/watch_dogs_controller.rb
  66. 45  app/controllers/watchdogs_controller.rb
  67. 85  app/controllers/wiki_links_controller.rb
  68. 5  app/helpers/about_helper.rb
  69. 2  app/helpers/account_helper.rb
  70. 6  app/helpers/activity_helper.rb
  71. 2  app/helpers/admin/comments_helper.rb
  72. 30  app/helpers/admin/stats_helper.rb
  73. 2  app/helpers/admin/thunderdome_helper.rb
  74. 2  app/helpers/admin/user_roles_helper.rb
  75. 2  app/helpers/api_helper.rb
  76. 882  app/helpers/application_helper.rb
  77. 41  app/helpers/battle_royale_helper.rb
  78. 259  app/helpers/bill_helper.rb
  79. 2  app/helpers/commentary_helper.rb
  80. 2  app/helpers/comments_helper.rb
  81. 5  app/helpers/committee_helper.rb
  82. 2  app/helpers/contact_helper.rb
  83. 2  app/helpers/crp_controller_helper.rb
  84. 2  app/helpers/districts_helper.rb
  85. 9  app/helpers/facebook_helper.rb
  86. 2  app/helpers/featured_people_helper.rb
  87. 10  app/helpers/friends_helper.rb
  88. 19  app/helpers/gossip_helper.rb
  89. 88  app/helpers/index_helper.rb
  90. 23  app/helpers/industry_helper.rb
  91. 19  app/helpers/issue_helper.rb
  92. 2  app/helpers/mailing_list_items_helper.rb
  93. 2  app/helpers/meta_helper.rb
  94. 15  app/helpers/notebook_items_helper.rb
  95. 14  app/helpers/notebook_links_helper.rb
  96. 8  app/helpers/notebook_videos_helper.rb
  97. 202  app/helpers/people_helper.rb
  98. 2  app/helpers/political_notebook_helper.rb
  99. 55  app/helpers/political_notebooks_helper.rb
  100. 123  app/helpers/profile_helper.rb
  101. 16  app/helpers/remote_link_renderer.rb
  102. 33  app/helpers/resources_helper.rb
  103. 112  app/helpers/roll_call_helper.rb
  104. 2  app/helpers/scrape_tools_helper.rb
  105. 8  app/helpers/search_helper.rb
  106. 12  app/helpers/span_link_renderer.rb
  107. 2  app/helpers/states_helper.rb
  108. 14  app/helpers/thunderdome_helper.rb
  109. 2  app/helpers/twitter_configs_helper.rb
  110. 2  app/helpers/twitter_helper.rb
  111. 2  app/helpers/user_feeds_helper.rb
  112. 2  app/helpers/user_mailing_lists_helper.rb
  113. 2  app/helpers/watch_dogs_helper.rb
  114. 81  app/helpers/watchdogs_helper.rb
  115. 2  app/helpers/wiki_links_helper.rb
  116. 181  app/models/action.rb
  117. 3  app/models/action_reference.rb
  118. 9  app/models/amendment.rb
  119. 5  app/models/api_hit.rb
  120. 90  app/models/article.rb
  121. 7  app/models/article_sweeper.rb
  122. 1,326  app/models/bill.rb
  123. 7  app/models/bill_battle.rb
  124. 3  app/models/bill_comment.rb
  125. 7  app/models/bill_committee.rb
  126. 6  app/models/bill_cosponsor.rb
  127. 6  app/models/bill_fulltext.rb
  128. 4  app/models/bill_interest_group.rb
  129. 3  app/models/bill_position_organization.rb
  130. 7  app/models/bill_relation.rb
  131. 5  app/models/bill_stats.rb
  132. 8  app/models/bill_subject.rb
  133. 15  app/models/bill_text_node.rb
  134. 81  app/models/bill_text_version.rb
  135. 3  app/models/bill_title.rb
  136. 12  app/models/bill_vote.rb
  137. 47  app/models/bookmark.rb
  138. 47  app/models/bounce_handler.rb
  139. 164  app/models/comment.rb
  140. 4  app/models/comment_score.rb
  141. 182  app/models/commentary.rb
  142. 6  app/models/commentary_rating.rb
  143. 309  app/models/committee.rb
  144. 8  app/models/committee_meeting.rb
  145. 4  app/models/committee_meetings_bill.rb
  146. 9  app/models/committee_person.rb
  147. 28  app/models/committee_report.rb
  148. 5  app/models/committee_stats.rb
  149. 218  app/models/comparison.rb
  150. 3  app/models/comparison_data_point.rb
  151. 21  app/models/congress_session.rb
  152. 4  app/models/contributor.rb
  153. 18  app/models/crp_industry.rb
  154. 16  app/models/crp_interest_group.rb
  155. 3  app/models/crp_sector.rb
  156. 3  app/models/dem_dem_comparison.rb
  157. 229  app/models/district.rb
  158. 73  app/models/emailer.rb
  159. 21  app/models/facebook_publisher.rb
  160. 13  app/models/facebook_user.rb
  161. 30  app/models/facebook_user_bill.rb
  162. 21  app/models/featured_person.rb
  163. 8  app/models/featured_person_sweeper.rb
  164. 5  app/models/forum.rb
  165. 28  app/models/fragment_cache_sweeper.rb
  166. 41  app/models/friend.rb
  167. 4  app/models/friend_email.rb
  168. 3  app/models/friend_invite.rb
  169. 26  app/models/friend_observer.rb
  170. 28  app/models/gossip.rb
  171. 2  app/models/gpo_billtext_timestamp.rb
  172. 4  app/models/hot_bill_category.rb
  173. 7  app/models/index_sweeper.rb
  174. 5  app/models/industry_stats.rb
  175. 5  app/models/issue_stats.rb
  176. 245  app/models/list_representative.rb
  177. 245  app/models/list_senator.rb
  178. 8  app/models/mailing_list_item.rb
  179. 2  app/models/meta.rb
  180. 11  app/models/mini_mailing_list.rb
  181. 30  app/models/notebook_file.rb
  182. 28  app/models/notebook_item.rb
  183. 55  app/models/notebook_link.rb
  184. 7  app/models/notebook_note.rb
  185. 32  app/models/notebook_video.rb
  186. 39  app/models/page_view.rb
  187. 2  app/models/panel_referrer.rb
  188. 1,602  app/models/person.rb
  189. 9  app/models/person_approval.rb
  190. 6  app/models/person_cycle_contribution.rb
  191. 6  app/models/person_sector.rb
  192. 19  app/models/person_stats.rb
  193. 3  app/models/person_view.rb
  194. 40  app/models/political_notebook.rb
  195. 9  app/models/privacy_option.rb
  196. 8  app/models/refer.rb
  197. 3  app/models/rep_dem_comparison.rb
  198. 3  app/models/rep_rep_comparison.rb
  199. 12  app/models/role.rb
  200. 145  app/models/roll_call.rb
  201. 66  app/models/roll_call_vote.rb
  202. 9  app/models/search.rb
  203. 45  app/models/sector.rb
  204. 3  app/models/sidebar.rb
  205. 7  app/models/sidebar_item.rb
  206. 23  app/models/site_text.rb
  207. 3  app/models/site_text_page.rb
  208. 167  app/models/state.rb
  209. 390  app/models/subject.rb
  210. 30  app/models/subject_relation.rb
  211. 5  app/models/twitter_config.rb
  212. 16  app/models/upcoming_bill.rb
  213. 791  app/models/user.rb
  214. 25  app/models/user_ip_address.rb
  215. 75  app/models/user_mailing_list.rb
  216. 68  app/models/user_notifier.rb
  217. 11  app/models/user_observer.rb
  218. 3  app/models/user_role.rb
  219. 6  app/models/user_warning.rb
  220. 8  app/models/video.rb
  221. 15  app/models/watch_dog.rb
  222. 63  app/models/wiki_link.rb
  223. 8  app/models/write_rep_email.rb
  224. 4  app/models/write_rep_email_msgid.rb
  225. 27  app/models/zipcode_district.rb
  226. 1  app/views/about/_learn.html.erb
  227. 139  app/views/about/beta_feedback.html.erb
  228. 11  app/views/about/blog.html.erb
  229. 75  app/views/about/congress.html.erb
  230. 32  app/views/about/copyright_policy.html.erb
  231. 51  app/views/about/hillstaff.html.erb
  232. 149  app/views/about/howtouse.html.erb
  233. 232  app/views/about/index.html.erb
  234. 23  app/views/about/political_notebooks.html.erb
  235. 46  app/views/about/privacy_policy.html.erb
  236. 41  app/views/about/resources.html.erb
  237. 91  app/views/about/rss.html.erb
  238. 14  app/views/about/screencast.html.erb
  239. 104  app/views/about/terms_of_service.html.erb
  240. 1  app/views/account/_learn.html.erb
  241. 20  app/views/account/accept_tos.html.erb
  242. 7  app/views/account/confirm.html.erb
  243. 6  app/views/account/forgot_password.html.erb
  244. 56  app/views/account/index.html.erb
  245. 110  app/views/account/login.html.erb
  246. 95  app/views/account/login_modal.html.erb
  247. 10  app/views/account/logout.html.erb
  248. 30  app/views/account/new_openid.html.erb
  249. 1  app/views/account/pwmail.html.erb
  250. 7  app/views/account/reset_password.html.erb
  251. 75  app/views/account/signup.html.erb
  252. 36  app/views/account/welcome.html.erb
  253. 10  app/views/account/why.html.erb
  254. 11  app/views/activity/_latest_actions.html.erb
  255. 16  app/views/activity/_learn.html.erb
  256. 7  app/views/activity/latest.html.erb
  257. 31  app/views/admin/articles/_form.html.erb
  258. 1  app/views/admin/articles/_learn.html.erb
  259. 7  app/views/admin/articles/edit.html.erb
  260. 33  app/views/admin/articles/list.html.erb
  261. 9  app/views/admin/articles/new.html.erb
  262. 21  app/views/admin/articles/show.html.erb
  263. 0  app/views/admin/bill_summaries/_learn.html.erb
  264. 26  app/views/admin/bill_summaries/_new_bill_form.html.erb
  265. 30  app/views/admin/bill_summaries/defaulttitle.html.erb
  266. 9  app/views/admin/bill_summaries/edit.html.erb
  267. 6  app/views/admin/bill_summaries/index.html.erb
  268. 6  app/views/admin/bill_summaries/new_bill.html.erb
  269. 1  app/views/admin/bill_summaries/save_new_bill.html.erb
  270. 16  app/views/admin/bill_summaries/session_relations.html.erb
  271. 43  app/views/admin/commentary/_form.html.erb
  272. 1  app/views/admin/commentary/_learn.html.erb
  273. 6  app/views/admin/commentary/edit.html.erb
  274. 27  app/views/admin/commentary/list.html.erb
  275. 8  app/views/admin/commentary/new.html.erb
  276. 40  app/views/admin/commentary/pending.html.erb
  277. 8  app/views/admin/commentary/show.html.erb
  278. 25  app/views/admin/comments/comments_search.html.erb
  279. 44  app/views/admin/comments/index.html.erb
  280. 12  app/views/admin/featured_people/_form.html.erb
  281. 1  app/views/admin/featured_people/_learn.html.erb
  282. 9  app/views/admin/featured_people/edit.html.erb
  283. 25  app/views/admin/featured_people/list.html.erb
  284. 8  app/views/admin/featured_people/new.html.erb
  285. 8  app/views/admin/featured_people/show.html.erb
  286. 1  app/views/admin/index/_learn.html.erb
  287. 50  app/views/admin/index/index.html.erb
  288. 14  app/views/admin/sidebar_items/_form.html.erb
  289. 10  app/views/admin/sidebar_items/_item.html.erb
  290. 15  app/views/admin/sidebar_items/_item_entry.html.erb
  291. 1  app/views/admin/sidebar_items/_learn.html.erb
  292. 9  app/views/admin/sidebar_items/edit.html.erb
  293. 26  app/views/admin/sidebar_items/list.html.erb
  294. 24  app/views/admin/sidebar_items/manage.html.erb
  295. 10  app/views/admin/sidebar_items/new.html.erb
  296. 8  app/views/admin/sidebar_items/show.html.erb
  297. 20  app/views/admin/sidebars/_form.html.erb
  298. 1  app/views/admin/sidebars/_learn.html.erb
  299. 9  app/views/admin/sidebars/edit.html.erb
  300. 26  app/views/admin/sidebars/list.html.erb
  301. 8  app/views/admin/sidebars/new.html.erb
46  CREDITS
... ...
@@ -0,0 +1,46 @@
  1
+# OpenCongress - a Ruby on Rails application for displaying information about Congress
  2
+#
  3
+# Copyright (C) 2005-2006 Participatory Culture Foundation
  4
+#
  5
+# This program is free software; you can redistribute it and/or modify
  6
+# it under the terms of the GNU General Public License as published by
  7
+# the Free Software Foundation; either version 2 of the License, or
  8
+# (at your option) any later version.
  9
+#
  10
+# This program is distributed in the hope that it will be useful,
  11
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13
+# GNU General Public License for more details.
  14
+#
  15
+# You should have received a copy of the GNU General Public License
  16
+# along with this program; if not, write to the Free Software
  17
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  18
+#
  19
+
  20
+The Participatory Politics Foundation is:
  21
+
  22
+Board of Directors 
  23
+
  24
+Tiffiniy Cheng
  25
+Nicholas Nassar
  26
+David Moore
  27
+Nicholas Reville
  28
+Holmes Wilson
  29
+
  30
+Staff
  31
+
  32
+David Moore, Executive Director
  33
+Andrew Packer, Project Coordinator
  34
+Andy Ross, Software Developer
  35
+Donny Shaw, Researcher / Blogger
  36
+David Shettler, Software Developer
  37
+
  38
+Other Contributors
  39
+
  40
+Ben Matasar
  41
+Neil Cook
  42
+Jason Packer
  43
+Scott Chacon
  44
+Jeff Mielke
  45
+
  46
+Built with support from the Sunlight Foundation.
3  Capfile
... ...
@@ -0,0 +1,3 @@
  1
+load 'deploy' if respond_to?(:namespace) # cap2 differentiator
  2
+Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
  3
+load 'config/deploy'
340  LICENSE
... ...
@@ -0,0 +1,340 @@
  1
+		    GNU GENERAL PUBLIC LICENSE
  2
+		       Version 2, June 1991
  3
+
  4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
  5
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  6
+ Everyone is permitted to copy and distribute verbatim copies
  7
+ of this license document, but changing it is not allowed.
  8
+
  9
+			    Preamble
  10
+
  11
+  The licenses for most software are designed to take away your
  12
+freedom to share and change it.  By contrast, the GNU General Public
  13
+License is intended to guarantee your freedom to share and change free
  14
+software--to make sure the software is free for all its users.  This
  15
+General Public License applies to most of the Free Software
  16
+Foundation's software and to any other program whose authors commit to
  17
+using it.  (Some other Free Software Foundation software is covered by
  18
+the GNU Lesser General Public License instead.)  You can apply it to
  19
+your programs, too.
  20
+
  21
+  When we speak of free software, we are referring to freedom, not
  22
+price.  Our General Public Licenses are designed to make sure that you
  23
+have the freedom to distribute copies of free software (and charge for
  24
+this service if you wish), that you receive source code or can get it
  25
+if you want it, that you can change the software or use pieces of it
  26
+in new free programs; and that you know you can do these things.
  27
+
  28
+  To protect your rights, we need to make restrictions that forbid
  29
+anyone to deny you these rights or to ask you to surrender the rights.
  30
+These restrictions translate to certain responsibilities for you if you
  31
+distribute copies of the software, or if you modify it.
  32
+
  33
+  For example, if you distribute copies of such a program, whether
  34
+gratis or for a fee, you must give the recipients all the rights that
  35
+you have.  You must make sure that they, too, receive or can get the
  36
+source code.  And you must show them these terms so they know their
  37
+rights.
  38
+
  39
+  We protect your rights with two steps: (1) copyright the software, and
  40
+(2) offer you this license which gives you legal permission to copy,
  41
+distribute and/or modify the software.
  42
+
  43
+  Also, for each author's protection and ours, we want to make certain
  44
+that everyone understands that there is no warranty for this free
  45
+software.  If the software is modified by someone else and passed on, we
  46
+want its recipients to know that what they have is not the original, so
  47
+that any problems introduced by others will not reflect on the original
  48
+authors' reputations.
  49
+
  50
+  Finally, any free program is threatened constantly by software
  51
+patents.  We wish to avoid the danger that redistributors of a free
  52
+program will individually obtain patent licenses, in effect making the
  53
+program proprietary.  To prevent this, we have made it clear that any
  54
+patent must be licensed for everyone's free use or not licensed at all.
  55
+
  56
+  The precise terms and conditions for copying, distribution and
  57
+modification follow.
  58
+
  59
+		    GNU GENERAL PUBLIC LICENSE
  60
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
  61
+
  62
+  0. This License applies to any program or other work which contains
  63
+a notice placed by the copyright holder saying it may be distributed
  64
+under the terms of this General Public License.  The "Program", below,
  65
+refers to any such program or work, and a "work based on the Program"
  66
+means either the Program or any derivative work under copyright law:
  67
+that is to say, a work containing the Program or a portion of it,
  68
+either verbatim or with modifications and/or translated into another
  69
+language.  (Hereinafter, translation is included without limitation in
  70
+the term "modification".)  Each licensee is addressed as "you".
  71
+
  72
+Activities other than copying, distribution and modification are not
  73
+covered by this License; they are outside its scope.  The act of
  74
+running the Program is not restricted, and the output from the Program
  75
+is covered only if its contents constitute a work based on the
  76
+Program (independent of having been made by running the Program).
  77
+Whether that is true depends on what the Program does.
  78
+
  79
+  1. You may copy and distribute verbatim copies of the Program's
  80
+source code as you receive it, in any medium, provided that you
  81
+conspicuously and appropriately publish on each copy an appropriate
  82
+copyright notice and disclaimer of warranty; keep intact all the
  83
+notices that refer to this License and to the absence of any warranty;
  84
+and give any other recipients of the Program a copy of this License
  85
+along with the Program.
  86
+
  87
+You may charge a fee for the physical act of transferring a copy, and
  88
+you may at your option offer warranty protection in exchange for a fee.
  89
+
  90
+  2. You may modify your copy or copies of the Program or any portion
  91
+of it, thus forming a work based on the Program, and copy and
  92
+distribute such modifications or work under the terms of Section 1
  93
+above, provided that you also meet all of these conditions:
  94
+
  95
+    a) You must cause the modified files to carry prominent notices
  96
+    stating that you changed the files and the date of any change.
  97
+
  98
+    b) You must cause any work that you distribute or publish, that in
  99
+    whole or in part contains or is derived from the Program or any
  100
+    part thereof, to be licensed as a whole at no charge to all third
  101
+    parties under the terms of this License.
  102
+
  103
+    c) If the modified program normally reads commands interactively
  104
+    when run, you must cause it, when started running for such
  105
+    interactive use in the most ordinary way, to print or display an
  106
+    announcement including an appropriate copyright notice and a
  107
+    notice that there is no warranty (or else, saying that you provide
  108
+    a warranty) and that users may redistribute the program under
  109
+    these conditions, and telling the user how to view a copy of this
  110
+    License.  (Exception: if the Program itself is interactive but
  111
+    does not normally print such an announcement, your work based on
  112
+    the Program is not required to print an announcement.)
  113
+
  114
+These requirements apply to the modified work as a whole.  If
  115
+identifiable sections of that work are not derived from the Program,
  116
+and can be reasonably considered independent and separate works in
  117
+themselves, then this License, and its terms, do not apply to those
  118
+sections when you distribute them as separate works.  But when you
  119
+distribute the same sections as part of a whole which is a work based
  120
+on the Program, the distribution of the whole must be on the terms of
  121
+this License, whose permissions for other licensees extend to the
  122
+entire whole, and thus to each and every part regardless of who wrote it.
  123
+
  124
+Thus, it is not the intent of this section to claim rights or contest
  125
+your rights to work written entirely by you; rather, the intent is to
  126
+exercise the right to control the distribution of derivative or
  127
+collective works based on the Program.
  128
+
  129
+In addition, mere aggregation of another work not based on the Program
  130
+with the Program (or with a work based on the Program) on a volume of
  131
+a storage or distribution medium does not bring the other work under
  132
+the scope of this License.
  133
+
  134
+  3. You may copy and distribute the Program (or a work based on it,
  135
+under Section 2) in object code or executable form under the terms of
  136
+Sections 1 and 2 above provided that you also do one of the following:
  137
+
  138
+    a) Accompany it with the complete corresponding machine-readable
  139
+    source code, which must be distributed under the terms of Sections
  140
+    1 and 2 above on a medium customarily used for software interchange; or,
  141
+
  142
+    b) Accompany it with a written offer, valid for at least three
  143
+    years, to give any third party, for a charge no more than your
  144
+    cost of physically performing source distribution, a complete
  145
+    machine-readable copy of the corresponding source code, to be
  146
+    distributed under the terms of Sections 1 and 2 above on a medium
  147
+    customarily used for software interchange; or,
  148
+
  149
+    c) Accompany it with the information you received as to the offer
  150
+    to distribute corresponding source code.  (This alternative is
  151
+    allowed only for noncommercial distribution and only if you
  152
+    received the program in object code or executable form with such
  153
+    an offer, in accord with Subsection b above.)
  154
+
  155
+The source code for a work means the preferred form of the work for
  156
+making modifications to it.  For an executable work, complete source
  157
+code means all the source code for all modules it contains, plus any
  158
+associated interface definition files, plus the scripts used to
  159
+control compilation and installation of the executable.  However, as a
  160
+special exception, the source code distributed need not include
  161
+anything that is normally distributed (in either source or binary
  162
+form) with the major components (compiler, kernel, and so on) of the
  163
+operating system on which the executable runs, unless that component
  164
+itself accompanies the executable.
  165
+
  166
+If distribution of executable or object code is made by offering
  167
+access to copy from a designated place, then offering equivalent
  168
+access to copy the source code from the same place counts as
  169
+distribution of the source code, even though third parties are not
  170
+compelled to copy the source along with the object code.
  171
+
  172
+  4. You may not copy, modify, sublicense, or distribute the Program
  173
+except as expressly provided under this License.  Any attempt
  174
+otherwise to copy, modify, sublicense or distribute the Program is
  175
+void, and will automatically terminate your rights under this License.
  176
+However, parties who have received copies, or rights, from you under
  177
+this License will not have their licenses terminated so long as such
  178
+parties remain in full compliance.
  179
+
  180
+  5. You are not required to accept this License, since you have not
  181
+signed it.  However, nothing else grants you permission to modify or
  182
+distribute the Program or its derivative works.  These actions are
  183
+prohibited by law if you do not accept this License.  Therefore, by
  184
+modifying or distributing the Program (or any work based on the
  185
+Program), you indicate your acceptance of this License to do so, and
  186
+all its terms and conditions for copying, distributing or modifying
  187
+the Program or works based on it.
  188
+
  189
+  6. Each time you redistribute the Program (or any work based on the
  190
+Program), the recipient automatically receives a license from the
  191
+original licensor to copy, distribute or modify the Program subject to
  192
+these terms and conditions.  You may not impose any further
  193
+restrictions on the recipients' exercise of the rights granted herein.
  194
+You are not responsible for enforcing compliance by third parties to
  195
+this License.
  196
+
  197
+  7. If, as a consequence of a court judgment or allegation of patent
  198
+infringement or for any other reason (not limited to patent issues),
  199
+conditions are imposed on you (whether by court order, agreement or
  200
+otherwise) that contradict the conditions of this License, they do not
  201
+excuse you from the conditions of this License.  If you cannot
  202
+distribute so as to satisfy simultaneously your obligations under this
  203
+License and any other pertinent obligations, then as a consequence you
  204
+may not distribute the Program at all.  For example, if a patent
  205
+license would not permit royalty-free redistribution of the Program by
  206
+all those who receive copies directly or indirectly through you, then
  207
+the only way you could satisfy both it and this License would be to
  208
+refrain entirely from distribution of the Program.
  209
+
  210
+If any portion of this section is held invalid or unenforceable under
  211
+any particular circumstance, the balance of the section is intended to
  212
+apply and the section as a whole is intended to apply in other
  213
+circumstances.
  214
+
  215
+It is not the purpose of this section to induce you to infringe any
  216
+patents or other property right claims or to contest validity of any
  217
+such claims; this section has the sole purpose of protecting the
  218
+integrity of the free software distribution system, which is
  219
+implemented by public license practices.  Many people have made
  220
+generous contributions to the wide range of software distributed
  221
+through that system in reliance on consistent application of that
  222
+system; it is up to the author/donor to decide if he or she is willing
  223
+to distribute software through any other system and a licensee cannot
  224
+impose that choice.
  225
+
  226
+This section is intended to make thoroughly clear what is believed to
  227
+be a consequence of the rest of this License.
  228
+
  229
+  8. If the distribution and/or use of the Program is restricted in
  230
+certain countries either by patents or by copyrighted interfaces, the
  231
+original copyright holder who places the Program under this License
  232
+may add an explicit geographical distribution limitation excluding
  233
+those countries, so that distribution is permitted only in or among
  234
+countries not thus excluded.  In such case, this License incorporates
  235
+the limitation as if written in the body of this License.
  236
+
  237
+  9. The Free Software Foundation may publish revised and/or new versions
  238
+of the General Public License from time to time.  Such new versions will
  239
+be similar in spirit to the present version, but may differ in detail to
  240
+address new problems or concerns.
  241
+
  242
+Each version is given a distinguishing version number.  If the Program
  243
+specifies a version number of this License which applies to it and "any
  244
+later version", you have the option of following the terms and conditions
  245
+either of that version or of any later version published by the Free
  246
+Software Foundation.  If the Program does not specify a version number of
  247
+this License, you may choose any version ever published by the Free Software
  248
+Foundation.
  249
+
  250
+  10. If you wish to incorporate parts of the Program into other free
  251
+programs whose distribution conditions are different, write to the author
  252
+to ask for permission.  For software which is copyrighted by the Free
  253
+Software Foundation, write to the Free Software Foundation; we sometimes
  254
+make exceptions for this.  Our decision will be guided by the two goals
  255
+of preserving the free status of all derivatives of our free software and
  256
+of promoting the sharing and reuse of software generally.
  257
+
  258
+			    NO WARRANTY
  259
+
  260
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
  261
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
  262
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
  263
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
  264
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  265
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
  266
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
  267
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
  268
+REPAIR OR CORRECTION.
  269
+
  270
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
  271
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
  272
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
  273
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
  274
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
  275
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
  276
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
  277
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
  278
+POSSIBILITY OF SUCH DAMAGES.
  279
+
  280
+		     END OF TERMS AND CONDITIONS
  281
+
  282
+	    How to Apply These Terms to Your New Programs
  283
+
  284
+  If you develop a new program, and you want it to be of the greatest
  285
+possible use to the public, the best way to achieve this is to make it
  286
+free software which everyone can redistribute and change under these terms.
  287
+
  288
+  To do so, attach the following notices to the program.  It is safest
  289
+to attach them to the start of each source file to most effectively
  290
+convey the exclusion of warranty; and each file should have at least
  291
+the "copyright" line and a pointer to where the full notice is found.
  292
+
  293
+    <one line to give the program's name and a brief idea of what it does.>
  294
+    Copyright (C) <year>  <name of author>
  295
+
  296
+    This program is free software; you can redistribute it and/or modify
  297
+    it under the terms of the GNU General Public License as published by
  298
+    the Free Software Foundation; either version 2 of the License, or
  299
+    (at your option) any later version.
  300
+
  301
+    This program is distributed in the hope that it will be useful,
  302
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
  303
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  304
+    GNU General Public License for more details.
  305
+
  306
+    You should have received a copy of the GNU General Public License
  307
+    along with this program; if not, write to the Free Software
  308
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  309
+
  310
+
  311
+Also add information on how to contact you by electronic and paper mail.
  312
+
  313
+If the program is interactive, make it output a short notice like this
  314
+when it starts in an interactive mode:
  315
+
  316
+    Gnomovision version 69, Copyright (C) year name of author
  317
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
  318
+    This is free software, and you are welcome to redistribute it
  319
+    under certain conditions; type `show c' for details.
  320
+
  321
+The hypothetical commands `show w' and `show c' should show the appropriate
  322
+parts of the General Public License.  Of course, the commands you use may
  323
+be called something other than `show w' and `show c'; they could even be
  324
+mouse-clicks or menu items--whatever suits your program.
  325
+
  326
+You should also get your employer (if you work as a programmer) or your
  327
+school, if any, to sign a "copyright disclaimer" for the program, if
  328
+necessary.  Here is a sample; alter the names:
  329
+
  330
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
  331
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
  332
+
  333
+  <signature of Ty Coon>, 1 April 1989
  334
+  Ty Coon, President of Vice
  335
+
  336
+This General Public License does not permit incorporating your program into
  337
+proprietary programs.  If your program is a subroutine library, you may
  338
+consider it more useful to permit linking proprietary applications with the
  339
+library.  If this is what you want to do, use the GNU Lesser General
  340
+Public License instead of this License.
70  README
... ...
@@ -0,0 +1,70 @@
  1
+# OpenCongress - a Ruby on Rails application for displaying information about Congress
  2
+#
  3
+# Copyright (C) 2005-2006 Participatory Culture Foundation
  4
+#
  5
+# This program is free software; you can redistribute it and/or modify
  6
+# it under the terms of the GNU General Public License as published by
  7
+# the Free Software Foundation; either version 2 of the License, or
  8
+# (at your option) any later version.
  9
+#
  10
+# This program is distributed in the hope that it will be useful,
  11
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
  12
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13
+# GNU General Public License for more details.
  14
+#
  15
+# You should have received a copy of the GNU General Public License
  16
+# along with this program; if not, write to the Free Software
  17
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  18
+
  19
+== OpenCongress Rails Project
  20
+
  21
+-- Installing OpenCongress --
  22
+
  23
+First of all, the OpenCongress project is a PostgreSQL only project.  Don't have delusions of using MySQL with it or you will be hurtin.  Since I personally had little experience with Postgres before this, I will include some tips for all you Mysql only guys and gals out there.
  24
+
  25
+Here is what you have to do to get OpenCongress close to working on your personal machine :
  26
+
  27
+  1. install postgresql
  28
+
  29
+  2. install tsearch in contrib
  30
+
  31
+  3. gem install ferret, bluecloth, simple-rss, postgres-pr
  32
+
  33
+  4. copy config/database.sample to config/database.yml and edit it
  34
+
  35
+  5. create the databases
  36
+	createdb opencongress_dev
  37
+	opencongress_dev < db/tsearch2.sql
  38
+  	createdb opencongress_test
  39
+
  40
+  6. rake migrate
  41
+
  42
+--
  43
+
  44
+Next, you will have to get the data from govtrack and fill in your database with the parsed govtrack data
  45
+
  46
+  mkdir /data/govtrack/109
  47
+  cd /data/govtrack/109
  48
+  rsync -az govtrack.us::govtrackdata/us/109/bills .
  49
+  rsync -az govtrack.us::govtrackdata/us/109/repstats .
  50
+  rsync -az govtrack.us::govtrackdata/us/109/bills.index.xml .
  51
+  rsync -az govtrack.us::govtrackdata/us/109/committeeschedule.xml .
  52
+  rsync -az govtrack.us::govtrackdata/us/109/rolls .
  53
+
  54
+Now, you will have to actually parse the data
  55
+
  56
+  ruby bin/govtrack_parse_people.rb
  57
+  ruby bin/govtrack_parse_bills.rb 
  58
+  ruby bin/govtrack_parse_committees.rb 
  59
+  ruby bin/govtrack_parse_committee_schedules.rb 
  60
+  ruby parse_individual_bills.rb 
  61
+
  62
+--
  63
+
  64
+Now, just run 'mongrel_rails start' and you should have something going on localhost:3000 - have fun!
  65
+
  66
+Lastly, some Postgres tips:
  67
+  
  68
+  starting pg:  pg_ctl -D data -l logfile start
  69
+  accessing pg from the command line : psql opencongress_dev
  70
+
10  Rakefile
... ...
@@ -0,0 +1,10 @@
  1
+# Add your own tasks in files placed in lib/tasks ending in .rake,
  2
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
  3
+
  4
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
  5
+
  6
+require 'rake'
  7
+require 'rake/testtask'
  8
+require 'rake/rdoctask'
  9
+
  10
+require 'tasks/rails'
86  app/controllers/about_controller.rb
... ...
@@ -0,0 +1,86 @@
  1
+class AboutController < ApplicationController
  2
+#  caches_page :index, :blog, :resources, :congress, :howtouse, :rss, :feedback
  3
+  skip_before_filter :has_accepted_tos?
  4
+  skip_before_filter :store_location, :only => ["privacy_policy","terms_of_service"]
  5
+
  6
+  
  7
+  def index
  8
+    @learn_off = true
  9
+    @breadcrumb = { 
  10
+      1 => { 'text' => "About", 'url' => { :controller => 'about' } }
  11
+    }
  12
+    @page_title = 'About Open Congress'
  13
+  end
  14
+
  15
+  def blog
  16
+    @learn_off = true
  17
+    @breadcrumb = { 
  18
+      1 => { 'text' => "About Blog", 'url' => { :controller => 'about', :action => 'blog' } }
  19
+    }
  20
+    @page_title = 'About OpenCongress Blog'
  21
+  end
  22
+  
  23
+  def resources
  24
+    @page_title = "General Overview / Information about Congress"
  25
+    @learn_off = true
  26
+    @breadcrumb = { 
  27
+      1 => { 'text' => "Congress Resources", 'url' => { :controller => 'about', :action => 'resources' } }
  28
+    }
  29
+  end
  30
+
  31
+  def congress
  32
+    # Set @learn_off to remove "Learn More" from the layout
  33
+    @learn_off = true
  34
+    @page_title = 'About Congress'
  35
+  end
  36
+
  37
+  def howtouse
  38
+    @learn_off = true
  39
+    @breadcrumb = { 
  40
+      1 => { 'text' => "How To Use Open Congress", 'url' => { :controller => 'about', :action => 'howtouse'} }
  41
+    }
  42
+    @page_title = "How To Use Open Congress"
  43
+  end
  44
+  
  45
+  def beta_feedback
  46
+    @learn_off = true
  47
+    @breadcrumb = { 
  48
+      1 => { 'text' => "Feedback", 'url' => { :controller => 'about', :action => 'beta_feedback'} }
  49
+    }
  50
+    @page_title = "Feedback"
  51
+  end
  52
+  
  53
+  def rss
  54
+  	@learn_off = true
  55
+  	@breadcrumb = {
  56
+  	  1 => { 'text' => "RSS", 'url' => { :controller => 'about', :action => 'rss' } }
  57
+  	}
  58
+  	@page_title = "Use RSS to Easily Track Developments in Congress"
  59
+  end
  60
+  
  61
+  def political_notebooks
  62
+     @learn_off = true
  63
+     @page_title = "About My Political Notebook"
  64
+  end
  65
+
  66
+  def screencast
  67
+    @learn_off
  68
+    @page_title = "Screencast"
  69
+  end
  70
+
  71
+  def terms_of_service
  72
+     @head_title = "Terms of Service and Comment Policy"
  73
+  end                                                   
  74
+  
  75
+  def privacy_policy
  76
+     @head_title = "Privacy Policy"
  77
+  end
  78
+
  79
+private                            
  80
+
  81
+
  82
+  def learn_from_controller(controller_name)
  83
+    text = render_to_string(:partial => "#{controller_name}/learn")
  84
+    process_bluecloth_text(text)
  85
+  end
  86
+end
452  app/controllers/account_controller.rb
... ...
@@ -0,0 +1,452 @@
  1
+class AccountController < ApplicationController
  2
+  before_filter :login_from_cookie, :except => "reset_password"
  3
+  before_filter :login_required, :only => ["welcome","accept_tos"]
  4
+  after_filter :check_forums, :only => ["login","activate"]
  5
+  after_filter :check_wiki, :only => ["login", "activate"]
  6
+  
  7
+  skip_before_filter :store_location
  8
+
  9
+  skip_before_filter :has_accepted_tos?, :only => ["accept_tos","logout"]
  10
+
  11
+  include OpenIdAuthentication
  12
+
  13
+#  observer :user_observer
  14
+
  15
+  def index
  16
+    if current_user.to_s == "false"
  17
+      redirect_to(:action => 'login')
  18
+    else
  19
+      redirect_to(:controller => "profile", :action => "profile", :login => current_user.login)
  20
+    end
  21
+  end
  22
+
  23
+  def get_user_email
  24
+    if params[:id] == API_KEYS['wiki_callback_key']
  25
+      user = User.find(:first, :conditions => ["lower(login) = ?", params[:login].downcase])
  26
+      render :text => "#{user.email}"
  27
+    else
  28
+      redirect_to :action => :index
  29
+    end
  30
+  end
  31
+  
  32
+  def get_user_full_name
  33
+    if params[:id] == API_KEYS['wiki_callback_key']
  34
+      user = User.find(:first, :conditions => ["lower(login) = ?", params[:login].downcase])
  35
+      render :text => "#{user.full_name}"
  36
+    else
  37
+      redirect_to :action => :index
  38
+    end
  39
+  end
  40
+
  41
+  def login
  42
+    if params[:login_action]
  43
+      session[:login_action] = {:url => session[:return_to], :action_result => params[:login_action]}
  44
+    end    
  45
+    
  46
+    # Forum Integration
  47
+    if params[:modal]
  48
+      render :action => "login_modal", :layout => false
  49
+    end
  50
+    
  51
+    if params[:ReturnUrl]
  52
+      session[:return_to] = params[:ReturnUrl]
  53
+    end
  54
+    
  55
+    if params[:wiki_return_page]
  56
+      session[:return_to] = "#{WIKI_URL}/#{params[:wiki_return_page]}"
  57
+    end
  58
+    if using_open_id?
  59
+       open_id_authentication(params[:openid_url])
  60
+    elsif params[:user]
  61
+      beer = User.find_by_login(params[:user][:login])
  62
+      logger.info beer.to_yaml
  63
+      self.current_user = User.authenticate(params[:user][:login], params[:user][:password])
  64
+      return unless request.post?
  65
+    else
  66
+      return unless request.post?
  67
+    end
  68
+    
  69
+    if logged_in?
  70
+      self.current_user.update_attribute(:previous_login_date, self.current_user.last_login ? self.current_user.last_login : Time.now)
  71
+      self.current_user.update_attribute(:last_login, Time.now)
  72
+      ip = self.current_user.user_ip_addresses.find_or_create_by_addr(UserIpAddress.int_form(request.remote_ip))
  73
+      self.current_user.check_feed_key
  74
+      process_login_actions
  75
+      if params[:remember_me] == "1"
  76
+        self.current_user.remember_me
  77
+        cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at }
  78
+      end
  79
+      if self.current_user.fans.find(:first, :conditions => ["confirmed = ? AND created_at > ?", false, self.current_user.previous_login_date])
  80
+        flash[:notice] = "Logged in * " + "<a href='#{url_for(:controller => "friends", :login => self.current_user.login)}'>New Friends Requests!</a> *"
  81
+      else
  82
+        flash[:notice] = "Logged in successfully"
  83
+      end
  84
+      redirect_back_or_default(:controller => 'profile', :action => 'profile', :login => current_user.login)
  85
+    else
  86
+      flash.now[:warning] = "Login failed"
  87
+    end
  88
+  end
  89
+  
  90
+  def accept_tos
  91
+    @page_title = "Please Accept our Terms of Service and Privacy Policy"
  92
+    if request.post?
  93
+      user = User.find_by_id(current_user.id)
  94
+      if params[:accept_tos] == "1"
  95
+        user.accepted_tos = true
  96
+        user.accepted_tos_at = Time.now
  97
+        user.save!
  98
+        logger.info "USER TOS: #{user.accepted_tos}"
  99
+        self.current_user = User.find_by_id(user.id)
  100
+        redirect_back_or_default(:controller => 'profile', :action => 'profile', :login => current_user.login)
  101
+      end
  102
+    end
  103
+  end
  104
+
  105
+  def signup
  106
+   @page_title = "Create a New Account"
  107
+
  108
+    logger.info session.inspect
  109
+    
  110
+    @user = User.new(params[:user])
  111
+    @user.email = session[:invite].invitee_email unless session[:invite].nil? or request.post?
  112
+    
  113
+    return unless request.post?
  114
+    @user.accepted_tos = true
  115
+    @user.accepted_tos_at = Time.now
  116
+
  117
+
  118
+    if @user.zipcode
  119
+      @senators, @reps = Person.find_current_congresspeople_by_zipcode(@user.zipcode, @user.zip_four)
  120
+      @user.representative_id = @reps.first.id if (@reps && @reps.length == 1)
  121
+    end  
  122
+    @user.save!
  123
+    
  124
+    # check for an invitation
  125
+    if session[:invite]
  126
+      Friend.create_confirmed_friendship(@user, session[:invite].inviter)
  127
+      session[:invite] = nil
  128
+    end
  129
+    
  130
+    redirect_to(:controller => '/account', :action => 'confirm', :login => @user.login)
  131
+  rescue ActiveRecord::RecordInvalid
  132
+    render :action => 'signup'
  133
+  end
  134
+
  135
+  def confirm
  136
+    @user = User.find_by_login(params[:login], :conditions => ["activated_at is null"])
  137
+  end
  138
+
  139
+  def logout
  140
+    if params[:wiki_return_page]
  141
+      session[:return_to] = "http://www.opencongress.org/wiki/#{params[:wiki_return_page]}"
  142
+    end    
  143
+    redirect_loc = session[:return_to]
  144
+    self.current_user.forget_me if logged_in?
  145
+    cookies.delete :auth_token
  146
+    cookies.delete '_session_id'
  147
+    # Forum Integration
  148
+    cookies.delete 'lussumocookieone'
  149
+    cookies.delete 'lussumocookietwo'
  150
+    cookies['PHPSESSID'] = {:value => '', :path => '/', :expires => Time.at(0), :domain => ".www.opencongress.org" }
  151
+    cookies['PHPSESSID'] = {:value => '', :path => '/', :expires => Time.at(0), :domain => ".opencongress.org" }
  152
+    cookies['PHPSESSID'] = {:value => '', :path => '/', :expires => Time.at(0), :domain => ".www.opencongress.org" }
  153
+    cookies.delete 'wikiToken', {:domain => '.opencongress.org'}
  154
+    cookies.delete 'wiki_session', {:domain => '.opencongress.org'}
  155
+    cookies.delete 'wikiUserID', {:domain => '.opencongress.org'}
  156
+    cookies.delete 'wikiUserName', {:domain => '.opencongress.org'}
  157
+    
  158
+    reset_session
  159
+    session[:return_to] = redirect_loc
  160
+    flash[:notice] = "You have been logged out."
  161
+    
  162
+    #redirect_back_or_default('/')
  163
+    redirect_to :controller => 'index'
  164
+  end
  165
+  
  166
+  def activate
  167
+   @user = User.find_by_activation_code(params[:id])
  168
+   if @user and @user.activate
  169
+     self.current_user = @user
  170
+     redirect_to(:controller => '/account', :action => 'welcome')
  171
+     return
  172
+   else
  173
+     flash[:notice] = "Invalid Confirmation Link"
  174
+     redirect_to(:controller => '/account', :action => "signup")
  175
+     return
  176
+   end
  177
+
  178
+  end
  179
+
  180
+  def welcome
  181
+    @user = current_user
  182
+    @show_tracked_list = true
  183
+    @most_viewed_bills = PageView.popular('Bill', DEFAULT_COUNT_TIME, 5)
  184
+    @senators, @reps = Person.find_current_congresspeople_by_zipcode(@user.zipcode, @user.zip_four) if ( logged_in? && @user == current_user && !(@user.zipcode.nil? || @user.zipcode.empty?))
  185
+  end
  186
+
  187
+  def forgot_password
  188
+    @breadcrumb = {
  189
+      1 => { 'text' => "Forgot Password", 'url' => "/account/forgot_password" }
  190
+    }
  191
+
  192
+    return unless request.post?
  193
+    if @user = User.find_by_email(params[:user][:email])
  194
+      @user.forgot_password
  195
+      @user.save!
  196
+#      redirect_back_or_default(:controller => '/account', :action => 'index')
  197
+      @page_title = "Forgot Password"
  198
+      render :action => "pwmail"
  199
+    else
  200
+      flash[:notice] = "Could not find a user with that email address"
  201
+    end
  202
+  end
  203
+
  204
+  def reset_password
  205
+    redirect_to '/account/forgot_password' and return if params[:id].blank?
  206
+    @user = User.find_by_password_reset_code(params[:id])
  207
+    @breadcrumb = {
  208
+      1 => { 'text' => "Reset Password", 'url' => "/account/reset_password" }
  209
+    }
  210
+    raise if @user.nil?
  211
+    return if @user unless request.post?
  212
+      if (params[:user][:password] == params[:user][:password_confirmation])
  213
+        self.current_user = @user #for the next two lines to work
  214
+        current_user.password_confirmation = params[:user][:password_confirmation]
  215
+        current_user.password = params[:user][:password]
  216
+        @user.reset_password
  217
+        flash[:notice] = current_user.save ? "Password reset" : "Password not reset"
  218
+      else
  219
+        flash[:notice] = "Password mismatch"
  220
+      end
  221
+      redirect_back_or_default(:controller => '/account', :action => 'index')
  222
+  end
  223
+
  224
+  def profile
  225
+    @user = User.find_by_login(params[:user])
  226
+  end
  227
+  def change_pw
  228
+    @user = current_user
  229
+    if (params[:user][:password] == params[:user][:password_confirmation])
  230
+      self.current_user = @user #for the next two lines to work
  231
+      current_user.password_confirmation = params[:user][:password_confirmation]
  232
+      current_user.password = params[:user][:password]
  233
+      @user.reset_password
  234
+      flash[:notice] = current_user.save ? "Password reset" : "Password not reset"
  235
+    else
  236
+      flash[:notice] = "Password mismatch"
  237
+    end
  238
+    redirect_back_or_default(:controller => '/profile', :action => 'profile', :login => current_user.login)
  239
+  end
  240
+  def mailing_list
  241
+   if params[:user][:mailing] && params[:user][:mailing] == "1"
  242
+     current_user.mailing = true
  243
+     flash[:notice] = "Subscribed to the Mailing List"
  244
+   else
  245
+     current_user.mailing = false
  246
+     flash[:notice] = "Un-Subscribed from the Mailing List"
  247
+   end 
  248
+   current_user.save!
  249
+   redirect_back_or_default(:controller => '/profile', :action => 'profile', :login => current_user.login)
  250
+  end
  251
+
  252
+  def why
  253
+  end
  254
+
  255
+  def invited
  256
+    invite = FriendInvite.find_by_invite_key(params[:id])
  257
+    
  258
+    session[:invite] = invite
  259
+    
  260
+    redirect_to :controller => 'register'
  261
+  end
  262
+
  263
+  def new_openid
  264
+   @page_title = "New OpenID Account"
  265
+   identity_url = session[:idurl]
  266
+   if request.post? && identity_url
  267
+     begin
  268
+       @user = User.new(params[:user])
  269
+       @user.identity_url = identity_url
  270
+       @user.email = session[:invite].invitee_email unless session[:invite].nil? or request.post?
  271
+  
  272
+       if @user.zipcode
  273
+         @senators, @reps = Person.find_current_congresspeople_by_zipcode(@user.zipcode, @user.zip_four)
  274
+         @user.representative_id = @reps.first.id if (@reps && @reps.length == 1)
  275
+       end
  276
+       @user.save!
  277
+  
  278
+       # check for an invitation
  279
+       if session[:invite]
  280
+         Friend.create_confirmed_friendship(@user, session[:invite].inviter)
  281
+         session[:invite] = nil
  282
+       end
  283
+
  284
+       redirect_to(:controller => '/account', :action => 'confirm', :login => @user.login)
  285
+     rescue ActiveRecord::RecordInvalid
  286
+       render :action => 'signup'
  287
+     end
  288
+    end
  289
+  end
  290
+  
  291
+  def check_forums
  292
+   if logged_in?
  293
+     begin
  294
+       fuser = Forum.find(:first, :conditions => ["Name = ?", current_user.login])
  295
+       unless fuser
  296
+          fuser = Forum.create({:Name => current_user.login, :Password => current_user.crypted_password, :RoleID => 3, :DateFirstVisit => Time.new(), :DateLastActive => Time.new()})
  297
+       end
  298
+       vkey = Digest::SHA1.hexdigest( Time.now.to_s.split(//).sort_by {rand}.join )
  299
+       fuser.VerificationKey = vkey
  300
+       fuser.save
  301
+       cookies[:lussumocookieone] = fuser.UserID.to_s
  302
+       cookies[:lussumocookietwo] = vkey
  303
+     rescue
  304
+     end
  305
+   end
  306
+  end
  307
+
  308
+  def check_wiki
  309
+    if logged_in?
  310
+      begin
  311
+        require 'net/http'
  312
+        require 'uri'
  313
+        require 'cgi'
  314
+
  315
+        cookie_domain = '.opencongress.org'
  316
+
  317
+        data = "wpName=#{CGI::escape(current_user.login)}&wpPassword=#{API_KEY['wiki_pass']}&wpLoginattempt=Log%20in&#{API_KEYS['wiki_key']}=true"
  318
+
  319
+        headers = {
  320
+          'Content-Type' => 'application/x-www-form-urlencoded'
  321
+        }
  322
+
  323
+        http = Net::HTTP.new(RAILS_ENV == 'production' ? 'wiki.opencongress.org' : WIKI_BASE.gsub(/http:\/\//,''), 80)
  324
+
  325
+        path = "/index.php?title=Special:UserLogin&returnto=Main_Page"
  326
+        resp, data = http.post(path,data,headers)
  327
+
  328
+        returned_cookies = resp['set-cookie'].split(',')
  329
+        returned_cookies.each do |b|
  330
+          b.strip!
  331
+          if b =~ /^([A-Za-z0-9_]+)\=([A-Za-z0-9_]+)/
  332
+            cookie_name, cookie_value = [$1, $2]
  333
+            logger.info cookie_name
  334
+            cookies[cookie_name] = {:value => cookie_value, :expires => 30.days.from_now, :domain => cookie_domain, :path => '/'}
  335
+          end
  336
+        end
  337
+      rescue
  338
+      end
  339
+    end
  340
+  end
  341
+
  342
+  def add_openid
  343
+      authenticate_with_open_id(params[:identity_url]) do |status, identity_url, registration|
  344
+        if status.successful?
  345
+          user = User.find_by_id(current_user.id)
  346
+          user.identity_url = identity_url
  347
+          if user.save
  348
+            flash[:notice] = "OpenID identity added"
  349
+          else
  350
+            flash[:notice] = "A user already exists with that open ID"
  351
+          end
  352
+        else
  353
+          flash[:notice] = "Failed Login"
  354
+        end
  355
+        redirect_to user_profile_path(current_user.login)
  356
+      end
  357
+  end
  358
+
  359
+  protected
  360
+
  361
+#  def open_id_authentication
  362
+#    authenticate_with_open_id do |result, identity_url|
  363
+#      if result.successful?
  364
+#        self.current_user = User.find_or_create_by_identity_url(identity_url)
  365
+#      end
  366
+#    end
  367
+#  end
  368
+     def open_id_authentication(identity_url)
  369
+        # Pass optional :required and :optional keys to specify what sreg fields you want.
  370
+        # Be sure to yield registration, a third argument in the #authenticate_with_open_id block.
  371
+        authenticate_with_open_id(identity_url, :required => [:nickname, :email]) do |status, identity_url, registration|
  372
+          if status.successful?
  373
+            if self.current_user = User.find_by_identity_url(identity_url)
  374
+              # registration is a hash containing the valid sreg keys given above
  375
+              # use this to map them to fields of your user model
  376
+#              {'login=' => 'nickname', 'email=' => 'email', 'full_name=' => 'fullname'}.each do |attr, reg|
  377
+#                current_user.send(attr, registration[reg]) unless registration[reg].blank?
  378
+#              end
  379
+              unless self.current_user.save
  380
+                flash[:error] = "Error saving the fields from your OpenID profile: #{current_user.errors.full_messages.to_sentence}"
  381
+              end
  382
+            else
  383
+             u = User.new()
  384
+              {'login=' => 'nickname', 'email=' => 'email', 'full_name=' => 'fullname'}.each do |attr, reg|
  385
+                u.send(attr, registration[reg]) unless registration[reg].blank?
  386
+              end
  387
+              if u.save && self.current_user = User.find_by_identity_url(identity_url)
  388
+                logger.info "rock on"
  389
+              else 
  390
+                session[:idurl] = identity_url
  391
+                redirect_to :action => "new_openid" and return
  392
+              end
  393
+            end
  394
+          end
  395
+        end
  396
+      end
  397
+
  398
+  private
  399
+  def root_url
  400
+    home_url
  401
+  end
  402
+  def process_login_actions
  403
+    #debugger
  404
+    if session[:action] && session[:action][:url]
  405
+      case session[:action][:url]
  406
+      when /\/bill\/([0-9]{3}-\w{2,})\//
  407
+        ident = $1
  408
+        if ident
  409
+          bill = Bill.find_by_ident(ident)
  410
+          if bill
  411
+            if session[:login_action][:action_result].to_i == 0
  412
+              b = BillVote.find_or_create_by_user_id_and_bill_id(current_user.id, bill.id)
  413
+              b.support = 0
  414
+              b.save
  415
+            elsif session[:login_action][:action_result].to_i == 1
  416
+              b = BillVote.find_or_create_by_user_id_and_bill_id(current_user.id, bill.id)
  417
+              b.support = 1
  418
+              b.save
  419
+            end
  420
+          end
  421
+        end
  422
+      end
  423
+    if session[:login_action][:action_result]
  424
+      if session[:login_action][:action_result] == 'track'
  425
+      case session[:login_action][:url]
  426
+      when /\/bill\/([0-9]{3}-\w{2,})\//
  427
+        ident = $1
  428
+        if ident
  429
+          bill = Bill.find_by_ident(ident)
  430
+          if bill
  431
+            bookmark = Bookmark.new(:user_id => current_user.id)
  432
+            bill.bookmarks << bookmark
  433
+          end    
  434
+        end
  435
+      when /\/([^\/]+)\/[^\/]+\/(\d+)/
  436
+        obj = $1
  437
+        id = $2
  438
+        if id && obj
  439
+          object = Object.const_get(obj)
  440
+          this_object = object.find_by_id(id)
  441
+          if this_object
  442
+            bookmark = Bookmark.new(:user_id => current_user.id)
  443
+            this_object.bookmarks << bookmark
  444
+          end
  445
+        end
  446
+      end
  447
+      end
  448
+    end
  449
+  end
  450
+  end