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
-
5
1
from setuptools import setup
6
2
7
3
if __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" ))
12
4
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
+
1
5
from django .apps import AppConfig
2
6
3
7
4
8
class MermaidConfig (AppConfig ):
5
9
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