Friday, 8 July 2011

Adding accessibility 'skip to' links

<div id="accessibility">
<a href="#skiptonavigation" accesskey="n">Skip to navigation</a>
<a href="#skiptocontent" accesskey="c">Skip to content</a>
</div>

<a name="skiptocontent"></a>


#accessibility {display: absolute; }
#accessibility a
{
position:absolute;
left:-10000px;
top:auto;
width:1px;
height:1px;
overflow:hidden;
}
#accessibility a:focus
{
position:static;
width:auto;
height:auto;
}

from http://webaim.org/techniques/css/invisiblecontent/

Tuesday, 5 July 2011

Looping through the children of a specified node

Here is a JSP to dump out the child nodes of a specified parent node, & the properties of the child nodes.


<%request.setAttribute("silentAuthor", new Boolean(true));%><%
%><%@include file="/libs/foundation/global.jsp"%><%
response.setContentType("text");
response.setCharacterEncoding("utf-8");
%><%@ page import="java.util.Iterator,
com.day.cq.wcm.foundation.Paragraph,
com.day.cq.wcm.foundation.ParagraphSystem,
com.day.text.Text,
com.day.cq.tagging.Tag,
com.day.cq.wcm.api.PageFilter,
com.day.cq.tagging.TagManager,
com.day.cq.wcm.api.components.IncludeOptions,
java.util.Calendar,
java.util.Collection,
java.util.regex.*,
java.util.Map,
org.apache.sling.api.resource.ResourceUtil,
org.apache.commons.lang.StringUtils,
org.apache.commons.lang.StringEscapeUtils"%><%

//slingResponse.setContentType("application/xml;charset=utf-8");
slingResponse.setCharacterEncoding("utf-8");

String fullRecipeList = slingRequest.getParameter("pathsList");
if (!StringUtils.isEmpty(fullRecipeList))
{
String[] recipeList = fullRecipeList.split("\n");


for (int recipeCount=0; recipeCount < recipeList.length; recipeCount++)
{
if (StringUtils.isEmpty(recipeList[recipeCount].trim()))
{
continue;
}

// Strip off everything after the ".html"
int positionOfHtml = recipeList[recipeCount].indexOf(".html");
String currentRecipePath = "";
if (positionOfHtml > 0)
{
currentRecipePath = recipeList[recipeCount].substring(0, positionOfHtml);
}
else
{
currentRecipePath = recipeList[recipeCount];
}

Resource resRootPage = slingRequest.getResourceResolver().resolve(currentRecipePath);

if (resRootPage == null)
{
continue;
}

Iterator children = ResourceUtil.listChildren(resRootPage);

while (children.hasNext())
{
Resource resourcePage2 = children.next();

if (resourcePage2.getPath().indexOf("jcr:content") > -1)
{
continue;
}

Node n = resourcePage2.adaptTo(Node.class);
if (n == null)
{
continue;
}
%>
<%= n.getPath() %> <%
PropertyIterator resProps = n.getProperties();
if (resProps == null)
{
continue;
}

long nProps = resProps.getSize();
for (int i = 0; i < nProps; i++)
{
Property p = resProps.nextProperty();
if (!p.getDefinition().isMultiple())
{
%> <%= p.getName() %> <%= p.getString() %> <%
}
}
}
}
}
%>

Friday, 1 July 2011

Components need dialogs

Weird behaviour. I can't get a component to appear in the design view unless it has a dialog associated with it.

Wednesday, 22 June 2011

Accessing DAM Asset meta information

Here's some cool information from AK:-

To get the metadata in a simplefashion, you can use the standard sling json representation:
http://localhost:4502//jcr:content/metadata.infinity.json

For example:
http://localhost:4502/content/dam/geometrixx/banners/dsc.jpg/jcr:content/metadata.infinity.json

Docs on metadata:
http://dev.day.com/content/docs/en/cq/current/dam/metadata_for_digitalasset
management.html


There is also the Sharepoint connector for JCR as a separate product,
which might be useful if there is a Sharepoint involved:
http://dev.day.com/content/docs/en/crx/connectors/sharepoint/current.html

If you need further custom code on the CQ side to provide e.g. new
servlets / JSPs that expose dam assets in a custom way, here are some more
links:

General docs:
http://dev.day.com/content/docs/en/cq/current.html#Working%20with%20Digital
%20Assets%20in%20CQ%20DAM


CQ DAM API (Java):
http://dev.day.com/content/docs/en/cq/current/javadoc/com/day/cq/dam/api/pa
ckage-summary.html


Some more (developer) info on extending DAM:
http://dev.day.com/content/docs/en/cq/current/dam/customizing_and_extending
cq5dam.html


Regards,
Alex

Wednesday, 25 May 2011

w3c validation

I shouldn't need reminding about this.

Today, a tester showed me the validation report on a site I've been working on. Ouch!

Check your html here: http://validator.w3.org/

Add this as unit testing in the dev process.

Wednesday, 18 May 2011

Performance list

When approaching a new website launch, make sure you run through the Day performance & security checks.

http://dev.day.com/content/docs/en/cq/current/deploying/performance.html

CRX hotfixes

When approaching any new project, always ensure you have the CRX hotfixes installed. CRX v2.1.0.10 at least (although, there is 2.1.0.13 available).

NB, CRX hotfixes are cumulative - so you can just installv the latest one.