Beispiel #1
0
def jquery(url="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js",
           standalone=False):
    if standalone:
        path = ARTDOC / "js" / "jquery.js"
        file = path.open("wb")
        file.write(urllib.urlopen(url).read())
        file.close()
        return [HTML.script(src=str(path))]
    else:
        return [HTML.script(src=url)]
Beispiel #2
0
def jquery(url="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.js",
           standalone=False):
    if standalone:
        path = ARTDOC / "js" / "jquery.js"
        file = path.open("wb")
        file.write(urllib.urlopen(url).read())
        file.close()
        return [HTML.script(src=str(path))]
    else:
        return [HTML.script(src=url)]
Beispiel #3
0
def mathjax(
        url="http://cdn.mathjax.org/mathjax/latest/MathJax.js",
        zip_url="https://github.com/mathjax/MathJax/archive/master.zip",
        config="TeX-AMS_HTML",
        extra={
            "HTML-CSS": {
                "scale": 90,
                "availableFonts": ["TeX"],
                "preferredFont": "TeX"
            },
            "TeX": {
                "equationNumbers": {
                    "autoNumber": "AMS"
                }
            }
        },
        standalone=False):
    if standalone:
        zip_file = tempfile.NamedTemporaryFile(suffix=".zip", delete=False)
        zip_file.write(urllib.urlopen(zip_url).read())
        zip_filename = zip_file.name
        zip_file.close()
        zipfile.ZipFile(zip_filename).extractall(str(ARTDOC))
        os.remove(zip_filename)
        url = str(ARTDOC / "MathJax-master" / "MathJax.js")

    if config:
        url = url + "?config=" + config
    if extra is not None:
        js = "MathJax.Hub.Config({0})".format(json.dumps(extra))
    else:
        js = ""
    return [HTML.script(dict(src=url), js)]
Beispiel #4
0
def mathjax(url="http://cdn.mathjax.org/mathjax/latest/MathJax.js",
            zip_url="https://github.com/mathjax/MathJax/archive/master.zip", 
            config="TeX-AMS_HTML", 
            extra={"HTML-CSS": {"scale": 90, "availableFonts": ["TeX"], "preferredFont": "TeX"},
                   "TeX": {"equationNumbers": {"autoNumber": "AMS"}}},
            standalone=False):
    if standalone:
        zip_file = tempfile.NamedTemporaryFile(suffix=".zip", delete=False)
        zip_file.write(urllib.urlopen(zip_url).read())
        zip_filename = zip_file.name
        zip_file.close()
        zipfile.ZipFile(zip_filename).extractall(str(ARTDOC)) 
        os.remove(zip_filename)
        url = str(ARTDOC / "MathJax-master" / "MathJax.js")

    if config:
        url = url + "?config=" + config
    if extra is not None:
        js = "MathJax.Hub.Config({0})".format(json.dumps(extra))
    else:
        js = ""
    return [HTML.script(dict(src=url), js)] 
Beispiel #5
0
 def _build_html_scripts(self):
     for url in self.scripts:
         self.elements.body.append(E.script(src=url))
Beispiel #6
0
def artdoc():
    return [
      HTML.link(rel="stylesheet", href=".artdoc/css/style.css"),
      HTML.script(src=".artdoc/js/main.js")
    ]
Beispiel #7
0
def highlight(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "highlight.pack.js"))]
Beispiel #8
0
def clipboard(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "clipboard.js"))]
Beispiel #9
0
def velocity(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "velocity.js"))]
Beispiel #10
0
def artdoc():
    return [
        HTML.link(rel="stylesheet", href=".artdoc/css/style.css"),
        HTML.script(src=".artdoc/js/main.js")
    ]
Beispiel #11
0
def highlight(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "highlight.pack.js"))]
Beispiel #12
0
def clipboard(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "clipboard.js"))]
Beispiel #13
0
def velocity(*args, **kwargs):
    return [HTML.script(src=str(ARTDOC / "js" / "velocity.js"))]