Skip to content

Commit

Permalink
Embed gitter channel (#183)
Browse files Browse the repository at this point in the history
* Embed Gitter Channel #32.

* Gitter Sidecar button added. Fixes #32

* Deleted unused imports
  • Loading branch information
AntonioMateoGomez authored and juanpedromoreno committed May 16, 2017
1 parent 87edac0 commit c96023a
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 4 deletions.
6 changes: 6 additions & 0 deletions docs/src/main/tut/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ micrositeGitHostingUrl := "https://gitlab.com/gitlab-org/gitlab-ce"
micrositeAnalyticsToken := 'UA-XXXXX-Y'
```

- `micrositeGitterChannel`: This setting is used to enabled the Gitter sidecar Channel functionality, by default is enabled. The chat room is taken from `micrositeGithubOwner` and `micrositeGithubRepo`.

```
micrositeGitterChannel := true
```

- `micrositeHighlightTheme`: by default, the theme of Highlight.js is [default](https://highlightjs.org/static/demo/), however, you can configure it to a different theme thanks to this setting:

```
Expand Down
6 changes: 5 additions & 1 deletion src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ trait MicrositeKeys {
val micrositeAnalyticsToken: SettingKey[String] =
settingKey[String](
"Optional. Add your property id of Google Analytics to add a Google Analytics tracker")
val micrositeGitterChannel: SettingKey[Boolean] = SettingKey[Boolean](
"Optional. Includes Gitter sidecar Chat functionality. Enabled by default."
)

val publishMicrositeCommandKey: String = "publishMicrositeCommand"
}
Expand Down Expand Up @@ -198,7 +201,8 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
case _ => ""
},
gitHostingService = micrositeGitHostingService.value.name,
gitHostingUrl = micrositeGitHostingUrl.value
gitHostingUrl = micrositeGitHostingUrl.value,
gitSidecarChat = micrositeGitterChannel.value
)
))
}
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/microsites/MicrositesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ object MicrositesPlugin extends AutoPlugin {
micrositeGitHostingUrl := "",
micrositePushSiteWith := GHPagesPlugin,
micrositeAnalyticsToken := "",
micrositeGitterChannel := true,
includeFilter in Jekyll := ("*.html" | "*.css" | "*.png" | "*.jpg" | "*.jpeg" | "*.gif" | "*.js" | "*.swf" | "*.md" | "*.webm" | "*.ico" | "CNAME"),
commands ++= Seq(publishMicrositeCommand)
)
Expand Down
13 changes: 12 additions & 1 deletion src/main/scala/microsites/layouts/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,17 @@ abstract class Layout(config: MicrositeSettings) {
script(src := js)
}

val gitSidecar: List[TypedTag[String]] = {
if (config.gitSettings.gitSidecarChat &&
(!config.gitSettings.githubOwner.isEmpty || !config.gitSettings.githubRepo.isEmpty)) {
List(
script(s"""((window.gitter = {}).chat = {}).options = {
|room: '${config.gitSettings.githubOwner}/${config.gitSettings.githubRepo}'};""".stripMargin),
script(src := s"https://sidecar.gitter.im/dist/sidecar.v1.js")
)
} else Nil
}

List(
script(src := "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"),
script(
Expand All @@ -158,7 +169,7 @@ abstract class Layout(config: MicrositeSettings) {
|});
|hljs.initHighlighting();
""".stripMargin)
) ++ customJsList ++ customCDNList
) ++ customJsList ++ customCDNList ++ gitSidecar
}

def kazariEnableScript: TypedTag[String] = script(s"""
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/microsites/microsites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ case class MicrositeGitSettings(
githubOwner: String,
githubRepo: String,
gitHostingService: MicrositeKeys.GitHostingService,
gitHostingUrl: String)
gitHostingUrl: String,
gitSidecarChat: Boolean)

case class MicrositeUrlSettings(micrositeBaseUrl: String, micrositeDocumentationUrl: String)

Expand Down
8 changes: 7 additions & 1 deletion src/test/scala/microsites/util/Arbitraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ trait Arbitraries {
githubRepo Arbitrary.arbitrary[String]
gitHostingService Arbitrary.arbitrary[GitHostingService]
gitHostingUrl Arbitrary.arbitrary[String]
gitSidecarChat Arbitrary.arbitrary[Boolean]
micrositeKazariEvaluatorUrl Arbitrary.arbitrary[String]
micrositeKazariEvaluatorToken Arbitrary.arbitrary[String]
micrositeKazariGithubToken Arbitrary.arbitrary[String]
Expand Down Expand Up @@ -159,7 +160,12 @@ trait Arbitraries {
micrositeExtraMdFiles
),
MicrositeUrlSettings(micrositeBaseUrl, micrositeDocumentationUrl),
MicrositeGitSettings(githubOwner, githubRepo, gitHostingService, gitHostingUrl),
MicrositeGitSettings(
githubOwner,
githubRepo,
gitHostingService,
gitHostingUrl,
gitSidecarChat),
KazariSettings(
micrositeKazariEvaluatorUrl,
micrositeKazariEvaluatorToken,
Expand Down

0 comments on commit c96023a

Please sign in to comment.