Skip to content

Commit

Permalink
Merge pull request #4 from ocdtrekkie/master
Browse files Browse the repository at this point in the history
Update with 20140801.1 from audreyt
  • Loading branch information
ocdtrekkie committed Aug 1, 2014
2 parents 661e881 + f6de780 commit 866b5b4
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 27 deletions.
3 changes: 2 additions & 1 deletion README.mkdn
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ or an array of strings), or a plain-text command string.
Runs one or more commands specified in the `command` field.

Also takes a CSV structure that contains fields to be appended to
the first column after the last row.
the first column after the last row. If the `row` query parameter
is given, insert and paste on the specified row instead.

### GET /_/page/cells
Returns a JSON representation of all defined cells in the page.
Expand Down
52 changes: 37 additions & 15 deletions main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion manifest.appcache
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CACHE MANIFEST
# Wed Jul 30 14:27:51 CST 2014
# Fri Aug 1 15:01:55 CST 2014

CACHE:

Expand All @@ -16,6 +16,7 @@ static/jszip.js
static/shim.js
static/xlsx.js
static/xlsxworker.js
static/jquery.js

# pad page
static/ethercalc.js
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ethercalc",
"description": "Multi-User Spreadsheet Server",
"version": "0.20140730.0",
"version": "0.20140801.3",
"homepage": "http://ethercalc.net/",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion package.json.ls
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exec "perl -pi -e 's/# [A-Z].*\\n/# @{[`date`]}/m' manifest.appcache"
name: \ethercalc
description: 'Multi-User Spreadsheet Server'
version: \0.20140730.0
version: \0.20140801.3
homepage: 'http://ethercalc.net/'
repository:
type: 'git'
Expand Down
14 changes: 14 additions & 0 deletions player.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 18 additions & 8 deletions src/main.ls
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,16 @@

@put '/_/:room': ->
@response.type Text
{room} = @params
snapshot <~ request-to-save @request
<~ SC._put @params.room, snapshot
<~ SC._put room, snapshot
<~ DB.del "log-#room"
IO.sockets.in "log-#room" .emit \data { snapshot, type: \snapshot }
@response.send 201 \OK

@post '/_/:room': ->
{room} = @params
return if room is \Kaohsiung-explode-20140801
command <~ request-to-command @request
unless command
@response.type Text
Expand All @@ -145,14 +149,19 @@
if command is /^loadclipboard\s*/
row = 1
row += Number(RegExp.$1) if snapshot is /\nsheet:c:\d+:r:(\d+):/
command := [command, "paste A#row all"]
if parseInt(@query.row)
row = parseInt(@query.row)
command := [command, "insertrow A#row", "paste A#row all"]
else
command := [command, "paste A#row all"]
command := [command] unless Array.isArray command
SC[room]?ExecuteCommand command * \\n
IO.sockets.in "log-#room" .emit \data {
type: \execute
cmdstr: command * \\n
room
}
cmdstr = command * \\n
<~ DB.multi!
.rpush "log-#room" cmdstr
.rpush "audit-#room" cmdstr
.bgsave!.exec!
SC[room]?ExecuteCommand cmdstr
IO.sockets.in "log-#room" .emit \data { cmdstr, room, type: \execute }
@response.json 202 {command}

@post '/_': ->
Expand Down Expand Up @@ -201,6 +210,7 @@
DB.hset "ecell-#room", user, ecell
| \execute
return if auth is \0
return if cmdstr is /^set sheet defaulttextvalueformat text-wiki\s*$/
if KEY and hmac(room) isnt auth
reply { type: \error, message: "Invalid session key. Modifications will not be saved." }
return
Expand Down
9 changes: 9 additions & 0 deletions src/player.ls
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@
ss.context.sheetobj.ScheduleSheetCommands "#cmdstr\n#refreshCmd\n", false, true
else
ss.context.sheetobj.ScheduleSheetCommands "recalc\n", false, true
| \snapshot
vex?closeAll!
SocialCalc.hadSnapshot = true
if @data.snapshot
parts = ss.DecodeSpreadsheetSave @data.snapshot
if parts?sheet
ss.sheet.ResetSheet!
ss.ParseSheetSave @data.snapshot.substring parts.sheet.start, parts.sheet.end
ss.context.sheetobj.ScheduleSheetCommands "recalc\n", false, true
| \recalc
if @data.force
SocialCalc.Formula.SheetCache.sheets = {}
Expand Down

0 comments on commit 866b5b4

Please sign in to comment.