File tree Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Expand file tree Collapse file tree 2 files changed +34
-5
lines changed Original file line number Diff line number Diff line change 1
1
# -*- coding: utf-8 -*-
2
+ from __future__ import absolute_import , division , print_function
2
3
3
4
import click
5
+ import os
4
6
5
7
6
8
@click .command ()
7
- def djan (args = None ):
8
- """Console script for python_vuejs"""
9
- click .echo ("Replace this message by putting your code into "
10
- "python_vuejs.cli.main" )
11
- click .echo ("See click documentation at http://click.pocoo.org/" )
9
+ @click .argument ('project' )
10
+ def djangobuild (project ):
11
+ """
12
+ Called inside `package.json`
13
+ """
14
+ template_file = 'templates/{project}/index.html' .format (project = project )
15
+ with open (template_file , "r+" ) as f :
16
+ lines = f .readlines ()
17
+ f .seek (0 )
18
+ lines .insert (0 , "{% load staticfiles %}\n " )
19
+ for line in lines :
20
+ f .write (line .replace ('href=/' , "href={% static '/" )
21
+ .replace ('.css' , ".css' %}" )
22
+ .replace ('src=/' , "src={% static '/" )
23
+ .replace ('.js' , ".js' %}" ))
24
+
25
+
26
+ @click .command ()
27
+ @click .argument ('project' )
28
+ def djangofy (project ):
29
+ """
30
+ Convert Vue.js webpack project into a django app
31
+ """
32
+ os .makedirs ('{project}/templates/{project}/' .format (project = project ))
33
+ # TODO:
34
+ # create urls.py
35
+ # create __init__.py
36
+ # create empty index.html under templates/project
37
+ # edit `index.json` build
38
+ # edit `package.json` build
Original file line number Diff line number Diff line change 37
37
'vuecli=python_vuejs.vuejs:install_vue_cli' ,
38
38
'startvueapp=python_vuejs.vuejs:startvueapp' ,
39
39
'startvueapp=python_vuejs.vuejs:vuedev' ,
40
+ 'djangobuild=python_vueks.django:djbuild' ,
41
+ 'djangofy=python_vuejs.django:djvue' ,
40
42
]
41
43
},
42
44
include_package_data = True ,
You can’t perform that action at this time.
0 commit comments