From 7272e6e41deb8bc4dba8d96f42e766ef2eb4dde6 Mon Sep 17 00:00:00 2001 From: AntonioMateoGomez Date: Tue, 11 Jun 2019 11:53:52 +0200 Subject: [PATCH 1/3] Adds cloudflare highlight scripts in the main footer --- .../scala/microsites/layouts/Layout.scala | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/main/scala/microsites/layouts/Layout.scala b/src/main/scala/microsites/layouts/Layout.scala index d2c85e00..9d2a4b52 100644 --- a/src/main/scala/microsites/layouts/Layout.scala +++ b/src/main/scala/microsites/layouts/Layout.scala @@ -205,6 +205,28 @@ abstract class Layout(config: MicrositeSettings) { """.stripMargin)) ++ customJsList ++ customCDNList ++ gitSidecar } + def mainScripts: List[TypedTag[String]] = { + val BuiltinLanguages = Set("scala", "java", "bash") + + val languages = + config.visualSettings.highlightLanguages.map(lang => s"'$lang'").mkString("[", ",", "]") + + val languageScripts = + config.visualSettings.highlightLanguages.filterNot(BuiltinLanguages.contains).map { lang => + script( + src := s"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/${lang}.min.js") + } + + List( + script(src := "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"), + script( + src := "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"), + script(src := "{{site.url}}{{site.baseurl}}/highlight/highlight.pack.js") + ) ++ languageScripts ++ List(script(s"""hljs.configure({languages:${languages}}); + |hljs.initHighlighting(); + """.stripMargin)) + } + def globalFooter: TypedTag[String] = { val divs: Seq[TypedTag[String]] = div( @@ -247,7 +269,8 @@ abstract class Layout(config: MicrositeSettings) { id := "site-footer", div( cls := "container", - divs + divs, + mainScripts ) ) } From 47e312ccf096d5fe8977b831e3a65a55fbe6a37e Mon Sep 17 00:00:00 2001 From: AntonioMateoGomez Date: Tue, 11 Jun 2019 12:37:53 +0200 Subject: [PATCH 2/3] Removes jQuery and Bootstrap scripts in the mainScripts --- src/main/scala/microsites/layouts/Layout.scala | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/scala/microsites/layouts/Layout.scala b/src/main/scala/microsites/layouts/Layout.scala index 9d2a4b52..eee93169 100644 --- a/src/main/scala/microsites/layouts/Layout.scala +++ b/src/main/scala/microsites/layouts/Layout.scala @@ -218,9 +218,6 @@ abstract class Layout(config: MicrositeSettings) { } List( - script(src := "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"), - script( - src := "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js"), script(src := "{{site.url}}{{site.baseurl}}/highlight/highlight.pack.js") ) ++ languageScripts ++ List(script(s"""hljs.configure({languages:${languages}}); |hljs.initHighlighting(); From 1e481b9aa04366605ead2b8d4f414b2555c8f8cb Mon Sep 17 00:00:00 2001 From: AntonioMateoGomez Date: Tue, 11 Jun 2019 12:56:40 +0200 Subject: [PATCH 3/3] Renames mainScripts into highLightingScript and removes cloudfare script from it --- src/main/scala/microsites/layouts/Layout.scala | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/src/main/scala/microsites/layouts/Layout.scala b/src/main/scala/microsites/layouts/Layout.scala index eee93169..a7c56704 100644 --- a/src/main/scala/microsites/layouts/Layout.scala +++ b/src/main/scala/microsites/layouts/Layout.scala @@ -205,22 +205,10 @@ abstract class Layout(config: MicrositeSettings) { """.stripMargin)) ++ customJsList ++ customCDNList ++ gitSidecar } - def mainScripts: List[TypedTag[String]] = { - val BuiltinLanguages = Set("scala", "java", "bash") - - val languages = - config.visualSettings.highlightLanguages.map(lang => s"'$lang'").mkString("[", ",", "]") - - val languageScripts = - config.visualSettings.highlightLanguages.filterNot(BuiltinLanguages.contains).map { lang => - script( - src := s"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/languages/${lang}.min.js") - } - + def highLightingScript: List[TypedTag[String]] = { List( script(src := "{{site.url}}{{site.baseurl}}/highlight/highlight.pack.js") - ) ++ languageScripts ++ List(script(s"""hljs.configure({languages:${languages}}); - |hljs.initHighlighting(); + ) ++ List(script(s"""hljs.initHighlighting(); """.stripMargin)) } @@ -267,7 +255,7 @@ abstract class Layout(config: MicrositeSettings) { div( cls := "container", divs, - mainScripts + highLightingScript ) ) }