kopia lustrzana https://github.com/rtts/django-simplecms
Let's rock!
rodzic
a5d468d54c
commit
8dcf61c766
|
@ -85,7 +85,7 @@ Another useful feature is the automatic compilation of `SCSS` files to
|
|||
Use the provided helper command `simplecms` to quickly setup a new
|
||||
project:
|
||||
|
||||
$ pip install https://github.com/rtts/django-simplecms.git
|
||||
$ pip install django-simplecms
|
||||
$ simplecms mysite
|
||||
|
||||
After the project files have been created, initialize the database and
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
__version__ = '1.0.4'
|
||||
default_app_config = 'cms.apps.CmsConfig'
|
||||
|
|
|
@ -1,48 +1,58 @@
|
|||
import os, argparse, shutil, example
|
||||
import os, re, argparse, shutil, example, cms
|
||||
from pip._internal.operations import freeze as pip
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='SimpleCMS')
|
||||
parser.add_argument('project_name', nargs='?')
|
||||
if project_name := parser.parse_args().project_name:
|
||||
project_dir = os.path.join(os.getcwd(), project_name)
|
||||
else:
|
||||
project_name = os.path.basename(os.getcwd())
|
||||
parser.add_argument('project_name', nargs='?', default='.')
|
||||
project_name = parser.parse_args().project_name
|
||||
if project_name == '.':
|
||||
project_dir = os.getcwd()
|
||||
if input(f'Do you want to create a new project in `{project_dir}` ?\033[1D') in 'Yy':
|
||||
create_project(project_name, project_dir)
|
||||
project_name = os.path.basename(project_dir)
|
||||
else:
|
||||
project_dir = os.path.join(os.getcwd(), project_name)
|
||||
if re.match(r'^\w+$', project_name):
|
||||
if input(f'Do you want to create a new project in `{project_dir}` ?\033[1D') in 'Yy':
|
||||
create_project(project_name, project_dir)
|
||||
else:
|
||||
print(f'Invalid project name: {project_name}')
|
||||
|
||||
|
||||
def create_project(project_name, project_dir):
|
||||
os.makedirs(project_dir, exist_ok=True)
|
||||
with open(os.path.join(project_dir, 'requirements.txt'), 'w') as f:
|
||||
for line in pip.freeze():
|
||||
|
||||
# Central point of failure
|
||||
if 'django_simplecms' in line:
|
||||
line = 'git+https://github.com/rtts/django-simplecms'
|
||||
|
||||
line = f'django-simplecms=={cms.__version__}'
|
||||
print(line, file=f)
|
||||
|
||||
shutil.copytree(os.path.dirname(example.__file__), os.path.join(project_dir, project_name), dirs_exist_ok=True)
|
||||
shutil.copytree(os.path.dirname(example.__file__),os.path.join(project_dir, project_name), dirs_exist_ok=True)
|
||||
with open(os.open(os.path.join(project_dir, 'manage.py'), os.O_CREAT|os.O_WRONLY, 0o755), 'w') as f:
|
||||
print('''#!/usr/bin/env python
|
||||
import os, sys
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')
|
||||
from django.core.management import execute_from_command_line
|
||||
execute_from_command_line(sys.argv)''', file=f)
|
||||
print('#!/usr/bin/env python',
|
||||
'import os, sys',
|
||||
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
|
||||
'from django.core.management import execute_from_command_line',
|
||||
'execute_from_command_line(sys.argv)',
|
||||
sep='\n', file=f)
|
||||
with open(os.path.join(project_dir, project_name, 'wsgi.py'), 'w') as f:
|
||||
print('import os',
|
||||
'from django.core.wsgi import get_wsgi_application',
|
||||
f"os.environ.setdefault('DJANGO_SETTINGS_MODULE', '{project_name}.settings')",
|
||||
'application = get_wsgi_application()',
|
||||
sep='\n', file=f)
|
||||
with open(os.path.join(project_dir, '.gitignore'), 'w') as f:
|
||||
print('*.pyc\n__pycache__/', file=f)
|
||||
|
||||
print(f'''
|
||||
Successfully created project "{project_name}"
|
||||
print(f'Successfully created project "{project_name}"',
|
||||
'',
|
||||
'Things to do next:',
|
||||
'- create a database',
|
||||
'- ./manage.py makemigrations',
|
||||
'- ./manage.py migrate',
|
||||
'- ./manage.py createsuperuser',
|
||||
'- ./manage.py runserver',
|
||||
sep='\n')
|
||||
|
||||
Things to do next:
|
||||
- create a database
|
||||
- ./manage.py makemigrations
|
||||
- ./manage.py migrate
|
||||
- ./manage.py createsuperuser
|
||||
- ./manage.py runserver
|
||||
''')
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -5,8 +5,7 @@ from django.conf.urls.static import static
|
|||
from django.views.generic import RedirectView
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
|
||||
admin.site.site_header = settings.PROJECT_NAME.capitalize()
|
||||
admin.site.site_title = settings.PROJECT_NAME.capitalize()
|
||||
admin.site.site_header = admin.site.site_title = settings.PROJECT_NAME.replace('_', ' ').title()
|
||||
urlpatterns = staticfiles_urlpatterns() + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||
urlpatterns += [
|
||||
path('admin/', admin.site.urls),
|
||||
|
|
3
setup.py
3
setup.py
|
@ -1,4 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import cms
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
with open('README.md', 'r') as fh:
|
||||
|
@ -7,7 +8,7 @@ with open('README.md', 'r') as fh:
|
|||
setup(
|
||||
name = 'django-simplecms',
|
||||
description = 'Simple Django CMS',
|
||||
version = '1.0.3',
|
||||
version = cms.__version__,
|
||||
author = 'Jaap Joris Vens',
|
||||
author_email = 'jj+cms@rtts.eu',
|
||||
url = 'https://github.com/rtts/django-simplecms',
|
||||
|
|
Ładowanie…
Reference in New Issue