highlight: factorizes css and js requirements
authorJean Privat <jean@pryen.org>
Tue, 3 Jun 2014 13:06:10 +0000 (09:06 -0400)
committerJean Privat <jean@pryen.org>
Tue, 3 Jun 2014 13:06:10 +0000 (09:06 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit
src/nitlight.nit

index fbe013e..c9dec07 100644 (file)
@@ -200,6 +200,22 @@ pre.nitcode .line:hover{ background-color: #FFFFE0; } /* current line */
 .popover { max-width: 800px !important; }
 """
        end
+
+       # Additional content to inject in the <head> tag
+       # Note: does not include `css_content`; handle it yourself.
+       fun head_content: String
+       do
+               return """<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">\n"""
+       end
+
+       # Additional content to inject just before the closing </body> tag
+       fun foot_content: String
+       do
+               return """
+<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
+<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
+<script>$(".popupable").popover({html:true, placement:'top'})/*initialize bootstrap popover*/</script>"""
+       end
 end
 
 redef class HTMLTag
index 9112916..dd40996 100644 (file)
@@ -69,7 +69,7 @@ for mm in mmodules do
                        </style>
                        """
                else
-                       page.add_raw_html """<link rel="stylesheet" type="text/css" href="style.css" />"""
+                       page.add_raw_html v.head_content
                end
                page.add_raw_html """<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">\n"""
                page.add_raw_html "</head><body><pre class='nit_code'>"
@@ -78,9 +78,7 @@ for mm in mmodules do
        if not opt_fragment.value then
                page.add(v.html)
                page.add_raw_html "</pre>"
-               page.add_raw_html """<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>\n"""
-               page.add_raw_html """<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>\n"""
-               page.add_raw_html """<script>$(".popupable").popover({html:true, placement:'top'})/*initialize bootstrap popover*/</script>\n"""
+               page.add_raw_html v.foot_content
                page.add_raw_html "</body>"
        else
                page = v.html