File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change 1- from distutils import dir_util
2- from os .path import dirname , join
3- from urllib .request import urlretrieve
4-
51from setuptools import setup
62
73if __name__ == "__main__" :
8- cdn = "https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.4.3/mermaid.js"
9- static = join (dirname (__file__ ), "src" , "django_mermaid" , "static" )
10- dir_util .create_tree (static , ["mermaid.js" ])
11- urlretrieve (cdn , join (static , "mermaid.js" ))
124 setup ()
Original file line number Diff line number Diff line change 1+ from distutils import dir_util
2+ from os .path import dirname , join , exists
3+ from urllib .request import urlretrieve
4+
15from django .apps import AppConfig
26
37
48class MermaidConfig (AppConfig ):
59 name = "django_mermaid"
10+
11+ def ready (self ):
12+ """Download mermaid.js from CDN if not already present"""
13+ cdn = "https://cdnjs.cloudflare.com/ajax/libs/mermaid/9.4.3/mermaid.js"
14+ static = join (dirname (__file__ ), "static" )
15+ if not exists (join (static , "mermaid.js" )):
16+ dir_util .create_tree (static , ["mermaid.js" ])
17+ urlretrieve (cdn , join (static , "mermaid.js" ))
You can’t perform that action at this time.
0 commit comments