Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes metatags and solarized-dark issues #187

Merged
merged 7 commits into from
May 19, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion docs/src/main/tut/docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,31 @@ Therefore, considering the example above, your microsite documentation would be
micrositeAuthor := "47 Degrees"
```

- `micrositeOrganizationHomepage`: this particular setting is used for the homepage url, similar to the way we've seen in other properties. This link is used in the footer-left link in the microsite. By default, the value is taken from the sbt setting `organizationHomepage`. In case you don´t provide any value for that setting, it will take it from the sbt setting `homepage`:
- `micrositeHomepage`: used for the homepage url, similar to the way we've seen in other properties. This link is used in the footer-left link in the microsite. By default, the value is taken from the sbt setting `homepage`.

```
micrositeHomepage := "https://47deg.github.io/sbt-microsites/"
```

- `micrositeOrganizationHomepage`: this particular setting is used for organization the homepage url, similar to the way we've seen in other properties. This link is used in the footer-left link in the microsite. By default, the value is taken from the sbt setting `organizationHomepage`. In case you don´t provide any value for that setting, it will take it from the sbt setting `homepage`:

```
micrositeOrganizationHomepage := "http://www.47deg.com"
```

- `micrositeTwitter`: this setting is used for the Twitter integration. This generates a meta that Twitter uses in its [Twitter Cards](https://cards-dev.twitter.com/validator).

```
micrositeTwitter := "@sbt-microsites"
```

- `micrositeTwitterCreator`: this particular setting is used for the Twitter integration. This generates a meta that Twitter uses in its [Twitter Cards](https://cards-dev.twitter.com/validator).

```
micrositeTwitterCreator := "@47deg"
```


- `micrositeGithubOwner` and `micrositeGithubRepo`: in order to add links to the `GitHub` repo. It's also needed for publishing the site when `github4s` is chosen (see `micrositePushSiteWith` setting). Both, `micrositeGithubOwner` and `micrositeGithubRepo` are required:

```
Expand Down
8 changes: 6 additions & 2 deletions src/main/scala/microsites/MicrositeKeys.scala
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import sbt._
import sbt.complete.DefaultParsers.OptNotSpace
import sbtorgpolicies.github.GitHubOps
import tut.Plugin._
import sbtorgpolicies.io._
import sbtorgpolicies.io.syntax._

trait MicrositeKeys {

Expand Down Expand Up @@ -62,8 +64,9 @@ trait MicrositeKeys {
val micrositeHomepage: SettingKey[String] = settingKey[String]("Microsite homepage")
val micrositeOrganizationHomepage: SettingKey[String] =
settingKey[String]("Microsite organisation homepage")
val micrositeTwitter: SettingKey[String] = settingKey[String]("Microsite twitter")
val micrositeBaseUrl: SettingKey[String] = settingKey[String]("Microsite site base url")
val micrositeTwitter: SettingKey[String] = settingKey[String]("Microsite twitter")
val micrositeTwitterCreator: SettingKey[String] = settingKey[String]("Microsite twitter")
val micrositeBaseUrl: SettingKey[String] = settingKey[String]("Microsite site base url")
val micrositeDocumentationUrl: SettingKey[String] =
settingKey[String]("Microsite site documentation url")
val micrositeHighlightTheme: SettingKey[String] = settingKey[String]("Microsite Highlight Theme")
Expand Down Expand Up @@ -158,6 +161,7 @@ trait MicrositeAutoImportSettings extends MicrositeKeys {
homepage = micrositeHomepage.value,
organizationHomepage = micrositeOrganizationHomepage.value,
twitter = micrositeTwitter.value,
twitterCreator = micrositeTwitterCreator.value,
analytics = micrositeAnalyticsToken.value
),
visualSettings = MicrositeVisualSettings(
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/microsites/MicrositesPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ object MicrositesPlugin extends AutoPlugin {
micrositeBaseUrl := "",
micrositeDocumentationUrl := "",
micrositeTwitter := "",
micrositeTwitterCreator := "",
micrositeHighlightTheme := "default",
micrositeConfigYaml := ConfigYml(
yamlPath = Some((resourceDirectory in Compile).value / "microsite" / "_config.yml")),
Expand Down Expand Up @@ -89,7 +90,7 @@ object MicrositesPlugin extends AutoPlugin {
micrositeKazariEvaluatorUrl := "https://scala-evaluator-212.herokuapp.com",
micrositeKazariEvaluatorToken := "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.S2F6YXJp.Jl2eqMfw8IakJF93PjxTbrf-8YUJgX5OoOfy5JHE8Yw",
micrositeKazariGithubToken := "",
micrositeKazariCodeMirrorTheme := "solarized-dark",
micrositeKazariCodeMirrorTheme := "monokai",
micrositeKazariDependencies := Seq(),
micrositeKazariResolvers := Seq(),
micrositeGitHostingService := GitHub,
Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/microsites/layouts/HomeLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ class HomeLayout(config: MicrositeSettings) extends Layout(config) {
)

def scriptsKazari: List[TypedTag[String]] =
scripts ++ List(script(src := "{{ site.baseurl }}/js/kazari.js"), script(kazariEnableScript))
scripts ++ List(script(src := "{{ site.baseurl }}/js/kazari.js"), kazariEnableScript)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍


}
61 changes: 42 additions & 19 deletions src/main/scala/microsites/layouts/Layout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,40 +54,63 @@ abstract class Layout(config: MicrositeSettings) {
|ga('send', 'pageview');
""".stripMargin))
else None

val twitter: Option[TypedTag[String]] =
if (config.identity.twitter.nonEmpty) {
Some(meta(name := "twitter:site", content := config.identity.twitter))
} else None

val twitterCreator: Option[TypedTag[String]] =
if (config.identity.twitterCreator.nonEmpty) {
Some(meta(name := "twitter:creator", content := config.identity.twitterCreator))
} else None

val kazariDep: Option[TypedTag[String]] =
if (config.micrositeKazariSettings.micrositeKazariDependencies.nonEmpty) {
Some(
meta(
name := "kazari-dependencies",
content :=
config.micrositeKazariSettings.micrositeKazariDependencies
.map(dependency =>
s"${dependency.groupId};${dependency.artifactId}_${dependency.scalaVersion};${dependency.version}")
.mkString(",")
))
} else None

val kazariRes: Option[TypedTag[String]] =
if (config.micrositeKazariSettings.micrositeKazariResolvers.nonEmpty) {
Some(
meta(
name := "kazari-resolvers",
content :=
config.micrositeKazariSettings.micrositeKazariResolvers.mkString(",")))
} else None

def metas: List[TypedTag[String]] =
List(
title(config.identity.name),
meta(charset := "utf-8"),
meta(httpEquiv := "X-UA-Compatible", content := "IE=edge,chrome=1"),
title(config.identity.name),
meta(name := "viewport", content := "width=device-width, initial-scale=1.0"),
meta(name := "description", content := config.identity.description),
meta(name := "author", content := config.identity.author),
meta(name := "description", content := config.identity.description),
meta(name := "og:image", content := "{{site.url}}{{site.baseurl}}/img/poster.png"),
meta(name := "og:title", content := config.identity.name),
meta(name := "og:site_name", content := config.identity.name),
meta(name := "og:url", content := config.identity.homepage),
meta(name := "og:type", content := "website"),
meta(name := "og:description", content := config.identity.description),
meta(name := "twitter:image", content := "{{site.url}}{{site.baseurl}}/img/poster.png"),
meta(name := "twitter:card", content := "summary_large_image"),
meta(name := "twitter:site", content := config.identity.twitter),
meta(
name := "kazari-dependencies",
content :=
config.micrositeKazariSettings.micrositeKazariDependencies
.map(dependency =>
s"${dependency.groupId};${dependency.artifactId}_${dependency.scalaVersion};${dependency.version}")
.mkString(",")
),
meta(
name := "kazari-resolvers",
content :=
config.micrositeKazariSettings.micrositeKazariResolvers.mkString(",")),
link(
rel := "icon",
`type` := "image/png",
href := "{{site.url}}{{site.baseurl}}/img/favicon.png")
) ++ ganalytics.toList
href := "{{site.url}}{{site.baseurl}}/img/favicon.png"),
meta(name := "twitter:title", content := config.identity.name),
meta(name := "twitter:image", content := s"${config.identity.homepage}img/poster.png"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check here we have the slash at the end (there is a helper to check it)

meta(name := "twitter:description", content := config.identity.description),
meta(name := "twitter:card", content := "summary_large_image")
) ++ twitter.toList ++ twitterCreator.toList ++ kazariDep.toList ++ kazariRes.toList ++ ganalytics.toList

def favicons: List[TypedTag[String]] =
(if (config.visualSettings.favicons.nonEmpty) {
config.visualSettings.favicons
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/microsites/microsites.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ case class MicrositeIdentitySettings(
homepage: String,
organizationHomepage: String,
twitter: String,
twitterCreator: String,
analytics: String)

case class MicrositeFileLocations(
Expand Down
2 changes: 2 additions & 0 deletions src/test/scala/microsites/util/Arbitraries.scala
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ trait Arbitraries {
homepage ← Arbitrary.arbitrary[String]
organizationHomepage ← Arbitrary.arbitrary[String]
twitter ← Arbitrary.arbitrary[String]
twitterCreator ← Arbitrary.arbitrary[String]
analytics ← Arbitrary.arbitrary[String]
highlightTheme ← Arbitrary.arbitrary[String]
micrositeConfigYaml ← configYamlArbitrary.arbitrary
Expand Down Expand Up @@ -145,6 +146,7 @@ trait Arbitraries {
homepage,
organizationHomepage,
twitter,
twitterCreator,
analytics),
MicrositeVisualSettings(highlightTheme, palette, favicon),
micrositeConfigYaml,
Expand Down