Skip to content

Commit

Permalink
Merge 8c5d15c into b384e9c
Browse files Browse the repository at this point in the history
  • Loading branch information
MrTango committed Jan 26, 2021
2 parents b384e9c + 8c5d15c commit 2b5a5bb
Show file tree
Hide file tree
Showing 36 changed files with 536 additions and 1,018 deletions.
15 changes: 15 additions & 0 deletions .github/ISSUE_TEMPLATE.md
@@ -0,0 +1,15 @@
* bobtemplates.plone version:
* Python version:
* Operating System:

### Description

Describe what you were trying to get done.
Tell us what happened, what went wrong, and what you expected to happen.

### What I Did

```
Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
```
43 changes: 43 additions & 0 deletions .github/workflows/python-package.yml
@@ -0,0 +1,43 @@
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Python package

on:
push:
branches: [master]
pull_request:
branches: [master]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.7, 2.7]

steps:
- uses: actions/checkout@v2
- uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install xmllint
run: sudo apt-get install libxml2-dev libxslt1-dev libjpeg-dev

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 tox tox-gh-actions
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install -e .
- name: Test with tox
run: |
tox
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -41,3 +41,4 @@ Vagrantfile
/.tmppytes
/.tmppytest
*.bak
/venv
13 changes: 13 additions & 0 deletions CHANGES.rst
Expand Up @@ -10,6 +10,19 @@ Changelog
- Change default answer of "Use XML Model" to false, because the Python way is usually easier and provides a better developer experience
[MrTango]

- Pin importlib-metadata = >=1 to avoid broken buildout in new packages
[MrTango]

- Change bundle names for svelte_app, it's now <my-app-name>-bundle.js/css, which makes it better distinguishable in Browser inspector
[MrTango]

- Optimize skeleton test maxtrix, to be much faster
[MrTango]

- Override index method in viewlets, not the render method.
[MrTango]


5.2.0 (2020-11-12)
------------------

Expand Down
1 change: 1 addition & 0 deletions bobtemplates/plone/addon/.gitignore.bob
Expand Up @@ -29,4 +29,5 @@ report.html
.vscode/
.tox/
reports/
venv/
# excludes
1 change: 1 addition & 0 deletions bobtemplates/plone/addon/test_plone52.cfg
Expand Up @@ -10,3 +10,4 @@ update-versions-file = test_plone52.cfg
[versions]
plone.testing = 7.0.1
collective.recipe.vscode = >=0.1.6
importlib-metadata = 1.1.3
2 changes: 2 additions & 0 deletions bobtemplates/plone/behavior.py
Expand Up @@ -3,6 +3,7 @@
from bobtemplates.plone.base import echo
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import update_file
from bobtemplates.plone.utils import run_isort
from lxml import etree

import case_conversion as cc
Expand Down Expand Up @@ -99,6 +100,7 @@ def post_renderer(configurator):
"""
_update_package_configure_zcml(configurator)
_update_behaviors_configure_zcml(configurator)
run_isort(configurator)
git_commit(
configurator,
'Add behavior: {0}'.format(
Expand Down
2 changes: 2 additions & 0 deletions bobtemplates/plone/content_type.py
Expand Up @@ -8,6 +8,7 @@
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import is_string_in_file
from bobtemplates.plone.base import update_file
from bobtemplates.plone.utils import run_isort
from lxml import etree
from mrbob.bobexceptions import SkipQuestion
from mrbob.bobexceptions import ValidationError
Expand Down Expand Up @@ -274,6 +275,7 @@ def post_renderer(configurator):
_update_rolemap_xml(configurator)
_update_metadata_xml(configurator)
_update_setup_py(configurator)
run_isort(configurator)
git_commit(
configurator,
'Add content_type: {0}'.format(
Expand Down
Expand Up @@ -59,7 +59,7 @@ class {{{ dexterity_type_name_klass }}}IntegrationTest(unittest.TestCase):
schema = fti.lookupSchema()
{{% if dexterity_type_supermodel %}}
schema_name = portalTypeToSchemaName('{{{ dexterity_type_name }}}')
self.assertEqual(schema_name, schema.getName())
self.assertIn(schema_name.lstrip('plone_0_'), schema.getName())
{{% else %}}
self.assertEqual(I{{{ dexterity_type_name_klass }}}, schema)
{{% endif %}}
Expand Down Expand Up @@ -166,7 +166,7 @@ class {{{ dexterity_type_name_klass }}}IntegrationTest(unittest.TestCase):
self.portal,
'{{{ dexterity_type_name_normalized }}}_id',
title='{{{ dexterity_type_name }}} container',
)
)
self.parent = self.portal[parent_id]
with self.assertRaises(InvalidParameterError):
api.content.create(
Expand All @@ -185,7 +185,7 @@ class {{{ dexterity_type_name_klass }}}IntegrationTest(unittest.TestCase):
self.portal,
'{{{ dexterity_type_name_normalized }}}_id',
title='{{{ dexterity_type_name }}} container',
)
)
self.parent = self.portal[parent_id]
obj = api.content.create(
container=self.parent,
Expand Down
2 changes: 2 additions & 0 deletions bobtemplates/plone/indexer.py
Expand Up @@ -4,6 +4,7 @@
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import remove_unwanted_files
from bobtemplates.plone.base import update_configure_zcml
from bobtemplates.plone.utils import run_isort

import case_conversion as cc

Expand Down Expand Up @@ -77,6 +78,7 @@ def post_renderer(configurator):
_update_package_configure_zcml(configurator)
_update_indexers_configure_zcml(configurator)
_remove_unwanted_files(configurator)
run_isort(configurator)
git_commit(
configurator,
'Add indexer: {0}'.format(
Expand Down
Expand Up @@ -18,6 +18,7 @@ class IndexerIntegrationTest(unittest.TestCase):
def test_dummy(self):
self.assertTrue(True)


class IndexerFunctionalTest(unittest.TestCase):

layer = {{{package.uppercasename}}}_FUNCTIONAL_TESTING
Expand Down
2 changes: 2 additions & 0 deletions bobtemplates/plone/subscriber.py
Expand Up @@ -4,6 +4,7 @@
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import remove_unwanted_files
from bobtemplates.plone.base import update_configure_zcml
from bobtemplates.plone.utils import run_isort

import case_conversion as cc

Expand Down Expand Up @@ -82,6 +83,7 @@ def post_renderer(configurator):
_update_package_configure_zcml(configurator)
_update_subscribers_configure_zcml(configurator)
_remove_unwanted_files(configurator)
run_isort(configurator)
git_commit(
configurator,
'Add subscriber: {0}'.format(
Expand Down
15 changes: 15 additions & 0 deletions bobtemplates/plone/svelte_app.py
@@ -1,8 +1,10 @@
# -*- coding: utf-8 -*-

from bobtemplates.plone.base import base_prepare_renderer
from bobtemplates.plone.base import echo
from bobtemplates.plone.base import git_commit
from bobtemplates.plone.base import update_file
from bobtemplates.plone.utils import run_isort
from lxml import etree
from mrbob.bobexceptions import ValidationError

Expand Down Expand Up @@ -60,9 +62,22 @@ def pre_renderer(configurator):
def post_renderer(configurator):
"""Post rendering."""
_update_configure_zcml(configurator)
run_isort(configurator)
git_commit(
configurator,
'Add Svelte app: in svelte_apps/{0}'.format(
configurator.variables['svelte_app_name'],
),
)
echo(
'===================================================\n'
'=> Sucessfully added: {0} in svelte_apps/{1} \n'
'=> you might want to go into the dir and run:\n'
'$ yarn\n'
'and then:'
'$ yarn dev\n'.format(
configurator.variables['template_id'],
configurator.variables['svelte_app_name'],
),
'info',
)
Expand Up @@ -8,8 +8,8 @@
<value key="enabled">True</value>
<value key="load_defer">True</value>
<value key="compile">False</value>
<value key="jscompilation">++plone++{{{ package.dottedname }}}.svelte/{{{ svelte_app_name_dashed }}}/bundle.js</value>
<value key="csscompilation">++plone++{{{ package.dottedname }}}.svelte/{{{ svelte_app_name_dashed }}}/bundle.css</value>
<value key="jscompilation">++plone++{{{ package.dottedname }}}.svelte/{{{ svelte_app_name_dashed }}}/{{{ svelte_app_name_dashed }}}-bundle.js</value>
<value key="csscompilation">++plone++{{{ package.dottedname }}}.svelte/{{{ svelte_app_name_dashed }}}/{{{ svelte_app_name_dashed }}}-bundle.css</value>
<value key="last_compilation">2020-10-29 22:00:00</value>
</records>

Expand Down
Expand Up @@ -8,9 +8,9 @@

<link rel='icon' type='image/png' href='favicon.png'>
<link rel='stylesheet' href='global.css'>
<link rel='stylesheet' href='bundle.css'>
<link rel='stylesheet' href='{{{ svelte_app_name_dashed }}}-bundle.css'>

<script defer src='bundle.js'></script>
<script defer src='{{{ svelte_app_name_dashed }}}-bundle.js'></script>
</head>

<body>
Expand Down
Expand Up @@ -14,7 +14,7 @@ export default {
sourcemap: true,
format: 'iife',
name: '{{{ svelte_app_file_name }}}',
file: '../../src/{{{ package.namespace }}}/{{{ package.name }}}/svelte_apps/{{{ svelte_app_name_dashed }}}/bundle.js'
file: '../../src/{{{ package.namespace }}}/{{{ package.name }}}/svelte_apps/{{{ svelte_app_name_dashed }}}/{{{ svelte_app_name_dashed }}}-bundle.js'
},
plugins: [
svelte({
Expand All @@ -29,7 +29,7 @@ export default {
// we'll extract any component CSS out into
// a separate file - better for performance
css: css => {
css.write('bundle.css');
css.write('{{{ svelte_app_name_dashed }}}-bundle.css');
}
}),

Expand Down
Expand Up @@ -3,22 +3,22 @@
</script>

<style>
main {
.svelte-app-wrapper {
text-align: center;
padding: 1em;
max-width: 240px;
margin: 0 auto;
}

h1 {
h2 {
color: #ff3e00;
text-transform: uppercase;
font-size: 4em;
font-size: 2em;
font-weight: 100;
}

@media (min-width: 640px) {
main {
.svelte-app-wrapper {
max-width: none;
}
}
Expand All @@ -30,11 +30,12 @@
<!--<svelte:options tag="{{{ svelte_app_name_dashed }}}" /> -->
{{% endif %}}

<main>
<h1>This is your Svelte app: {name}!</h1>
<div class="svelte-app-wrapper">
<h2>This is your Svelte app: {name}!</h2>
<input name="app-name" bind:value={name}>
<p>
Visit the
<a href="https://svelte.dev/tutorial">Svelte tutorial</a>
to learn how to build Svelte apps.
</p>
</main>
</div>
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from plone.app.testing import setRoles
from plone.app.testing import TEST_USER_ID
from {{{package.dottedname}}}.testing import {{{package.uppercasename}}}_FUNCTIONAL_TESTING
# from {{{package.dottedname}}}.testing import {{{package.uppercasename}}}_FUNCTIONAL_TESTING
from {{{package.dottedname}}}.testing import {{{package.uppercasename}}}_INTEGRATION_TESTING

import unittest
Expand Down
Expand Up @@ -17,7 +17,7 @@ class {{{ viewlet_python_class_name }}}(ViewletBase):
</li>'''
{{% endif %}}

def render(self):
def index(self):
{{% if viewlet_template %}}
return super({{{ viewlet_python_class_name }}}, self).render()
{{% else %}}
Expand Down
2 changes: 2 additions & 0 deletions package_tests/base.py
Expand Up @@ -14,11 +14,13 @@ def init_package_base_structure(package_root):
package_path = os.path.join(package_root, u"src/" + package_namespace_path)
profiles_path = os.path.join(package_path, u"profiles/default")
views_path = os.path.join(package_path, u"views")
svelte_apps_path = os.path.join(package_path, u"svelte_apps")
theme_path = os.path.join(package_path, u"theme")
os.makedirs(package_root)
os.makedirs(package_path)
os.makedirs(profiles_path)
os.makedirs(views_path)
os.makedirs(svelte_apps_path)
os.makedirs(theme_path)
template = """
[main]
Expand Down
6 changes: 4 additions & 2 deletions package_tests/test_svelte_app.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-

from .base import init_package_base_structure
from bobtemplates.plone import base
from bobtemplates.plone import svelte_app
from mrbob.bobexceptions import ValidationError
Expand All @@ -11,10 +12,11 @@


def test_prep_renderer(tmpdir):
target_path = tmpdir.strpath + '/collective.todo'
package_root = tmpdir.strpath + "/collective.todo"
init_package_base_structure(package_root)
configurator = Configurator(
template='bobtemplates.plone:svelte_app',
target_directory=target_path,
target_directory=package_root,
variables={
'svelte_app_name': 'my-cool-svelte-app',
},
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
@@ -1,4 +1,3 @@
-cconstraints.txt
setuptools
Sphinx
tox
2 changes: 0 additions & 2 deletions setup.cfg
Expand Up @@ -47,8 +47,6 @@ testpaths =

norecursedirs = fixures

isort_ignore =

[coverage:run]
parallel = True
branch = True
Expand Down

0 comments on commit 2b5a5bb

Please sign in to comment.