Skip to content

Instantly share code, notes, and snippets.

View jpotts's full-sized avatar

Jeff Potts jpotts

View GitHub Profile
@jpotts
jpotts / gist:10878584
Created April 16, 2014 13:50
Remove an aspect from every node in the repository
var results = search.luceneSearch("ASPECT:\"ASPECT NAME HERE\"");
for each (var doc in results) {
doc.removeAspect("ASPECT NAME HERE");
}
@jpotts
jpotts / createSomecoClient.groovy
Created April 28, 2014 21:53
Create an instance of a custom type in Alfresco that extends sys:base using cmis:item support in CMIS 1.1
clientName = "Some Client"
folder = session.getObjectByPath('/test/testfolder1')
props = new HashMap<String, Object>()
props["cmis:objectTypeId"] = "I:sc:client"
props["sc:clientId"] = "56789"
props["sc:clientName"] = clientName
props["cmis:name"] = clientName
@jpotts
jpotts / fetch-content.js
Last active August 29, 2015 14:07
List content entries matching specific criteria using the contentful content delivery API
var contentful = require('contentful');
var spaceId = 'someSpaceId';
var accessToken = 'someAccessToken';
var contentTypeId = 'someContentTypeId';
var client = contentful.createClient({
space: spaceId,
accessToken: accessToken,
secure: true,
@jpotts
jpotts / fetch-content.js
Created October 6, 2014 18:59
Fetching content from Prismic
var Prismic = require('prismic.io').Prismic;
var testRepo = 'https://some-repo.prismic.io/api';
var api;
Prismic.Api(testRepo, function(err, api) {
if (err) console.log(err);
// assumes a collection named 'content'
api.form('content').ref(api.master()).submit(function(err, docs) {
@jpotts
jpotts / create-content.js
Last active August 29, 2015 14:07
Create content using the contentful CM API
var contentful = require('contentful-management');
var spaceId = 'someSpaceId';
var accessToken = 'someAccessToken';
var contentTypeId = 'someContentTypeId';
var client = contentful.createClient({
space: spaceId,
accessToken: accessToken,
secure: true,
@jpotts
jpotts / fetch-content.js
Created October 6, 2014 22:32
Fetching all content of a certain type using Gitana for CloudCMS
var Gitana = require('gitana');
var repoId = 'someRepoId';
conn = Gitana.connect({
}, function(err) {
if (err) console.log(err);
});
conn.readRepository(repoId).then(function () {
@jpotts
jpotts / create-content.js
Last active August 29, 2015 14:07
Creating content in Cloud CMS using the Gitana JavaScript driver
var Gitana = require('gitana');
var repoId = 'someRepoId';
conn = Gitana.connect({
}, function(err) {
if (err) console.log(err);
});
conn.readRepository(repoId).then(function () {
@jpotts
jpotts / fetch-bookmark.js
Created November 2, 2014 03:51
Using the Prismic.io API to fetch the doc linked to a bookmark
var Prismic = require('prismic.io').Prismic;
var testRepo = 'https://your-repo.prismic.io/api';
Prismic.Api(testRepo, function(err, api) {
if (err) console.log(err);
var id = api.bookmarks['dealOfTheWeek'];
console.log('id: ' + id);
api.form('everything').ref(api.master()).query('[[:d = at(document.id, "' + id + '")]]').submit(function(err, docs) {
@jpotts
jpotts / blog-post.json
Created November 3, 2014 00:38
Snippet of prismic.io blog post document mask
{
"Blog Post" : {
"body" : {
"type" : "StructuredText",
"config" : {
"placeholder" : "Start writing your blog post here...",
"minHeight" : "400px",
"imageConstraint" : {
"width" : 640.0
}
@jpotts
jpotts / GetDocumentExample.java
Created November 25, 2014 04:53
Showing how to grab a document, either by ID or by path, from an Alfresco 5.0.a repository, even when the user does not have access to the enclosing folders
package com.alfresco.api.example;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import org.apache.chemistry.opencmis.client.api.Document;
import org.apache.chemistry.opencmis.client.api.Session;
public class GetDocumentExample extends BaseOnPremExample {