• Stars
    star
    104
  • Rank 330,604 (Top 7 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created over 9 years ago
  • Updated over 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

WOOT model for Scala and JavaScript via Scala.js

Build Status

WOOT with Scala.js

  • Collaborative text editing, using the WOOT algorithm.
  • Implemented in Scala, running on both the JVM and a JavaScript interpreter.

For the Impatient

$ sbt server/run

Then open http://127.0.0.1:8080/ to edit a document.

Open another browser at the same address, and you'll get the idea of collaboration.

What is WOOT?

WOOT is a collaborative text editing algorithm, allowing multiple users ("sites") to insert or delete characters (WChar) from a shared document (WString). The algorithm preserves the intention of users, and ensures that the text converges to the same state for all users.

Its key properties are simplicity, and avoiding the need for a reliable network or vector clocks (it can be peer-to-peer).

The key references are:

  • Oster et al. (2005) Real time group editors without Operational transformation, report paper 5580, INRIA - PDF

  • Oster et al. (2006) Data Consistency for P2P Collaborative Editing, CSCW'06 - PDF

WOOT stands for With Out Operational Transforms.

Presentations

I've spoken about this project at Scala Days 2015: there's video and also the slides.

This Project

This project contains a Scala implementation of WOOT. It has been compiled to JavaScript using Scala.js. In other words, this is an example of sharing one implementation (the WOOT model) in both a JavaScript and Scala context.

WOOT is only the algorithm for text consistency. You need to bring your own editor and network layer.

This example includes the ACE editor, which is wired up to the Scala.js implementation of WOOT locally within the browser. Updates are sent over a web socket to a http4s server which also maintains a copy of the model, but on the JVM.

Screen Shot of Editor being Used

Performance

This is a simple implementation that is slow for bulk actions (e.g., paste and cut).

To improve performance you will want to:

  • measure what's slow for your scenarios
  • batch messages between client and server (maybe)
  • optimize the trim, canIntegrate, and indexOf methods.

I may get round to doing this at some point!

What Happens When You Run the Web Server

Running the sever code will likely produce:

$ sbt "project server" run
[info] Loading global plugins from ...
[info] Loading project definition from wootjs/project/project
[info] Loading project definition from wootjs/project
[info] Set current project to woot
[info] Set current project to woot-server
[info] Fast optimizing wootjs/client/target/scala-2.11/woot-client-fastopt.js
[info] Running Main
2015-04-08 13:43:52 [run-main-0] INFO  WootServer - Starting Http4s-blaze WootServer on '0.0.0.0:8080'
...

Notice that the Scala.js compiler has run on the woot-client project, to convert the client Scala code into JavaScript. This JavaScript, woot-client-fastopt.js, is made available on the classpath of the server, so it can be included on the web page. The web page is server/src/main/resources/index.html.

This reflects the structure of the project:

  • client - Scala source code, to be compiled to JavaScript.
  • server - Scala source code to run server-side, plus other assets to be served, such as HTML, CSS and plain old JavaScript.
  • wootModel - Scala source code shared by both the client and server projects. This is the WOOT algorithm, implemented once, used in the JVM and the JavaScript runtime.

Exploring the Code

  1. server/src/main/resources/index.html is the starting point for the client. This folder also contains a trivial websocket JavaScript client (ws.js) and the editor bindings (editor.js).
  2. editor.js creates a local instance of the "woot client" and kicks off the web socket interactions.
  3. client/src/main/scala/client/WootClient.scala is the exposed interface to the WOOT model. This is Scala compiled to JavaScript.
  4. server/src/main/scala/main.scala is the server that accepts and broadcasts WOOT operations to clients.

Tests

The tests for this project are implemented as ScalaCheck properties.

Running the tests in the JVM

sbt> project wootModelJVM
sbt> coverage
sbt> test

Then open wootModel/jvm/target/scala-2.11/scoverage-report/index.html

Publishing Woot Model

It will now be available with

resolvers += "<repo-name>" at "http://dl.bintray.com/content/<repo-name>/maven",
libraryDependencies += "com.dallaway.richard" %%% "woot-model" % "<current-version>",

Reference

Scala.js Learning Path

If you're new to Scala:

  • Creative Scala - a free course from Underscore teaching Scala using drawing primitives backed by Scala.js.

And then...

License

Copyright 2015 Richard Dallaway

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

lift-cookbook

ASCII Doc source for Lift Cookbook
HTML
58
star
2

sloppy

Sloppy deliberately slows the transfer of data between client and server.
Java
33
star
3

enumeration-examples

Demonstrates the pros and cons of scala.Enumeration and examines alternative structures
Scala
18
star
4

aws-lambda-scala-slack

Example Slack integration via Lambda and AWS API Gateway
Scala
15
star
5

liftmodules-imap-idle

Allows Lift apps to receive push-like email.
Scala
13
star
6

liftmodules-googleanalytics

A Lift Module to add Google Analytics Tracking code a web site.
Scala
11
star
7

cloudbees-lift-filter

Scala
8
star
8

slick-upsert

Exampes of Upsert in Slick 3
Scala
5
star
9

aws-gateway-mapping-playground

This project emulates aspects of the mapping environment to make it easier to test templates.
Scala
4
star
10

typechecking-sql

Examples of type-checked SQL
Scala
4
star
11

brightontide

Tide Times for Brighton, UK delivered via Twitter
HTML
3
star
12

skitters-blog

This is our dog's blog
HTML
3
star
13

Think-Stats

Python
3
star
14

jchav

JChav is a way to see the change in performance of your web application over time, by running a benchmark test for each build you produce.
Java
3
star
15

liftmodules-builder

Scala
2
star
16

ensime-atom-example

Simple sbt test project
Scala
2
star
17

seb-arduino-course

Java
2
star
18

crud_percent_s

Example of problem with Crud List in 2.5-SNAPSHOT
Scala
2
star
19

Sussex

Final backup of my Sussex home directory when I finished my DPhil
R
2
star
20

lift-graph-example

Examples using Flot and Google Chart API for adding graphs to a Lift App
Scala
2
star
21

slick-postgresql-stored-proc

Scala
2
star
22

wiring-link-action

Scala
2
star
23

example-webhook

Example apps that make use of the Taykt.com web hooks API
Scala
2
star
24

telepost

IMAP email to Telegr.am format blog post files
Scala
2
star
25

onthehour

The source to @onthehour
Rust
2
star
26

brighton-tide-post

Posts the low tides for Brighton (UK) to Twitter and Mastodon
Scala
2
star
27

plain-in

Using `IN` safely with Slick Plain SQL queries
Scala
1
star
28

skitters-template

Telegr.am template for the dog's blog
JavaScript
1
star
29

lift_basic_2.4-M2_2.8.1_plus_eclipse

Scala
1
star
30

slick-ilike-example

Scala
1
star
31

rust-brighton-embedded-day-4

Rust
1
star
32

list-of-tuples

Scala
1
star
33

basic.g8

Basic Scala Progamming Template
Scala
1
star
34

DNAm

Run existing DNAm models
Rust
1
star
35

london_class_march_2011_sitemap_css

Scala
1
star
36

scala-robot-dev

Robocode Robot Development
Scala
1
star
37

lift_xhtml_checkboxes_question

Scala
1
star
38

io-scripts

Scala
1
star
39

envdump

Java
1
star
40

london_class_march_2011_wiz

Scala
1
star
41

rust-brighton-embedded-day-1

GDB
1
star
42

typelevel-kitchensink

All the typelevel.scala dependcies in one SBT.
Scala
1
star
43

restore-rand

Rust
1
star
44

rust-brighton-embedded-day-3

Rust
1
star
45

rust-brighton-embedded-day-2

Rust
1
star
46

slick-blank

Scala
1
star
47

pg-enum

Scala
1
star
48

london_class_march_2011_json_comet

Scala
1
star
49

mysql-lift-charset-test

Lift app to try to insert UTF-8 data to a MySQL database
Scala
1
star
50

lift-jsoncall

JavaScript
1
star
51

so46199828

Scala
1
star
52

delay_keyup_via_list_rest_wiring

Scala
1
star
53

bbdemo-skillsmatter

The end-of-evening state of the code created during my Skillsmatter presentations 8 Mar 2010
Scala
1
star
54

dl4j-scala-iris

Exploring the DeepLearning4J Iris Exampl
Scala
1
star
55

MatchWithoutCurrentValueExample

Example of using MatchWithoutCurrentValue
Scala
1
star
56

sbt-template

A plain SBT project
Scala
1
star
57

london_class_march_2011_wiring

Scala
1
star
58

shutdown-test

shutdown test
Scala
1
star
59

slickless-hlist-getresult

Using slickless to generate GetResult instances for HLists
Scala
1
star
60

discarded-values

Scala
1
star
61

insert_from_selects

Examples of inserting with a select
Scala
1
star
62

jane-posterous

1
star
63

lift_onclick

Scala
1
star
64

blinky-rtfm

1
star