Skip to content

Commit

Permalink
Merge pull request #16 from aem-design/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wildone authored Feb 7, 2020
2 parents ad304af + 83ff264 commit f233a4d
Show file tree
Hide file tree
Showing 118 changed files with 2,667 additions and 44 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ jobs:

- name: install dependencies
run: |
sudo apt-get update --fix-missing
sudo apt-get install ansible libcurl4-openssl-dev libssl-dev socat default-jdk
python -m pip install --upgrade pip
pip install -r requirements.txt
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,120 @@ content/_cq_tags/aemdesign/component-dialog: &component-dialog
- default: {title: "Title", value: "default"}


# Social Share
vue-widgets/social-share:
contents:
json: true
jsonKey: social-share
config: ''
fields:
label:
title: 'Label'
value:
field: 'textfield'
order: 1
required: false
tooltip: 'Optional label'

# Search Input
vue-widgets/search-input:
contents:
json: true
jsonKey: search-input
config:
- funnelback-concierge-endpoint
fields:
input-label:
title: 'Input Label'
value:
field: 'textfield'
order: 1
required: false
tooltip: 'Label for the input field'
destination:
title: 'Destination Page'
value:
externalizer: true
field: 'pathbrowser'
order: 2
required: false
tooltip: 'Page to send the search query to. Query emitted via an in-page JavaScript event (if empty).'
default-collection:
title: 'Default Collection'
value:
field: 'select'
items:
- label: ''
value: ''
- label: 'Search'
value: 'search-default'
- label: 'Courses'
value: 'search-courses'
- label: 'News'
value: 'search-news'
- label: 'Events'
value: 'search-events'
order: 3
placeholder: 'Please choose a collection'
required: false
tooltip: 'Default collection to use when a user is making a search query.'
toggleable:
title: 'Visibility Toggle'
value:
field: 'checkbox'
order: 4
required: false
tooltip: 'Toggle the search input visibility by a click (i.e. global header)'
show-collections:
title: 'Show Collections'
value:
field: 'checkbox'
order: 5
required: false
tooltip: 'Toggle the search collection buttons'
show-concierge:
title: 'Show Concierge'
value:
field: 'checkbox'
order: 6
required: false
tooltip: 'Toggle the concierge'
# Search Results
vue-widgets/search-results:
contents:
json: true
jsonKey: search-results
config:
- funnelback-search-endpoint
fields:
no-results-message:
title: 'No Results Message'
value:
field: 'textarea'
order: 1
required: false
slot: no-results-message
tooltip: 'Message to show when no results are found.'
invalid-response-message:
title: 'Invalid Response Message'
value:
field: 'textarea'
order: 2
required: false
slot: invalid-message
tooltip: 'Message to show when an unexpected error occurs.'
pager-mode:
title: 'Pagination Mode'
value:
field: 'select'
items:
- label: 'Paged List'
value: 'pagination'
- label: 'Infinite list'
value: 'infinite'
order: 3


# Showcase Copy
content/_cq_tags/aemdesign-showcase/component-dialog: *component-dialog

Expand Down
101 changes: 70 additions & 31 deletions aemdesign-aem-compose/content-generator/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ const isDebug = process.argv.find(function(value) { return value === "--debug"})
const {
each,
escape,
isArray,
isString,
size,
} = require('lodash')

Expand Down Expand Up @@ -147,7 +149,7 @@ function escapeXml(unsafe) {

function titleCase(str) {
try {
return str.toLowerCase().split(' ').map(word => (
return str.toLowerCase().replace('-', ' ').split(' ').map(word => (
word.replace(word[0], word[0].toUpperCase())
)).join(' ')
} catch (ex) {
Expand Down Expand Up @@ -193,40 +195,77 @@ function generateContent(categoryTemplate, categoryTemplateDefault, category, pa
}
} else {
if (contentData.content !== undefined) {
const templateHasAttributes = templatePatch.indexOf('%%attributes%%')>-1

for (const field of Object.keys(contentData.content)) {
folderName = field
templatePatch = templatePatch.replace('%%node%%', field)

const fieldValues = contentData.content[field]
let fieldAttributes = ""

//for all fields apart from json flag
for (const fieldName of Object.keys(fieldValues).filter(x => x !== 'json')) {
const value = fieldValues[fieldName]
//check if the field is explicitly mentioned in template
if (templatePatch.indexOf('%%' + fieldName + '%%')>-1) {
//replace field value
templatePatch = templatePatch.replace(
'%%' + fieldName + '%%',
fieldValues.json === true && fieldName === 'value' ? Buffer.from(JSON.stringify(value)).toString('base64') : value
)
} else if (templateHasAttributes) {
//if not array add to attributes collection
if (!Array.isArray(value)) {
fieldAttributes += fieldName + '="' + value + '" '
const templateHasAttributes = templatePatch.indexOf('%%attributes%%')>-1

//check if json being specified as contents
if (contentData.json) {
const content = contentData.content

templatePatch = templatePatch.replace('%%title%%', titleCase(contentData.jsonKey))
templatePatch = templatePatch.replace('%%value%%', contentData.jsonKey)
//remove attributes field is exist in template
templatePatch = templatePatch.replace('%%attributes%%', "")

if (isArray(content) || isString(content)) {
let localPatch = template

localPatch = localPatch.replace('%%title%%', titleCase(contentData.key))
localPatch = localPatch.replace('%%value%%', Buffer.from(JSON.stringify(content || [])).toString('base64'))
//remove attributes field is exist in template
localPatch = localPatch.replace('%%attributes%%', "")

writeTemplate(`${rootPath}/${category}/${path}/${contentData.key}`, categoryTemplateDefault, localPatch)
} else {
//if array join and add as array string
fieldAttributes += fieldName + '="[' + Object.values(value).join(",") + ']" '
each(content, (field, key) => {
let localPatch = template

localPatch = localPatch.replace('%%title%%', field.title)
localPatch = localPatch.replace('%%value%%', Buffer.from(JSON.stringify(field || [])).toString('base64'))
//remove attributes field is exist in template
localPatch = localPatch.replace('%%attributes%%', "")

writeTemplate(`${rootPath}/${category}/${path}/${contentData.key}/${key}`, categoryTemplateDefault, localPatch)
})
}

} else {

for (const field of Object.keys(contentData.content)) {
folderName = field
templatePatch = templatePatch.replace('%%node%%', field)

const fieldValues = contentData.content[field]
let fieldAttributes = ""

//for all fields apart from json flag
for (const fieldName of Object.keys(fieldValues).filter(x => x !== 'json')) {
const value = fieldValues[fieldName]
//check if the field is explicitly mentioned in template
if (templatePatch.indexOf('%%' + fieldName + '%%')>-1) {
//replace field value
templatePatch = templatePatch.replace(
'%%' + fieldName + '%%',
fieldValues.json === true && fieldName === 'value' ? Buffer.from(JSON.stringify(value)).toString('base64') : value
)
} else if (templateHasAttributes) {
//if not array add to attributes collection
if (!Array.isArray(value)) {
fieldAttributes += fieldName + '="' + value + '" '
} else {
//if array join and add as array string
fieldAttributes += fieldName + '="[' + Object.values(value).join(",") + ']" '
}
}
}
//replace attributes placeholder with collected fields
if (templateHasAttributes) {
templatePatch = templatePatch.replace('%%attributes%%', fieldAttributes)
}
}

}
//replace attributes placeholder with collected fields
if (templateHasAttributes) {
templatePatch = templatePatch.replace('%%attributes%%', fieldAttributes)
}
}


} else {
logToConsole('Nothing to do with:', path)
return
Expand Down
22 changes: 11 additions & 11 deletions aemdesign-aem-compose/content-generator/generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,18 @@ try {
}

if (contents !== undefined) {

contents.forEach(content => {

debug({"PROCESSING DIRECT CONTENT": content})

categories[category][subcategory].content.push({
content : content,
template : data.template || '',
type : 'content',
})
each(contents, (content, key) => {
if (key !== 'json' && key !== 'jsonKey') {
categories[category][subcategory].content.push({
content,
key,
json : contents.json,
jsonKey : contents.jsonKey || '',
template : data.template || '',
type : 'content',
})
}
})
continue;
}

if (prefixes !== undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="sling:OsgiConfig"
user.default="admin"
user.mapping="[design.aem.aemdesign-aem-services:content-services=actool-service,design.aem.aemdesign-aem-services=actool-service]"/>
user.mapping="[design.aem.aemdesign-aem-services:content-services=sling-scripting,design.aem.aemdesign-aem-services=sling-scripting]"/>
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@

<filter root="/conf/aemdesign-showcase"/>
<filter root="/content/experience-fragments/aemdesign-showcase" mode="update"/>
<filter root="/content/usergenerated/content/aemdesign-showcase/au/en/content/forms" mode="update"/>
</workspaceFilter>
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@
</par>
</article>
</jcr:content>
<button/>
<form/>
<hidden/>
<options/>
<text/>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:allowedTemplates="[/conf/aemdesign-showcase/settings/wcm/templates/.*]"
cq:template="/conf/aemdesign-showcase/settings/wcm/templates/onecolumn"
jcr:primaryType="cq:PageContent"
jcr:title="Button"
sling:resourceType="aemdesign/components/template/base">
<article
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/article">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/container">
<contentblock1
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/contentblock"
componentId="contentblock1"
title="Default"
variant="advsection">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/container">
<button
jcr:primaryType="nt:unstructured"
jcr:title="Submit"
sling:resourceType="aemdesign/components/forms/button"
name="button1"
type="submit"
value="button"/>
</par>
</contentblock1>
<contentblock2
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/contentblock"
componentId="contentblock2"
title="Button"
variant="advsection">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/container">
<button
jcr:primaryType="nt:unstructured"
jcr:title="Button"
sling:resourceType="aemdesign/components/forms/button"
name="button2"
type="button"
value="button"/>
</par>
</contentblock2>
</par>
</article>
</jcr:content>
</jcr:root>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:allowedTemplates="[/conf/aemdesign-showcase/settings/wcm/templates/.*]"
cq:template="/conf/aemdesign-showcase/settings/wcm/templates/onecolumn"
jcr:primaryType="cq:PageContent"
jcr:title="Form"
sling:resourceType="aemdesign/components/template/base">
<article
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/article">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/container">
<contentblock1
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/contentblock"
componentId="contentblock1"
title="Default"
variant="advsection">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/layout/container">
<form
jcr:primaryType="nt:unstructured"
sling:resourceType="aemdesign/components/forms/form/v1/form"
id="form1"
action="/content/usergenerated/aemdesign-showcase/au/en/component/forms/form/cq-gen1575718682458/"
actionType="foundation/components/form/actions/store"/>
</par>
</contentblock1>
</par>
</article>
</jcr:content>
</jcr:root>
Loading

0 comments on commit f233a4d

Please sign in to comment.