|
1 | 1 | # -*- coding: utf-8 -*- |
| 2 | +from __future__importabsolute_import,division,print_function |
2 | 3 |
|
3 | 4 | importclick |
| 5 | +importos |
4 | 6 |
|
5 | 7 |
|
6 | 8 | @click.command() |
7 | | -defdjan(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 | +defdjangobuild(project): |
| 11 | +""" |
| 12 | + Called inside `package.json` |
| 13 | + """ |
| 14 | +template_file='templates/{project}/index.html'.format(project=project) |
| 15 | +withopen(template_file,"r+")asf: |
| 16 | +lines=f.readlines() |
| 17 | +f.seek(0) |
| 18 | +lines.insert(0,"{% load staticfiles %}\n") |
| 19 | +forlineinlines: |
| 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 | +defdjangofy(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 |