Skip to content

Commit

Permalink
Merge pull request #13 from 47deg/jp-fixes-config-yml-site-adds-multi…
Browse files Browse the repository at this point in the history
…-task

JP - Creates new makeMicrosite task
  • Loading branch information
juanpedromoreno authored Sep 12, 2016
2 parents 1af74da + 91711bf commit 75b9ea7
Show file tree
Hide file tree
Showing 19 changed files with 672 additions and 387 deletions.
2 changes: 2 additions & 0 deletions .scalafmt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--style defaultWithAlign
--maxColumn 100
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright 2016 47 Degrees, LLC. <http://www.47deg.com>

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.
41 changes: 18 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

## Prerequisites

* [Jekyll](https://jekyllrb.com/):
* Install [Jekyll](https://jekyllrb.com/), locally, depending on your platform, you might do this with:

```bash
yum install jekyll

apt-get install jekyll

gem install jekyll
```

## Install:
## Install

Add plugin in `project/plugins.sbt`:
```
Expand All @@ -20,30 +24,23 @@ Enable the plugin in `build.sbt`:
enablePlugins(MicrositesPlugin)
```

## Create the microsite
## Build the microsite

Write markdown documents called `index.md` in `src/tut` like [this one](https://gist.github.com/rafaparadela/9ccfcf1f52c5282c9a5e894b0ddf6508).
Once you have written down your documents you can build the microste running this sbt task:

Create microsite
```
sbt> microsite
sbt> makeMicrosite
```

Compile:
Internally, sequentially it'll run other tasks, among theirs, [`tut`](https://github.com/tpolecat/tut) and `makeSite` ([sbt-site](https://github.com/sbt/sbt-site)) tasks.

```
sbt> tut
```
## View the microsite in your browser

Make site:
```
sbt> makeSite
```
1. In a shell, navigate to the generated site directory in `target/site`

Preview site:
```
sbt> previewSite
```
2. Start jekyll with `jekyll serve`

3. Navigate to http://localhost:4000/yourbase_url/ in your browser, where `yourbase_url` depends on your own preferences (see `micrositeBaseUrl` setting).

## Microsite settings

Expand All @@ -69,7 +66,7 @@ micrositeDocumentationUrl := "/docs.html"

- The author of the microsite is taken from the sbt setting `organizationName`, but you can override it:
```
micrositeAuthor := "Rafa Paradela"
micrositeAuthor := "47 Degrees"
```

- The homepage of the microsite is taken from the sbt setting `homepage`, but you can override it:
Expand Down Expand Up @@ -99,9 +96,9 @@ micrositeImgDirectory := (resourceDirectory in Compile).value / "site" / "images
micrositeImgDirectory := (resourceDirectory in Compile).value / "site" / "styles"
```

- `micrositeExtratMdFiles` setting could be handy if you want to include additional markdown files in your site, and these files are not located in the same place of your `tut` directory. By default, the setting is set up as a empty list. You could override it, in this way:
- `micrositeExtratMdFiles` setting could be handy if you want to include additional markdown files in your site, and these files are not located in the same place of your `tut` directory. By default, the setting is set up as a empty map. You could override it, in this way:
```
micrositeExtratMdFiles := Seq(file("CONTRIBUTING.md"))
micrositeExtratMdFiles := Map(file("README.md") -> "index.md", file("CONTRIBUTING.md") -> "contributing.md")
```

- Style uses essentially 8 colors which palette can be set through the setting `micrositePalette` as below:
Expand All @@ -117,7 +114,5 @@ micrositePalette := Map(
"white-color" -> "#FFFFFF")
```

## Images



38 changes: 28 additions & 10 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
organization := "com.fortysevendeg"
name := "sbt-microsites"
version := "1.0.1-SNAPSHOT"
sbtPlugin := true
import sbt.Keys._
import de.heikoseeberger.sbtheader.license.Apache2_0

lazy val main = (project in file("."))
lazy val artifactSettings = Seq(
name := "sbt-microsites",
organization := "com.fortysevendeg",
organizationName := "47 Degrees",
organizationHomepage := Some(new URL("http://47deg.com")),
headers := Map(
"scala" -> Apache2_0("2016", "47 Degrees, LLC. <http://www.47deg.com>")
)
)

lazy val commonSettings = Seq(
sbtPlugin := true,
scalaVersion in ThisBuild := "2.10.6",
resolvers += Resolver.sonatypeRepo("releases"),
libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.6.0",
scalafmtConfig in ThisBuild := Some(file(".scalafmt"))
) ++ reformatOnCompileSettings

lazy val allSettings = commonSettings ++ artifactSettings ++ tutSettings

lazy val `sbt-microsites` = (project in file("."))
.settings(moduleName := "sbt-microsites")
.settings(allSettings: _*)
.settings(addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3"))
.settings(addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.3"))
.settings(addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0"))
.settings(tutSettings :_*)
.settings(libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.6.0")
.enablePlugins(JavaServerAppPackaging, UniversalPlugin, JekyllPlugin)
.settings(addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.3"))
.settings(addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0"))
.enablePlugins(JavaServerAppPackaging, UniversalPlugin, JekyllPlugin, AutomateHeaderPlugin)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version = 0.13.8
sbt.version = 0.13.12
7 changes: 5 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.7.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.3")
addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.4.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.0.0")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.0.1")
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.6.0")
addSbtPlugin("com.geirsson" % "sbt-scalafmt" % "0.3.1")
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2")
46 changes: 46 additions & 0 deletions publish.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
lazy val gpgFolder = sys.env.getOrElse("GPG_FOLDER", ".")
lazy val publishSnapshot = taskKey[Unit]("Publish only if the version is a SNAPSHOT")

pgpPassphrase := Some(sys.env.getOrElse("GPG_PASSPHRASE", "").toCharArray)
pgpPublicRing := file(s"$gpgFolder/pubring.gpg")
pgpSecretRing := file(s"$gpgFolder/secring.gpg")

credentials += Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
sys.env.getOrElse("PUBLISH_USERNAME", ""),
sys.env.getOrElse("PUBLISH_PASSWORD", "")
)

scmInfo := Some(
ScmInfo(url("https://github.com/47deg/sbt-microsites"),
"https://github.com/47deg/sbt-microsites.git"))
licenses := Seq(
"Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
publishMavenStyle := true
publishArtifact in Test := false
pomIncludeRepository := Function.const(false)

publishTo := {
val nexus = "https://oss.sonatype.org/"
if (isSnapshot.value)
Some("Snapshots" at nexus + "content/repositories/snapshots")
else
Some("Releases" at nexus + "service/local/staging/deploy/maven2")
}
publishSnapshot := Def.taskDyn {
if (isSnapshot.value) Def.task {
PgpKeys.publishSigned.value
} else Def.task(println("Actual version is not a Snapshot. Skipping publish."))
}.value

pomExtra :=
<developers>
<developer>
<name>47 Degrees (twitter: @47deg)</name>
<email>hello@47deg.com</email>
</developer>
<developer>
<name>47 Degrees</name>
</developer>
</developers>
51 changes: 37 additions & 14 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
@@ -1,22 +1,45 @@
/*
* Copyright 2016 47 Degrees, LLC. <http://www.47deg.com>
*
* 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.
*/

package microsites

import sbt._

trait MicrositeKeys {
val microsite = taskKey[Seq[File]]("Create microsite files")
val micrositeName = settingKey[String]("Microsite name")
val micrositeDescription = settingKey[String]("Microsite description")
val micrositeAuthor = settingKey[String]("Microsite author")
val micrositeHomepage = settingKey[String]("Microsite homepage")
val micrositeTwitter = settingKey[String]("Microsite twitter")
val micrositeBaseUrl = settingKey[String]("Microsite site base url")
val makeMicrosite = taskKey[Unit]("Main Task to build a Microsite")
val microsite = taskKey[Seq[File]]("Create microsite files")
val micrositeConfig = taskKey[Unit]("Copy microsite config to the site folder")
val micrositeName = settingKey[String]("Microsite name")
val micrositeDescription = settingKey[String]("Microsite description")
val micrositeAuthor = settingKey[String]("Microsite author")
val micrositeHomepage = settingKey[String]("Microsite homepage")
val micrositeTwitter = settingKey[String]("Microsite twitter")
val micrositeBaseUrl = settingKey[String]("Microsite site base url")
val micrositeDocumentationUrl = settingKey[String]("Microsite site documentation url")
val micrositeHighlightTheme = settingKey[String]("Microsite Highlight Theme")
val micrositeImgDirectory = settingKey[File]("Optional. Microsite images directory. By default, it'll be the resourcesDirectory + '/microsite/img'")
val micrositeCssDirectory = settingKey[File]("Optional. Microsite CSS directory. By default, it'll be the resourcesDirectory + '/microsite/css'")
val micrositeExtratMdFiles = settingKey[Seq[File]]("Optional. Additional document files located in a different place from the tutSourceDirectory. By default, it's empty")
val micrositePalette = settingKey[Map[String, String]]("Microsite palette")
val micrositeHighlightTheme = settingKey[String]("Microsite Highlight Theme")
val micrositeImgDirectory = settingKey[File](
"Optional. Microsite images directory. By default, it'll be the resourcesDirectory + '/microsite/img'")
val micrositeCssDirectory = settingKey[File](
"Optional. Microsite CSS directory. By default, it'll be the resourcesDirectory + '/microsite/css'")
val micrositeExtratMdFiles = settingKey[Map[File, String]](
"Optional. The key is related with the source file, the map value corresponds with the target relative file path. " +
"This keys is useful for those document files that are located in a different places from the tutSourceDirectory. " +
"By default, it's empty")
val micrositePalette = settingKey[Map[String, String]]("Microsite palette")
val micrositeGithubOwner = settingKey[String]("Microsite Github owner")
val micrositeGithubRepo = settingKey[String]("Microsite Github repo")
val micrositeGithubRepo = settingKey[String]("Microsite Github repo")
}
object MicrositeKeys extends MicrositeKeys
object MicrositeKeys extends MicrositeKeys
19 changes: 0 additions & 19 deletions src/main/scala/microsites/MicrositeSettings.scala

This file was deleted.

Loading

0 comments on commit 75b9ea7

Please sign in to comment.