Skip to content

Instantly share code, notes, and snippets.

View trieloff's full-sized avatar
🏠
Working from home

Lars Trieloff trieloff

🏠
Working from home
View GitHub Profile
var request = require('request-promise');
var github = {
token: null,
getUser: function() {
return request({
"method":"GET",
"uri": "https://api.github.com/user",
"json": true,
var github = {
getUserReposUrl: function(user) {
return user.repos_url;
}
};
function main(params) {
github.token = params.token;
return github.getUser()
.then(github.getUserReposUrl);
var github = {
getUserRepos: function(uri, repos) {
return request({
"method": "GET",
"uri": uri,
"json": true,
"resolveWithFullResponse": true,
"headers": {
"Authorization": "Bearer " + github.token,
"User-Agent": "My little demo app"
var github = {
isPublic: function(repo) {
return !repo.private;
},
isOriginal: function(repo) {
return !repo.fork;
},
licenseUrl: function(repo) {
var github = {
checkLicense: function(uri) {
return request({
"method": "GET",
"uri": uri,
"json": true,
"headers": {
"Authorization": "Bearer " + github.token,
"User-Agent": "My little demo app"
}
var request = require('request-promise');
var github = {
token: null,
getUser: function() {
return request({
"method":"GET",
"uri": "https://api.github.com/user",
"json": true,
@trieloff
trieloff / cq_dialog.xml
Created April 11, 2017 09:59
A simple AEM dialog definition
<cq:dialog jcr:primaryType="nt:unstructured" jcr:title="Embed" sling:resourceType="cq/gui/components/authoring/dialog">
<content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<url
jcr:primaryType="nt:unstructured"
fieldDescription="URL of a page that supports oEmbed auto-discovery (e.g. YouTube)"
fieldLabel="Web page address"
name="./webpage"
@trieloff
trieloff / component.jsp
Created April 11, 2017 10:04
How to get an edit configuration property in JSP
<%@include file="/libs/foundation/global.jsp"%><%
%><%
String url = properties.get("webpage", String.class);
%>
@trieloff
trieloff / design_dialog.xml
Created April 11, 2017 10:24
Defining a simple design dialog for configuring a component's content policies
<cq:design_dialog jcr:primaryType="nt:unstructured" jcr:title="Embed" sling:resourceType="cq/gui/components/authoring/dialog" jcr:description="Content policy for embedding content">
<content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<tabs jcr:primaryType="nt:unstructured" maximized="true" sling:resourceType="granite/ui/components/coral/foundation/tabs">
<items jcr:primaryType="nt:unstructured">
<properties jcr:primaryType="nt:unstructured" jcr:title="Main" margin="true" sling:resourceType="granite/ui/components/coral/foundation/fixedcolumns">
<items jcr:primaryType="nt:unstructured">
<content jcr:primaryType="nt:unstructured" margin="false" sling:resourceType="granite/ui/components/coral/foundation/container">
<items jcr:primaryType="nt:unstructured">
<allowedSites jcr:primaryType="nt:unstructured" fieldDescription="I
@trieloff
trieloff / component_with_policy.jsp
Created April 11, 2017 10:28
Getting a content policy's property in JSP
<%@include file="/libs/foundation/global.jsp"%><%
String[] whitelist = currentStyle.get("allowedSites", new String[0]);
%>