├── .gitignore ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.textile ├── Rakefile ├── app ├── controllers │ ├── application_controller.rb │ ├── openid_controller.rb │ └── storage_controller.rb ├── helpers │ ├── application_helper.rb │ └── storage_helper.rb ├── javascripts │ ├── application.js │ ├── defaults.js │ ├── editable.js │ ├── intro.js │ ├── jquery-extensions.js │ ├── keyboard.js │ ├── lib │ │ ├── jquery-ui.min.js │ │ ├── jquery.min.js │ │ └── json2.js │ ├── models.js │ ├── outro.js │ ├── projects.js │ ├── reusable │ │ ├── feedback.js │ │ ├── lock.js │ │ ├── mvc.js │ │ └── storage.js │ ├── search.js │ ├── tasks.js │ └── test │ │ ├── lock_test.js │ │ └── riot.js ├── models │ ├── collection.rb │ ├── project.rb │ ├── setting.rb │ ├── task.rb │ ├── user.rb │ ├── wingman.rb │ └── wingman │ │ └── hash_helpers.rb └── views │ ├── application │ ├── login.html.erb │ └── main.html.erb │ ├── layouts │ ├── application.html.erb │ └── login.html.erb │ └── openid │ └── new.html.erb ├── config.ru ├── config ├── application.rb ├── boot.rb ├── environment.rb ├── environments │ ├── development.rb │ ├── production.rb │ └── test.rb ├── initializers │ ├── backtrace_silencers.rb │ ├── inflections.rb │ ├── mime_types.rb │ ├── openid.rb │ ├── secret_token.rb │ └── session_store.rb ├── locales │ └── en.yml ├── mongoid.yml └── routes.rb ├── db └── seeds.rb ├── doc └── README_FOR_APP ├── lib ├── db_store.rb └── tasks │ ├── .gitkeep │ └── js.rake ├── public ├── 404.html ├── 422.html ├── 500.html ├── favicon.ico ├── images │ ├── openid.gif │ ├── rails.png │ ├── spinner.gif │ └── wingman_logo.png ├── javascripts │ └── all.js ├── robots.txt ├── screenshots │ └── wingman.png └── stylesheets │ ├── .gitkeep │ ├── aristo.css │ ├── images │ ├── button_bg.png │ ├── datepicker.gif │ ├── icon_sprite.png │ ├── progress_bar.gif │ ├── red_button_bg.gif │ ├── red_gradient.gif │ ├── slider_h_bg.gif │ ├── slider_handles.png │ ├── slider_v_bg.gif │ ├── subtle_button_bg.gif │ ├── tab_bg.gif │ ├── the_gradient.gif │ ├── todo.png │ ├── todo_blank.png │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ ├── ui-bg_flat_10_000000_40x100.png │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ ├── ui-bg_glass_65_ffffff_1x400.png │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ ├── ui-bg_highlight-soft_100_eeeeee_1x100.png │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ ├── ui-icons_222222_256x240.png │ ├── ui-icons_228ef1_256x240.png │ ├── ui-icons_ef8c08_256x240.png │ ├── ui-icons_ffd27a_256x240.png │ └── ui-icons_ffffff_256x240.png │ ├── ipad.css │ ├── iphone.css │ ├── print.css │ ├── scaffold.css │ └── screen.css ├── script └── rails ├── test ├── functional │ └── storage_controller_test.rb ├── integration │ └── test.rb ├── performance │ └── browsing_test.rb ├── test_helper.rb └── unit │ └── helpers │ └── storage_helper_test.rb └── vendor └── plugins └── .gitkeep /.gitignore: -------------------------------------------------------------------------------- 1 | *.swp 2 | *.swo 3 | *.DS_Store 4 | *.log 5 | *.pid 6 | tmp/ 7 | config/database.yml 8 | config/settings.yml 9 | config/development.sphinx.conf 10 | db/sphinx/* 11 | public/library/images/* 12 | public/library/images 13 | test/fixtures/file_tests/backups/ 14 | test/fixtures/file_tests/premium_documents.zip 15 | test/fixtures/file_tests/_*.csv 16 | db/sphinx/development 17 | config/development.sphinx.conf 18 | db/cstore/ 19 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | # Locked to 3rc until mongoid is updated 4 | gem 'rails', '3.0.5' 5 | gem 'mongoid', '2.0.0.rc.1' 6 | gem 'bson_ext', '1.2.4' 7 | gem 'json' 8 | gem 'ruby-openid', :require => 'openid' 9 | gem 'mongoid_session_store' 10 | 11 | group :test do 12 | gem 'capybara' 13 | gem 'launchy' 14 | end 15 | 16 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | abstract (1.0.0) 5 | actionmailer (3.0.5) 6 | actionpack (= 3.0.5) 7 | mail (~> 2.2.15) 8 | actionpack (3.0.5) 9 | activemodel (= 3.0.5) 10 | activesupport (= 3.0.5) 11 | builder (~> 2.1.2) 12 | erubis (~> 2.6.6) 13 | i18n (~> 0.4) 14 | rack (~> 1.2.1) 15 | rack-mount (~> 0.6.13) 16 | rack-test (~> 0.5.7) 17 | tzinfo (~> 0.3.23) 18 | activemodel (3.0.5) 19 | activesupport (= 3.0.5) 20 | builder (~> 2.1.2) 21 | i18n (~> 0.4) 22 | activerecord (3.0.5) 23 | activemodel (= 3.0.5) 24 | activesupport (= 3.0.5) 25 | arel (~> 2.0.2) 26 | tzinfo (~> 0.3.23) 27 | activeresource (3.0.5) 28 | activemodel (= 3.0.5) 29 | activesupport (= 3.0.5) 30 | activesupport (3.0.5) 31 | arel (2.0.9) 32 | bson (1.2.4) 33 | bson_ext (1.2.4) 34 | builder (2.1.2) 35 | capybara (0.4.1.2) 36 | celerity (>= 0.7.9) 37 | culerity (>= 0.2.4) 38 | mime-types (>= 1.16) 39 | nokogiri (>= 1.3.3) 40 | rack (>= 1.0.0) 41 | rack-test (>= 0.5.4) 42 | selenium-webdriver (>= 0.0.27) 43 | xpath (~> 0.1.3) 44 | celerity (0.8.8) 45 | childprocess (0.1.7) 46 | ffi (~> 0.6.3) 47 | configuration (0.0.5) 48 | culerity (0.2.12) 49 | erubis (2.6.6) 50 | abstract (>= 1.0.0) 51 | ffi (0.6.3) 52 | rake (>= 0.8.7) 53 | i18n (0.4.1) 54 | json (1.4.6) 55 | json_pure (1.4.3) 56 | launchy (0.3.3) 57 | configuration (>= 0.0.5) 58 | rake (>= 0.8.1) 59 | mail (2.2.15) 60 | activesupport (>= 2.3.6) 61 | i18n (>= 0.4.0) 62 | mime-types (~> 1.16) 63 | treetop (~> 1.4.8) 64 | mime-types (1.16) 65 | mongo (1.1.5) 66 | bson (>= 1.1.5) 67 | mongoid (2.0.0.rc.1) 68 | activemodel (~> 3.0) 69 | mongo (~> 1.1.5) 70 | tzinfo (~> 0.3.22) 71 | will_paginate (~> 3.0.pre) 72 | mongoid_session_store (1.1.1) 73 | actionpack (~> 3.0.0) 74 | actionpack (~> 3.0.0) 75 | activemodel (~> 3.0.0) 76 | activemodel (~> 3.0.0) 77 | mongoid (~> 2.0.0.pre) 78 | mongoid (~> 2.0.0.pre) 79 | nokogiri (1.3.3) 80 | polyglot (0.3.1) 81 | rack (1.2.1) 82 | rack-mount (0.6.13) 83 | rack (>= 1.0.0) 84 | rack-test (0.5.7) 85 | rack (>= 1.0) 86 | rails (3.0.5) 87 | actionmailer (= 3.0.5) 88 | actionpack (= 3.0.5) 89 | activerecord (= 3.0.5) 90 | activeresource (= 3.0.5) 91 | activesupport (= 3.0.5) 92 | bundler (~> 1.0) 93 | railties (= 3.0.5) 94 | railties (3.0.5) 95 | actionpack (= 3.0.5) 96 | activesupport (= 3.0.5) 97 | rake (>= 0.8.7) 98 | thor (~> 0.14.4) 99 | rake (0.8.7) 100 | ruby-openid (2.1.8) 101 | rubyzip (0.9.1) 102 | selenium-webdriver (0.0.29) 103 | childprocess (>= 0.0.7) 104 | ffi (~> 0.6.3) 105 | json_pure 106 | rubyzip 107 | thor (0.14.6) 108 | treetop (1.4.8) 109 | polyglot (>= 0.3.1) 110 | tzinfo (0.3.23) 111 | will_paginate (3.0.pre2) 112 | xpath (0.1.3) 113 | nokogiri (~> 1.3) 114 | 115 | PLATFORMS 116 | ruby 117 | 118 | DEPENDENCIES 119 | bson_ext (= 1.2.4) 120 | capybara 121 | json 122 | launchy 123 | mongoid (= 2.0.0.rc.1) 124 | mongoid_session_store 125 | rails (= 3.0.5) 126 | ruby-openid 127 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.textile: -------------------------------------------------------------------------------- 1 |
 2 | .::    .   .:::::::::.    :::.  .,-:::::/   .        :     :::.     :::.    :::.
 3 | ';;,  ;;  ;;;' ;;;`;;;;,  `;;;,;;-'````'    ;;,.    ;;;    ;;`;;    `;;;;,  `;;;
 4 |  '[[, [[, [['  [[[  [[[[[. '[[[[[   [[[[[[/ [[[[, ,[[[[,  ,[[ '[[,   [[[[[. '[[
 5 |    Y$c$$$c$P   $$$  $$$ "Y$c$$"$$c.    "$$  $$$$$$$$"$$$c $$$cc$$$c  $$$ "Y$c$$
 6 |     "88"888    888  888    Y88 `Y8bo,,,o88o 888 Y88" 888o 888   888, 888    Y88
 7 |      "M "M"    MMM  MMM     YM   `'YMUP"YMM MMM  M'  "MMM YMM   ""`. MMM     YM
 8 |                                                   
 9 |                                                   An open source to-do list app
10 | 
11 | 12 | h3. News 13 | 14 | Twitter: "@alex_young":http://twitter.com/alex_young. 15 | 16 | * [2011-02-27] Updated to Rails 3.0.5, Mongoid 2.0.0.rc.1, added mongoid_session_store, empty search will show a message again 17 | * [2011-01-24] OpenID will be remember in a cookie 18 | * [2010-12-01] Various interface bug fixes 19 | * [2010-11-25] Added list to move task to a different project (so dragging isn't required). Keyboard shortcut is 'f' 20 | * [2010-11-17] Added 'Not Today' button 21 | * [2010-11-09] Default titles will be set instead of blank project names 22 | * [2010-11-06] shift-j and shift-k move through projects, return will mark as done, added text export to export project to-do lists 23 | * [2010-11-03] Task names and notes are now escaped, so pasting in HTML should be OK 24 | 25 | !http://github.com/alexyoung/wingman/raw/master/public/screenshots/wingman.png! 26 | 27 | This is an open source to-do list web application. It features a rich desktop-like interface. 28 | 29 | "Try the demo":http://wingman.heroku.com/ 30 | 31 | h3. Installation 32 | 33 | You'll need the following: 34 | 35 | # An account with an OpenID provider. These are easier to come by than you might think (if you use Flickr you have one through Yahoo!) 36 | # A mongo server. I use "MongoHQ":http://mongohq.com/ for some projects, but it's easy to install locally (with apt, homebrew, ports, etc.) 37 | # A web server for public use. Apache or Nginx with "Passenger":http://www.modrails.com/ will work great 38 | # This project will also work well with Heroku 39 | 40 | To install: 41 | 42 | # Check the project out with git clone 43 | # Fill out your Mongo server details in config/mongoid.yml 44 | # Run bundle install (prefix with sudo if required) 45 | # Run rails server or install for your web server 46 | 47 | h3. Heroku Configuration 48 | 49 | Run this to add the settings Mongo requires: 50 | 51 | 52 | heroku config:add MONGOID_HOST=server_hostname MONGOID_PORT=27039 MONGOID_DATABASE=database_name MONGOID_USERNAME=username MONGOID_PASSWORD=password 53 | 54 | 55 | h3. Libraries 56 | 57 | * Rails 3 58 | * ruby-openid, "documentation":http://openidenabled.com/files/ruby-openid/docs/2.1.2/, "example code":http://github.com/pelle/ruby-openid/blob/master/examples/rails_openid/app/controllers/consumer_controller.rb 59 | * mongoid, "documentation":http://mongoid.org/docs/installation/ 60 | * jQuery, "jQueryUI":http://jqueryui.com 61 | * "Aristo jQuery theme":http://taitems.tumblr.com/post/482577430/introducing-aristo-a-jquery-ui-theme, "demo":http://www.warfuric.com/taitems/demo.html 62 | * json2 63 | 64 | h3. Assets 65 | 66 | * "OpenID badge":http://openid.net/foundation/news/logos/ 67 | * Aristo theme graphics 68 | 69 | h3. To-do 70 | 71 | * The models should use embedded relationships 72 | * Improved mobile interface 73 | 74 | h3. License (GPL) 75 | 76 | This program is free software: you can redistribute it and/or modify 77 | it under the terms of the GNU General Public License as published by 78 | the Free Software Foundation, either version 3 of the License, or 79 | (at your option) any later version. 80 | 81 | This program is distributed in the hope that it will be useful, 82 | but WITHOUT ANY WARRANTY; without even the implied warranty of 83 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 84 | GNU General Public License for more details. 85 | 86 | You should have received a copy of the GNU General Public License 87 | along with this program. If not, see "http://www.gnu.org/licenses/":http://www.gnu.org/licenses/. 88 | 89 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 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.expand_path('../config/application', __FILE__) 5 | require 'rake' 6 | 7 | Wingman::Application.load_tasks 8 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | #protect_from_forgery 3 | 4 | def main 5 | load_user 6 | end 7 | 8 | def logout 9 | session.clear 10 | redirect_to '/' 11 | end 12 | 13 | def alljs 14 | render :text => Wingman.alljs 15 | end 16 | 17 | private 18 | 19 | def load_user 20 | @current_user = User.find :first, :conditions => { :identity_url => session[:identity_url] } 21 | end 22 | 23 | def requires_authentication 24 | if session[:identity_url] and load_user 25 | true 26 | else 27 | respond_to do |wants| 28 | wants.js { render :text => 'Access denied', :status => :unauthorized } 29 | wants.html { redirect_to new_openid_url } 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /app/controllers/openid_controller.rb: -------------------------------------------------------------------------------- 1 | require 'openid/store/memory' 2 | require 'openid/store/filesystem' 3 | require 'lib/db_store' 4 | 5 | class OpenidController < ApplicationController 6 | def index 7 | render :action => 'new' 8 | end 9 | 10 | def new 11 | end 12 | 13 | def create 14 | openid_response = openid_consumer.begin params[:openid_url] 15 | immediate = false 16 | return_to = url_for :action => 'complete', :only_path => false 17 | realm = url_for :action => 'index', :only_path => false 18 | cookies[:open_id] = params[:openid_url] 19 | 20 | if openid_response.send_redirect?(realm, return_to, immediate) 21 | redirect_to openid_response.redirect_url(realm, return_to, immediate) 22 | else 23 | render :text => openid_response.html_markup(realm, return_to, immediate, {'id' => 'openid_form'}) 24 | end 25 | rescue OpenID::DiscoveryFailure 26 | flash[:error] = 'Error, please enter a valid OpenID URL' 27 | redirect_to '/' 28 | end 29 | 30 | def complete 31 | current_url = url_for :action => 'complete', :only_path => false 32 | parameters = params.reject { |k,v| request.path_parameters[k.to_sym] } 33 | openid_response = openid_consumer.complete(parameters, current_url) 34 | case openid_response.status 35 | when OpenID::Consumer::FAILURE 36 | if openid_response.display_identifier 37 | flash[:error] = "Verification of #{openid_response.display_identifier} failed: #{openid_response.message}" 38 | else 39 | flash[:error] = "Verification failed: #{openid_response.message}" 40 | end 41 | when OpenID::Consumer::SUCCESS 42 | session[:identity_url] = openid_response.identity_url 43 | 44 | unless User.find :first, :conditions => { :identity_url => openid_response.identity_url } 45 | User.create :identity_url => openid_response.identity_url, :display_identifier => openid_response.display_identifier 46 | end 47 | 48 | flash[:info] = "Verification of #{openid_response.display_identifier} succeeded." 49 | when OpenID::Consumer::SETUP_NEEDED 50 | flash[:error] = "Immediate request failed - Setup needed" 51 | when OpenID::Consumer::CANCEL 52 | flash[:error] = "OpenID transaction cancelled." 53 | else 54 | flash[:error] = "OpenID login failed." 55 | end 56 | redirect_to '/' 57 | end 58 | 59 | private 60 | 61 | def openid_store 62 | OpenID::Store::DbStore.new 63 | end 64 | 65 | def openid_consumer 66 | if @openid_consumer.nil? 67 | @openid_consumer = OpenID::Consumer.new(session, openid_store) 68 | end 69 | return @openid_consumer 70 | end 71 | 72 | end 73 | 74 | -------------------------------------------------------------------------------- /app/controllers/storage_controller.rb: -------------------------------------------------------------------------------- 1 | class StorageController < ApplicationController 2 | before_filter :requires_authentication 3 | 4 | # The entire collection of data 5 | def restore 6 | data = { 7 | 'collections' => kv_hash('collections'), 8 | 'settings' => kv_hash('settings'), 9 | 'projects' => collection_hash('projects'), 10 | 'tasks' => collection_hash('tasks') 11 | } 12 | 13 | render :json => data 14 | end 15 | 16 | # GET /storage/archive 17 | def archive 18 | # TODO: Pagination 19 | @tasks = Task.where(:user_id => @current_user.id).and(:archived => true).desc(:created_at) 20 | render :json => @tasks 21 | end 22 | 23 | # POST /storage 24 | def create 25 | json = JSON.parse params[:data] 26 | json['user_id'] = @current_user.id 27 | 28 | save_and_respond do 29 | collection_class(params[:collection]).create json 30 | end 31 | end 32 | 33 | # PUT /storage 34 | def update 35 | json = JSON.parse params[:data] 36 | json['user_id'] = @current_user.id 37 | item = collection_class(params[:collection]).find( 38 | :first, 39 | :conditions => { 40 | :user_id => @current_user.id, 41 | :id => json['id'] 42 | } 43 | ) 44 | 45 | if item.nil? 46 | render :json => { 'error' => "Couldn't find #{params[:collection]} with ID: #{json['id']}" }, :status => :error 47 | else 48 | save_and_respond do 49 | item.update_attributes json 50 | item 51 | end 52 | end 53 | end 54 | 55 | # PUT /storage/set_key_value 56 | def set_key_value 57 | json = JSON.parse params['data'] 58 | key = json['key'] 59 | value = json['value'] 60 | item = collection_class(params['collection']).find(:all, :conditions => { :user_id => @current_user.id, :key => key })[0] 61 | 62 | save_and_respond do 63 | if item.nil? 64 | item = collection_class(params['collection']).create({ :key => key, :value => value, :user_id => @current_user.id }) 65 | else 66 | item.update_attributes :value => value 67 | end 68 | item 69 | end 70 | end 71 | 72 | # DELETE /storage 73 | def destroy 74 | item = collection_class(params[:collection]).find( 75 | :first, 76 | :conditions => { 77 | :user_id => @current_user.id, 78 | :id => params[:id] 79 | } 80 | ) 81 | 82 | save_and_respond do 83 | item.destroy 84 | item 85 | end 86 | end 87 | 88 | def update_user 89 | @current_user.update_attributes :name => params[:current_user][:name] 90 | if @current_user.valid? 91 | render :text => 'Your name has been changed' 92 | else 93 | render :text => @current_user.errors.full_messages.to_sentence, :status => :error 94 | end 95 | end 96 | 97 | private 98 | include Wingman::HashHelpers 99 | 100 | def save_and_respond(&block) 101 | respond_to do |format| 102 | item = yield 103 | if item.valid? 104 | format.json { head :ok, :status => :success } 105 | else 106 | format.json { render :json => item.errors, :status => :unprocessable_entity } 107 | end 108 | end 109 | end 110 | end 111 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | def logged_in? 3 | session[:identity_url] 4 | end 5 | 6 | def render_flash 7 | flash.map do |flash_type, message| 8 | display_flash flash_type, message 9 | end.compact.join("\n") 10 | end 11 | 12 | def display_flash(flash_type, message) 13 | html =<<-HTML 14 |
15 |
16 |

17 | #{flash_type.to_s.titlecase}: #{message}.

18 |
19 |
20 | HTML 21 | end 22 | 23 | def flash_icon(flash_type) 24 | case flash_type 25 | when :error 26 | 'ui-icon-alert' 27 | when :info, :sucess 28 | 'ui-icon-info' 29 | else 30 | '' 31 | end 32 | end 33 | 34 | def flash_class(flash_type) 35 | case flash_type 36 | when :info, :sucess 37 | 'highlight' 38 | else 39 | flash_type 40 | end 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /app/helpers/storage_helper.rb: -------------------------------------------------------------------------------- 1 | module StorageHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/javascripts/application.js: -------------------------------------------------------------------------------- 1 | var dateFormat = 'yy/mm/dd', 2 | originalEditableValue, 3 | dragLock = new Lock(), 4 | userAgent, 5 | userAgentFamily; 6 | 7 | if (navigator.userAgent.match(/iPad/i) != null) { 8 | userAgent = 'iPad'; 9 | userAgentFamily = 'iOS'; 10 | } else if (navigator.userAgent.match(/iPhone/i) != null) { 11 | userAgent = 'iPhone'; 12 | userAgentFamily = 'iOS'; 13 | } 14 | 15 | $(document).ajaxError(function(e, xhr, settings, exception) { 16 | Storage.done(); 17 | if (xhr.status !== 200) { 18 | if (settings.url.match(/update_openid/)) { 19 | $('#settings-feedback').html(Feedback.message('error', xhr.responseText)); 20 | } else if (xhr.status === 401) { 21 | window.location = '/logout'; 22 | } else { 23 | console.log('error in: ' + settings.url + ' \n' + 'error: ' + xhr.responseText); 24 | } 25 | } 26 | }); 27 | 28 | Storage.ready = function() { 29 | generateExampleData(); 30 | ProjectsController.displayAll(); 31 | resize(); 32 | Feedback.hide(); 33 | }; 34 | 35 | Storage.loading = function() { 36 | $('#loading-indicator').show(); 37 | }; 38 | 39 | Storage.done = function() { 40 | setTimeout(function() { $('#loading-indicator').hide('fade', {}, 250) }, 500); 41 | }; 42 | 43 | function generateExampleData() { 44 | if (Project.findAll().length === 0) { 45 | var p = Project.create({ name: 'Project ' + 1, tags: 'tag1 tag2 tag3', notes: null }); 46 | Task.create({ 'project_id': p.id, name: 'Example task', done: false, archived: false }); 47 | var t = Task.create({ 'project_id': null, name: 'Example task to do today', done: false, archived: false }); 48 | Collection.set('inbox', []); 49 | Collection.set('today', [t.get('id')]); 50 | Collection.set('next', []); 51 | } 52 | } 53 | 54 | if ($('#login-dialog').length === 0) { 55 | Feedback.info('Loading...'); 56 | Storage.remote.read(); 57 | } else { 58 | $('#OpenIDHelpLink').click(function() { 59 | $('.open-id-help').toggle(); 60 | }); 61 | } 62 | 63 | // Correct widths and heights based on window size 64 | function resize() { 65 | var height = $(window).height() - $('#global-menu').height() - 11, containerWidth = $($('ul.project-header')[0]).width(), 66 | width = $('.content').width() - $('.ui-icon-todo').width() - $('.ui-icon-trash').width() - 88 + 'px'; 67 | 68 | $('.outline-view').css({ height: height + 'px' }); 69 | $('.content').css({ height: height + 'px', width: $('body').width() - $('.outline-view').width() - $('.content-divider').width() - 1 + 'px' }); 70 | $('.content-divider').css({ height: height + 'px' }); 71 | 72 | if (!containerWidth) { 73 | containerWidth = $('.content').width(); 74 | } 75 | 76 | $('.todo-items .button').each(function() { 77 | this.style.width = containerWidth - $($(this).prev('.state')[0]).width() - 22 + 'px'; 78 | }); 79 | $('.name-text').css({ width: width, 'max-width': parseInt(width, 10) - 50 }); 80 | } 81 | 82 | $(window).resize(function() { 83 | setTimeout(resize, 100); 84 | }); 85 | 86 | $(window).focus(resize); 87 | 88 | function selectedCollectionIsNamed() { 89 | return $('.outline-view .items li.selected a').hasClass('named-collection'); 90 | } 91 | 92 | function selectedProject() { 93 | return $('.outline-view .items.projects li.selected a').itemID(); 94 | } 95 | 96 | function selectProject() { 97 | var setting = Settings.get('outline-view'); 98 | if (setting && setting.length > 0) { 99 | $(setting).trigger('click'); 100 | } 101 | 102 | if ($('.outline-view .selected').length === 0) { 103 | $('.outline-view .items.projects li a').first().trigger('click'); 104 | } 105 | 106 | if ($('.outline-view .selected').length === 0) { 107 | $('#show-today').trigger('click'); 108 | } 109 | } 110 | 111 | function hideArchiveButtonIfRequired() { 112 | if ($('.todo-items .done').length > 0 && $('ul.archive li.selected').length === 0) { 113 | $('#archive-tasks').closest('li').show(); 114 | } else { 115 | $('#archive-tasks').closest('li').hide(); 116 | } 117 | } 118 | 119 | // Outline view 120 | $('.outline-view ul.items a').live('click', function() { 121 | if (dragLock.locked) return; 122 | 123 | var element = $(this), selectedItem; 124 | element.closest('.outline-view').find('li.selected').removeClass('selected'); 125 | element.parent().toggleClass('selected'); 126 | 127 | if (element.closest('ul').hasClass('projects')) { 128 | ProjectsController.display(Project.find(element.itemID()), element); 129 | } 130 | 131 | selectedItem = '#' + element.attr('id'); 132 | if (Settings.get('outline-view') !== selectedItem) { 133 | Settings.set('outline-view', selectedItem); 134 | } 135 | closeEditable(); 136 | }); 137 | 138 | // Sections 139 | $('#show-settings').click(function() { 140 | $('#settings-feedback').html(''); 141 | $('.content').hide(); 142 | $('#settings').show(); 143 | $('.task-related-button').hide(); 144 | $('.settings-related-button').show(); 145 | $('.outline-view .selected').removeClass('selected'); 146 | }); 147 | 148 | $('.outline-view a').live('click', function() { 149 | if (dragLock.locked) return; 150 | 151 | TasksController.removeArchived(); 152 | $('.content').hide(); 153 | $('#project').show(); 154 | $('.task-related-button').show(); 155 | $('.settings-related-button').hide(); 156 | 157 | $('#project-todo-items').addClass('todo-items'); 158 | $('#search-todo-items').removeClass('todo-items'); 159 | $('#search input').val(defaultFieldValues.search); 160 | 161 | resize(); 162 | $('#delete-task').closest('li').hide(); 163 | $('#not-today').closest('li').hide(); 164 | hideArchiveButtonIfRequired(); 165 | }); 166 | 167 | $('.named-collection').click(function() { 168 | if (dragLock.locked) return; 169 | 170 | var collectionName = $(this).attr('id').split('-')[1], 171 | displayOptions = {}; 172 | 173 | $('.outline-view .selected').removeClass('selected'); 174 | $(this).closest('li').addClass('selected'); 175 | $('#project').show(); 176 | 177 | if (selectedCollectionIsNamed()) { 178 | displayOptions = { show_projects: true }; 179 | } 180 | 181 | TasksController.display(jQuery.map(Collection.get(collectionName) || [], function(value) { 182 | return Task.find(value); 183 | }), displayOptions); 184 | $('.project-field').hide(); 185 | }); 186 | 187 | $('#show-archive').click(function() { 188 | if (dragLock.locked) return; 189 | 190 | $('.project-field').hide(); 191 | TasksController.clear(); 192 | $('#project').show(); 193 | 194 | Feedback.info('Loading...'); 195 | 196 | // TODO: Paginate 197 | jQuery.getJSON('/storage/archive', function(data) { 198 | Feedback.hide(); 199 | var tasks = []; 200 | jQuery.each(data, function() { 201 | this.id = this._id; 202 | Storage.data.tasks[this.id] = this; 203 | tasks.push(Task.find(this.id)); 204 | }); 205 | if (tasks && tasks.length > 0) { 206 | TasksController.display(tasks, { show_projects: true }); 207 | } else { 208 | Feedback.info('No tasks have been archived.'); 209 | } 210 | }); 211 | }); 212 | 213 | // State change (done) 214 | $('.project-field .state').live('click', function() { 215 | $('.todo-items .state').each(function() { 216 | var element = $(this); 217 | if (!element.hasClass('done')) { 218 | element.trigger('click'); 219 | } 220 | }); 221 | 222 | var project = Project.find(selectedProject()); 223 | project.set('done', true); 224 | ProjectsController.displayState(project); 225 | }); 226 | 227 | $('#delete-task').click(function() { 228 | TasksController.destroy($('.todo-items .highlight').closest('li')); 229 | TasksController.destroy($('.todo-items li.task.details')); 230 | $('#delete-task').closest('li').hide(); 231 | }); 232 | 233 | $('#archive-tasks').click(function() { 234 | TasksController.archive($('.todo-items .done').parents('li.task')); 235 | }); 236 | 237 | $('#not-today').click(function() { 238 | $('#not-today').closest('li').hide(); 239 | TasksController.notToday($('.todo-items .highlight').closest('li')); 240 | }); 241 | 242 | function parseDate(value) { 243 | if (!value) return (new Date()); 244 | return $.datepicker.parseDate(dateFormat, value, {}); 245 | } 246 | 247 | function presentDate(value) { 248 | if (!value) return; 249 | return $.datepicker.formatDate($.datepicker.RFC_2822, $.datepicker.parseDate(dateFormat, value, {})); 250 | } 251 | 252 | function datePickerSave(value, element, picker) { 253 | var d = $.datepicker.parseDate('mm/dd/yy', value, {}), 254 | container; 255 | element.html(' ' 256 | + '' + $.datepicker.formatDate($.datepicker.RFC_2822, d) + ''); 257 | $(picker).remove(); 258 | 259 | // Save 260 | container = element.closest('li.task'); 261 | if (container.length > 0) { 262 | Task.find(container.itemID()).set('due', $.datepicker.formatDate(dateFormat, d)); 263 | } else { 264 | Project.find(selectedProject()).set('due', $.datepicker.formatDate(dateFormat, d)); 265 | } 266 | } 267 | 268 | function escapeQuotes(text) { 269 | return text ? text.replace(/"/g, '"') : text; 270 | } 271 | 272 | $('.editable-field').live('click', function(e) { 273 | var element = $(this), 274 | content, 275 | datePicker, 276 | closestDate, 277 | input, 278 | container = element.closest('li.task'); 279 | 280 | if (e.target.nodeName === 'INPUT' || e.target.nodeName === 'FORM') return true; 281 | if (element.find('form').length > 0) return true; 282 | 283 | closeEditable(element); 284 | 285 | if (element.find('form').length === 0) { 286 | if (element.hasClass('type-date')) { 287 | if (container.length > 0) { 288 | closestDate = Task.find(container.itemID()).get('due'); 289 | } else { 290 | closestDate = Project.find(selectedProject()).get('due'); 291 | } 292 | 293 | $('.content').first().append('
'); 294 | datePicker = $('#datepicker').datepicker({ autoSize: true, onSelect: function(value) { datePickerSave(value, element, this); }, defaultDate: parseDate(closestDate) }); 295 | datePicker.css({ 'position': 'absolute', 'z-index': 99, 'left': element.offset().left, 'top': element.offset().top }); 296 | } else { 297 | try { 298 | if (content === defaultFieldValues[element.attr('name')]) { 299 | content = ''; 300 | } else if (container.itemID()) { 301 | content = Task.find(container.itemID()).get(element.attr('name')); 302 | } else { 303 | var projectFieldName = element.attr('name').split(/project_/), 304 | projectID = $('.outline-view li.selected a').itemID(); 305 | content = Project.find(projectID).get(projectFieldName[1]); 306 | } 307 | 308 | if (!content) content = ''; 309 | 310 | if (element.hasClass('large')) { 311 | input = ''; 312 | } else { 313 | input = ''; 314 | } 315 | element.html('
' + input + '
').find('.field').trigger('focus'); 316 | originalEditableValue = content; 317 | } catch (exception) { 318 | console.log(exception); 319 | } 320 | } 321 | } 322 | }); 323 | 324 | $('.clear-due').live('click', function(e) { 325 | var element = $(this); 326 | var task = Task.find(element.closest('.task').itemID()); 327 | task.set('due', null); 328 | element.closest('li').html(defaultFieldValues.due); 329 | element.remove(); 330 | e.preventDefault(); 331 | return false; 332 | }); 333 | 334 | if (userAgentFamily != 'iOS') { 335 | $('.editable .field').live('blur', function(e) { 336 | saveEditable(); 337 | closeEditable(); 338 | }); 339 | } 340 | 341 | if (userAgentFamily !== 'iOS') { 342 | $('.content').live('click', function(e) { 343 | if ($(e.target).hasClass('content')) { 344 | TasksController.closeEditors(); 345 | $('.todo-items .highlight').removeClass('highlight'); 346 | } 347 | }); 348 | } 349 | 350 | // Delete project dialog 351 | $('#delete-project-dialog').dialog({ 352 | autoOpen: false, 353 | width: 600, 354 | buttons: { 355 | 'OK': function() { 356 | $(this).dialog('close'); 357 | Project.destroy(selectedProject()); 358 | ProjectsController.displayAll(); 359 | $('a.named-collection').first().click(); 360 | }, 361 | 'Cancel': function() { 362 | $(this).dialog('close'); 363 | } 364 | }, 365 | modal: true 366 | }); 367 | 368 | $('#export-text-dialog').dialog({ 369 | autoOpen: false, 370 | width: 600, 371 | buttons: { 372 | 'OK': function() { 373 | $(this).dialog('close'); 374 | }, 375 | }, 376 | modal: true 377 | }); 378 | 379 | // Modal login panel 380 | $('#login-dialog').dialog({ 381 | autoOpen: true, 382 | title: 'Please Login', 383 | width: 400, 384 | modal: true, 385 | closeOnEscape: false, 386 | beforeclose: function() { return false; } 387 | }); 388 | $('#login-button').button({ }); 389 | $('#login-button').click(function() { $(this).closest('form').submit(); }); 390 | $('#openid_url').select(); 391 | 392 | // Resize when the dialog opens/closes else it sometimes messes up the scrollbars 393 | $('#delete-project-button').click(function(e) { 394 | $('#delete-project-dialog').dialog('open'); 395 | resize(); 396 | e.preventDefault(); 397 | return false; 398 | }); 399 | 400 | $('#export-text-button').click(function(e) { 401 | $('#export-text-dialog').dialog('open'); 402 | var input = $('#export-text-value'), 403 | project = Project.find(selectedProject()), 404 | tasks = ProjectsController.tasks(project), 405 | output = '', 406 | done; 407 | 408 | for (var i in tasks) { 409 | done = tasks[i].get('done') ? '✓ ' : '◻ '; 410 | output += done + tasks[i].get('name') + '\n'; 411 | } 412 | input.html(output); 413 | e.preventDefault(); 414 | }); 415 | 416 | $(document).bind('dialogclose', function(event, ui) { 417 | resize(); 418 | }); 419 | 420 | $('.state').live('mouseenter', function() { $(this).addClass('ui-state-hover'); }); 421 | $('.state').live('mouseleave', function() { $(this).removeClass('ui-state-hover'); }); 422 | 423 | $('.delete').live('mouseenter', function() { $(this).addClass('ui-state-hover'); }); 424 | $('.delete').live('mouseleave', function() { $(this).removeClass('ui-state-hover'); }); 425 | 426 | $('.outline-view ul.items li').live('mouseenter', function() { 427 | $(this).addClass('hover'); 428 | }); 429 | 430 | $('.outline-view ul.items li').live('mouseleave', function() { 431 | $(this).removeClass('hover'); 432 | }); 433 | 434 | // Resizable panes 435 | (function() { 436 | var moving = false, width = 0; 437 | 438 | function start() { 439 | moving = true; 440 | } 441 | 442 | function end() { 443 | if (width > 0) { 444 | Settings.set('outline-view-width', width); 445 | } 446 | moving = false; 447 | } 448 | 449 | function move(e) { 450 | if (moving) { 451 | $('.outline-view').css({ width: e.pageX }); 452 | width = e.pageX; 453 | resize(); 454 | } 455 | } 456 | 457 | $('.content-divider').bind('mousedown', start); 458 | $(document).bind('mousemove', move); 459 | $(document).bind('mouseup', end); 460 | })(); 461 | 462 | // Setup 463 | $('.todo-items .button').button({}); 464 | $('.add-button').button({ icons: { primary: 'ui-icon-circle-plus' } }); 465 | $('#delete-task').button({ icons: { primary: 'ui-icon-trash' } }); 466 | $('#archive-tasks').button({ icons: { primary: 'ui-icon-arrowreturnthick-1-e' } }); 467 | $('#not-today').button({ icons: { primary: 'ui-icon-arrowreturnthick-1-e' } }); 468 | $('#show-settings').button({ icons: { primary: 'ui-icon-gear' } }); 469 | $('#logout').button({ icons: { primary: 'ui-icon-power' } }); 470 | $('#search').button({ icons: { primary: 'ui-icon-search' } }); 471 | 472 | // disableTextSelect works better than disableSelection 473 | $('.content-divider').disableTextSelect(); 474 | 475 | $('.todo-items .done').addClass('ui-state-disabled'); 476 | 477 | $('#project-todo-items').sortable({ 478 | handle: '.handle', 479 | stop: function(e, ui) { dragLock.unlock(); TasksController.saveSort(e, ui); }, 480 | revert: true, 481 | start: function(e, ui) { dragLock.lock(); $(ui.item).addClass('dragging'); } 482 | }).disableSelection(); 483 | $('.outline-view ul .projects').sortable({ stop: ProjectsController.saveSort }).disableSelection(); 484 | 485 | $('#tabs').tabs(); 486 | 487 | // Today droppable 488 | $('#show-today').droppable({ 489 | hoverClass: 'hover-drag', 490 | dragClass: 'dragging', 491 | accept: '.task', 492 | drop: function(e, ui) { 493 | var taskElement = $(e.srcElement).closest('.task'), 494 | task = Task.find(taskElement.itemID()); 495 | 496 | // Add to today 497 | if (task) { 498 | Collection.appendItem('today', task.get('id')); 499 | taskElement.find('.ui-icon-todo').addClass('ui-icon-todo-today'); 500 | 501 | // Remove from inbox 502 | Collection.removeItem('inbox', task.get('id')); 503 | 504 | if ($('#show-inbox').closest('li').hasClass('selected')) { 505 | taskElement.remove(); 506 | } 507 | } 508 | 509 | dragLock.timedUnlock(); 510 | } 511 | }); 512 | 513 | $('#show-inbox').droppable({ 514 | hoverClass: 'hover-drag', 515 | dragClass: 'dragging', 516 | accept: '.task', 517 | drop: function(e, ui) { 518 | var taskElement = $(e.srcElement).closest('.task'), 519 | task = Task.find(taskElement.itemID()), 520 | projectCollection; 521 | 522 | // Add to inbox 523 | if (task) { 524 | // Remove from today/projects 525 | Collection.removeItem('today', task.get('id')); 526 | 527 | if (task.get('project_id')) { 528 | Collection.removeItem('project_tasks_' + task.get('project_id'), task.get('id')); 529 | } 530 | 531 | // Add to inbox 532 | Collection.appendItem('inbox', task.get('id')); 533 | task.set('project_id', null); 534 | 535 | if (taskElement) taskElement.remove(); 536 | } 537 | 538 | dragLock.timedUnlock(); 539 | } 540 | }); 541 | 542 | // This is used by the settings form 543 | $('form.settings_form').submit(function(e) { 544 | $('#settings-feedback').html(''); 545 | var target = $(e.target); 546 | jQuery.post(target.attr('action'), target.serialize(), function() { 547 | $('#settings-feedback').html(Feedback.message('info', 'Your details have been changed')); 548 | }); 549 | e.preventDefault(); 550 | return false; 551 | }); 552 | 553 | $('.project-field').hide(); 554 | setTimeout(resize, 200); 555 | -------------------------------------------------------------------------------- /app/javascripts/defaults.js: -------------------------------------------------------------------------------- 1 | var defaultFieldValues = { 2 | name: 'Untitled task', 3 | notes: 'Notes', 4 | due: 'Due Date', 5 | search: 'Search', 6 | project_name: 'Untitled', 7 | project_notes: 'Notes' 8 | }; 9 | 10 | -------------------------------------------------------------------------------- /app/javascripts/editable.js: -------------------------------------------------------------------------------- 1 | function closeEditable(element) { 2 | $('.editable-field form.editable').each(function() { 3 | var form = $(this), 4 | value = form.find('.field').val(), 5 | container = form.parent(); 6 | if (!value || value.length === 0) { 7 | value = defaultFieldValues[container.attr('name')]; 8 | } 9 | 10 | // Add 'project: ' to the task name 11 | if (selectedCollectionIsNamed()) { 12 | var task = Task.find(form.parents('.task').itemID()), 13 | project = Project.find(task.get('project_id')); 14 | if (project) { 15 | value = project.get('name') + ': ' + value; 16 | } 17 | } 18 | 19 | // I sometimes get NOT_FOUND_ERR: DOM Exception 8 if I don't do html('') 20 | container.html('').text(value); 21 | }); 22 | $('#datepicker').remove(); 23 | } 24 | 25 | function saveEditable() { 26 | var input = $('.editable .field').first(), 27 | projectID, 28 | taskID, 29 | task, 30 | project; 31 | 32 | if (input.length === 0) return; 33 | projectID = $('.outline-view li.selected a').itemID(); 34 | 35 | if (projectID && input.closest('.task').length === 0) { 36 | project = Project.find(projectID); 37 | jQuery.each(['name', 'notes'], function(index, field) { 38 | if (input.closest('.' + field).length > 0) { 39 | project.set(field, input.val()); 40 | } 41 | }); 42 | ProjectsController.displayAll(); 43 | } else { 44 | taskID = input.closest('li.task').itemID(); 45 | if (taskID) { 46 | task = Task.find(taskID); 47 | jQuery.each(['name', 'tags', 'notes'], function(index, field) { 48 | if (input.closest('.' + field).length > 0) { 49 | task.set(field, input.val()); 50 | } 51 | }); 52 | } 53 | } 54 | } 55 | 56 | // FIXME: I don't understand the cause of this 57 | // browser fix -- the columns break when pasting content 58 | // Seen in Chrome and Safari 59 | $('form.editable textarea').live('paste', function(e) { 60 | setTimeout(resize, 5); 61 | setTimeout(resize, 10); 62 | }); 63 | 64 | $('form.editable').live('submit', function(e) { 65 | e.preventDefault(); 66 | saveEditable(); 67 | closeEditable(); 68 | }); 69 | 70 | -------------------------------------------------------------------------------- /app/javascripts/intro.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function() { 2 | 3 | -------------------------------------------------------------------------------- /app/javascripts/jquery-extensions.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | function isScrolledIntoView(elem) { 3 | var documentTop = $(window).scrollTop(); 4 | var documentBottom = documentTop + $(window).height() - $('#global-menu').height(); 5 | 6 | var elementTop = $(elem).offset().top; 7 | var elementBottom = elementTop + $(elem).height(); 8 | 9 | return ((elementBottom >= documentTop) && (elementTop <= documentBottom) 10 | && (elementBottom <= documentBottom) && (elementTop >= documentTop)); 11 | } 12 | 13 | $.fn.highlight = function() { 14 | var element = $(this), 15 | scrollContainer = $('#project'); 16 | element.addClass('highlight'); 17 | if (!isScrolledIntoView(element)) { 18 | scrollContainer.animate({ scrollTop: element.position().top }, 250); 19 | } 20 | }; 21 | 22 | $.fn.escapeText = function(text) { 23 | if (text) { 24 | return $('
').text(text).html(); 25 | } 26 | }; 27 | 28 | $.fn.disableTextSelect = function() { 29 | return this.each(function() { 30 | if ($.browser.mozilla) { 31 | $(this).css('MozUserSelect', 'none'); 32 | } else if ($.browser.msie) { 33 | $(this).bind('selectstart', function() { return false; }); 34 | } else { 35 | $(this).mousedown(function() { return false; }); 36 | } 37 | }); 38 | }; 39 | 40 | $.fn.enableTextSelect = function() { 41 | return this.each(function() { 42 | if ($.browser.mozilla) { 43 | $(this).css('MozUserSelect', 'text'); 44 | } else if ($.browser.msie) { 45 | $(this).bind('selectstart', function() { return true; }); 46 | } else { 47 | $(this).mousedown(function() { return true; }); 48 | } 49 | }); 50 | }; 51 | 52 | $.fn.itemID = function() { 53 | try { 54 | return $(this).attr('id').match(/_(\d+)/)[1]; 55 | } catch (exception) { 56 | return null; 57 | } 58 | }; 59 | })(jQuery); 60 | 61 | -------------------------------------------------------------------------------- /app/javascripts/keyboard.js: -------------------------------------------------------------------------------- 1 | function initKeyboardHandlers() { 2 | var nextResponder = $(); 3 | 4 | function saveField(e) { 5 | saveEditable(); 6 | closeEditable(); 7 | } 8 | 9 | $('.todo-items :input').live('focus', function() { 10 | nextResponder = $(this).closest('li').next(); 11 | }); 12 | 13 | $(document).bind('keyup', function(e) { 14 | if (e.which === 27) { 15 | // [esc] 16 | if ($('.task.details').length > 0 17 | && $('.editable .field').length === 0) { 18 | var task = $('.task.details'); 19 | TasksController.closeEditors(); 20 | task.find('.button').click(); 21 | } else if ($('.editable .field').length > 0) { 22 | closeEditable(); 23 | nextResponder = null; 24 | } else if ($('.task .highlight').length > 0) { 25 | $('#project').click(); 26 | } 27 | } 28 | 29 | if (e.which === 9) { 30 | // Tab 31 | if ($('#sort-dialog').is(':visible')) return; 32 | if ($('.editable .field').length > 0) saveField(e); 33 | e.preventDefault(); 34 | if (!nextResponder) nextResponder = $('ul.details li.first'); 35 | 36 | if (nextResponder.hasClass('last')) { 37 | nextResponder.click(); 38 | nextResponder = nextResponder.closest('ul').find('li.first'); 39 | } else { 40 | nextResponder.click(); 41 | } 42 | 43 | return false; 44 | } 45 | }); 46 | 47 | $(document).bind('keypress', function(e) { 48 | if ($(e.target).is(':input')) return; 49 | 50 | if (e.which === 35) { 51 | // # for delete 52 | var selectedTask = $('.task .highlight').first(); 53 | if (selectedTask.length > 0) { 54 | $('.delete-button').click(); 55 | e.preventDefault(); 56 | return; 57 | } 58 | } 59 | 60 | if (e.which === 74) { 61 | // J 62 | var navItems = $('.outline-view li a'), 63 | selected = $('.outline-view li.selected a').first(), 64 | i = navItems.index(selected); 65 | $(navItems[i == navItems.length - 1 ? 0 : i + 1]).click(); 66 | e.preventDefault(); 67 | return; 68 | } else if (e.which === 75) { 69 | // K 70 | var navItems = $('.outline-view li a'), 71 | selected = $('.outline-view li.selected a').first(), 72 | i = navItems.index(selected); 73 | $(navItems[i == 0 ? navItems.length - 1 : i - 1]).click(); 74 | e.preventDefault(); 75 | return; 76 | } 77 | 78 | if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return; 79 | 80 | if (e.which === 106) { 81 | // j 82 | TasksController.closeEditors(); 83 | var selectedTask = $('.task .highlight').first(), 84 | nextElement = $('.task .highlight').closest('li').next().find('.button'); 85 | if (selectedTask.length === 0) { 86 | $('li.body li.task .button').first().click(); 87 | } else if (nextElement.length > 0) { 88 | nextElement.click(); 89 | } else { 90 | $('li.body li.task .button').first().click(); 91 | } 92 | } else if (e.which === 107) { 93 | // k 94 | TasksController.closeEditors(); 95 | var selectedTask = $('.task .highlight').first(), 96 | prevElement = $('.task .highlight').closest('li').prev().find('.button'); 97 | if (selectedTask.length === 0) { 98 | $('li.body li.task .button').last().click(); 99 | e.preventDefault(); 100 | } else if (prevElement.length > 0) { 101 | prevElement.click(); 102 | e.preventDefault(); 103 | } else { 104 | $('li.body li.task .button').last().click(); 105 | e.preventDefault(); 106 | } 107 | } else if ((e.which === 32 || e.which === 79 || e.which === 111) 108 | && $('.task .highlight').length > 0) { 109 | // space or 'o' 110 | TasksController.open($('.task .highlight').closest('.button')); 111 | e.preventDefault(); 112 | } else if (e.which === 110) { 113 | $('.task.add-button').click(); 114 | e.preventDefault(); 115 | } else if (e.which === 121) { 116 | $('#archive-tasks').click(); 117 | } else if (e.which === 102) { 118 | // 'f' - folder menu 119 | $('.sort-task').click(); 120 | } else if (e.which === 13) { 121 | var selectedTask = $('.task .highlight'); 122 | if (selectedTask.length > 0) { 123 | selectedTask.prev('.state').click(); 124 | e.preventDefault(); 125 | return; 126 | } 127 | } 128 | }); 129 | } 130 | 131 | initKeyboardHandlers(); 132 | 133 | -------------------------------------------------------------------------------- /app/javascripts/lib/json2.js: -------------------------------------------------------------------------------- 1 | /* 2 | http://www.JSON.org/json2.js 3 | 2010-03-20 4 | 5 | Public Domain. 6 | 7 | NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. 8 | 9 | See http://www.JSON.org/js.html 10 | 11 | 12 | This code should be minified before deployment. 13 | See http://javascript.crockford.com/jsmin.html 14 | 15 | USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO 16 | NOT CONTROL. 17 | 18 | 19 | This file creates a global JSON object containing two methods: stringify 20 | and parse. 21 | 22 | JSON.stringify(value, replacer, space) 23 | value any JavaScript value, usually an object or array. 24 | 25 | replacer an optional parameter that determines how object 26 | values are stringified for objects. It can be a 27 | function or an array of strings. 28 | 29 | space an optional parameter that specifies the indentation 30 | of nested structures. If it is omitted, the text will 31 | be packed without extra whitespace. If it is a number, 32 | it will specify the number of spaces to indent at each 33 | level. If it is a string (such as '\t' or ' '), 34 | it contains the characters used to indent at each level. 35 | 36 | This method produces a JSON text from a JavaScript value. 37 | 38 | When an object value is found, if the object contains a toJSON 39 | method, its toJSON method will be called and the result will be 40 | stringified. A toJSON method does not serialize: it returns the 41 | value represented by the name/value pair that should be serialized, 42 | or undefined if nothing should be serialized. The toJSON method 43 | will be passed the key associated with the value, and this will be 44 | bound to the value 45 | 46 | For example, this would serialize Dates as ISO strings. 47 | 48 | Date.prototype.toJSON = function (key) { 49 | function f(n) { 50 | // Format integers to have at least two digits. 51 | return n < 10 ? '0' + n : n; 52 | } 53 | 54 | return this.getUTCFullYear() + '-' + 55 | f(this.getUTCMonth() + 1) + '-' + 56 | f(this.getUTCDate()) + 'T' + 57 | f(this.getUTCHours()) + ':' + 58 | f(this.getUTCMinutes()) + ':' + 59 | f(this.getUTCSeconds()) + 'Z'; 60 | }; 61 | 62 | You can provide an optional replacer method. It will be passed the 63 | key and value of each member, with this bound to the containing 64 | object. The value that is returned from your method will be 65 | serialized. If your method returns undefined, then the member will 66 | be excluded from the serialization. 67 | 68 | If the replacer parameter is an array of strings, then it will be 69 | used to select the members to be serialized. It filters the results 70 | such that only members with keys listed in the replacer array are 71 | stringified. 72 | 73 | Values that do not have JSON representations, such as undefined or 74 | functions, will not be serialized. Such values in objects will be 75 | dropped; in arrays they will be replaced with null. You can use 76 | a replacer function to replace those with JSON values. 77 | JSON.stringify(undefined) returns undefined. 78 | 79 | The optional space parameter produces a stringification of the 80 | value that is filled with line breaks and indentation to make it 81 | easier to read. 82 | 83 | If the space parameter is a non-empty string, then that string will 84 | be used for indentation. If the space parameter is a number, then 85 | the indentation will be that many spaces. 86 | 87 | Example: 88 | 89 | text = JSON.stringify(['e', {pluribus: 'unum'}]); 90 | // text is '["e",{"pluribus":"unum"}]' 91 | 92 | 93 | text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t'); 94 | // text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]' 95 | 96 | text = JSON.stringify([new Date()], function (key, value) { 97 | return this[key] instanceof Date ? 98 | 'Date(' + this[key] + ')' : value; 99 | }); 100 | // text is '["Date(---current time---)"]' 101 | 102 | 103 | JSON.parse(text, reviver) 104 | This method parses a JSON text to produce an object or array. 105 | It can throw a SyntaxError exception. 106 | 107 | The optional reviver parameter is a function that can filter and 108 | transform the results. It receives each of the keys and values, 109 | and its return value is used instead of the original value. 110 | If it returns what it received, then the structure is not modified. 111 | If it returns undefined then the member is deleted. 112 | 113 | Example: 114 | 115 | // Parse the text. Values that look like ISO date strings will 116 | // be converted to Date objects. 117 | 118 | myData = JSON.parse(text, function (key, value) { 119 | var a; 120 | if (typeof value === 'string') { 121 | a = 122 | /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value); 123 | if (a) { 124 | return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4], 125 | +a[5], +a[6])); 126 | } 127 | } 128 | return value; 129 | }); 130 | 131 | myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) { 132 | var d; 133 | if (typeof value === 'string' && 134 | value.slice(0, 5) === 'Date(' && 135 | value.slice(-1) === ')') { 136 | d = new Date(value.slice(5, -1)); 137 | if (d) { 138 | return d; 139 | } 140 | } 141 | return value; 142 | }); 143 | 144 | 145 | This is a reference implementation. You are free to copy, modify, or 146 | redistribute. 147 | */ 148 | 149 | /*jslint evil: true, strict: false */ 150 | 151 | /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply, 152 | call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours, 153 | getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join, 154 | lastIndex, length, parse, prototype, push, replace, slice, stringify, 155 | test, toJSON, toString, valueOf 156 | */ 157 | 158 | 159 | // Create a JSON object only if one does not already exist. We create the 160 | // methods in a closure to avoid creating global variables. 161 | 162 | if (!this.JSON) { 163 | this.JSON = {}; 164 | } 165 | 166 | (function () { 167 | 168 | function f(n) { 169 | // Format integers to have at least two digits. 170 | return n < 10 ? '0' + n : n; 171 | } 172 | 173 | if (typeof Date.prototype.toJSON !== 'function') { 174 | 175 | Date.prototype.toJSON = function (key) { 176 | 177 | return isFinite(this.valueOf()) ? 178 | this.getUTCFullYear() + '-' + 179 | f(this.getUTCMonth() + 1) + '-' + 180 | f(this.getUTCDate()) + 'T' + 181 | f(this.getUTCHours()) + ':' + 182 | f(this.getUTCMinutes()) + ':' + 183 | f(this.getUTCSeconds()) + 'Z' : null; 184 | }; 185 | 186 | String.prototype.toJSON = 187 | Number.prototype.toJSON = 188 | Boolean.prototype.toJSON = function (key) { 189 | return this.valueOf(); 190 | }; 191 | } 192 | 193 | var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 194 | escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, 195 | gap, 196 | indent, 197 | meta = { // table of character substitutions 198 | '\b': '\\b', 199 | '\t': '\\t', 200 | '\n': '\\n', 201 | '\f': '\\f', 202 | '\r': '\\r', 203 | '"' : '\\"', 204 | '\\': '\\\\' 205 | }, 206 | rep; 207 | 208 | 209 | function quote(string) { 210 | 211 | // If the string contains no control characters, no quote characters, and no 212 | // backslash characters, then we can safely slap some quotes around it. 213 | // Otherwise we must also replace the offending characters with safe escape 214 | // sequences. 215 | 216 | escapable.lastIndex = 0; 217 | return escapable.test(string) ? 218 | '"' + string.replace(escapable, function (a) { 219 | var c = meta[a]; 220 | return typeof c === 'string' ? c : 221 | '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 222 | }) + '"' : 223 | '"' + string + '"'; 224 | } 225 | 226 | 227 | function str(key, holder) { 228 | 229 | // Produce a string from holder[key]. 230 | 231 | var i, // The loop counter. 232 | k, // The member key. 233 | v, // The member value. 234 | length, 235 | mind = gap, 236 | partial, 237 | value = holder[key]; 238 | 239 | // If the value has a toJSON method, call it to obtain a replacement value. 240 | 241 | if (value && typeof value === 'object' && 242 | typeof value.toJSON === 'function') { 243 | value = value.toJSON(key); 244 | } 245 | 246 | // If we were called with a replacer function, then call the replacer to 247 | // obtain a replacement value. 248 | 249 | if (typeof rep === 'function') { 250 | value = rep.call(holder, key, value); 251 | } 252 | 253 | // What happens next depends on the value's type. 254 | 255 | switch (typeof value) { 256 | case 'string': 257 | return quote(value); 258 | 259 | case 'number': 260 | 261 | // JSON numbers must be finite. Encode non-finite numbers as null. 262 | 263 | return isFinite(value) ? String(value) : 'null'; 264 | 265 | case 'boolean': 266 | case 'null': 267 | 268 | // If the value is a boolean or null, convert it to a string. Note: 269 | // typeof null does not produce 'null'. The case is included here in 270 | // the remote chance that this gets fixed someday. 271 | 272 | return String(value); 273 | 274 | // If the type is 'object', we might be dealing with an object or an array or 275 | // null. 276 | 277 | case 'object': 278 | 279 | // Due to a specification blunder in ECMAScript, typeof null is 'object', 280 | // so watch out for that case. 281 | 282 | if (!value) { 283 | return 'null'; 284 | } 285 | 286 | // Make an array to hold the partial results of stringifying this object value. 287 | 288 | gap += indent; 289 | partial = []; 290 | 291 | // Is the value an array? 292 | 293 | if (Object.prototype.toString.apply(value) === '[object Array]') { 294 | 295 | // The value is an array. Stringify every element. Use null as a placeholder 296 | // for non-JSON values. 297 | 298 | length = value.length; 299 | for (i = 0; i < length; i += 1) { 300 | partial[i] = str(i, value) || 'null'; 301 | } 302 | 303 | // Join all of the elements together, separated with commas, and wrap them in 304 | // brackets. 305 | 306 | v = partial.length === 0 ? '[]' : 307 | gap ? '[\n' + gap + 308 | partial.join(',\n' + gap) + '\n' + 309 | mind + ']' : 310 | '[' + partial.join(',') + ']'; 311 | gap = mind; 312 | return v; 313 | } 314 | 315 | // If the replacer is an array, use it to select the members to be stringified. 316 | 317 | if (rep && typeof rep === 'object') { 318 | length = rep.length; 319 | for (i = 0; i < length; i += 1) { 320 | k = rep[i]; 321 | if (typeof k === 'string') { 322 | v = str(k, value); 323 | if (v) { 324 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 325 | } 326 | } 327 | } 328 | } else { 329 | 330 | // Otherwise, iterate through all of the keys in the object. 331 | 332 | for (k in value) { 333 | if (Object.hasOwnProperty.call(value, k)) { 334 | v = str(k, value); 335 | if (v) { 336 | partial.push(quote(k) + (gap ? ': ' : ':') + v); 337 | } 338 | } 339 | } 340 | } 341 | 342 | // Join all of the member texts together, separated with commas, 343 | // and wrap them in braces. 344 | 345 | v = partial.length === 0 ? '{}' : 346 | gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + 347 | mind + '}' : '{' + partial.join(',') + '}'; 348 | gap = mind; 349 | return v; 350 | } 351 | } 352 | 353 | // If the JSON object does not yet have a stringify method, give it one. 354 | 355 | if (typeof JSON.stringify !== 'function') { 356 | JSON.stringify = function (value, replacer, space) { 357 | 358 | // The stringify method takes a value and an optional replacer, and an optional 359 | // space parameter, and returns a JSON text. The replacer can be a function 360 | // that can replace values, or an array of strings that will select the keys. 361 | // A default replacer method can be provided. Use of the space parameter can 362 | // produce text that is more easily readable. 363 | 364 | var i; 365 | gap = ''; 366 | indent = ''; 367 | 368 | // If the space parameter is a number, make an indent string containing that 369 | // many spaces. 370 | 371 | if (typeof space === 'number') { 372 | for (i = 0; i < space; i += 1) { 373 | indent += ' '; 374 | } 375 | 376 | // If the space parameter is a string, it will be used as the indent string. 377 | 378 | } else if (typeof space === 'string') { 379 | indent = space; 380 | } 381 | 382 | // If there is a replacer, it must be a function or an array. 383 | // Otherwise, throw an error. 384 | 385 | rep = replacer; 386 | if (replacer && typeof replacer !== 'function' && 387 | (typeof replacer !== 'object' || 388 | typeof replacer.length !== 'number')) { 389 | throw new Error('JSON.stringify'); 390 | } 391 | 392 | // Make a fake root object containing our value under the key of ''. 393 | // Return the result of stringifying the value. 394 | 395 | return str('', {'': value}); 396 | }; 397 | } 398 | 399 | 400 | // If the JSON object does not yet have a parse method, give it one. 401 | 402 | if (typeof JSON.parse !== 'function') { 403 | JSON.parse = function (text, reviver) { 404 | 405 | // The parse method takes a text and an optional reviver function, and returns 406 | // a JavaScript value if the text is a valid JSON text. 407 | 408 | var j; 409 | 410 | function walk(holder, key) { 411 | 412 | // The walk method is used to recursively walk the resulting structure so 413 | // that modifications can be made. 414 | 415 | var k, v, value = holder[key]; 416 | if (value && typeof value === 'object') { 417 | for (k in value) { 418 | if (Object.hasOwnProperty.call(value, k)) { 419 | v = walk(value, k); 420 | if (v !== undefined) { 421 | value[k] = v; 422 | } else { 423 | delete value[k]; 424 | } 425 | } 426 | } 427 | } 428 | return reviver.call(holder, key, value); 429 | } 430 | 431 | 432 | // Parsing happens in four stages. In the first stage, we replace certain 433 | // Unicode characters with escape sequences. JavaScript handles many characters 434 | // incorrectly, either silently deleting them, or treating them as line endings. 435 | 436 | text = String(text); 437 | cx.lastIndex = 0; 438 | if (cx.test(text)) { 439 | text = text.replace(cx, function (a) { 440 | return '\\u' + 441 | ('0000' + a.charCodeAt(0).toString(16)).slice(-4); 442 | }); 443 | } 444 | 445 | // In the second stage, we run the text against regular expressions that look 446 | // for non-JSON patterns. We are especially concerned with '()' and 'new' 447 | // because they can cause invocation, and '=' because it can cause mutation. 448 | // But just to be safe, we want to reject all unexpected forms. 449 | 450 | // We split the second stage into 4 regexp operations in order to work around 451 | // crippling inefficiencies in IE's and Safari's regexp engines. First we 452 | // replace the JSON backslash pairs with '@' (a non-JSON character). Second, we 453 | // replace all simple value tokens with ']' characters. Third, we delete all 454 | // open brackets that follow a colon or comma or that begin the text. Finally, 455 | // we look to see that the remaining characters are only whitespace or ']' or 456 | // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval. 457 | 458 | if (/^[\],:{}\s]*$/. 459 | test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@'). 460 | replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']'). 461 | replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { 462 | 463 | // In the third stage we use the eval function to compile the text into a 464 | // JavaScript structure. The '{' operator is subject to a syntactic ambiguity 465 | // in JavaScript: it can begin a block or an object literal. We wrap the text 466 | // in parens to eliminate the ambiguity. 467 | 468 | j = eval('(' + text + ')'); 469 | 470 | // In the optional fourth stage, we recursively walk the new structure, passing 471 | // each name/value pair to a reviver function for possible transformation. 472 | 473 | return typeof reviver === 'function' ? 474 | walk({'': j}, '') : j; 475 | } 476 | 477 | // If the text is not JSON parseable, then a SyntaxError is thrown. 478 | 479 | throw new SyntaxError('JSON.parse'); 480 | }; 481 | } 482 | }()); 483 | -------------------------------------------------------------------------------- /app/javascripts/models.js: -------------------------------------------------------------------------------- 1 | var Project, 2 | Task, 3 | Collection, 4 | Settings; 5 | 6 | Project = new Model('projects'); 7 | Task = new Model('tasks'); 8 | Settings = new KeyValueModel('settings'); 9 | Collection = new KeyValueModel('collections'); 10 | 11 | Collection.isActive = function(collectionName) { 12 | return $('#show-' + collectionName).closest('li').hasClass('selected'); 13 | }; 14 | 15 | Collection.removeItem = function(collectionName, value) { 16 | Collection.set(collectionName, $.map(Collection.get(collectionName), function(innerValue) { 17 | return value === innerValue ? null : innerValue; 18 | })); 19 | }; 20 | 21 | Collection.appendItem = function(collectionName, value) { 22 | var items = Collection.get(collectionName); 23 | if (items) { 24 | items.push(value); 25 | Collection.set(collectionName, items); 26 | } 27 | }; 28 | 29 | Project.afterCreate = function(project) { 30 | var items = Collection.get('projects') || []; 31 | items.push(project.get('id')); 32 | Collection.set('projects', items); 33 | }; 34 | 35 | Project.updateDone = function(project) { 36 | var done = false; 37 | done = Task.findAll({ 'project_id': project.get('id'), 'done': false }).length === 0; 38 | project.set('done', done); 39 | ProjectsController.displayState(project); 40 | }; 41 | 42 | Task.updateDueState = function(task) { 43 | var stateIcons = '', 44 | button; 45 | $('#task_' + task.get('id') + ' .task-state-icon').remove(); 46 | 47 | if (task.get('due')) { 48 | stateIcons = ''; 49 | if (task.get('due') < $.datepicker.formatDate('yy/mm/dd', new Date())) { 50 | stateIcons = ''; 51 | } 52 | } 53 | 54 | if (task.get('notes') && task.get('notes').length > 0) { 55 | stateIcons += ''; 56 | } 57 | 58 | if (stateIcons.length > 0) { 59 | button = $('#task_' + task.get('id') + ' .ui-button-text') 60 | button.prepend(stateIcons); 61 | } 62 | }; 63 | 64 | Task.updateProjectDoneState = function(task) { 65 | if (task.get('project_id')) { 66 | var project = Project.find(task.get('project_id')); 67 | Project.updateDone(project); 68 | } 69 | }; 70 | 71 | Task.afterCreate = function(task) { 72 | var items, collection; 73 | Task.updateProjectDoneState(task); 74 | 75 | if (task.get('project_id')) { 76 | collection = 'project_tasks_' + task.get('project_id'); 77 | } else if (Collection.isActive('inbox')) { 78 | collection = 'inbox'; 79 | } else if (Collection.isActive('today')) { 80 | collection = 'today'; 81 | } else if (Collection.isActive('next')) { 82 | collection = 'next'; 83 | } else { 84 | return; 85 | } 86 | items = Collection.get(collection) || []; 87 | items.unshift(task.get('id')); 88 | Collection.set(collection, items); 89 | }; 90 | 91 | Task.afterUpdate = function(task) { 92 | return Task.updateProjectDoneState(task); 93 | }; 94 | 95 | Task.search = function(regex) { 96 | var items = []; 97 | 98 | if (typeof regex === 'string') { 99 | regex = new RegExp(regex, 'i'); 100 | } 101 | 102 | jQuery.each(Storage.data[this.collectionName], function(key, item) { 103 | if (item && item.name.match(regex)) { 104 | items.push(new ModelInstance(Task, item)); 105 | } 106 | }); 107 | 108 | return items; 109 | }; 110 | 111 | Collection.inCollection = function(collectionName, task) { 112 | return $.inArray(task.get('id'), Collection.get(collectionName)) != -1; 113 | }; 114 | 115 | -------------------------------------------------------------------------------- /app/javascripts/outro.js: -------------------------------------------------------------------------------- 1 | }); 2 | 3 | -------------------------------------------------------------------------------- /app/javascripts/projects.js: -------------------------------------------------------------------------------- 1 | var ProjectsController = { 2 | displayState: function(project) { 3 | if (project.get('done') === ($('.project-field .state .ui-icon-check').length === 0)) { 4 | TasksController.toggleState($('.project-field .state')); 5 | } 6 | }, 7 | 8 | tasks: function(project) { 9 | var tasks = [], items; 10 | items = Collection.get('project_tasks_' + project.get('id')) || []; 11 | 12 | if (items.length === 0) { 13 | tasks = Task.findAll({ 'project_id': project.get('id'), 'archived': false }) 14 | } else { 15 | tasks = jQuery.map(items, function(id) { 16 | return Task.find(id); 17 | }); 18 | 19 | jQuery.each(tasks, function(index, task) { 20 | if (task.get('archived')) { 21 | delete tasks[index]; 22 | } 23 | }); 24 | } 25 | 26 | return tasks; 27 | }, 28 | 29 | display: function(project, element) { 30 | if (!element) { 31 | element = $('#show_project_' + project.get('id')); 32 | } 33 | 34 | var name = (project.get('name') || '').length === 0 ? defaultFieldValues.project_name : project.get('name') 35 | $('.project-field').show(); 36 | $('.project-header .name-text').html(name); 37 | 38 | /* 39 | if (project.get('tags')) { 40 | $('.project-header .tags').html(project.get('tags')); 41 | } else { 42 | $('.project-header .tags').html('Tags'); 43 | } 44 | */ 45 | 46 | if (project.get('notes')) { 47 | $('.project-header .notes').html(project.get('notes')); 48 | } else { 49 | $('.project-header .notes').html(defaultFieldValues.project_notes); 50 | } 51 | 52 | var tasks = ProjectsController.tasks(project); 53 | TasksController.display(tasks); 54 | ProjectsController.displayState(project); 55 | 56 | if (project.get('due')) { 57 | $('.project-header .due-date').html(presentDate(project.get('due'))); 58 | } else { 59 | $('.project-header .due-date').html('Due Date'); 60 | } 61 | 62 | $('#project-info').show(); 63 | 64 | if (Settings.get('outline-view-width')) { 65 | $('.outline-view').css({ width: Settings.get('outline-view-width') }); 66 | } 67 | }, 68 | 69 | displayAll: function() { 70 | $('.outline-view .projects li').remove(); 71 | 72 | jQuery.each(Collection.get('projects') || [], function(index, value) { 73 | ProjectsController.insert(Project.find(value)); 74 | }); 75 | selectProject(); 76 | }, 77 | 78 | insert: function(project) { 79 | if (!project) return; 80 | var name = (project.get('name') || '').length === 0 ? defaultFieldValues.project_name : project.get('name'), 81 | html = $('
  • ' + name + '
  • '); 82 | $('.outline-view .items.projects').append(html); 83 | $('.outline-view .projects li:last').droppable({ 84 | hoverClass: 'hover-drag', 85 | dragClass: 'dragging', 86 | accept: '.task', 87 | drop: function(e, ui) { 88 | var project = Project.find($(this).find('a').itemID()), 89 | taskElement = $(e.srcElement).closest('.task'), 90 | task = Task.find(taskElement.itemID()); 91 | 92 | // Move project 93 | if (project && task && project.get('id') != task.get('project_id')) { 94 | // Remove from old project list, if there was one 95 | if (task.get('project_id')) { 96 | Collection.removeItem('project_tasks_' + task.get('project_id'), task.get('id')); 97 | } 98 | 99 | // Remove from inbox 100 | Collection.removeItem('inbox', task.get('id')); 101 | Collection.appendItem('project_tasks_' + project.get('id'), task.get('id')); 102 | task.set('project_id', project.get('id')); 103 | task.set('archived', false); 104 | 105 | if (!$('#show-today').closest('li').hasClass('selected')) { 106 | taskElement.remove(); 107 | } 108 | 109 | // Insert the project name 110 | if (selectedCollectionIsNamed()) { 111 | var name = (project.get('name') || '').length === 0 ? defaultFieldValues.project_name : project.get('name'); 112 | taskElement.find('div.button .ui-button-text').html(name + ': ' + task.get('name')); 113 | } 114 | } 115 | dragLock.timedUnlock(); 116 | } 117 | }); 118 | 119 | return project; 120 | }, 121 | 122 | add: function() { 123 | // TODO: add at the top 124 | var project = Project.create({ 'name': 'New Project' }); 125 | Settings.set('outline-view', '#show_project_' + project.get('id')); 126 | ProjectsController.displayAll(); 127 | // TODO: select title element for editing 128 | $('#project-info .name-text').trigger('click'); 129 | }, 130 | 131 | saveSort: function(e, ui) { 132 | var items = []; 133 | $('.outline-view .items.projects a').each(function() { 134 | items.push($(this).itemID()); 135 | }); 136 | Collection.set('projects', items); 137 | }, 138 | 139 | installEvents: function() { 140 | $('.project.add-button').click(function() { 141 | ProjectsController.add(); 142 | }); 143 | } 144 | }; 145 | 146 | ProjectsController.installEvents(); 147 | -------------------------------------------------------------------------------- /app/javascripts/reusable/feedback.js: -------------------------------------------------------------------------------- 1 | var Feedback = { 2 | message: function(type, message) { 3 | var stateClass = type === 'error' ? 'ui-state-error' : 'ui-state-highlight', 4 | iconClass = type === 'error' ? 'ui-icon-alert' : 'ui-icon-info', 5 | html = '
    ' 6 | + '
    ' 7 | + '

    ' 8 | + ' ' + message + '

    ' 9 | + '
    ' 10 | + '
    '; 11 | return html; 12 | }, 13 | 14 | info: function(message) { 15 | $('#feedback').html(Feedback.message('info', message)); 16 | Feedback.show(); 17 | }, 18 | 19 | error: function(message) { 20 | $('#feedback').html(Feedback.message('error', message)); 21 | Feedback.show(); 22 | }, 23 | 24 | hide: function() { 25 | $('#feedback').html(''); 26 | $('#feedback').hide(); 27 | }, 28 | 29 | show: function() { 30 | $('#feedback').show(); 31 | } 32 | } 33 | 34 | -------------------------------------------------------------------------------- /app/javascripts/reusable/lock.js: -------------------------------------------------------------------------------- 1 | function Lock() { 2 | this.locked = false; 3 | this.lockTime = 1000; 4 | } 5 | 6 | Lock.prototype.lock = function() { 7 | this.locked = true; 8 | }; 9 | 10 | Lock.prototype.timedUnlock = function() { 11 | var lock = this, 12 | fn = arguments[0]; 13 | setTimeout(function() { lock.unlock(); if (fn) fn(); }, this.lockTime); 14 | }; 15 | 16 | Lock.prototype.unlock = function() { 17 | this.locked = false; 18 | }; 19 | 20 | -------------------------------------------------------------------------------- /app/javascripts/reusable/mvc.js: -------------------------------------------------------------------------------- 1 | function Model(collectionName) { 2 | this.collectionName = collectionName; 3 | Storage.data.models.push(this.collectionName); 4 | Storage.data[this.collectionName] = {}; 5 | } 6 | 7 | Model.prototype.find = function(id) { 8 | var item = Storage.data[this.collectionName][id]; 9 | if (typeof item !== 'undefined') { 10 | return (new ModelInstance(this, item)); 11 | } else { 12 | return null; 13 | } 14 | }; 15 | 16 | Model.prototype.findAll = function(options) { 17 | var items = []; 18 | 19 | for (var item in Storage.data[this.collectionName]) { 20 | var add = true; 21 | item = Storage.data[this.collectionName][item]; 22 | if (options) { 23 | jQuery.each(options, function(index, value) { 24 | if (item[index] !== value) { 25 | add = false; 26 | return false; 27 | } 28 | }); 29 | } 30 | 31 | if (add) { 32 | items.push(new ModelInstance(this, item)); 33 | } 34 | } 35 | return items; 36 | }; 37 | 38 | Model.prototype.create = function(item) { 39 | item.id = Storage.guid(); 40 | Storage.data[this.collectionName][item.id] = item; 41 | Storage.remote.create(this.collectionName, item); 42 | var instance = new ModelInstance(this, item); 43 | if (this.hasOwnProperty('afterCreate')) this.afterCreate(instance); 44 | return instance; 45 | }; 46 | 47 | Model.prototype.destroy = function(id) { 48 | delete Storage.data[this.collectionName][id]; 49 | Storage.remote.destroy(this.collectionName, { id: id }); 50 | if (this.hasOwnProperty('afterDestroy')) this.afterDestroy(); 51 | }; 52 | 53 | function KeyValueModel(collectionName) { 54 | this.collectionName = collectionName; 55 | Storage.data.models.push(this.collectionName); 56 | Storage.data[this.collectionName] = {}; 57 | } 58 | 59 | KeyValueModel.prototype.set = function(key, value) { 60 | Storage.data[this.collectionName][key] = value; 61 | Storage.remote.setKey(this.collectionName, { collection: this.collectionName, key: key, value: value }); 62 | }; 63 | 64 | KeyValueModel.prototype.get = function(key) { 65 | return Storage.data[this.collectionName][key]; 66 | }; 67 | 68 | function ModelInstance(model, item) { 69 | this.id = item.id; 70 | this.model = model; 71 | } 72 | 73 | ModelInstance.prototype.update = function(item) { 74 | Storage.data[this.model.collectionName][this.id] = $.extend(Storage.data[this.model.collectionName][this.id], item); 75 | Storage.remote.update(this.model.collectionName, item); 76 | if (this.model.hasOwnProperty('afterUpdate')) this.model.afterUpdate(this); 77 | return this; 78 | }; 79 | 80 | ModelInstance.prototype.get = function(field) { 81 | if (typeof field === 'undefined') { 82 | return Storage.data[this.model.collectionName][this.id]; 83 | } 84 | return Storage.data[this.model.collectionName][this.id][field]; 85 | }; 86 | 87 | ModelInstance.prototype.set = function(field, value) { 88 | if (value === Storage.data[this.model.collectionName][this.id][field]) return; 89 | Storage.data[this.model.collectionName][this.id][field] = value; 90 | Storage.remote.update(this.model.collectionName, this.json()); 91 | if (this.model.hasOwnProperty('afterUpdate')) this.model.afterUpdate(this); 92 | return this; 93 | }; 94 | 95 | ModelInstance.prototype.destroy = function() { 96 | delete Storage.data[this.model.collectionName][this.get('id')]; 97 | Storage.remote.destroy(this.model.collectionName, { id: this.get('id') }); 98 | if (this.hasOwnProperty('afterDestroy')) this.afterDestroy(); 99 | }; 100 | 101 | ModelInstance.prototype.json = function() { 102 | return Storage.data[this.model.collectionName][this.get('id')]; 103 | }; 104 | 105 | ModelInstance.prototype.valueOf = function() { 106 | return JSON.stringify(this.json()); 107 | }; 108 | 109 | -------------------------------------------------------------------------------- /app/javascripts/reusable/storage.js: -------------------------------------------------------------------------------- 1 | var Storage = { 2 | data: { models: [] }, 3 | 4 | guid: function() { 5 | return (new Date()).valueOf() + (Math.random() * 0x10000|0) + ''; 6 | }, 7 | 8 | loading: function() {}, 9 | done: function() {}, 10 | ready: function() {}, 11 | 12 | remote: { 13 | read: function() { 14 | Storage.loading(); 15 | jQuery.getJSON('/storage/restore', function(data) { 16 | Storage.done(); 17 | jQuery.each(data || [], function(index, value) { 18 | Storage.data[index] = value; 19 | }); 20 | Storage.ready(); 21 | }, 'json'); 22 | }, 23 | 24 | create: function(collection, json) { 25 | Storage.loading(); 26 | jQuery.post('/storage', { 27 | data: JSON.stringify(json), 28 | collection: collection 29 | }, 30 | function() { 31 | Storage.done(); 32 | }, 'json'); 33 | }, 34 | 35 | update: function(collection, json) { 36 | Storage.loading(); 37 | jQuery.post('/storage', { 38 | '_method': 'PUT', 39 | data: JSON.stringify(json), 40 | collection: collection 41 | }, 42 | function() { 43 | Storage.done(); 44 | }, 'json'); 45 | }, 46 | 47 | destroy: function(collection, json) { 48 | Storage.loading(); 49 | json['_method'] = 'DELETE'; 50 | json['collection'] = collection; 51 | jQuery.post('/storage', json, 52 | function() { 53 | Storage.done(); 54 | }, 'json'); 55 | }, 56 | 57 | setKey: function(collection, json) { 58 | Storage.loading(); 59 | jQuery.post('/storage/set_key_value', { '_method': 'PUT', collection: collection, data: JSON.stringify(json) }, 60 | function() { 61 | Storage.done(); 62 | }, 'json'); 63 | } 64 | } 65 | }; 66 | 67 | -------------------------------------------------------------------------------- /app/javascripts/search.js: -------------------------------------------------------------------------------- 1 | var SearchController = { 2 | run: function(e) { 3 | var input = $('#search input'), tasks; 4 | 5 | if (input.val().length == 0 && !$('#search-results').is(':visible')) { 6 | return; 7 | } 8 | 9 | if (input.val() === defaultFieldValues.search || input.val().length == 0) { 10 | $('#search-todo-items').html('
  • ' + Feedback.message('error', 'Enter a longer search phrase.') + '
  • '); 11 | return; 12 | } 13 | 14 | if (!$('#search-results').is(':visible')) { 15 | $('.outline-view .selected').removeClass('selected'); 16 | $('.content').hide(); 17 | $('#search-results').show(); 18 | $('#project-todo-items').removeClass('todo-items'); 19 | $('#search-todo-items').addClass('todo-items'); 20 | } 21 | 22 | tasks = Task.search(input.val()); 23 | 24 | if (tasks.length === 0) { 25 | $('#search-todo-items').html('
  • ' + Feedback.message('info', 'No results found.') + '
  • '); 26 | } else { 27 | TasksController.display(tasks); 28 | } 29 | resize(); 30 | 31 | e.preventDefault(); 32 | }, 33 | 34 | timer: function() { 35 | var searchText = $('#search input').val(); 36 | 37 | function timer() { 38 | var newText = $('#search input').val(); 39 | if (searchText != newText) { 40 | $('#search form input').trigger('change'); 41 | searchText = newText; 42 | } 43 | setTimeout(timer, 1000); 44 | } 45 | 46 | timer(); 47 | }, 48 | 49 | installEvents: function() { 50 | $('#search form').submit(function(e) { e.preventDefault(); }); 51 | $('#search form input').change(SearchController.run); 52 | $('#search form input').blur(function() { 53 | var input = $('#search form input'); 54 | if (input.val().trim().length === 0) 55 | input.val(defaultFieldValues.search); 56 | }); 57 | $('#search form input').click(function(e) { 58 | if ($('#search form input').val() === defaultFieldValues.search) { 59 | $('#search form input').val(''); 60 | } 61 | }); 62 | 63 | SearchController.timer(); 64 | } 65 | }; 66 | 67 | SearchController.installEvents(); 68 | -------------------------------------------------------------------------------- /app/javascripts/tasks.js: -------------------------------------------------------------------------------- 1 | var TasksController = { 2 | selectedTask: function() { 3 | return Task.find($('.task .highlight').closest('li').itemID() || $('.task.details').itemID()); 4 | }, 5 | 6 | open: function(button) { 7 | var name = button.find('span').html(), 8 | taskID = button.closest('li.task').itemID(), 9 | task, 10 | clearDueDate = ''; 11 | 12 | if (taskID) { 13 | task = Task.find(taskID); 14 | } 15 | 16 | if (task.get('due')) { 17 | clearDueDate = ' ' 18 | } 19 | 20 | task = $.extend({ tags: 'Tags', notes: defaultFieldValues.notes }, task); 21 | 22 | button.parent('li').addClass('details'); 23 | button.addClass('details'); 24 | button.find('span').html('
      ' 25 | + '
    • ' + jQuery().escapeText(task.get('name') || defaultFieldValues.name) + '
    • ' 26 | + '
    • ' + jQuery().escapeText(task.get('notes') || defaultFieldValues.notes) + '
    • ' 27 | + '
    • ' 28 | + clearDueDate 29 | + '' + (presentDate(task.get('due')) || defaultFieldValues.due) + '' 30 | + '
    • ' 31 | + '
    • ' 32 | + ' ' 33 | + ' ' 34 | + '
    • ' 35 | + '
    '); 36 | button.find('.editable-field').first().trigger('click'); 37 | return button; 38 | }, 39 | 40 | insert: function(task, append, options) { 41 | var button, container, projectID, extraClass = '', 42 | stateClass = task && task.get('done') ? 'task-done' : 'task-not-done', 43 | projectText = ''; 44 | 45 | if (typeof options === 'undefined') { 46 | options = {}; 47 | } 48 | 49 | if (!task) { 50 | projectID = $('.outline-view li.selected a').itemID() || null; 51 | task = Task.create({ name: defaultFieldValues.name, project_id: projectID, archived: false }); 52 | } 53 | 54 | if (task && Collection.inCollection('today', task)) { 55 | extraClass = ' ui-icon-todo-today'; 56 | } 57 | 58 | if (options.show_projects && task.get('project_id')) { 59 | var taskProject = Project.find(task.get('project_id')); 60 | if (taskProject) 61 | projectText = taskProject.get('name') + ': '; 62 | } 63 | 64 | container = $('
  • ' 65 | + '
    ' 66 | + '
    ' + projectText + jQuery().escapeText(task.get('name') || defaultFieldValues.name) + '
    ' 67 | + '
  • '); 68 | 69 | if (options.position >= 0) { 70 | container.insertAfter($('.todo-items li')[options.position]); 71 | } else if (append) { 72 | $('.todo-items').append(container); 73 | } else { 74 | $('.todo-items').prepend(container); 75 | } 76 | 77 | button = container.find('.button'); 78 | // TODO: secondary doesn't work how I want in this version of jQuery UI 79 | //button.button({ icons: { secondary: 'ui-icon-blank' } }); 80 | button.button({}); 81 | resize(); 82 | 83 | if (task.get('done')) { 84 | hideArchiveButtonIfRequired(); 85 | TasksController.toggleState(container.find('.state')); 86 | } 87 | 88 | Task.updateDueState(task); 89 | 90 | return button; 91 | }, 92 | 93 | closeEditors: function() { 94 | $('#datepicker').remove(); 95 | $('#delete-task').closest('li').hide(); 96 | $('#not-today').closest('li').hide(); 97 | $('.todo-items .button').removeClass('ui-state-active') 98 | $('.todo-items li.details').each(function() { 99 | var li = $(this), 100 | name = li.find('li.name').html(), 101 | form = li.find('form.editable'), 102 | span; 103 | 104 | if (form) { 105 | if (form.find('.field').length > 0) { 106 | try { 107 | form.parent().html(form.find('.field').val().trim()); 108 | } catch (exception) { 109 | } 110 | } 111 | } 112 | 113 | span = li.find('div.button').removeClass('details').find('span'); 114 | span.html(name); 115 | }); 116 | 117 | $('.todo-items li.details').removeClass('details'); 118 | TasksController.refreshDueStates(); 119 | }, 120 | 121 | refreshDueStates: function() { 122 | $('.todo-items .task').each(function() { 123 | var task = Task.find($(this).itemID()); 124 | if (task) { 125 | Task.updateDueState(task); 126 | } 127 | }); 128 | }, 129 | 130 | destroy: function(buttons) { 131 | buttons.each(function() { 132 | var buttonContainer = $(this), 133 | taskID = buttonContainer.itemID(); 134 | if (taskID) { 135 | Task.destroy(taskID); 136 | buttonContainer.remove(); 137 | } 138 | }); 139 | }, 140 | 141 | notToday: function(buttons) { 142 | buttons.each(function() { 143 | var buttonContainer = $(this), 144 | taskID = buttonContainer.itemID(); 145 | if (taskID) { 146 | var task = Task.find(taskID); 147 | Collection.removeItem('today', task.get('id')); 148 | if (!task.get('project_id')) { 149 | Collection.appendItem('inbox', task.get('id')); 150 | } 151 | buttonContainer.remove(); 152 | } 153 | }); 154 | }, 155 | 156 | archive: function(buttonContainers) { 157 | jQuery.each(buttonContainers, function() { 158 | var taskID = $(this).itemID(), 159 | task = Task.find(taskID); 160 | task.set('archived', true); 161 | Collection.removeItem('today', task.get('id')); 162 | }); 163 | buttonContainers.remove(); 164 | hideArchiveButtonIfRequired(); 165 | // TODO: Update project json 166 | // TODO: Get the IDs and send to server 167 | }, 168 | 169 | clear: function() { 170 | $('#archive-tasks').closest('li').hide(); 171 | $('.todo-items li').remove(); 172 | }, 173 | 174 | // Remove archived tasks from memory 175 | removeArchived: function() { 176 | jQuery.each(Task.findAll({ 'archived': true }), function() { 177 | delete Storage.data.tasks[this.id]; 178 | }); 179 | }, 180 | 181 | toggleState: function(element) { 182 | var container; 183 | 184 | if (!element.hasClass('state')) { 185 | element = element.find('.state'); 186 | } 187 | 188 | container = element.parent(); 189 | container.find('.done').removeClass('ui-state-disabled'); 190 | element.find('span').toggleClass('ui-icon-todo'); 191 | element.find('span').toggleClass('ui-icon-check'); 192 | element.toggleClass('done'); 193 | 194 | container.find('div.button').toggleClass('done'); 195 | 196 | if (container.find('.done').length > 0) { 197 | element.find('.ui-icon-todo-today').removeClass('ui-icon-todo-today'); 198 | } else if (Collection.isActive('today')) { 199 | element.find('.ui-icon').addClass('ui-icon-todo-today'); 200 | } 201 | 202 | $('.todo-items .done').addClass('ui-state-disabled'); 203 | hideArchiveButtonIfRequired(); 204 | }, 205 | 206 | display: function(tasks, options) { 207 | Feedback.hide(); 208 | TasksController.clear(); 209 | 210 | jQuery.each(tasks, function(index, task) { 211 | if (task) { 212 | TasksController.insert(task, true, options); 213 | } 214 | }); 215 | }, 216 | 217 | saveSort: function() { 218 | var items = [], collectionName; 219 | 220 | $('.todo-items .task').each(function() { 221 | items.push($(this).itemID()); 222 | }); 223 | 224 | if (selectedProject()) { 225 | Collection.set('project_tasks_' + selectedProject(), items); 226 | } else if ($('ul.archive li.selected').length === 0) { 227 | collectionName = $('li.selected .named-collection').attr('id').split('-')[1]; 228 | Collection.set(collectionName, items); 229 | } 230 | }, 231 | 232 | installEvents: function() { 233 | // Add tasks 234 | $('.task.add-button').click(function() { 235 | var taskPosition = $('.todo-items .highlight').closest('li').index(), 236 | options = taskPosition >= 0 ? { position: taskPosition } : undefined; 237 | TasksController.closeEditors(); 238 | TasksController.open(TasksController.insert(false, false, options)); 239 | }); 240 | 241 | $('.todo-items .state').live('click', function() { 242 | var element = $(this), 243 | container, 244 | task; 245 | 246 | TasksController.toggleState(element); 247 | task = Task.find(element.closest('li').itemID()); 248 | task.set('done', element.hasClass('done')); 249 | }); 250 | 251 | // Task single click 252 | (function() { 253 | // Don't use this for iOS 254 | if (userAgentFamily === 'iOS') return; 255 | 256 | function selectGroup(from, to) { 257 | var buttons = $('.todo-items .button'), 258 | indexes = [buttons.index(from), buttons.index(to)].sort(function(a, b) { return a - b; }), 259 | indexFrom = indexes[0], 260 | indexTo = indexes[1] + 1; 261 | 262 | $('.todo-items .button').slice(indexFrom, indexTo).each(function(index) { 263 | $(this).addClass('highlight'); 264 | }); 265 | } 266 | 267 | $('.todo-items .button').live('click', function(e) { 268 | var target = $(e.target), add = true, button; 269 | if (target.attr('nodeName') === 'TEXTAREA') return; 270 | if (target.attr('nodeName') === 'INPUT') return; 271 | if (target.attr('nodeName') === 'A') return; 272 | button = $(this); 273 | 274 | if (button.hasClass('highlight')) { 275 | add = false; 276 | } 277 | 278 | // Detect shift-click 279 | if (e.shiftKey) { 280 | var activeButton = $('.todo-items .highlight'); 281 | if (activeButton.length > 0) { 282 | selectGroup(activeButton, button); 283 | } 284 | } else { 285 | $('.todo-items .button').removeClass('highlight'); 286 | } 287 | 288 | if ($('.todo-items li.details').length > 0 289 | && $('.todo-items li.details').find('.button')[0] !== this) { 290 | TasksController.closeEditors(); 291 | } 292 | 293 | if (add) { 294 | button.highlight(); 295 | $('#delete-task').closest('li').show(); 296 | 297 | if (Collection.isActive('today')) { 298 | $('#not-today').closest('li').show(); 299 | } 300 | } else { 301 | if ($('.todo-items li.details').length === 0) { 302 | $('#delete-task').closest('li').hide(); 303 | } 304 | } 305 | }); 306 | })(); 307 | 308 | $('.todo-items .button').live((userAgentFamily === 'iOS' ? 'click' : 'dblclick'), function(e) { 309 | var target = $(e.target); 310 | if (target.closest('.li').length > 0) return; 311 | if (target.attr('nodeName') === 'INPUT') return; 312 | if (target.attr('nodeName') === 'TEXTAREA') return; 313 | if (target.hasClass('editable-field')) return; 314 | if (e.target === this) return; 315 | 316 | var button = $(this), 317 | name; 318 | 319 | TasksController.closeEditors(); 320 | button.addClass('highlight'); 321 | 322 | if (!button.hasClass('details')) { 323 | TasksController.open(button); 324 | } 325 | 326 | return false; 327 | }); 328 | 329 | $('a.close-task').live('click', function(e) { 330 | saveEditable(); 331 | closeEditable(); 332 | TasksController.closeEditors(); 333 | e.stopPropagation(); 334 | $('.todo-items .button').removeClass('highlight'); 335 | return false; 336 | }); 337 | 338 | $('a.sort-task').live('click', function(e) { 339 | var container = $('#sort-dialog').html('

    Select a new location for this task:

      ').find('ul'), 340 | task = TasksController.selectedTask(); 341 | container.append('
    • Today
    • '); 342 | container.append('
    • Projects:
    • '); 343 | jQuery.each(Collection.get('projects') || [], function(index, value) { 344 | var project = Project.find(value); 345 | if (project) 346 | container.append('
    • ' + project.get('name') + '
    • '); 347 | }); 348 | 349 | if (task.get('project_id')) { 350 | $('input[value="' + task.get('project_id') + '"]').attr({ 'checked': 'checked' }); 351 | } 352 | 353 | if (Collection.inCollection('today', task)) { 354 | $('input[value="today"]').attr({ 'checked': 'checked' }); 355 | } 356 | 357 | $('#sort-dialog').dialog('open') 358 | }); 359 | 360 | $('#sort-dialog').dialog({ 361 | autoOpen: false, 362 | width: 600, 363 | title: 'Organize Task', 364 | buttons: { 365 | 'OK': function() { 366 | var selected = $('input[name="folder"]:checked').val(), 367 | named = $('input[name="named-folder"]:checked').val(), 368 | task = TasksController.selectedTask(); 369 | if (task) { 370 | if (selected && parseInt(selected, 0) > 0) { 371 | // Move task to project 372 | var project = Project.find(selected); 373 | if (task.get('project_id')) { 374 | Collection.removeItem('project_tasks_' + task.get('project_id'), task.get('id')); 375 | } 376 | task.set('project_id', project.get('id')); 377 | Collection.appendItem('project_tasks_' + project.get('id'), task.get('id')); 378 | Collection.removeItem('inbox', task.get('id')); 379 | } 380 | 381 | if (named) { 382 | Collection.removeItem('today', task.get('id')); 383 | Collection.removeItem('inbox', task.get('id')); 384 | 385 | // Move task to named collection 386 | if (named === 'inbox') { 387 | Collection.appendItem('inbox', task.get('id')); 388 | } else if (named === 'today') { 389 | Collection.appendItem('today', task.get('id')); 390 | } 391 | } 392 | } 393 | $('.outline-view .selected a').click(); 394 | $(this).dialog('close'); 395 | }, 396 | 'Cancel': function() { 397 | $(this).dialog('close'); 398 | } 399 | }, 400 | modal: true 401 | }); 402 | 403 | } 404 | }; 405 | 406 | TasksController.installEvents(); 407 | -------------------------------------------------------------------------------- /app/javascripts/test/lock_test.js: -------------------------------------------------------------------------------- 1 | var Riot = require('./riot').Riot, 2 | sys = require('sys'); 3 | 4 | Riot.require('../reusable/lock.js'); 5 | 6 | Riot.context('Lock', function() { 7 | given('A lock', function() { 8 | var lock = new Lock(); 9 | 10 | asserts('locked should be false', lock.locked).isFalse(); 11 | asserts('the lock should lock', function() { 12 | lock.lock(); 13 | return lock.locked; 14 | }).isTrue(); 15 | 16 | // TODO: Testing timeout-based things is a problem 17 | }); 18 | }); 19 | 20 | Riot.run(); 21 | -------------------------------------------------------------------------------- /app/javascripts/test/riot.js: -------------------------------------------------------------------------------- 1 | /*jslint white: false plusplus: false onevar: false browser: true evil: true*/ 2 | /*riotGlobal window: true*/ 3 | (function(riotGlobal) { 4 | var Riot = { 5 | results: [], 6 | contexts: [], 7 | 8 | run: function(tests) { 9 | switch (Riot.detectEnvironment()) { 10 | case 'xpcomcore': 11 | Riot.formatter = new Riot.Formatters.XPComCore(); 12 | Riot.runAndReport(tests); 13 | Sys.exit(Riot.exitCode); 14 | break; 15 | 16 | case 'rhino': 17 | Riot.formatter = new Riot.Formatters.Text(); 18 | Riot.runAndReport(tests); 19 | java.lang.System.exit(Riot.exitCode); 20 | break; 21 | 22 | case 'node': 23 | Riot.formatter = new Riot.Formatters.Text(); 24 | Riot.runAndReport(tests); 25 | // TODO: exit with exit code from riot 26 | break; 27 | 28 | case 'non-browser-interpreter': 29 | Riot.formatter = new Riot.Formatters.Text(); 30 | Riot.runAndReport(tests); 31 | if (typeof quit !== 'undefined') { 32 | quit(Riot.exitCode); 33 | } 34 | break; 35 | 36 | case 'browser': 37 | Riot.formatter = new Riot.Formatters.HTML(); 38 | if (typeof window.onload === 'undefined' || window.onload == null) { 39 | Riot.browserAutoLoad(tests); 40 | } 41 | break; 42 | } 43 | }, 44 | 45 | browserAutoLoad: function(tests) { 46 | var timer; 47 | function fireContentLoadedEvent() { 48 | if (document.loaded) return; 49 | if (timer) window.clearTimeout(timer); 50 | document.loaded = true; 51 | 52 | if (Riot.requiredFiles.length > 0) { 53 | Riot.loadBrowserScripts(Riot.requiredFiles, tests); 54 | } else { 55 | Riot.runAndReport(tests); 56 | } 57 | } 58 | 59 | function checkReadyState() { 60 | if (document.readyState === 'complete') { 61 | document.detachEvent('readystatechange', checkReadyState); 62 | fireContentLoadedEvent(); 63 | } 64 | } 65 | 66 | function pollDoScroll() { 67 | try { document.documentElement.doScroll('left'); } 68 | catch(e) { 69 | timer = setTimeout(pollDoScroll, 10); 70 | return; 71 | } 72 | fireContentLoadedEvent(); 73 | } 74 | 75 | if (document.addEventListener) { 76 | document.addEventListener('DOMContentLoaded', fireContentLoadedEvent, false); 77 | } else { 78 | document.attachEvent('readystatechange', checkReadyState); 79 | if (window == top) 80 | timer = setTimeout(pollDoScroll, 10); 81 | } 82 | 83 | window.onload = fireContentLoadedEvent; 84 | }, 85 | 86 | loadBrowserScripts: function(files, tests) { 87 | var i, file; 88 | 89 | function loadBrowserScript(src, callback) { 90 | var script = document.createElement('script'), 91 | head = document.getElementsByTagName('head')[0], 92 | readyState; 93 | script.setAttribute('type', 'text/javascript'); 94 | script.setAttribute('src', src); 95 | script.onload = script.onreadystatechange = function() { 96 | if (!(readyState = script.readyState) || /loaded|complete/.test(readyState)) { 97 | script.onload = script.onreadystatechange = null; 98 | head.removeChild(script); 99 | if (callback) { 100 | setTimeout(callback, 1); 101 | } 102 | } 103 | }; 104 | 105 | head.insertBefore(script, head.firstChild); 106 | } 107 | 108 | if (files.length > 1) { 109 | file = files[0]; 110 | loadBrowserScript(file, function() { Riot.loadBrowserScripts(files.slice(1), tests); }); 111 | } else { 112 | file = files[0]; 113 | loadBrowserScript(file, function() { Riot.runAndReport(tests); }); 114 | } 115 | }, 116 | 117 | load: function() { 118 | switch (Riot.detectEnvironment()) { 119 | case 'xpcomcore': 120 | case 'rhino': 121 | case 'non-browser-interpreter': 122 | load(arguments[0]); 123 | break; 124 | case 'node': 125 | // Evaluate the required code in the global context, like load() would 126 | global.eval.call(global, Riot.node.fs.readFileSync(arguments[0]).toString()); 127 | break; 128 | case 'browser': 129 | var script = document.createElement('script'), 130 | head = document.getElementsByTagName('head'); 131 | script.setAttribute('type', 'text/javascript'); 132 | script.setAttribute('src', arguments[0]); 133 | head[0].insertBefore(script, head.firstChild); 134 | break; 135 | } 136 | }, 137 | 138 | requiredFiles: [], 139 | 140 | indexOf: function(array, value) { 141 | for (var i = 0; i < array.length; i++) { 142 | if (array[i] === value) { 143 | return i; 144 | } 145 | } 146 | return -1; 147 | }, 148 | 149 | require: function() { 150 | if (this.indexOf(this.requiredFiles, arguments[0]) == -1) { 151 | this.requiredFiles.push(arguments[0]); 152 | if (Riot.detectEnvironment() !== 'browser') { 153 | this.load(arguments[0]); 154 | } 155 | } 156 | }, 157 | 158 | detectEnvironment: function() { 159 | if (typeof this.env !== 'undefined') { 160 | return this.env; 161 | } 162 | 163 | this.env = (function() { 164 | if (typeof XPCOMCore !== 'undefined') { 165 | Riot.puts = print; 166 | return 'xpcomcore'; 167 | } else if (typeof window === 'undefined' && typeof java !== 'undefined') { 168 | Riot.puts = print; 169 | return 'rhino'; 170 | } else if (typeof exports !== 'undefined') { 171 | // TODO: Node should be checked more thoroughly 172 | Riot.node = { 173 | fs: require('fs'), 174 | sys: require('sys') 175 | } 176 | 177 | Riot.puts = Riot.node.sys.puts; 178 | 179 | return 'node'; 180 | } else if (typeof window === 'undefined') { 181 | Riot.puts = print; 182 | return 'non-browser-interpreter'; 183 | } else { 184 | return 'browser'; 185 | } 186 | })(); 187 | 188 | return this.env; 189 | }, 190 | 191 | runAndReport: function(tests) { 192 | this.running = true; 193 | var benchmark = Riot.Benchmark.run(1, function() { Riot.runAllContexts(tests); }); 194 | Riot.formatter.separator(); 195 | Riot.summariseAllResults(); 196 | Riot.formatter.line(benchmark); 197 | this.running = false; 198 | }, 199 | 200 | runAllContexts: function(tests) { 201 | if (typeof tests !== 'undefined') { 202 | this.withDSL(tests)(); 203 | } 204 | 205 | for (var i = 0; i < this.contexts.length; i++) { 206 | this.contexts[i].run(); 207 | } 208 | }, 209 | 210 | functionBody: function(fn) { 211 | return '(' + fn.toString().replace(/\s+$/, '') + ')()'; 212 | }, 213 | 214 | withDSL: function(fn, context) { 215 | var body = this.functionBody(fn), 216 | f = new Function('context', 'given', 'asserts', 'should', 'setup', 'teardown', body), 217 | args = [ 218 | Riot.context, 219 | Riot.given, 220 | function() { return context.asserts.apply(context, arguments); }, 221 | function() { return context.should.apply(context, arguments); }, 222 | function() { return context.setup.apply(context, arguments); }, 223 | function() { return context.teardown.apply(context, arguments); } 224 | ]; 225 | 226 | return function() { f.apply(Riot, args); }; 227 | }, 228 | 229 | context: function(title, callback) { 230 | var context = new Riot.Context(title, callback); 231 | 232 | if (this.running) { 233 | context.run(); 234 | } else { 235 | Riot.contexts.push(context); 236 | } 237 | 238 | return context; 239 | }, 240 | 241 | given: function(title, callback) { 242 | title = 'Given ' + title; 243 | return Riot.context(title, callback); 244 | }, 245 | 246 | summariseAllResults: function() { return this.summarise(this.results); }, 247 | 248 | summarise: function(results) { 249 | var failures = 0; 250 | for (var i = 0; i < results.length; i++) { 251 | if (!results[i].pass) { failures++; } 252 | } 253 | this.formatter.line(results.length + ' assertions: ' + failures + ' failures'); 254 | this.exitCode = failures > 0 ? 1 : 0; 255 | }, 256 | 257 | addResult: function(context, assertion, pass) { 258 | var result = { 259 | assertion: assertion, 260 | pass: pass, 261 | context: context 262 | }; 263 | this.results.push(result); 264 | } 265 | }; 266 | 267 | Riot.Benchmark = { 268 | results: [], 269 | 270 | addResult: function(start, end) { 271 | this.results.push(end - start); 272 | }, 273 | 274 | displayResults: function() { 275 | var total = 0, 276 | seconds = 0, 277 | i = 0; 278 | for (i = 0; i < this.results.length; i++) { 279 | total += this.results[i]; 280 | } 281 | seconds = total / 1000; 282 | return 'Elapsed time: ' + total + 'ms (' + seconds + ' seconds)'; 283 | }, 284 | 285 | run: function(times, callback) { 286 | this.results = []; 287 | for (var i = 0; i < times; i++) { 288 | var start = new Date(), 289 | end = null; 290 | callback(); 291 | end = new Date(); 292 | this.addResult(start, end); 293 | } 294 | return this.displayResults(); 295 | } 296 | }; 297 | 298 | Riot.Formatters = { 299 | HTML: function() { 300 | function display(html) { 301 | var results = document.getElementById('test-results'); 302 | results.innerHTML += html; 303 | } 304 | 305 | this.line = function(text) { 306 | display('

      ' + text + '

      '); 307 | }; 308 | 309 | this.pass = function(message) { 310 | display('

      ' + message + '

      '); 311 | }; 312 | 313 | this.fail = function(message) { 314 | display('

      ' + message + '

      '); 315 | }; 316 | 317 | this.error = function(message, exception) { 318 | this.fail(message); 319 | display('

      Exception: ' + exception + '

      '); 320 | }; 321 | 322 | this.context = function(name) { 323 | display('

      ' + name + '

      '); 324 | }; 325 | 326 | this.given = function(name) { 327 | display('

      ' + name + '

      '); 328 | }; 329 | 330 | this.separator = function() { 331 | display('
      '); 332 | }; 333 | }, 334 | 335 | Text: function() { 336 | function display(text) { 337 | Riot.puts(text); 338 | } 339 | 340 | this.line = function(text) { 341 | display(text); 342 | }; 343 | 344 | this.pass = function(message) { 345 | this.line(' +\033[32m ' + message + '\033[0m'); 346 | }; 347 | 348 | this.fail = function(message) { 349 | this.line(' -\033[31m ' + message + '\033[0m'); 350 | }; 351 | 352 | this.error = function(message, exception) { 353 | this.fail(message); 354 | this.line(' Exception: ' + exception); 355 | }; 356 | 357 | this.context = function(name) { 358 | this.line(name); 359 | }; 360 | 361 | this.given = function(name) { 362 | this.line(name); 363 | }; 364 | 365 | this.separator = function() { 366 | this.line(''); 367 | }; 368 | }, 369 | 370 | XPComCore: function() { 371 | var formatter = new Riot.Formatters.Text(); 372 | formatter.line = function(text) { 373 | puts(text); 374 | }; 375 | return formatter; 376 | } 377 | }; 378 | 379 | Riot.Context = function(name, callback) { 380 | this.name = name; 381 | this.callback = callback; 382 | this.assertions = []; 383 | }; 384 | 385 | Riot.Context.prototype = { 386 | asserts: function(name, result) { 387 | var assertion = new Riot.Assertion(this.name, name, result); 388 | this.assertions.push(assertion); 389 | return assertion; 390 | }, 391 | 392 | should: function(name, result) { 393 | return this.asserts('should ' + name, result); 394 | }, 395 | 396 | setup: function(setupFunction) { 397 | this.setupFunction = setupFunction; 398 | }, 399 | 400 | teardown: function(teardownFunction) { 401 | this.teardownFunction = teardownFunction; 402 | }, 403 | 404 | runSetup: function() { 405 | if (typeof this.setupFunction !== 'undefined') { 406 | return this.setupFunction(); 407 | } 408 | }, 409 | 410 | runTeardown: function() { 411 | if (typeof this.teardownFunction !== 'undefined') { 412 | return this.teardownFunction(); 413 | } 414 | }, 415 | 416 | formatContextName: function() { 417 | if (this.name.match(/^Given/)) { 418 | Riot.formatter.given(this.name); 419 | } else { 420 | Riot.formatter.context(this.name); 421 | } 422 | }, 423 | 424 | run: function() { 425 | this.formatContextName(); 426 | Riot.withDSL(this.callback, this)(); 427 | this.runSetup(); 428 | for (var i = 0; i < this.assertions.length; i++) { 429 | var pass = false, 430 | assertion = this.assertions[i]; 431 | try { 432 | assertion.run(); 433 | pass = true; 434 | Riot.formatter.pass(assertion.name); 435 | } catch (e) { 436 | if (typeof e.name !== 'undefined' && e.name === 'Riot.AssertionFailure') { 437 | Riot.formatter.fail(e.message); 438 | } else { 439 | Riot.formatter.error(assertion.name, e); 440 | } 441 | } 442 | 443 | Riot.addResult(this.name, assertion.name, pass); 444 | } 445 | this.runTeardown(); 446 | } 447 | }; 448 | 449 | Riot.AssertionFailure = function(message) { 450 | var error = new Error(message); 451 | error.name = 'Riot.AssertionFailure'; 452 | return error; 453 | }; 454 | 455 | Riot.Assertion = function(contextName, name, expected) { 456 | this.name = name; 457 | this.expectedValue = expected; 458 | this.contextName = contextName; 459 | this.kindOf = this.typeOf; 460 | this.isTypeOf = this.typeOf; 461 | 462 | this.setAssertion(function(actual) { 463 | if ((actual() === null) || (actual() === undefined)) { 464 | throw(new Riot.AssertionFailure("Expected a value but got '" + actual() + "'")); 465 | } 466 | }); 467 | }; 468 | 469 | Riot.Assertion.prototype = { 470 | setAssertion: function(assertion) { 471 | this.assertion = assertion; 472 | }, 473 | 474 | run: function() { 475 | var that = this; 476 | this.assertion(function() { return that.expected(); }); 477 | }, 478 | 479 | fail: function(message) { 480 | throw(new Riot.AssertionFailure(this.name + ': ' + message)); 481 | }, 482 | 483 | expected: function() { 484 | if (typeof this.expectedMemo === 'undefined') { 485 | if (typeof this.expectedValue === 'function') { 486 | try { 487 | this.expectedMemo = this.expectedValue(); 488 | } catch (exception) { 489 | this.expectedValue = exception; 490 | } 491 | } else { 492 | this.expectedMemo = this.expectedValue; 493 | } 494 | } 495 | return this.expectedMemo; 496 | }, 497 | 498 | // Based on http://github.com/visionmedia/jspec/blob/master/lib/jspec.js 499 | // Short-circuits early, can compare arrays 500 | isEqual: function(a, b) { 501 | if (typeof a != typeof b) return; 502 | if (a === b) return true; 503 | if (a instanceof RegExp) { 504 | return a.toString() === b.toString(); 505 | } 506 | if (a instanceof Date) { 507 | return Number(a) === Number(b); 508 | } 509 | if (typeof a != 'object') return; 510 | if (a.length !== undefined) { 511 | if (a.length !== b.length) { 512 | return; 513 | } else { 514 | for (var i = 0, len = a.length; i < len; ++i) { 515 | if (!this.isEqual(a[i], b[i])) { 516 | return; 517 | } 518 | } 519 | } 520 | } 521 | for (var key in b) { 522 | if (!this.isEqual(a[key], b[key])) { 523 | return; 524 | } 525 | } 526 | return true; 527 | }, 528 | 529 | /* Assertions */ 530 | equals: function(expected) { 531 | this.setAssertion(function(actual) { 532 | if (!this.isEqual(actual(), expected)) { 533 | this.fail(expected + ' does not equal: ' + actual()); 534 | } 535 | }); 536 | }, 537 | 538 | matches: function(expected) { 539 | this.setAssertion(function(actual) { 540 | if (!expected.test(actual())) { 541 | this.fail("Expected '" + actual() + "' to match '" + expected + "'"); 542 | } 543 | }); 544 | }, 545 | 546 | raises: function(expected) { 547 | this.setAssertion(function(actual) { 548 | try { 549 | actual(); 550 | return; 551 | } catch (exception) { 552 | if (expected !== exception) { 553 | this.fail('raised ' + exception + ' instead of ' + expected); 554 | } 555 | } 556 | this.fail('did not raise ' + expected); 557 | }); 558 | }, 559 | 560 | typeOf: function(expected) { 561 | this.setAssertion(function(actual) { 562 | var t = typeof actual(); 563 | if (t === 'object') { 564 | if (actual()) { 565 | if (typeof actual().length === 'number' && 566 | !(actual.propertyIsEnumerable('length')) && 567 | typeof actual().splice === 'function') { 568 | t = 'array'; 569 | } 570 | } else { 571 | t = 'null'; 572 | } 573 | } 574 | 575 | if (t !== expected.toLowerCase()) { 576 | this.fail(expected + ' is not a type of ' + actual()); 577 | } 578 | }); 579 | }, 580 | 581 | isTrue: function() { 582 | this.setAssertion(function(actual) { 583 | if (actual() !== true) { 584 | this.fail(actual() + ' was not true'); 585 | } 586 | }); 587 | }, 588 | 589 | isFalse: function() { 590 | this.setAssertion(function(actual) { 591 | if (actual() !== false) { 592 | this.fail(actual() + ' was not false'); 593 | } 594 | }); 595 | }, 596 | 597 | isNull: function() { 598 | this.setAssertion(function(actual) { 599 | if (actual() !== null) { 600 | this.fail(actual() + ' was not null'); 601 | } 602 | }); 603 | }, 604 | 605 | isNotNull: function() { 606 | this.setAssertion(function(actual) { 607 | if (actual() === null) { 608 | this.fail(actual() + ' was null'); 609 | } 610 | }); 611 | } 612 | }; 613 | 614 | if (typeof exports !== 'undefined') { 615 | exports.Riot = Riot; 616 | } else if (typeof riotGlobal.Riot === 'undefined') { 617 | riotGlobal.Riot = Riot; 618 | 619 | if (typeof riotGlobal.load === 'undefined') { 620 | riotGlobal.load = function() { }; 621 | } 622 | } 623 | })(typeof window === 'undefined' ? this : window); 624 | -------------------------------------------------------------------------------- /app/models/collection.rb: -------------------------------------------------------------------------------- 1 | class Collection 2 | include Mongoid::Document 3 | end 4 | -------------------------------------------------------------------------------- /app/models/project.rb: -------------------------------------------------------------------------------- 1 | class Project 2 | include Mongoid::Document 3 | index :user_id 4 | references_many :tasks, :dependent => :destroy 5 | end 6 | -------------------------------------------------------------------------------- /app/models/setting.rb: -------------------------------------------------------------------------------- 1 | class Setting 2 | include Mongoid::Document 3 | index :user_id 4 | end 5 | -------------------------------------------------------------------------------- /app/models/task.rb: -------------------------------------------------------------------------------- 1 | class Task 2 | include Mongoid::Document 3 | include Mongoid::Timestamps 4 | index :project_id 5 | index :user_id 6 | end 7 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User 2 | include Mongoid::Document 3 | field :identity_url 4 | field :display_identifier 5 | field :name 6 | index :identity_url, :unique => true 7 | end 8 | -------------------------------------------------------------------------------- /app/models/wingman.rb: -------------------------------------------------------------------------------- 1 | module Wingman 2 | # Concatenates all the JavaScript, used by 3 | # a rake task and development mode 4 | def self.alljs 5 | %w(app/javascripts/lib/json2.js 6 | app/javascripts/lib/jquery.min.js 7 | app/javascripts/lib/jquery-ui.min.js 8 | app/javascripts/intro.js 9 | app/javascripts/reusable/feedback.js 10 | app/javascripts/reusable/lock.js 11 | app/javascripts/reusable/storage.js 12 | app/javascripts/reusable/mvc.js 13 | app/javascripts/models.js 14 | app/javascripts/jquery-extensions.js 15 | app/javascripts/defaults.js 16 | app/javascripts/editable.js 17 | app/javascripts/tasks.js 18 | app/javascripts/projects.js 19 | app/javascripts/application.js 20 | app/javascripts/search.js 21 | app/javascripts/keyboard.js 22 | app/javascripts/outro.js).map do |file| 23 | File.read(file) 24 | end.join("\n") 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/models/wingman/hash_helpers.rb: -------------------------------------------------------------------------------- 1 | module Wingman::HashHelpers 2 | COLLECTIONS = { 3 | 'tasks' => Task, 4 | 'projects' => Project, 5 | 'settings' => Setting, 6 | 'collections' => Collection 7 | } 8 | 9 | def collection_hash(name) 10 | conditions = { :user_id => @current_user.id } 11 | 12 | if name == 'tasks' 13 | conditions[:archived] = false 14 | end 15 | 16 | items = COLLECTIONS[name].find(:all, :conditions => conditions) 17 | items.inject({}) { |i, r| i[r.id] = r.raw_attributes; i[r.id]['id'] = r.id; i[r.id].delete('_id'); i } 18 | end 19 | 20 | def kv_hash(name) 21 | items = COLLECTIONS[name].find(:all, :conditions => { :user_id => @current_user.id }) 22 | hash = {} 23 | items.each do |item| 24 | hash[item.key] = item.value 25 | end 26 | hash 27 | end 28 | 29 | def collection_class(collection) 30 | COLLECTIONS[collection] 31 | end 32 | end 33 | -------------------------------------------------------------------------------- /app/views/application/login.html.erb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/app/views/application/login.html.erb -------------------------------------------------------------------------------- /app/views/application/main.html.erb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/app/views/application/main.html.erb -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Wingman 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | <% if Rails.env == 'production' %> 15 | <%= javascript_include_tag 'all.js' %> 16 | <% else %> 17 | <%= javascript_include_tag 'all-development.js' %> 18 | <% end %> 19 | 20 | 21 | <% unless logged_in? %> 22 |
      23 | <%= render :template => 'openid/new' %> 24 |
      25 | <% end %> 26 | 27 |
      28 |
        29 |
      • Collect

      • 30 |
      • 31 | 34 |
      • 35 |
      • Plan

      • 36 |
      • 37 | 41 |
      • 42 |
      • Organize

      • 43 |
      • 44 |
          45 |
        46 |
      • 47 |
      • Log

      • 48 |
      • 49 | 52 |
      • 53 |
      54 |
      55 |
      56 |
      57 | 60 | 61 |
      62 | 63 |
      64 | 65 | 66 | 67 |
        68 |
      • 69 |
      • Notes
      • 70 |
      • 71 |
          72 |
        73 |
      • 74 |
      75 |
      76 | 84 | 181 | 194 | 195 | 196 | -------------------------------------------------------------------------------- /app/views/layouts/login.html.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/views/openid/new.html.erb: -------------------------------------------------------------------------------- 1 | <%= form_tag openid_path do %> 2 | <%= raw render_flash %> 3 |

      Enter an OpenID to continue.

      4 | 11 |

      12 | <%= text_field_tag 'openid_url', cookies[:open_id], :size => 30 %> 13 |

      14 |

      15 | Login OpenID Help 16 |

      17 | <% end %> 18 | 19 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require ::File.expand_path('../config/environment', __FILE__) 4 | run Wingman::Application 5 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require File.expand_path('../boot', __FILE__) 2 | 3 | require 'action_controller/railtie' 4 | require 'action_mailer/railtie' 5 | require 'active_resource/railtie' 6 | 7 | # If you have a Gemfile, require the gems listed there, including any gems 8 | # you've limited to :test, :development, or :production. 9 | Bundler.require(:default, Rails.env) if defined?(Bundler) 10 | 11 | module Wingman 12 | class Application < Rails::Application 13 | # Settings in config/environments/* take precedence over those specified here. 14 | # Application configuration should go into files in config/initializers 15 | # -- all .rb files in that directory are automatically loaded. 16 | 17 | # Custom directories with classes and modules you want to be autoloadable. 18 | # config.autoload_paths += %W(#{config.root}/extras) 19 | 20 | # Only load the plugins named here, in the order given (default is alphabetical). 21 | # :all can be used as a placeholder for all plugins not explicitly named. 22 | # config.plugins = [ :exception_notification, :ssl_requirement, :all ] 23 | 24 | # Activate observers that should always be running. 25 | # config.active_record.observers = :cacher, :garbage_collector, :forum_observer 26 | 27 | # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. 28 | # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. 29 | # config.time_zone = 'Central Time (US & Canada)' 30 | 31 | # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. 32 | # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] 33 | # config.i18n.default_locale = :de 34 | 35 | # JavaScript files you want as :defaults (application.js is always included). 36 | # config.action_view.javascript_expansions[:defaults] = %w(jquery rails) 37 | 38 | # Configure the default encoding used in templates for Ruby 1.9. 39 | config.encoding = "utf-8" 40 | 41 | # Configure sensitive parameters which will be filtered from the log file. 42 | config.filter_parameters += [:password] 43 | end 44 | end 45 | 46 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | require 'rubygems' 2 | 3 | # Set up gems listed in the Gemfile. 4 | gemfile = File.expand_path('../../Gemfile', __FILE__) 5 | begin 6 | ENV['BUNDLE_GEMFILE'] = gemfile 7 | require 'bundler' 8 | Bundler.setup 9 | rescue Bundler::GemNotFound => e 10 | STDERR.puts e.message 11 | STDERR.puts "Try running `bundle install`." 12 | exit! 13 | end if File.exist?(gemfile) 14 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the rails application 2 | require File.expand_path('../application', __FILE__) 3 | 4 | # Initialize the rails application 5 | Wingman::Application.initialize! 6 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Wingman::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the webserver when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Log error messages when you accidentally call methods on nil. 10 | config.whiny_nils = true 11 | 12 | # Show full error reports and disable caching 13 | config.consider_all_requests_local = true 14 | config.action_view.debug_rjs = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Don't care if the mailer can't send 18 | config.action_mailer.raise_delivery_errors = false 19 | 20 | # Print deprecation notices to the Rails logger 21 | config.active_support.deprecation = :log 22 | end 23 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Wingman::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # The production environment is meant for finished, "live" apps. 5 | # Code is not reloaded between requests 6 | config.cache_classes = true 7 | 8 | # Full error reports are disabled and caching is turned on 9 | config.consider_all_requests_local = false 10 | config.action_controller.perform_caching = true 11 | 12 | # Specifies the header that your server uses for sending files 13 | config.action_dispatch.x_sendfile_header = "X-Sendfile" 14 | 15 | # For nginx: 16 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' 17 | 18 | # If you have no front-end server that supports something like X-Sendfile, 19 | # just comment this out and Rails will serve the files 20 | 21 | # See everything in the log (default is :info) 22 | # config.log_level = :debug 23 | 24 | # Use a different logger for distributed setups 25 | # config.logger = SyslogLogger.new 26 | 27 | # Use a different cache store in production 28 | # config.cache_store = :mem_cache_store 29 | 30 | # Disable Rails's static asset server 31 | # In production, Apache or nginx will already do this 32 | config.serve_static_assets = true 33 | 34 | # Enable serving of images, stylesheets, and javascripts from an asset server 35 | # config.action_controller.asset_host = "http://assets.example.com" 36 | 37 | # Disable delivery errors, bad email addresses will be ignored 38 | # config.action_mailer.raise_delivery_errors = false 39 | 40 | # Enable threaded mode 41 | # config.threadsafe! 42 | 43 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 44 | # the I18n.default_locale when a translation can not be found) 45 | config.i18n.fallbacks = true 46 | 47 | # Send deprecation notices to registered listeners 48 | config.active_support.deprecation = :notify 49 | end 50 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Wingman::Application.configure do 2 | # Settings specified here will take precedence over those in config/environment.rb 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Log error messages when you accidentally call methods on nil. 11 | config.whiny_nils = true 12 | 13 | # Show full error reports and disable caching 14 | config.consider_all_requests_local = true 15 | config.action_controller.perform_caching = false 16 | 17 | # Raise exceptions instead of rendering exception templates 18 | config.action_dispatch.show_exceptions = false 19 | 20 | # Disable request forgery protection in test environment 21 | config.action_controller.allow_forgery_protection = false 22 | 23 | # Tell Action Mailer not to deliver emails to the real world. 24 | # The :test delivery method accumulates sent emails in the 25 | # ActionMailer::Base.deliveries array. 26 | config.action_mailer.delivery_method = :test 27 | 28 | # Use SQL instead of Active Record's schema dumper when creating the test database. 29 | # This is necessary if your schema can't be completely dumped by the schema dumper, 30 | # like if you have constraints or database-specific column types 31 | # config.active_record.schema_format = :sql 32 | 33 | # Print deprecation notices to the stderr 34 | config.active_support.deprecation = :stderr 35 | end 36 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format 4 | # (all these examples are active by default): 5 | # ActiveSupport::Inflector.inflections do |inflect| 6 | # inflect.plural /^(ox)$/i, '\1en' 7 | # inflect.singular /^(ox)en/i, '\1' 8 | # inflect.irregular 'person', 'people' 9 | # inflect.uncountable %w( fish sheep ) 10 | # end 11 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | # Mime::Type.register_alias "text/html", :iphone 6 | -------------------------------------------------------------------------------- /config/initializers/openid.rb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/config/initializers/openid.rb -------------------------------------------------------------------------------- /config/initializers/secret_token.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | # Make sure the secret is at least 30 characters and all random, 6 | # no regular words or you'll be exposed to dictionary attacks. 7 | # Wingman::Application.config.secret_token = '43d25a9249e916d58373586193a2bbc2a0940c7623d2485255c82e7bfc7fddd037e5a643c4550ba5079fe03d040bd5414a0f955483f6adc9f945ecf2c8fe6b83' 8 | -------------------------------------------------------------------------------- /config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Wingman::Application.config.session_store :cookie_store, :key => '_wingman_session' 4 | Wingman::Application.config.session_store :mongoid_store, :key => '_wingman_session' 5 | 6 | # Use the database for sessions instead of the cookie-based default, 7 | # which shouldn't be used to store highly confidential information 8 | # (create the session table with "rake db:sessions:create") 9 | # Wingman::Application.config.session_store :active_record_store 10 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Sample localization file for English. Add more files in this directory for other locales. 2 | # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. 3 | 4 | en: 5 | hello: "Hello world" 6 | -------------------------------------------------------------------------------- /config/mongoid.yml: -------------------------------------------------------------------------------- 1 | defaults: &defaults 2 | 3 | development: 4 | <<: *defaults 5 | host: localhost 6 | port: 27017 7 | database: wingman_development 8 | 9 | test: 10 | <<: *defaults 11 | database: wingman_test 12 | host: localhost 13 | port: 27017 14 | 15 | # set these environment variables on your production server 16 | production: 17 | <<: *defaults 18 | host: <%= ENV['MONGOID_HOST'] %> 19 | port: <%= ENV['MONGOID_PORT'] %> 20 | database: <%= ENV['MONGOID_DATABASE'] %> 21 | username: <%= ENV['MONGOID_USERNAME'] %> 22 | password: <%= ENV['MONGOID_PASSWORD'] %> 23 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Wingman::Application.routes.draw do 2 | root :to => '', :action => 'main', :controller => 'application' 3 | match 'logout' => 'application#logout' 4 | match 'javascripts/all-development.js' => 'application#alljs' 5 | 6 | resource :storage, :controller => 'storage', :as => :storage do 7 | member do 8 | put :set_key_value 9 | get :restore 10 | get :archive 11 | post :update_user 12 | end 13 | end 14 | 15 | resource :openid, :controller => 'openid', :as => :openid do 16 | member do 17 | get :complete 18 | get :index 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # This file should contain all the record creation needed to seed the database with its default values. 2 | # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). 3 | # 4 | # Examples: 5 | # 6 | # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) 7 | # Mayor.create(:name => 'Daley', :city => cities.first) 8 | -------------------------------------------------------------------------------- /doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /lib/db_store.rb: -------------------------------------------------------------------------------- 1 | require 'openid/store/interface' 2 | 3 | module OpenID::Store 4 | class Association 5 | include Mongoid::Document 6 | field :secret, :type => Binary 7 | 8 | def from_record 9 | OpenID::Association.new(handle, secret.to_s, issued, lifetime, assoc_type) 10 | end 11 | end 12 | 13 | class Nonce 14 | include Mongoid::Document 15 | end 16 | 17 | class DbStore < OpenID::Store::Interface 18 | def self.cleanup_nonces 19 | now = Time.now.to_i 20 | Nonce.delete_all(["timestamp > ? OR timestamp < ?", now + OpenID::Nonce.skew, now - OpenID::Nonce.skew]) 21 | end 22 | 23 | def self.cleanup_associations 24 | now = Time.now.to_i 25 | Association.delete_all(['issued + lifetime > ?',now]) 26 | end 27 | 28 | def store_association(server_url, assoc) 29 | remove_association(server_url, assoc.handle) 30 | 31 | # BSON::Binary is used because secrets raise an exception 32 | # due to character encoding 33 | Association.create(:server_url => server_url, 34 | :handle => assoc.handle, 35 | :secret => BSON::Binary.new(assoc.secret), 36 | :issued => assoc.issued, 37 | :lifetime => assoc.lifetime, 38 | :assoc_type => assoc.assoc_type) 39 | end 40 | 41 | def get_association(server_url, handle = nil) 42 | assocs = if handle.blank? 43 | Association.find :all, :conditions => { :server_url => server_url } 44 | else 45 | Association.find :all, :conditions => { :server_url => server_url, :handle => handle } 46 | end 47 | 48 | assocs.reverse.each do |assoc| 49 | a = assoc.from_record 50 | if a.expires_in == 0 51 | assoc.destroy 52 | else 53 | return a 54 | end 55 | end if assocs.any? 56 | 57 | return nil 58 | end 59 | 60 | def remove_association(server_url, handle) 61 | Association.find(:all, :conditions => { :server_url => server_url, :handle => handle }).each do |assoc| 62 | assoc.destroy! 63 | end 64 | end 65 | 66 | def use_nonce(server_url, timestamp, salt) 67 | return false if Nonce.find(:first, :conditions => { :server_url => server_url, :timestamp => timestamp, :salt => salt}) 68 | return false if (timestamp - Time.now.to_i).abs > OpenID::Nonce.skew 69 | Nonce.create(:server_url => server_url, :timestamp => timestamp, :salt => salt) 70 | return true 71 | end 72 | end 73 | end 74 | 75 | -------------------------------------------------------------------------------- /lib/tasks/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/lib/tasks/.gitkeep -------------------------------------------------------------------------------- /lib/tasks/js.rake: -------------------------------------------------------------------------------- 1 | require File.join(Rails.root, 'app', 'models', 'wingman') 2 | 3 | namespace :js do 4 | task :build do 5 | File.open(File.join(Rails.root, 'public', 'javascripts', 'all.js'), 'w+') do |f| 6 | f << Wingman.alljs 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 17 | 18 | 19 | 20 | 21 |
      22 |

      The page you were looking for doesn't exist.

      23 |

      You may have mistyped the address or the page may have moved.

      24 |
      25 | 26 | 27 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 17 | 18 | 19 | 20 | 21 |
      22 |

      The change you wanted was rejected.

      23 |

      Maybe you tried to change something you didn't have access to.

      24 |
      25 | 26 | 27 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 17 | 18 | 19 | 20 | 21 |
      22 |

      We're sorry, but something went wrong.

      23 |

      We've been notified about this issue and we'll take a look at it shortly.

      24 |
      25 | 26 | 27 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/favicon.ico -------------------------------------------------------------------------------- /public/images/openid.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/images/openid.gif -------------------------------------------------------------------------------- /public/images/rails.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/images/rails.png -------------------------------------------------------------------------------- /public/images/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/images/spinner.gif -------------------------------------------------------------------------------- /public/images/wingman_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/images/wingman_logo.png -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /public/screenshots/wingman.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/screenshots/wingman.png -------------------------------------------------------------------------------- /public/stylesheets/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/.gitkeep -------------------------------------------------------------------------------- /public/stylesheets/images/button_bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/button_bg.png -------------------------------------------------------------------------------- /public/stylesheets/images/datepicker.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/datepicker.gif -------------------------------------------------------------------------------- /public/stylesheets/images/icon_sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/icon_sprite.png -------------------------------------------------------------------------------- /public/stylesheets/images/progress_bar.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/progress_bar.gif -------------------------------------------------------------------------------- /public/stylesheets/images/red_button_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/red_button_bg.gif -------------------------------------------------------------------------------- /public/stylesheets/images/red_gradient.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/red_gradient.gif -------------------------------------------------------------------------------- /public/stylesheets/images/slider_h_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/slider_h_bg.gif -------------------------------------------------------------------------------- /public/stylesheets/images/slider_handles.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/slider_handles.png -------------------------------------------------------------------------------- /public/stylesheets/images/slider_v_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/slider_v_bg.gif -------------------------------------------------------------------------------- /public/stylesheets/images/subtle_button_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/subtle_button_bg.gif -------------------------------------------------------------------------------- /public/stylesheets/images/tab_bg.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/tab_bg.gif -------------------------------------------------------------------------------- /public/stylesheets/images/the_gradient.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/the_gradient.gif -------------------------------------------------------------------------------- /public/stylesheets/images/todo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/todo.png -------------------------------------------------------------------------------- /public/stylesheets/images/todo_blank.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/todo_blank.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_diagonals-thick_18_b81900_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_diagonals-thick_18_b81900_40x40.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_diagonals-thick_20_666666_40x40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_diagonals-thick_20_666666_40x40.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_flat_10_000000_40x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_flat_10_000000_40x100.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_glass_100_f6f6f6_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_glass_100_f6f6f6_1x400.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_glass_100_fdf5ce_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_glass_100_fdf5ce_1x400.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_glass_65_ffffff_1x400.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_gloss-wave_35_f6a828_500x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_gloss-wave_35_f6a828_500x100.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_highlight-soft_100_eeeeee_1x100.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-bg_highlight-soft_75_ffe45c_1x100.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-icons_222222_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-icons_222222_256x240.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-icons_228ef1_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-icons_228ef1_256x240.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-icons_ef8c08_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-icons_ef8c08_256x240.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-icons_ffd27a_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-icons_ffd27a_256x240.png -------------------------------------------------------------------------------- /public/stylesheets/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /public/stylesheets/ipad.css: -------------------------------------------------------------------------------- 1 | body { font: 110% Helvetica, Arial, sans-serif; } 2 | h1 { font-size: 150%; } 3 | -------------------------------------------------------------------------------- /public/stylesheets/iphone.css: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/public/stylesheets/iphone.css -------------------------------------------------------------------------------- /public/stylesheets/print.css: -------------------------------------------------------------------------------- 1 | #left-hand-container, 2 | #global-menu { display: none } 3 | -------------------------------------------------------------------------------- /public/stylesheets/scaffold.css: -------------------------------------------------------------------------------- 1 | body { background-color: #fff; color: #333; } 2 | 3 | body, p, ol, ul, td { 4 | font-family: verdana, arial, helvetica, sans-serif; 5 | font-size: 13px; 6 | line-height: 18px; 7 | } 8 | 9 | pre { 10 | background-color: #eee; 11 | padding: 10px; 12 | font-size: 11px; 13 | } 14 | 15 | a { color: #000; } 16 | a:visited { color: #666; } 17 | a:hover { color: #fff; background-color:#000; } 18 | 19 | .fieldWithErrors { 20 | padding: 2px; 21 | background-color: red; 22 | display: table; 23 | } 24 | 25 | #errorExplanation { 26 | width: 400px; 27 | border: 2px solid red; 28 | padding: 7px; 29 | padding-bottom: 12px; 30 | margin-bottom: 20px; 31 | background-color: #f0f0f0; 32 | } 33 | 34 | #errorExplanation h2 { 35 | text-align: left; 36 | font-weight: bold; 37 | padding: 5px 5px 5px 15px; 38 | font-size: 12px; 39 | margin: -7px; 40 | background-color: #c00; 41 | color: #fff; 42 | } 43 | 44 | #errorExplanation p { 45 | color: #333; 46 | margin-bottom: 0; 47 | padding: 5px; 48 | } 49 | 50 | #errorExplanation ul li { 51 | font-size: 12px; 52 | list-style: square; 53 | } 54 | 55 | -------------------------------------------------------------------------------- /public/stylesheets/screen.css: -------------------------------------------------------------------------------- 1 | body { font: 82.5% Helvetica, Arial, sans-serif; margin: 0; padding: 0; background-color: #fff } 2 | 3 | h1, h2, h3, h4, h5, h6 { margin: 0; padding: 0 } 4 | 5 | #global-menu { position: fixed; bottom: 0; width: 100%; float: left; padding: 5px 0; margin: 0; border-left: none; border-right: none; border-bottom: none } 6 | #global-menu ul { list-style-type: none; margin: 0 5px; padding: 0; clear: right } 7 | #global-menu ul li { float: left; margin-right: 5px } 8 | #global-menu ul li.right { float: right; margin-left: 5px; margin-right: 0 } 9 | #global-menu ul li form { margin: 0; padding: 0 } 10 | #global-menu ul li form input { margin: 0; } 11 | 12 | #loading-indicator { padding: 8px 10px 0 0; line-height: 13px; color: red } 13 | 14 | .container h2 { margin-top: 10px } 15 | .container { padding: 10px } 16 | 17 | .title h1 { padding: 5px 5px 5px 10px; text-shadow: #fff 0 1px 1px; color: #4f4f4f; } 18 | div.title { margin: 0; padding: 0; border-bottom: 1px solid #b6b6b6; background-color: #b6b6b6; background: url('images/the_gradient.gif') 0 0 repeat-x } 19 | 20 | .outline-view { float: left; width: 23%; background-color: #dfe3ea; overflow: auto; } 21 | .outline-view ul { list-style-type: none; margin: 0; padding: 0 } 22 | .outline-view ul.items li { margin: 0; padding: 0; } 23 | .outline-view ul.items a { color: #000; text-decoration: none; display: block; padding: 7px 25px } 24 | .outline-view ul.items li.selected a { color: #fff; font-weight: bold; text-shadow: #666 0 1px 1px } 25 | .outline-view ul.items .selected { 26 | background-color: #8897ba; 27 | filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b2bed7', endColorstr='#8897ba'); 28 | background: -webkit-gradient(linear, left top, left bottom, from(#b2bed7), to(#8897ba)); 29 | background: -moz-linear-gradient(top, #b2bed7, #8897ba); 30 | } 31 | .outline-view .hover { background-color: #f0f0f0; } 32 | .outline-view .hover-drag { background-color: #ffc !important; border: 3px solid #3333dd !important } 33 | .dragging { width: 100px !important } 34 | .outline-view h2 { font-size: 100%; padding: 10px 10px 2px 10px; text-shadow: #fff 0 1px 1px; text-transform: uppercase; color: #696969 } 35 | .outline-view a { outline: none } 36 | 37 | .content { float: left; width: 77%; margin: 0; padding: 0; overflow: auto; overflow-x: hidden } 38 | .content-divider { float: left; background-color: #b6b6b6; width: 2px; margin: 0; padding: 0; cursor: e-resize; cursor: col-resize; } 39 | 40 | /* Only webkit seems to show text selections when double clicking on the buttons */ 41 | ul.todo-items { margin: 0; padding: 0; list-style-type: none; -webkit-user-select: none; } 42 | ul.todo-items li { margin: 1px 0; width: 100%; white-space: nowrap } 43 | ul.todo-items .button { text-align: left; } 44 | ul.todo-items .button .ui-button-text { text-align: left; overflow: hidden; text-overflow: ellipsis; -o-text-overflow: ellipsis; } 45 | .state, .delete { margin: 0 1px; position: relative; padding: 6px 0 7px 0; cursor: pointer; width: 30px; float: left; } 46 | .state span.ui-icon, .delete span.ui-icon { margin: 0 6px 0 7px; } 47 | .delete { float: right } 48 | 49 | ul.project-header { list-style-type: none; margin: 0; padding: 0; width: 100% } 50 | ul.project-header > li { border-bottom: 1px solid #b6b6b6; margin: 0; padding: 8px } 51 | ul.project-header li.body { border: none } 52 | .name-text { margin-left: 5px !important; float: left } 53 | 54 | ul.folders { list-style-type: none; margin: 0; padding: 0 } 55 | ul.folders li { margin: 0; padding: 0 } 56 | 57 | ul.todo-items li.details { margin: 10px 0 } 58 | .button .ui-button-text { background-image: url('/stylesheets/images/subtle_button_bg.gif') !important } 59 | ul.todo-items div.details > span { background-color: #f0f0f0 !important; background-image: none !important } 60 | ul.todo-items ul.details { list-style-type: none; margin: 0; padding: 0; font-weight: normal; } 61 | ul.todo-items ul.details > li { border-bottom: 1px solid #b6b6b6; margin: 0; padding: 8px 0 } 62 | ul.todo-items ul.details .buttons { border: none; width: 40%; float: right; padding-bottom: 4px } 63 | ul.todo-items ul.details li.last { border: none; width: 48%; float: left; padding-bottom: 4px } 64 | ul.todo-items ul.details .name { font-weight: bold } 65 | .ui-icon-todo { background-image: url('images/todo_blank.png') !important; } 66 | .ui-icon-todo-today { background-image: url('images/todo.png') !important; } 67 | .todo-items .highlight > span { background-color: #dfe3ea !important; background-image: none !important; } 68 | 69 | .search, .search .ui-button-text { background-color: #fff !important; background-image: none !important } 70 | .search { cursor: default !important } 71 | .search .ui-button-text { cursor: default !important } 72 | .search input { border: none; padding: 0; margin: 0 } 73 | .search input:focus { outline: none; } 74 | 75 | input.editable { width: 99%; background-color: #ffc; border: 1px solid #b6b6b6; padding: 4px } 76 | textarea.editable { width: 99%; background-color: #ffc; border: 1px solid #b6b6b6; padding: 4px } 77 | .large { white-space: pre !important } 78 | 79 | .red-button .ui-state-default .ui-button-text { background: url(images/red_button_bg.gif) 0px 0px repeat-x !important; } 80 | .red-button .ui-state-hover .ui-button-text { background: url(images/red_button_bg.gif) 0px 0px repeat-x !important; } 81 | .red-button .ui-state-active .ui-button-text { background: url(images/red_button_bg.gif) 0px bottom repeat-x !important; } 82 | 83 | .task-state-icon { float: right } 84 | 85 | #feedback { padding: 0 20px } 86 | #settings-feedback { padding: 0; margin: 0 0 20px 0 } 87 | div.submit { margin-top: 10px } 88 | 89 | .close-task, .clear-due, .sort-task { float: right; border: none !important; background-color: transparent; } 90 | .close-task a, .sort-task a { border: none !important; font-weight: bold; background-color: transparent; display: block; text-align: right } 91 | .sort-task { width: 20px } 92 | a.close-task:active, a.sort-task:active { color: #000 !important } 93 | .clear-due { float: left; margin: 0 5px 0 0; padding: 0; width: 16px; height: 16px } 94 | .due-button { float: left; border: none !important; margin-right: 5px; width: 5em } 95 | 96 | table { margin: 1em 0 0 0; padding: 2px; border: #b6b6b6 solid 1px } 97 | td, th { text-align: left; margin: 0; padding: 5px 50px 5px 5px } 98 | th { background-color: #ffc } 99 | 100 | .help-content { background-color: #ffd; margin: 0; padding: 0; } 101 | .help h3 { background-color: #eaeaea; color: #000; margin: 0; padding: 5px 10px; text-shadow: #fff 0 1px 1px; font-size: 13px } 102 | .help p { margin: 0; padding: 5px 10px } 103 | 104 | #OpenIDHelpLink { margin-left: 1em } 105 | #openid_url:focus { background-color: #ffc } 106 | #openid_url { width: 330px; margin-left: 7px } 107 | 108 | .settings_form label { width: 7.5em; display: block; float: left } 109 | .settings_form input { float: left } 110 | .settings_form div { clear: both } 111 | 112 | #export-text-value { width: 90%; height: 300px; font-size: 110%; font-family: courier } 113 | -------------------------------------------------------------------------------- /script/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. 3 | 4 | APP_PATH = File.expand_path('../../config/application', __FILE__) 5 | require File.expand_path('../../config/boot', __FILE__) 6 | require 'rails/commands' 7 | -------------------------------------------------------------------------------- /test/functional/storage_controller_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class StorageControllerTest < ActionController::TestCase 4 | def setup 5 | generate_fixtures 6 | @request.accept = 'application/json' 7 | end 8 | 9 | def teardown 10 | destroy_fixtures 11 | end 12 | 13 | test 'access control session fail' do 14 | @request.accept = 'text/html' 15 | post :create, { 'collection' => 'tasks', 'data' => '{"id":111111,"name":"do this"}' }, :identity_url => nil 16 | assert_redirected_to new_openid_url 17 | end 18 | 19 | test 'access control account hack' do 20 | @request.accept = 'text/javascript' 21 | @task.name = 'Example Task Updated' 22 | json = @task.attributes 23 | json['id'] = json['_id'] 24 | 25 | put :update, { 'collection' => 'tasks', 'data' => json.to_json }, :identity_url => 'https://example.com/fake' 26 | assert_response :unauthorized 27 | end 28 | 29 | test 'create' do 30 | post :create, { 'collection' => 'tasks', 'data' => '{"id":111111,"name":"do this"}' }, :identity_url => @user.identity_url 31 | assert_response :success 32 | end 33 | 34 | test 'update' do 35 | @task.name = 'Example Task Updated' 36 | json = @task.attributes 37 | json['id'] = json['_id'] 38 | put :update, { 'collection' => 'tasks', 'data' => json.to_json }, :identity_url => @user.identity_url 39 | assert_response :success 40 | end 41 | 42 | test 'update not found' do 43 | put :update, { 'collection' => 'tasks', 'data' => { '_id' => 1, 'name' => 'test' }.to_json }, :identity_url => @user.identity_url 44 | assert_response :error 45 | end 46 | 47 | test 'set_key_value create' do 48 | json = { 'key' => 'test', 'value' => [1, 2, 3, 4] }.to_json 49 | put :set_key_value, { 'data' => json, 'collection' => 'collections' }, :identity_url => @user.identity_url 50 | assert_response :success 51 | assert_equal [1, 2, 3, 4], Collection.find(:first, :conditions => { :key => 'test' }).value 52 | end 53 | 54 | test 'set_key_value update' do 55 | json = { 'key' => "project_tasks_#{@project.id}", 'value' => [@project.id, 1] }.to_json 56 | put :set_key_value, { 'data' => json, 'collection' => 'collections' }, :identity_url => @user.identity_url 57 | assert_response :success 58 | assert_equal [@project.id, 1], Collection.find(:first, :conditions => { :key => "project_tasks_#{@project.id}" }).value 59 | end 60 | 61 | test 'destroy' do 62 | delete :destroy, { 'id' => @task.id, 'collection' => 'tasks' }, :identity_url => @user.identity_url 63 | assert_response :success 64 | end 65 | end 66 | 67 | -------------------------------------------------------------------------------- /test/integration/test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'capybara' 3 | require 'capybara/dsl' 4 | 5 | Capybara.app = Rails.application 6 | Capybara.default_wait_time = 3 7 | 8 | class IntegrationTest < ActionController::TestCase 9 | include Capybara 10 | 11 | def setup 12 | Capybara.current_driver = :selenium 13 | generate_fixtures 14 | @open_id = '' 15 | @password = '' 16 | end 17 | 18 | def teardown 19 | destroy_fixtures 20 | end 21 | 22 | test 'login' do 23 | # Todo: Testing this application with Capybara is really annoying 24 | # I don't understand how to trigger dblclick, keyboard shortcuts, etc. 25 | # Plus, how do I mock the open ID login? 26 | visit '/' 27 | fill_in 'openid_url', :with => @open_id 28 | click_link 'login-button' 29 | fill_in 'Passwd', :with => @password 30 | click 'signIn' 31 | if page.has_css? '#approve_button' 32 | click_button 'approve_button' 33 | end 34 | Capybara.default_wait_time = 3 35 | find(:css, 'li.task .button').click 36 | sleep 30 37 | end 38 | end 39 | -------------------------------------------------------------------------------- /test/performance/browsing_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | require 'rails/performance_test_help' 3 | 4 | # Profiling results for each test method are written to tmp/performance. 5 | class BrowsingTest < ActionDispatch::PerformanceTest 6 | def test_homepage 7 | get '/' 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /test/test_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "test" 2 | require File.expand_path('../../config/environment', __FILE__) 3 | require 'rails/test_help' 4 | 5 | class ActiveSupport::TestCase 6 | def generate_fixtures 7 | @user = User.create({ :identity_url => 'https://example.com/username' }) 8 | @project = Project.create :id => 1, :user_id => @user.id, :name => 'Example Project' 9 | @task = Task.create :id => 1, :project_id => @project.id, :name => 'Example Task 1', :user_id => @user.id 10 | @collection = Collection.create :id => 1, :key => "project_tasks_#{@project.id}", :user_id => @user.id, :value => [@task.id] 11 | end 12 | 13 | def destroy_fixtures 14 | [User, Project, Task, Setting, Collection].each &:destroy_all 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /test/unit/helpers/storage_helper_test.rb: -------------------------------------------------------------------------------- 1 | require 'test_helper' 2 | 3 | class StorageHelperTest < ActionView::TestCase 4 | end 5 | -------------------------------------------------------------------------------- /vendor/plugins/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alexyoung/wingman/3e448c682631877811184fb5f62af94107800eb9/vendor/plugins/.gitkeep --------------------------------------------------------------------------------