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

Issues/691 develop sling12 #13

Open
wants to merge 31 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
976ed5e
#460 - Added the Image Info annotation to the Peregrine Sling Module
Jul 20, 2020
bd38d88
Merge branch 'develop' into issues/460-develop
Aug 4, 2020
0829c50
Removed per-model and moved the code into base.core
Aug 4, 2020
3271dcf
Removed the per-model module
Aug 4, 2020
7d211f6
Added the Image Info to the Themeclean’s Media Block Model
Aug 4, 2020
1939693
Merge branch 'develop' into issues/460-develop
reggie7 Dec 3, 2020
210af58
Merge branch 'develop-sling12' into issues/460-develop-sling12
Dec 3, 2020
774c31a
Merge branch 'issues/460-develop' into issues/460-develop-sling12
Dec 3, 2020
38ff28f
Remove unused stuff
Dec 3, 2020
e9b396f
Grab dimensions from the source
Dec 3, 2020
cd9adf8
Extract PerAsset.getOrSaveAndGetDimension()
Dec 7, 2020
eca7747
added sling junit tests for perAssets
cmrockwell Dec 7, 2020
10fe1ff
added tests and test images for example site. SVG should be supported…
cmrockwell Dec 7, 2020
5802b67
Merge branch 'develop-sling12' into issues/460-develop-sling12
Dec 8, 2020
78ed5ee
Merge pull request #676 from headwirecom/issues/460-develop-sling12-j…
reggie7 Dec 8, 2020
c7ab1de
Merge branch 'issues/460-develop-sling12' of https://github.com/headw…
Dec 8, 2020
4861ee7
Merge branch 'develop-sling12' into issues/460-develop-sling12
Dec 9, 2020
4bb3c0e
Cover SVG case
Dec 9, 2020
16d461c
fix for #679
Dec 9, 2020
48f5d80
Fix missing property to save the cards change
Dec 14, 2020
c65a6fe
update package-lock.json
Dec 14, 2020
9f75593
watchers are now reset upon changing component to prevent "undefined"…
Dec 14, 2020
def60b1
Merge pull request #680 from headwirecom/sling12/issues/679
reusr1 Dec 15, 2020
ea8a653
Merge branch 'develop-sling12' into issues/460-develop-sling12
Dec 15, 2020
0845e65
Use try-with-resources to auto-close InputStream
Dec 15, 2020
c4392db
Remove missing props on update
Dec 21, 2020
e8c937c
Switch approach to special prop
Dec 22, 2020
3a8df78
Merge pull request #671 from headwirecom/issues/460-develop-sling12
reusr1 Dec 23, 2020
c1ce707
make sure peregrine develop-sling12 builds with themecleanflex develo…
reusr1 Dec 23, 2020
f555ffa
Merge pull request #688 from headwirecom/issues/494-remove-empty-props
reusr1 Jan 4, 2021
9482392
#691: allow read access to all tenants on /perapi instead of /perapi/…
reusr1 Jan 4, 2021
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ before_script:

script:
- if [ ${TRAVIS_PULL_REQUEST} != "false" ]; then BUILD_BRANCH=$TRAVIS_PULL_REQUEST_BRANCH; else BUILD_BRANCH=$TRAVIS_BRANCH; fi
- cd docker && ./builddocker.sh ${BUILD_BRANCH} develop
- cd docker && ./builddocker.sh ${BUILD_BRANCH} develop-sling12
- ./pushdocker-travis.sh

after_script:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,6 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.imageio.ImageIO;
import javax.imageio.ImageReader;
import javax.imageio.stream.ImageInputStream;
import javax.jcr.*;
import javax.jcr.version.Version;
import javax.jcr.version.VersionHistory;
Expand Down Expand Up @@ -144,7 +141,8 @@
)
public class AdminResourceHandlerService
implements AdminResourceHandler {
public static final String DELETION_PROPERTY_NAME = "_opDelete";
public static final String PN_DELETE_NODE = "_opDelete";
public static final String PN_DELETE_PROPS = "_opDeleteProps";
public static final String MODE_PROPERTY = "mode";

private static final String PARENT_NOT_FOUND = "Could not find %s Parent Resource. Path: '%s', name: '%s'";
Expand Down Expand Up @@ -951,11 +949,12 @@ private void processNewAsset(PerAsset asset) throws IOException, RepositoryExcep
addTagsToNewAsset(asset, directory, directoryName, selector);
}
}
// Obtain the Asset Dimension and store directly in the meta data folder
handleAssetDimensions(asset);
} catch (ImageProcessingException e) {
logger.debug(EMPTY, e);
}

// Obtain the Asset Dimension and store directly in the meta data folder
asset.setDimension();
}

private void addTagsToNewAssetAsJson(PerAsset asset, Directory directory, String directoryName, ImageMetadataSelector selector) throws PersistenceException, RepositoryException {
Expand Down Expand Up @@ -2008,7 +2007,20 @@ private void updateResourceTree(Resource resource, Map<String, Object> propertie
if (deleteIfContainsMarkerProperty(resource, properties)) {
return;
}

ModifiableValueMap updateProperties = getModifiableProperties(resource, false);
if (properties.containsKey(PN_DELETE_PROPS)) {
final Object value = properties.remove(PN_DELETE_PROPS);
if (value instanceof String) {
properties.remove(value);
updateProperties.remove(value);
} else if (value instanceof List) {
final var list = (List) value;
list.forEach(properties::remove);
list.forEach(updateProperties::remove);
}
}

for (Entry<String, Object> entry : properties.entrySet()) {
String name = entry.getKey();
Object value = entry.getValue();
Expand All @@ -2020,12 +2032,13 @@ private void updateResourceTree(Resource resource, Map<String, Object> propertie
updateProperties.put(name, value);
}
}

baseResourceHandler.updateModification(resource);
}

private boolean deleteIfContainsMarkerProperty(Resource resource, Map<String, Object> properties) throws ManagementException {
if (properties.containsKey(DELETION_PROPERTY_NAME)) {
Object value = properties.get(DELETION_PROPERTY_NAME);
if (properties.containsKey(PN_DELETE_NODE)) {
Object value = properties.get(PN_DELETE_NODE);
if (value == null || Boolean.TRUE.toString().equalsIgnoreCase(value.toString())) {
// This indicates that this node shall be removed
try {
Expand Down Expand Up @@ -2068,6 +2081,7 @@ private void applyChildProperties(Resource parent, String childName, Map childPr
childProperties.remove(NAME);
childProperties.remove(SLING_RESOURCE_TYPE);
childProperties.remove(JCR_PRIMARY_TYPE);
childProperties.remove(PN_DELETE_PROPS);
child = createNode(parent, childName, NT_UNSTRUCTURED, resourceType);
// Now update the child with any remaining properties
writeProperties(childProperties, child);
Expand Down Expand Up @@ -2192,7 +2206,7 @@ private Resource handleExistingItem(Resource parent, Resource child, Map itemPro
// Get index of the matching resource child to compare with the index in the list
int index = getChildIndex(parent, child);
String name = child.getName();
if (getBoolean(itemProperties, DELETION_PROPERTY_NAME, false)) {
if (getBoolean(itemProperties, PN_DELETE_NODE, false)) {
try {
logger.trace("Remove List Child: '{}' ('{}')", name, child.getPath());
parent.getResourceResolver().delete(child);
Expand Down Expand Up @@ -2315,25 +2329,6 @@ private Node createPageOrTemplate(Resource parent, String name, String templateC
return newPage;
}

public void handleAssetDimensions(PerAsset perAsset) throws RepositoryException, IOException {
InputStream is = perAsset.getRenditionStream((String) null);
// Ignore images that do not have a jcr:data element aka stream
if (is != null) {
ImageInputStream iis = ImageIO.createImageInputStream(is);
Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
while (readers.hasNext()) {
ImageReader reader = readers.next();
reader.setInput(iis);
int minIndex = reader.getMinIndex();
int width = reader.getWidth(minIndex);
int height = reader.getHeight(minIndex);
perAsset.addTag("per-data", "width", width);
perAsset.addTag("per-data", "height", height);
break;
}
}
}

private String getPropsFromMap(Map source, String key, String defaultValue) {
String answer = defaultValue;
Object temp = source.get(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import java.io.IOException;
import javax.servlet.Servlet;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.factory.ModelFactory;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

Expand Down Expand Up @@ -82,8 +81,6 @@
public class UpdateResourceServlet extends AbstractBaseServlet {

public static final String FAILED_TO_UPDATE_PAGE = "Failed to Update Page";
@Reference
ModelFactory modelFactory;

@Reference
AdminResourceHandler resourceManagement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export default {
firstTime: [],
selection: null
},
dynWatchers: [],
toast: {
templateComponent: null,
missingEventPath: null
Expand Down Expand Up @@ -431,6 +432,9 @@ export default {
},

updateSelectedComponent() {
this.dynWatchers.forEach((watcher) => {
watcher.unwatch()
})
$perAdminApp.action(this, 'showComponentEdit', this.path).then(() => {
this.flushInlineState()
return this.$nextTick()
Expand Down Expand Up @@ -549,6 +553,14 @@ export default {
const dataInline = this.targetInline.split('.').slice(1)
this.inline = dataInline.join('.')
set(this.view, '/state/inline/doc', this.iframe.doc)
const modelPropName = this.getCurrentModelPropName()
this.dynWatchers.some((w, index) => {
if (w.modelPropName === modelPropName) {
w.unwatch()
this.dynWatchers.splice(index, 1)
return true
}
})
},

onInlineFocusOut(event) {
Expand All @@ -558,6 +570,9 @@ export default {
if (!isChromeBrowser() && event.target.innerHTML) {
event.target.innerHTML = event.target.innerHTML.trim()
}
const modelPropName = this.getCurrentModelPropName()
const unwatch = this.$watch(`node.${modelPropName}`, (val) => event.target.innerHTML = val)
this.dynWatchers.push({modelPropName, unwatch})
},

onInlineKeyDown(event) {
Expand Down Expand Up @@ -911,6 +926,10 @@ export default {
style.setAttribute('id', 'editing-extra-styles')
},

getCurrentModelPropName(vm = this) {
return vm.targetInline.split('.').slice(1).join('.')
},

isContentEditableOrNested(el) {
const component = this.findComponentEl(el)
let found = el
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,19 @@ export default {
watch: {
value(val) {
this.model[this.schema.model] = val

let propsToRemove = this.model['_opDeleteProps'] || []
if (val || val === 0 || val === "0") {
propsToRemove = propsToRemove.filter(x => x !== this.schema.model)
} else {
propsToRemove.push(this.schema.model)
}

if (propsToRemove.length > 0) {
this.model['_opDeleteProps'] = propsToRemove
} else {
delete this.model['_opDeleteProps']
}
}
},
created() {
Expand Down
Loading