Skip to content
Draft
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
78 changes: 78 additions & 0 deletions core/src/main/java/com/themecleanflex/models/ExternalModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.themecleanflex.models;

import com.peregrine.nodetypes.models.AbstractComponent;
import com.peregrine.nodetypes.models.IComponent;
import com.peregrine.nodetypes.models.Container;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import java.util.List;

import javax.inject.Inject;
import javax.inject.Named;

/*
//GEN[:DATA
{
"definitions": {
"External": {
"type": "object",
"x-type": "component",
"properties": {
"text": {
"type": "string",
"x-source": "inject",
"x-form-type": "texteditor"
}
}
}
},
"name": "External",
"componentPath": "themecleanflex/components/external",
"package": "com.themecleanflex.models",
"modelName": "External",
"classNameParent": "AbstractComponent"
}
//GEN]
*/

//GEN[:DEF
@Model(
adaptables = Resource.class,
resourceType = "themecleanflex/components/external",
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,
adapters = IComponent.class
)
@Exporter(
name = "jackson",
extensions = "json"
)

//GEN]
public class ExternalModel extends AbstractComponent {

public ExternalModel(Resource r) { super(r); }

//GEN[:INJECT
/* {"type":"string","x-source":"inject","x-form-type":"texteditor"} */
@Inject
private String text;


//GEN]

//GEN[:GETTERS
/* {"type":"string","x-source":"inject","x-form-type":"texteditor"} */
public String getText() {
return text;
}


//GEN]

//GEN[:CUSTOMGETTERS
//GEN]

}
5 changes: 5 additions & 0 deletions fragments/external/hatch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
convert: function($, f) {
f.bindPath($)
}
}
15 changes: 15 additions & 0 deletions fragments/external/model.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"definitions": {
"External": {
"type": "object",
"x-type": "component",
"properties": {
"htmlCode": {
"type": "string",
"x-source": "inject",
"x-form-type": "textarea"
}
}
}
}
}
7 changes: 7 additions & 0 deletions fragments/external/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"title": "External",
"group": "",
"model": {
"htmlCode": "<h1>code</h1>"
}
}
1 change: 1 addition & 0 deletions fragments/external/template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<div>external</div>
12 changes: 12 additions & 0 deletions fragments/external/template.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<template>
<div class="p-5" v-if="model.text == undefined">no content defined for component</div>
<div v-bind:data-per-path="model.path" v-html="model.text">
</div>
</template>

<script>
export default {
props: ['model']
}
</script>

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<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="per:Component"
jcr:title="External"
group=""
/>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"fields":[
{
"type":"material-textarea",
"rows":50,
"placeholder":"text",
"label":"HTML Code",
"model":"text",
"hint": "Embed external code with caution",
"x_form_group": "content"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<div v-bind:data-per-path="model.path" style="width:100%; padding: 6px;">
<div class="p-5" v-if="model.text == undefined">no content defined for component</div>
<div v-html="model.text" style="padding:6px;">
</div>
</div>
</template>

<script>
export default {
props: ['model']
}
</script>