Permalink
Browse files

* Initial commit for Stackato Sample App Contest.

  • Loading branch information...
audreyt committed Aug 20, 2011
0 parents commit a94b5569be275849ec13244078b438e51a733534
Showing with 29,281 additions and 0 deletions.
  1. +685 −0 Changes.txt
  2. +72 −0 LEGAL.txt
  3. +705 −0 LICENSE.txt
  4. +32 −0 README
  5. +189 −0 app.coffee
  6. +295 −0 app.js
  7. +950 −0 formatnumber2.js
  8. +4,749 −0 formula1.js
  9. BIN images/sc-1x1.gif
  10. BIN images/sc-aligncenter.gif
  11. BIN images/sc-alignleft.gif
  12. BIN images/sc-alignright.gif
  13. BIN images/sc-bordersoff.gif
  14. BIN images/sc-borderson.gif
  15. BIN images/sc-chooserarrow.gif
  16. BIN images/sc-commentbg.gif
  17. BIN images/sc-copy.gif
  18. BIN images/sc-cursorinsertleft.gif
  19. BIN images/sc-cursorinsertup.gif
  20. BIN images/sc-cut.gif
  21. BIN images/sc-defaultcolor.gif
  22. BIN images/sc-delete.gif
  23. BIN images/sc-deletecol.gif
  24. BIN images/sc-deleterow.gif
  25. BIN images/sc-divider1.gif
  26. BIN images/sc-drag-handles.gif
  27. BIN images/sc-drag-handles.png
  28. BIN images/sc-endcap-h.gif
  29. BIN images/sc-endcap-v.gif
  30. BIN images/sc-filldown.gif
  31. BIN images/sc-fillright.gif
  32. BIN images/sc-formuladialog.gif
  33. BIN images/sc-insertcol.gif
  34. BIN images/sc-insertrow.gif
  35. BIN images/sc-less-hd.gif
  36. BIN images/sc-less-hh.gif
  37. BIN images/sc-less-hn.gif
  38. BIN images/sc-less-vd.gif
  39. BIN images/sc-less-vh.gif
  40. BIN images/sc-less-vn.gif
  41. BIN images/sc-linkdialog.gif
  42. BIN images/sc-linkout.gif
  43. BIN images/sc-logo.gif
  44. BIN images/sc-main-h.gif
  45. BIN images/sc-main-v.gif
  46. BIN images/sc-merge.gif
  47. BIN images/sc-more-hd.gif
  48. BIN images/sc-more-hh.gif
  49. BIN images/sc-more-hn.gif
  50. BIN images/sc-more-vd.gif
  51. BIN images/sc-more-vh.gif
  52. BIN images/sc-more-vn.gif
  53. BIN images/sc-movefrom.gif
  54. BIN images/sc-movefromoff.gif
  55. BIN images/sc-moveinsert.gif
  56. BIN images/sc-moveinsertoff.gif
  57. BIN images/sc-movepaste.gif
  58. BIN images/sc-movepasteoff.gif
  59. BIN images/sc-multilinedialog.gif
  60. BIN images/sc-paneslider-h.gif
  61. BIN images/sc-paneslider-v.gif
  62. BIN images/sc-paste.gif
  63. BIN images/sc-pasteformats.gif
  64. BIN images/sc-peerbg.gif
  65. BIN images/sc-range2.gif
  66. BIN images/sc-recalc.gif
  67. BIN images/sc-redo.gif
  68. BIN images/sc-scrollarea-h.gif
  69. BIN images/sc-scrollarea-v.gif
  70. BIN images/sc-sumdialog.gif
  71. BIN images/sc-swapcolors.gif
  72. BIN images/sc-thumb-hd.gif
  73. BIN images/sc-thumb-hh.gif
  74. BIN images/sc-thumb-hn.gif
  75. BIN images/sc-thumb-vd.gif
  76. BIN images/sc-thumb-vh.gif
  77. BIN images/sc-thumb-vn.gif
  78. BIN images/sc-trackingline-h.gif
  79. BIN images/sc-trackingline-v.gif
  80. BIN images/sc-undo.gif
  81. BIN images/sc-unmerge.gif
  82. BIN images/sc-wikiflag.gif
  83. BIN images/sc-wikilinkflag.gif
  84. +20 −0 index.css
  85. +366 −0 index.mt
  86. +9 −0 package.json
  87. +1 −0 requirements.txt
  88. +5,804 −0 socialcalc-3.js
  89. +62 −0 socialcalc.css
  90. +818 −0 socialcalcconstants.js
  91. +1,618 −0 socialcalcpopup.js
  92. +685 −0 socialcalcserver.pl
  93. +3,585 −0 socialcalcspreadsheetcontrol.js
  94. +6,404 −0 socialcalctableeditor.js
  95. +687 −0 socialcalcviewer.js
  96. +80 −0 socketpolicy.pl
  97. +122 −0 start.css
  98. BIN static/img/davy/bg/home2.png
  99. BIN static/img/davy/bg/product.png
  100. BIN static/img/davy/btn/createpad-home.gif
  101. BIN static/img/davy/gfx/home-logo2.gif
  102. BIN static/img/davy/gfx/home-logo2.png
  103. BIN static/img/davy/gfx/screenshot.png
  104. +191 −0 third-party/class-js/README
  105. +117 −0 third-party/class-js/lib/Class.js
  106. +521 −0 third-party/wikiwyg/LICENSE
  107. +22 −0 third-party/wikiwyg/lib/Document/Emitter.js
  108. +23 −0 third-party/wikiwyg/lib/Document/Emitter/ByteCode.js
  109. +92 −0 third-party/wikiwyg/lib/Document/Emitter/HTML.js
  110. +175 −0 third-party/wikiwyg/lib/Document/Parser.js
  111. +202 −0 third-party/wikiwyg/lib/Document/Parser/Wikitext.js

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,72 @@
+SOCIALCALC LEGAL.txt FILE:
+
+LEGAL INFORMATION
+
+This LEGAL.txt file accompanies the SocialCalc program. It includes notices required by the
+licenses as well as general legal notices.
+
+=========================================
+ COPYRIGHT AND ATTRIBUTION NOTICES
+=========================================
+
+Copyright (C) 2009 Socialtext, Inc.
+All Rights Reserved.
+
+image:sc-logo.gif
+"SocialCalc"
+http://www.socialcalc.org/xoattrib
+
+=========================================
+ SOURCE CODE AVAILABILITY NOTICE
+=========================================
+
+The source code for this product is available from:
+http://socialcalc.org/.
+
+=========================================
+ GENERAL LEGAL NOTICES
+=========================================
+
+wikiCalc, Garden, and Software Garden are registered trademarks of Software Garden, Inc.
+Socialtext and SocialCalc are registered trademarks of Socialtext, Inc.
+The Socialtext logo and Dreamcatcher are trademarks of Socialtext, Inc.
+
+=========================================
+ LEGAL NOTICES REQUIRED BY THE LICENSE
+=========================================
+
+CHANGES MADE TO THE COVERED CODE (see CPAL Version 1.0 Section 3.3):
+
+2008-02-08:
+ Original Code started as a translation to JavaScript of code in SocialCalc 1.1.0 plus
+ much new code.
+
+ Python code for the OLPC XO-1 initially coded by Luke Closs of Socialtext, Inc.
+
+ JavaScript initially coded by Dan Bricklin of Software Garden, Inc., for Socialtext, Inc.
+ Based in part on the SocialCalc 1.1.0 code written in Perl.
+ The SocialCalc 1.1.0 code was:
+ Portions (c) Copyright 2005, 2006, 2007 Software Garden, Inc.
+ All Rights Reserved.
+ Portions (c) Copyright 2007 Socialtext, Inc.
+ All Rights Reserved.
+ The Perl SocialCalc started as modifications to the wikiCalc(R) program, version 1.0.
+ wikiCalc 1.0 was written by Software Garden, Inc.
+ Unless otherwise specified, referring to "SocialCalc" in comments refers to this
+ JavaScript version of the code, not the SocialCalc Perl code.
+
+----------
+
+(Documentation of future changes as the result of Modifications, including the date of
+change, will go here in this LEGAL.txt file. This documentation may be summaries of
+changes with the more detailed descriptions included in the actual modified files as
+appropriate.)
+
+==========
+
+THIRD PARTY CLAIMS (see CPAL Version 1.0 Section 3.4(a)):
+
+None.
+
+[End of LEGAL.txt]
+

Large diffs are not rendered by default.

Oops, something went wrong.
32 README
@@ -0,0 +1,32 @@
+ -=[MeetingCalc]=-
+
+ Language: CoffeeScript
+ Runtime: Node.js
+ Services: Redis
+ Browsers currently tested: Safari & Firefox.
+
+ .oO( Setup Instructions )Oo.
+
+ $ stackato push meetingcalc
+ Would you like to deploy from the current directory ? [Yn]:
+ Application Deployed URL: 'meetingcalc.stackato.local'?
+ Detected a Node.js Application, is this correct ? [Yn]:
+ Memory Reservation ? (64M, 128M, 256M, 512M, 1G, or 2G):
+ Would you like to bind any services to 'meetingcalc' ? [yN]: y
+ The following system services are available
+ 1. mongodb
+ 2. mysql
+ 3. postgresql
+ 4. redis
+ 5. <None of the above>
+ Please select one you wish to provision: 4
+ Specify the name of the service [redis-dd80a]:
+ Creating Service: OK
+ Binding Service: OK
+ Uploading Application:
+ Checking for available resources: OK
+ Processing resources: OK
+ Packing application: OK
+ Uploading (12K): 98% OK
+ Push Status: OK
+ Staging Application: OK
@@ -0,0 +1,189 @@
+port = Number(process.env.VCAP_APP_PORT || 3000)
+host = process.env.VCAP_APP_HOST || '127.0.0.1'
+redisPort = null
+redisHost = null
+redisPass = null
+
+services = JSON.parse(process.env.VCAP_SERVICES || "{}")
+for name, items of services
+ continue unless /^redis/.test(name)
+ if items && items.length
+ redisPort = items[0].credentials.port
+ redisHost = items[0].credentials.hostname
+ redisPass = items[0].credentials.password
+
+db = require('redis').createClient(redisPort, redisHost)
+db.auth(redisPass) if redisPass
+
+require('zappa') port, host, {db}, ->
+ enable 'serve jquery'
+ app.use express.static __dirname
+
+ def {db}
+
+ get '/': ->
+ response.contentType 'text/html'
+ response.sendfile 'index.mt'
+
+ get '/edit': ->
+ response.contentType 'text/html'
+ response.sendfile 'index.mt'
+
+ get '/start': -> render 'start'
+ get '/new': ->
+ response.redirect require("uuid-pure").newId(10)
+
+ view room: ->
+ coffeescript ->
+ window.location = '/#' + window.location.pathname.replace(/.*\//, '')
+
+ view start: ->
+ div id:"topnav_wrap", -> div id:"navigation"
+ div id:"intro-left", ->
+ h1 "MeetingCalc"
+ h2 "MeetingCalc is a web spreadsheet."
+ p "Your data is saved on the web, and people can edit the same document at the same time. Everybody's changes are instantly reflected on all screens."
+ p "Work together on inventories, survey forms, list managements, brainstorming sessions and more!"
+ div id:"intro-links", ->
+ a id:"newpadbutton", href:"/new", ->
+ span "Create new pad"
+ small "No sign-up, start editing instantly"
+
+ view layout: ->
+ html ->
+ head ->
+ title "MeetingCalc"
+ link href:"/start.css", rel:"stylesheet", type:"text/css"
+ body id:"framedpagebody", class:"home", ->
+ div id:"top", -> @body
+
+ at broadcast: ->
+ #io.sockets.in(@room).emit 'broadcast', @
+ switch @type
+ when 'chat'
+ db.rpush "chat-#{@room}", @msg, =>
+ io.sockets.emit 'chat', @
+ return
+ when 'ask.ecells'
+ db.hgetall "ecell-#{@room}", (err, values) =>
+ io.sockets.emit 'broadcast',
+ type: 'ecells'
+ ecells: values
+ room: @room
+ return
+ when 'my.ecell'
+ db.hset "ecell-#{@room}", @user, @ecell
+ return
+ when 'execute'
+ db.rpush "log-#{@room}", @cmdstr, =>
+ io.sockets.emit 'broadcast', @
+ return
+ when 'ask.snapshot'
+ db.lrange "log-#{@room}", 0, -1, (err, log) =>
+ db.lrange "chat-#{@room}", 0, -1, (err, chat) =>
+ io.sockets.emit 'broadcast',
+ type: 'log'
+ to: @user
+ room: @room
+ log: log
+ chat: chat
+ return
+ io.sockets.emit 'broadcast', @
+
+ client '/player.js': ->
+ SocialCalc ?= {}
+ SocialCalc._username = Math.random().toString()
+ SocialCalc.isConnected = true
+ SocialCalc.hadSnapshot = false
+ SocialCalc._room = window.location.hash.replace('#', '')
+ unless SocialCalc._room
+ window.location = '/start'
+ return
+
+ connect()
+ #subscribe(SocialCalc._room)
+
+ SocialCalc.Callbacks.broadcast = (type, data={}) ->
+ return unless SocialCalc.isConnected
+ data.user = SocialCalc._username
+ data.room = SocialCalc._room
+ data.type = type
+ emit 'broadcast', data
+
+ SocialCalc.isConnected = true
+ SocialCalc.Callbacks.broadcast "ask.snapshot"
+
+ at broadcast: ->
+ return unless SocialCalc?.isConnected
+ return if @user == SocialCalc._username
+ return if @to and @to != SocialCalc._username
+ return if @room and @room != SocialCalc._room
+
+ editor = SocialCalc.CurrentSpreadsheetControlObject.editor
+ switch @type
+ when "chat"
+ window.addmsg @msg
+ when "ecells"
+ for user, ecell of @ecells
+ continue if user == SocialCalc._username
+ peerClass = " " + user + " defaultPeer"
+ find = new RegExp(peerClass, "g")
+ cr = SocialCalc.coordToCr(ecell)
+ cell = SocialCalc.GetEditorCellElement(editor, cr.row, cr.col)
+ cell.element.className += peerClass if cell.element.className.search(find) == -1
+ break
+ when "ecell"
+ peerClass = " " + @user + " defaultPeer"
+ find = new RegExp(peerClass, "g")
+ if @original
+ origCR = SocialCalc.coordToCr(@original)
+ origCell = SocialCalc.GetEditorCellElement(editor, origCR.row, origCR.col)
+ origCell.element.className = origCell.element.className.replace(find, "")
+ cr = SocialCalc.coordToCr(@ecell)
+ cell = SocialCalc.GetEditorCellElement(editor, cr.row, cr.col)
+ cell.element.className += peerClass if cell.element.className.search(find) == -1
+ when "ask.snapshot"
+ SocialCalc.Callbacks.broadcast "snapshot",
+ to: @user
+ snapshot: SocialCalc.CurrentSpreadsheetControlObject.CreateSpreadsheetSave()
+ when "ask.ecell"
+ SocialCalc.Callbacks.broadcast "ecell",
+ to: @user
+ ecell: editor.ecell.coord
+ break
+ when "log"
+ break if SocialCalc.hadSnapshot
+ SocialCalc.hadSnapshot = true
+ spreadsheet = SocialCalc.CurrentSpreadsheetControlObject
+ window.addmsg @chat.join("\n"), true
+ cmdstr = @log.join("\n")
+ SocialCalc.CurrentSpreadsheetControlObject.context.sheetobj.ScheduleSheetCommands cmdstr, false, true
+ editor = SocialCalc.CurrentSpreadsheetControlObject.editor
+# editor.MoveECellCallback.broadcast = (e) ->
+# SocialCalc.Callbacks.broadcast "my.ecell"
+# ecell: e.ecell.coord
+ when "snapshot"
+ break if SocialCalc.hadSnapshot
+ SocialCalc.hadSnapshot = true
+ spreadsheet = SocialCalc.CurrentSpreadsheetControlObject
+ parts = spreadsheet.DecodeSpreadsheetSave(@snapshot)
+ if parts
+ if parts.sheet
+ spreadsheet.sheet.ResetSheet()
+ spreadsheet.ParseSheetSave @snapshot.substring(parts.sheet.start, parts.sheet.end)
+ spreadsheet.editor.LoadEditorSettings @snapshot.substring(parts.edit.start, parts.edit.end) if parts.edit
+ if spreadsheet.editor.context.sheetobj.attribs.recalc == "off"
+ spreadsheet.ExecuteCommand "redisplay", ""
+ spreadsheet.ExecuteCommand "set sheet defaulttextvalueformat text-wiki"
+ else
+ spreadsheet.ExecuteCommand "recalc", ""
+ spreadsheet.ExecuteCommand "set sheet defaulttextvalueformat text-wiki"
+ break
+ when "execute"
+ SocialCalc.CurrentSpreadsheetControlObject.context.sheetobj.ScheduleSheetCommands @cmdstr, @saveundo, true
+ break
+
+ get '/:room': ->
+ @layout = no
+ render 'room', @
+
Oops, something went wrong.

0 comments on commit a94b556

Please sign in to comment.