On Sat, Feb 13, 2016 at 5:57 AM, Sebastian Bazley <[email protected]> wrote: > Commit 5c4d6510288da6e6aac76693606b6fc6e427668f: > Revert sort - does not seem to work > ... > --- a/www/roster/views/committee.js.rb
Let me explain what is going on, how to test locally, and where I'm gong with this. What's going in is that files that end in .js.rb are syntactically ruby but are converted to javascript. Specifically this: https://github.com/apache/whimsy/blob/master/www/roster/views/app.js.rb ... is mapped into this: https://whimsy-test.apache.org/roster/app.js This conversion is done by Ruby2JS: https://github.com/rubys/ruby2js#description The first paragraph of that description explains what is going on here. Parenthesis are optional in Ruby. Javascript distinguishes between properties and methods. Ruby2JS distinguishes between the two by looking for either parameters being passed or the presence of parenthesis. In other words, what you did might have worked if only you had added '()' to convert the reference to the sort property to an actual function call. By the way, in this case, I probably would have sorted the results on the server. https://github.com/apache/whimsy/tree/master/www/roster/models You can see the results using by adding .json to the end of the link, e.g.: https://whimsy-test.apache.org/roster/committee/whimsy.json That being said, I'm not sure if JavaScript will preserve property order in JSON hashes. --- Why convert Ruby to JS? There is an advantage to coding both the client and server in the same language, hence the popularity of node.js. There also is an advantage to coding at a higher level than what JS provides. Spend a few minutes reviewing the generated JavaScript to see what I mean. You still will need to be aware that the object model available on the client and server are different. As Ruby2JS maps syntax, you can take advantage of the full JavaScript (and DOM) object model. By the way, bring up the roster committer page for yourself in Chrome and then bring up the developer tools. Look at the sources: it will show the original ruby sources. Exception will show the original .js.rb source line. You can set breakpoints, etc. --- I've committed a Rakefile and a tiny readme that will show you how to run this tool locally. And this sets up a listener that will restart the server if you change a source file. --- Where am I going with this? Simply put, React+Bootstrap rocks. The board agenda tool is an example of both being able to update data that is being shown in the browser, and to have interactive dialogs. If you are chair of a committee, you will soon be able to see buttons that will add or remove member and committers of that committee. This will invoke code on the server that will look something like the existing code in the board agenda tool: https://github.com/apache/whimsy/blob/master/www/board/agenda/views/actions/todos.json.rb The code on the server will be able to update LDAP, update SVN, and send emails. So when we get there, we should have lots of interesting discussions as to who should be able to do what actions, what should be updated, and who should be notified when those actions occur. Example: adding a committee member should probably notify board@ and set an effective date of three days from now in committee-info.txt. - Sam Ruby
