Skip to content

Commit

Permalink
Convert to Tut (#131)
Browse files Browse the repository at this point in the history
* WIP convert to tut

* WIP on #122

* Update to use wrapping like Shapeless book

* Comment control to turn on/off para indent

* Smoothing flow between sections

* Downgrade to fix Future appering as List()

* Complete conversion of chapter 2.

* Port chap 3 to tut

* Correct typos, Fixes #119

* Port Chapter 4 to tut

* Use loose lists

* Convert chaopter 5 to tut

* Correct typo; Fixes #120

* Remove un-needed continuation char

* Port 2nd half of Chap 5 to tut

* Remove another continuation char

* Port chapter 6 to tut

* Port chapter 7 to tut

* Remove Play appendix

* Silence //import messages

* Convert chapter 1 exercises to Tut fixed #123

* Port chater 2 exercises to Tut, Fixes #124

* Port chapter 3 exercises to tut (and fix up typos)

* Port chapter 4 exercises to Tut

* Port Chapter 5 exercises to Tut and move them to the end of chqpter

* Port joins chapter exercises to Tut

* Port chapter 7 exercises to tut

* Updated diagrams to match text

* Mention tut

* Thank the Slick team!

* Lightbend the links

* Use Slick 3.1.1

* Add commands for html and epub

* Remove continuation char; bump template; note open source ext

* Dave fixed all the problems

* Remove note that we intro combinators. We do that in chatper 4 now

* Fix output by running an action we said we ran

* Improve example output

* Fix language and formatting for chapter 5

* Fix incorrect link to section

* Fix typos and formatting

* Fix english and formatting

* Fix formatting

* IMprove description of Umderscore

* JDK 8 or later

* plain sql queries

* add space around subsection numbering in TOC

* typo sit's -> it's

* removed scala error fixed in slick 3.1 and scala 2.12.1

* debounce there, correct word order for rest

* moved sentence up a para, replace to with via

* Paran hell

* removed blank line

* sbt files
  • Loading branch information
d6y authored Feb 9, 2017
1 parent c9774b5 commit f764fb1
Show file tree
Hide file tree
Showing 41 changed files with 3,755 additions and 2,730 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ Thumbs.db
npm-debug.log

*.sublime-workspace

target
project/project
project/target
7 changes: 6 additions & 1 deletion Gruntfile.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@
ebook = require 'underscore-ebook-template'

module.exports = (grunt) ->
ebook(grunt)
ebook(grunt, {
dir: {
page : "target/pages",
template : "src/templates"
}
})
return
51 changes: 23 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,47 @@ Essential Slick
Getting Started
---------------

You'll need to install the grunt project dependencies the first time you check the project out:
You need to have installed docker. Then...

~~~
brew install pandoc
npm install -g grunt-cli
npm install
$ ./go.sh
$ npm install
$ sbt
sbt> pdf
~~~

To avoid running out of MetaSpace you'll also maybe want to:

```
export JAVA_OPTS="-Xmx3g -XX:+TieredCompilation -XX:ReservedCodeCacheSize=256m -XX:+UseNUMA -XX:+UseParallelGC -XX:+CMSClassUnloadingEnabled"
```

For upgrading:

~~~
rm -rf node_modules
npm install
~~~

Building
--------
Writing
-------

Use the following commands to build a single format:
The source files are in _src/pages_. Scala blocks are executed by tut when marked as:

~~~
grunt pdf
grunt html
grunt epub
~~~
```tut:book
your code here
```

All targets are placed in the `dist` directory.
Note:

Run the following to build all formats, start a web server to serve them all,
and rebuild if you change any files:
- no space before tut in the code block
- `~~~tut` isn't recognized by tut

~~~
grunt watch
~~~
For each chapter you'll need to update _src/main/rsources/application.conf_ to include the chapter database configuration.

Use the following to build all a ZIP of all formats:
The tut converted sources are output to _target/pages_.

~~~
grunt zip
~~~

The default grunt behaviour is to run `zip`:

~~~
grunt
~~~
The `dist` directory contains the PDF etc.

Publishing a Preview
--------------------
Expand Down
38 changes: 38 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
lazy val root = project.in(file("."))
.settings(tutSettings)

tutSourceDirectory := sourceDirectory.value / "pages"

tutTargetDirectory := target.value / "pages"

scalaVersion := "2.11.7"

scalacOptions ++= Seq(
"-deprecation",
"-encoding", "UTF-8",
"-unchecked",
"-feature",
"-Ywarn-dead-code",
"-Xlint",
"-Xfatal-warnings"
)

libraryDependencies ++= Seq(
"com.typesafe.slick" %% "slick" % "3.1.1",
"com.typesafe.slick" %% "slick-hikaricp" % "3.1.1",
"com.h2database" % "h2" % "1.4.185",
"ch.qos.logback" % "logback-classic" % "1.1.2",
"joda-time" % "joda-time" % "2.6",
"org.joda" % "joda-convert" % "1.2"
)

lazy val pdf = taskKey[Unit]("Builds the PDF version of the book")
lazy val html = taskKey[Unit]("Build the HTML version of the book")
lazy val epub = taskKey[Unit]("Build the ePub version of the book")
lazy val all = taskKey[Unit]("Build all versions of the book")

pdf := { tutQuick.value ; "grunt pdf" ! }
html := { tutQuick.value ; "grunt html" ! }
epub := { tutQuick.value ; "grunt epub" ! }
all := { pdf ; html ; epub }

7 changes: 7 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: '2'
services:
book:
image: underscoreio/book:latest
volumes:
- .:/source
- ~/.ivy2:/root/.ivy2
14 changes: 8 additions & 6 deletions etc/left-outer.graffle
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@
<key>Pad</key>
<integer>8</integer>
<key>Text</key>
<string>{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
<string>{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf760
\cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural

\f0\fs26 \cf0 Messages}</string>
Expand Down Expand Up @@ -166,12 +167,13 @@
<key>Pad</key>
<integer>8</integer>
<key>Text</key>
<string>{\rtf1\ansi\ansicpg1252\cocoartf1347\cocoasubrtf570
<string>{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf760
\cocoascreenfonts1{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\qc

\f0\fs26 \cf0 Users}</string>
\f0\fs26 \cf0 Rooms}</string>
<key>VerticalPad</key>
<integer>10</integer>
</dict>
Expand Down Expand Up @@ -336,7 +338,7 @@
<key>MasterSheets</key>
<array/>
<key>ModificationDate</key>
<string>2015-04-28 11:07:53 +0000</string>
<string>2017-01-16 22:49:48 +0000</string>
<key>Modifier</key>
<string>Richard Dallaway</string>
<key>NotesVisible</key>
Expand Down Expand Up @@ -417,7 +419,7 @@
</dict>
</array>
<key>Frame</key>
<string>{{1065, 181}, {1498, 951}}</string>
<string>{{178, 0}, {718, 877}}</string>
<key>ListView</key>
<true/>
<key>OutlineWidth</key>
Expand All @@ -431,7 +433,7 @@
<key>SidebarWidth</key>
<integer>120</integer>
<key>VisibleRegion</key>
<string>{{-402, -13}, {1363, 809}}</string>
<string>{{-12, 0}, {583, 735}}</string>
<key>Zoom</key>
<real>1</real>
<key>ZoomValues</key>
Expand Down
Binary file modified etc/schema.graffle
Binary file not shown.
2 changes: 2 additions & 0 deletions go.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env bash
docker-compose run book bash
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
"description": "The essential guide to Slick",
"version": "0.3.0",
"devDependencies": {
"underscore-ebook-template": "git+https://github.com/underscoreio/underscore-ebook-template.git#0.0.18"
"bootstrap" : "3.3.1",
"coffeeify" : "1.0.0",
"jquery" : "2.1.1",
"uglifyify" : "2.6.0",
"underscore" : "1.7.0",
"underscore-ebook-template" : "git+https://github.com/underscoreio/underscore-ebook-template.git#0.2.2"
},
"scripts": {
"test": "echo \"Error: no test specificed\" && exit 1"
Expand Down
1 change: 1 addition & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sbt.version=0.13.13
2 changes: 2 additions & 0 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.7")

Binary file modified src/img/Schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/img/left-outer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions src/main/resources/application.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
chapter01 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter01"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter02 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter02"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter03 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter03"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter04 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter04"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter05 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter05"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter06 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter06"
driver = "org.h2.Driver"
keepAliveConnection = true
}

chapter07 = {
connectionPool = disabled
url = "jdbc:h2:mem:chapter07"
driver = "org.h2.Driver"
keepAliveConnection = true
}

tsql {
driver = "slick.driver.H2Driver$"
db {
connectionPool = disabled
driver = "org.h2.Driver"
url = "jdbc:h2:mem:chapter07tsql;INIT=runscript from 'src/main/resources/integration-schema.sql'"
keepAliveConnection = false
}
}

1 change: 1 addition & 0 deletions src/main/resources/integration-schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
create table "message" ("content" VARCHAR NOT NULL,"id" BIGSERIAL NOT NULL PRIMARY KEY);
17 changes: 17 additions & 0 deletions src/main/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>

<logger name="slick" level="INFO"/>
<logger name="slick.ast" level="INFO"/>
<logger name="slick.compiler" level="INFO"/>
<logger name="slick.jdbc.JdbcBackend.statement" level="INFO"/>
<logger name="slick.jdbc.StatementInvoker.result" level="INFO"/>

<root level="info">
<appender-ref ref="STDOUT" />
</root>
</configuration>
41 changes: 20 additions & 21 deletions src/meta/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,27 @@ filenameStem: "essential-slick-3"
# Used by Pandoc to generate the PDF cover...
# see src/css/book.less for HTML/ePub covers:
coverColor: "F58B40"
copyright: "2015"
copyright: "2017"
tocDepth: 3
pages:
- src/pages/0-preface.md
- src/pages/1-basics.md
- src/pages/2-selecting.md
- src/pages/3-modifying.md
- src/pages/4-combining-actions.md
- src/pages/5-data_modelling.md
- src/pages/6-joins.md
- src/pages/7-plain_sql.md
- src/pages/links.md
- src/pages/start-of-appendix.md
- src/pages/8-databases.md
- src/pages/9-play-slick.md
- src/pages/solutions.md
- 0-preface.md
- 1-basics.md
- 2-selecting.md
- 3-modifying.md
- 4-combining-actions.md
- 5-data_modelling.md
- 6-joins.md
- 7-plain_sql.md
- links.md
- start-of-appendix.md
- 8-databases.md
- solutions.md
previewPages:
- src/pages/0-preface.md
- src/pages/1-basics.md
- src/pages/2-selecting.md
- src/pages/end-of-preview.md
- src/pages/links.md
- src/pages/start-of-appendix.md
- src/pages/solutions.md
- 0-preface.md
- 1-basics.md
- 2-selecting.md
- end-of-preview.md
- links.md
- start-of-appendix.md
- solutions.md
...
6 changes: 4 additions & 2 deletions src/meta/pdf.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
---
papersize: "a4paper"
papersize: "a5paper"
fontsize: "8pt"
geometry: "margin=.75in"
...
documentclass: "book"
...
Loading

0 comments on commit f764fb1

Please sign in to comment.