Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for json-based widgets/mashups #540

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ pyScss>=1.3.4,<2.0
Pygments
pillow
jsonpatch
jsonschema
14 changes: 7 additions & 7 deletions src/wirecloud/catalogue/fixtures/catalogue_search_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"popularity": "0",
"vendor": "Wirecloud",
"short_name": "Test",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"Incredible Test\", \"description\": \"This widget contains keywords like term mashable application component.\", \"wiring\": {\"inputs\": [{\"friendcode\": \"test-data\", \"actionlabel\": \"\", \"name\": \"inputendpoint\", \"label\": \"Input\", \"type\": \"text\", \"description\": \"input type text\"}], \"outputs\": [{\"friendcode\": \"test-data\", \"description\": \"output digit\", \"type\": \"text\", \"name\": \"outputendpoint\", \"label\": \"Output\"}]}, \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"Incredible Test\", \"description\": \"This widget contains keywords like term mashable application component.\", \"wiring\": {\"inputs\": [{\"friendcode\": \"test-data\", \"actionlabel\": \"\", \"name\": \"inputendpoint\", \"label\": \"Input\", \"type\": \"text\", \"description\": \"input type text\"}], \"outputs\": [{\"friendcode\": \"test-data\", \"description\": \"output digit\", \"type\": \"text\", \"name\": \"outputendpoint\", \"label\": \"Output\"}]}, \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-12T11:24:03Z",
"version": "1.5",
Expand All @@ -95,7 +95,7 @@
"popularity": "0",
"vendor": "Wirecloud",
"short_name": "Test",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"2.0\", \"type\": \"widget\", \"title\": \"New Incredible Test\", \"description\": \"This widget contains keywords like prefix mashable application component.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"2.0\", \"type\": \"widget\", \"title\": \"New Incredible Test\", \"description\": \"This widget contains keywords like prefix mashable application component.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-13T11:24:03Z",
"version": "2.0",
Expand All @@ -113,7 +113,7 @@
"popularity": "0",
"vendor": "Wirecloud",
"short_name": "Test",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"2.5\", \"type\": \"widget\", \"title\": \"The Best Incredible Test\", \"description\": \"This widget contains keywords regex mashable application component.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Test\", \"vendor\": \"Wirecloud\", \"version\": \"2.5\", \"type\": \"widget\", \"title\": \"The Best Incredible Test\", \"description\": \"This widget contains keywords regex mashable application component.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-14T11:24:03Z",
"version": "2.5",
Expand All @@ -131,7 +131,7 @@
"popularity": "0",
"vendor": "CoNWeT-Lab",
"short_name": "Clock_Now",
"json_description": "{\"name\": \"Clock_Now\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"Clock Now\", \"description\": \"This WireCloud widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Clock_Now\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"Clock Now\", \"description\": \"This WireCloud widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-15T11:24:03Z",
"version": "1.5",
Expand All @@ -149,7 +149,7 @@
"popularity": "0",
"vendor": "CoNWeT-Lab",
"short_name": "Clock_Now",
"json_description": "{\"name\": \"Clock_Now\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.11\", \"type\": \"widget\", \"title\": \"Last Clock Now\", \"description\": \"This WireCloud widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Clock_Now\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.11\", \"type\": \"widget\", \"title\": \"Last Clock Now\", \"description\": \"This WireCloud widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-16T11:24:03Z",
"version": "1.11",
Expand Down Expand Up @@ -347,7 +347,7 @@
"popularity": "0",
"vendor": "Wirecloud",
"short_name": "Book-Reader",
"json_description": "{\"name\": \"Book-Reader\", \"vendor\": \"Wirecloud\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"The Best Incredible Test\", \"description\": \"This widget contains keywords wiredrawers wiretappers wirephoto wirework wireway wired wireless.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Book-Reader\", \"vendor\": \"Wirecloud\", \"version\": \"1.5\", \"type\": \"widget\", \"title\": \"The Best Incredible Test\", \"description\": \"This widget contains keywords wiredrawers wiretappers wirephoto wirework wireway wired wireless.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-27T11:24:03Z",
"version": "1.5",
Expand All @@ -365,7 +365,7 @@
"popularity": "0",
"vendor": "CoNWeT-Lab",
"short_name": "Live_Sports",
"json_description": "{\"name\": \"Live_Sports\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.0\", \"type\": \"widget\", \"title\": \"Live Sports\", \"description\": \"This widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}}",
"json_description": "{\"name\": \"Live_Sports\", \"vendor\": \"CoNWeT-Lab\", \"version\": \"1.0\", \"type\": \"widget\", \"title\": \"Live Sports\", \"description\": \"This widget contains keywords like free button bluetooth.\", \"contents\": {\"src\": \"test.html\"}, \"widget_width\": \"4\", \"widget_height\": \"4\"}",
"creator": 80,
"creation_date": "2011-05-28T11:24:03Z",
"version": "1.0",
Expand Down
7 changes: 6 additions & 1 deletion src/wirecloud/commons/utils/template/parsers/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@
# along with Wirecloud. If not, see <http://www.gnu.org/licenses/>.

import json
from jsonschema.validators import Draft7Validator
import os

from django.utils.translation import ugettext as _

from wirecloud.commons.utils.template.base import is_valid_name, is_valid_vendor, is_valid_version, parse_contacts_info, TemplateParseException
from wirecloud.commons.utils.translation import get_trans_index
from wirecloud.platform.wiring.utils import get_wiring_skeleton, parse_wiring_old_version

with open(os.path.join(os.path.dirname(__file__), '../schemas/json_schema.schema.json'), 'r') as JSONSCHEMA_FILE:
JSONSCHEMA = json.load(JSONSCHEMA_FILE)
validator = Draft7Validator(JSONSCHEMA)

class JSONTemplateParser(object):

Expand Down Expand Up @@ -189,7 +194,7 @@ def _add_translation_index(self, value, **kwargs):
self._info['translation_index_usage'][index].append(kwargs)

def _init(self):

validator.validate(self._info, JSONSCHEMA)
self._check_string_fields(('title', 'description', 'longdescription', 'email', 'homepage', 'doc', 'changelog', 'image', 'smartphoneimage', 'license', 'licenseurl', 'issuetracker'))
self._check_contacts_fields(('authors', 'contributors'))
self._check_integer_fields(('macversion', ), default = 1)
Expand Down
Loading
Loading