<commit_before># Ping-Play

The ping-play project brings [BigPipe](https://www.facebook.com/note.php?note_id=389414033919) style streaming to 
[Play Framework](http://playframework.com/) applications. It includes tools for splitting your pages up into small
"pagelets" and support for streaming those pagelets down to the browser as soon as they are ready, which can 
significantly reduce page load time.

# Quick start

*Pre-requisite: this project requires Play 2.4, Scala 2.11.6, and Java 8.*

To add BigPipe streaming to your own pages, first, add the big-pipe dependency to your build:

```scala
libraryDependencies += "com.ybrikman.ping" %% "big-pipe" % "0.0.9"
```

Next, add support for the `.scala.stream` template type and some imports for it to your build:

```scala
TwirlKeys.templateFormats ++= Map("stream" -> "com.ybrikman.ping.scalaapi.bigpipe.HtmlStreamFormat"),
TwirlKeys.templateImports ++= Vector("com.ybrikman.ping.scalaapi.bigpipe.HtmlStream")
```

Now you can create streaming templates. These templates can mix normal HTML markup, which will be streamed to the 
browser immediately, with the `HtmlStream` class, which is a wrapper for an `Enumerator[Html]` that will be streamed
to the browser whenever the `Enumerator` has data. 

For example, here is a streaming template called `app/views/bigPipeExample.scala.stream`:

```html
@(body: HtmlStream)

<html>
  <head>
    <script src="@routes.Assets.versioned("com/ybrikman/ping/big-pipe.js")"></script>
  </head>
  <body><commit_msg>Updating version number in README.md to 0.0.10<commit_after># Ping-Play

The ping-play project brings [BigPipe](https://www.facebook.com/note.php?note_id=389414033919) style streaming to 
[Play Framework](http://playframework.com/) applications. It includes tools for splitting your pages up into small
"pagelets" and support for streaming those pagelets down to the browser as soon as they are ready, which can 
significantly reduce page load time.

# Quick start

*Pre-requisite: this project requires Play 2.4, Scala 2.11.6, and Java 8.*

To add BigPipe streaming to your own pages, first, add the big-pipe dependency to your build:

```scala
libraryDependencies += "com.ybrikman.ping" %% "big-pipe" % "0.0.10"
```

Next, add support for the `.scala.stream` template type and some imports for it to your build:

```scala
TwirlKeys.templateFormats ++= Map("stream" -> "com.ybrikman.ping.scalaapi.bigpipe.HtmlStreamFormat"),
TwirlKeys.templateImports ++= Vector("com.ybrikman.ping.scalaapi.bigpipe.HtmlStream")
```

Now you can create streaming templates. These templates can mix normal HTML markup, which will be streamed to the 
browser immediately, with the `HtmlStream` class, which is a wrapper for an `Enumerator[Html]` that will be streamed
to the browser whenever the `Enumerator` has data. 

For example, here is a streaming template called `app/views/bigPipeExample.scala.stream`:

```html
@(body: HtmlStream)

<html>
  <head>
    <script src="@routes.Assets.versioned("com/ybrikman/ping/big-pipe.js")"></script>
  </head>
  <body>
{'fraction_non_alphanumeric': 0.11245901639344262, 'fraction_numerical': 0.016065573770491802, 'mean_word_length': 4.912790697674419, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1230239', 'n_tokens_mistral': 993, 'n_tokens_neox': 931, 'n_words': 335}