cs132-twilio/CS-132-Twilio — pull request #19 by rcchan (2012-05-03 20:19:26+00:00)
Title: Updates 5/1

Made a bunch of structural changes to the way javascripts, assets, and module containers are handled in the application.
Also modified a lot of the way that ajax loading is handled (shouldnt be any functional change in the way your modules are integrated)

You can now join a class by texting JOIN [name] to register yourself on the system as name (so JOIN ryan for me) and subsequently JOIN [id] for any class id

You can use any length module code you want. We decided that 2 letter codes are just a pain to memorize plus a lot of phones have automatic word autocomplete anyway. ie. polling now uses the 'poll' keyword and stream uses the 'str' keyword.

The class list in the sidebar now autoloads based on the classes that are registered with the currently logged in user.
Multiple users are able to share the same classes (a single class can have more than one owner) since the database is set up to use an n-to-m mapping

Modules and class selection now works
(I'm not sure which things will actually require selection of multiple classes so I'm going to leave it at you're only allowed to select one class at a time. Of the modules so far, list and stream only use one class at a time and message is not class specific.)

Modules are given notice that the class has changed. Changing a class will no longer default the module to List. So make sure that your module has the appropriate handler for changeClass if it needs to respond when another class selected. Since modules are loaded via ajax, window.load functions dont work. Define a run() function in your module object instead. Feel free to borrow code from one of the existing module's js source files in my repository. In general, the structure is something like

File: Modulename.js

Twexter.modules.Modulename = {
run: function (){...},
changeClass: function(c = [id of selected class]){...}
custom: function (){ any additional code your module needs }
}

Note that javascripts may be reorganized on the filesystem in the near future (separating into modules directory as has already happened with views and controllers).

Also put up a registration (+styles) on the main page (fully working) so that you can add new users.

ReCaptcha has been slightly reengineered so that it works with AJAX
(issues with the way google/recaptcha uses document.write... whether to purposely ward off ajax attempts or not.)

Messaging now accepts autocompleted tokens (like the way fb does messaging) and knows to map them to the appropriate phone numbers (sending to either a student, class, or mix and combination of both)

Built an additional library to check if the auth is still valid and to take appropriate action (show a login) even when on a module page. (The login will intercept the rendering of the module and force login. No modules will be accessible until valid authtoken is accepted). Use $this->checkauth->check() for secure pages

Currently working on ability to add new streams. Have already mostly styled up the old posts. Automatically pulls in which streams below to a class.
Streams also have a timestamp that says "X units ago" like 5 minutes ago or 2 days ago, etc as appropriate. You can use this in your modules too by calling $(selector).timeago() or by using $.timeago(Date)