Skip to content

Commit 2e65a03

Browse files
authored
Merge pull request #119 from larsrh/topic/tut
Tut-powered blog
2 parents 7d9a902 + 40f44a5 commit 2e65a03

File tree

54 files changed

+331
-43
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+331
-43
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ Gemfile.lock
66
/vendor/bundle
77
css/main.css
88
.sass-cache
9+
target
10+
_posts
11+
.deploy

.travis.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,34 @@ sudo: false
22
language: ruby
33
rvm: 2.2
44

5+
env:
6+
global:
7+
- secure: "WowDbou7Zejy22YFIxnO0enMSGtxQi++cfp0IKDv/8aK2JVR2FG4TLvLUpW2py0QWfRCyUfNfPxM/Srr4czx580mG5PUrPdYwOR4sk3/VI2SA6FNxteObBp1I0eRopHrXzXFess50ruiLBDVuc+3eM63n2O1gl2VSnW7jKdpL80="
8+
59
install:
610
- bundle install
11+
- curl -s https://raw.githubusercontent.com/paulp/sbt-extras/master/sbt -o sbt
12+
- chmod +x sbt
713

814
script:
15+
- ./sbt run
916
- bundle exec jekyll build
17+
18+
cache:
19+
directories:
20+
- $HOME/.ivy2/cache
21+
- $HOME/.sbt/boot
22+
before_cache:
23+
- find $HOME/.ivy2 -name "ivydata-*.properties" -delete
24+
- find $HOME/.sbt -name "*.lock" -delete
25+
26+
branches:
27+
except:
28+
- master
29+
30+
deploy:
31+
- provider: script
32+
script: ./deploy.sh
33+
skip_cleanup: true
34+
on:
35+
branch: development

_config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ kramdown:
1414
hard_wrap: false
1515
highlighter: rouge
1616
exclude:
17-
["node_modules", "gulpfile.js", "package.json", "README.md", "CNAME", "vendor"]
17+
["node_modules", "gulpfile.js", "package.json", "README.md", "CNAME", "vendor", "src", "project", "build.sbt", "posts"]
1818
permalink: /blog/:year/:month/:day/:title.html
1919
paginate: 10
2020
paginate_path: "/blog/:num/"

build.sbt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
scalaVersion := "2.11.8"
2+
3+
name := "typelevel-blog-tut"
4+
5+
scalacOptions ++= Seq(
6+
"-deprecation",
7+
"-feature"
8+
)
9+
10+
libraryDependencies ++= Seq(
11+
"io.get-coursier" %% "coursier" % "1.0.0-M14",
12+
"io.get-coursier" %% "coursier-cache" % "1.0.0-M14",
13+
"com.chuusai" %% "shapeless" % "2.3.0",
14+
"org.yaml" % "snakeyaml" % "1.17"
15+
)
16+
17+
lazy val tutInput = SettingKey[File]("tutInput")
18+
lazy val tutOutput = SettingKey[File]("tutOutput")
19+
lazy val tutVersion = SettingKey[String]("tutVersion")
20+
21+
tutInput := (baseDirectory in ThisBuild).value / "posts"
22+
tutOutput := (baseDirectory in ThisBuild).value / "_posts"
23+
tutVersion := "0.4.4"
24+
25+
watchSources ++= (tutInput.value ** "*.md").get
26+
27+
enablePlugins(BuildInfoPlugin)
28+
29+
buildInfoKeys := Seq[BuildInfoKey](tutInput, tutOutput, tutVersion)
30+
31+
buildInfoPackage := "org.typelevel.blog"

deploy.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -o pipefail
4+
set -e
5+
6+
GIT_EMAIL="[email protected]"
7+
GIT_NAME="Typelevel Bot"
8+
REMOTE_REPO="https://$GH_TOKEN@github.com/typelevel/typelevel.github.com.git"
9+
BRANCH="master"
10+
11+
if [ -z "$GH_TOKEN" ]; then
12+
echo "No GitHub access token set, not deploying"
13+
exit 1
14+
fi
15+
16+
git config --global user.name "$GIT_NAME"
17+
git config --global user.email "$GIT_EMAIL"
18+
19+
git clone --depth 1 -b "$BRANCH" --no-checkout "$REMOTE_REPO" .deploy
20+
git archive --format=tar "$TRAVIS_COMMIT" | (
21+
cd .deploy
22+
tar xf -
23+
)
24+
25+
cp -r _posts .deploy
26+
27+
cd .deploy
28+
git add -A -f
29+
git commit -m "Update site at $(date --rfc-2822 -u)" --allow-empty
30+
git push

_posts/2016-09-30-subtype-typeclasses.md renamed to posts/2016-09-30-subtype-typeclasses.md

Lines changed: 23 additions & 42 deletions

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version=0.13.12

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.6.1")

src/main/scala/FrontMatter.scala

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package org.typelevel.blog
2+
3+
import coursier._
4+
import coursier.util.Parse
5+
import java.io.File
6+
import java.net.URLClassLoader
7+
8+
case class Tut(scala: String, binaryScala: String, dependencies: List[String]) {
9+
10+
val tutResolution: Resolution = Resolution(Set(
11+
Dependency(Module("org.tpolecat", s"tut-core_$binaryScala"), BuildInfo.tutVersion)
12+
))
13+
14+
val libResolution: Resolution = Resolution(dependencies.map { dep =>
15+
val (mod, v) = Parse.moduleVersion(dep, binaryScala).right.get
16+
Dependency(mod, v)
17+
}.toSet)
18+
19+
def invoke(file: File): Unit = {
20+
val tutClasspath = resolve(tutResolution).get
21+
val libClasspath = resolve(libResolution).get
22+
23+
val classLoader = new URLClassLoader(tutClasspath.map(_.toURI.toURL).toArray, null)
24+
val tutClass = classLoader.loadClass("tut.TutMain")
25+
val tutMain = tutClass.getDeclaredMethod("main", classOf[Array[String]])
26+
27+
val commandLine = Array(
28+
file.toString,
29+
BuildInfo.tutOutput.toString,
30+
".*",
31+
"-classpath",
32+
libClasspath.mkString(File.pathSeparator)
33+
)
34+
35+
tutMain.invoke(null, commandLine)
36+
}
37+
}
38+
39+
case class FrontMatter(tut: Tut)

src/main/scala/Main.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.typelevel.blog
2+
3+
import org.yaml.snakeyaml.Yaml
4+
5+
object Main extends App {
6+
7+
val posts = BuildInfo.tutInput.listFiles().toList.filter { file =>
8+
file.isFile() && file.getName.endsWith(".md")
9+
}.map(Post(_))
10+
11+
posts.foreach(_.process())
12+
13+
}

0 commit comments

Comments
 (0)