Skip to content

Commit bc08524

Browse files
author
cstrap
committed
init djangofy vue.js
1 parent a8f7f3a commit bc08524

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

python_vuejs/django.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,38 @@
11
# -*- coding: utf-8 -*-
2+
from __future__ import absolute_import, division, print_function
23

34
import click
5+
import os
46

57

68
@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

setup.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
'vuecli=python_vuejs.vuejs:install_vue_cli',
3838
'startvueapp=python_vuejs.vuejs:startvueapp',
3939
'startvueapp=python_vuejs.vuejs:vuedev',
40+
'djangobuild=python_vueks.django:djbuild',
41+
'djangofy=python_vuejs.django:djvue',
4042
]
4143
},
4244
include_package_data=True,

0 commit comments

Comments
 (0)