diff --git a/django_project b/django_project index 2973234..f7d4339 160000 --- a/django_project +++ b/django_project @@ -1 +1 @@ -Subproject commit 2973234ba1944b90fec2909a5d3a85bb07b43ee4 +Subproject commit f7d4339fda6a948579355282c6e520e045bd6ebe diff --git a/packages/cra-template/template/public/index.html b/packages/cra-template/template/public/index.html index 991181c..0494e69 100644 --- a/packages/cra-template/template/public/index.html +++ b/packages/cra-template/template/public/index.html @@ -24,7 +24,7 @@ work correctly both with client-side routing and a non-root public URL. Learn how to configure a non-root public URL by running `npm run build`. --> - React + @wq/app + {{ title }} diff --git a/packages/cra-template/template/public/manifest.json b/packages/cra-template/template/public/manifest.json index b12036d..ab0ec13 100644 --- a/packages/cra-template/template/public/manifest.json +++ b/packages/cra-template/template/public/manifest.json @@ -1,6 +1,6 @@ { "short_name": "{{ project_name }}", - "name": "{{ project_name }} Project", + "name": "{{ title }}", "icons": [ { "src": "favicon.ico", diff --git a/projects.py b/projects.py index cbe15bd..e0b22bc 100644 --- a/projects.py +++ b/projects.py @@ -24,6 +24,7 @@ class StartProjectCommand(startproject.Command): def add_arguments(self, parser): super(StartProjectCommand, self).add_arguments(parser) parser.add_argument('--domain', help="Web Domain") + parser.add_argument('--title', help="Site Title") parser.add_argument('--with-gis', help="Enable GeoDjango") parser.add_argument('--with-npm', help="Enable NPM") parser.add_argument('--wq-create-version', help="wq create version") @@ -35,6 +36,9 @@ def add_arguments(self, parser): @click.option( "-d", "--domain", help='Web domain (e.g. example.wq.io)' ) +@click.option( + "-t", "--title", help="Site title + App label" +) @click.option( "--with-gis/--without-gis", default=None, help="Enable GeoDjango" ) @@ -42,7 +46,7 @@ def add_arguments(self, parser): "--with-npm/--without-npm", default=None, help="Enable NPM (& Create React App)" ) -def create(project_name, destination, domain=None, +def create(project_name, destination, domain=None, title=None, with_gis=None, with_npm=None): """ Start a new project with wq.app and wq.db. A new Django project will be @@ -57,10 +61,10 @@ def create(project_name, destination, domain=None, See https://wq.io/docs/setup for more tips on getting started with wq. """ - do_create(project_name, destination, domain, with_gis, with_npm) + do_create(project_name, destination, domain, title, with_gis, with_npm) -def do_create(project_name, destination, domain, with_gis, with_npm): +def do_create(project_name, destination, domain, title, with_gis, with_npm): any_prompts = False if project_name is None: @@ -83,6 +87,16 @@ def do_create(project_name, destination, domain, with_gis, with_npm): default='{}.example.org'.format(project_name) ) + if title is None: + any_prompts = True + title = click.prompt( + 'Site title + App label', + default='{} Project'.format(project_name) + ) + elif title == '__old__': + title = '{} Project'.format(project_name) + + if with_gis is None: any_prompts = True with_gis = click.confirm( @@ -106,6 +120,7 @@ def do_create(project_name, destination, domain, with_gis, with_npm): template=template, extensions="py,yml,conf,html,sh,js,css,json,xml,gitignore".split(","), domain=domain, + title=title, wq_create_version=VERSION, with_gis=with_gis, with_npm=with_npm, @@ -128,6 +143,16 @@ def do_create(project_name, destination, domain, with_gis, with_npm): os.path.join(path, project_name), os.path.join(path, 'app'), ) + for filename in ('index.html', 'manifest.json'): + filepath = os.path.join(path, 'app', 'public', filename) + with open(filepath) as f: + content = f.read() + + content = content.replace('{{ title }}', title) + content = content.replace('{{ project_name }}', project_name) + + with open(filepath, 'w') as f: + f.write(content) else: os.remove(os.path.join(path, 'app', 'README.md')) @@ -180,4 +205,4 @@ def start(project_name, destination, domain=None, (DEPRECATED) Alias for wq create. """ click.echo('This command is deprecated. Use "wq create" instead.') - do_create(project_name, destination, domain, with_gis, with_npm) + do_create(project_name, destination, domain, '__old__', with_gis, with_npm) diff --git a/tests/expected/config1.json b/tests/expected/config1.json index 0dc81aa..617e29a 100644 --- a/tests/expected/config1.json +++ b/tests/expected/config1.json @@ -1,5 +1,12 @@ { + "site_title": "test Project", "pages": { + "index": { + "url": "", + "name": "index", + "verbose_name": "test Project", + "show_in_index": false + }, "login": { "name": "login", "url": "login" diff --git a/tests/expected/config2.json b/tests/expected/config2.json index e8d1dc8..d28e13f 100644 --- a/tests/expected/config2.json +++ b/tests/expected/config2.json @@ -1,5 +1,12 @@ { + "site_title": "test Project", "pages": { + "index": { + "url": "", + "name": "index", + "verbose_name": "test Project", + "show_in_index": false + }, "location": { "name": "location", "verbose_name": "location", diff --git a/tests/expected/config3.json b/tests/expected/config3.json index 99d1123..9ca9a74 100644 --- a/tests/expected/config3.json +++ b/tests/expected/config3.json @@ -1,5 +1,12 @@ { + "site_title": "test Project", "pages": { + "index": { + "url": "", + "name": "index", + "verbose_name": "test Project", + "show_in_index": false + }, "location": { "name": "location", "verbose_name": "location", diff --git a/tests/test-deploy.sh b/tests/test-deploy.sh index 57792a4..00a78e4 100755 --- a/tests/test-deploy.sh +++ b/tests/test-deploy.sh @@ -29,7 +29,7 @@ else NPM_FLAG="--without-npm" fi; -wq create test_project ./test_project -d test.wq.io $NPM_FLAG $GIS_FLAG +wq create test_project ./test_project -d test.wq.io -t "test Project" $NPM_FLAG $GIS_FLAG # Verify ./deploy.sh works cd test_project