Skip to content

Instantly share code, notes, and snippets.

View vmassol's full-sized avatar

Vincent Massol vmassol

View GitHub Profile
@vmassol
vmassol / gist:1255867
Created October 1, 2011 10:45
Docbook parsing with XWiki Rendering using the Doxia bridge
Index: xwiki-rendering/xwiki-rendering-syntaxes/xwiki-rendering-syntax-doxia/pom.xml
===================================================================
--- xwiki-rendering/xwiki-rendering-syntaxes/xwiki-rendering-syntax-doxia/pom.xml (revision 5c84b2cc2f38e6f22c74a4e2133dae1a43bc7ff0)
+++ xwiki-rendering/xwiki-rendering-syntaxes/xwiki-rendering-syntax-doxia/pom.xml (revision )
@@ -45,6 +45,24 @@
</exclusion>
</exclusions>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.doxia</groupId>
@vmassol
vmassol / Main.ExternalLinksJSON
Created October 31, 2011 18:13
JSON Generation for External Links
{{velocity}}
#if("$!{request.xpage}" == 'plain')
$response.setContentType('application/json')
#end
##==============================
## Offset = item # at which to start displaying data
##==============================
#set($offset = $util.parseInt($request.get('offset')))
## offset starts from 0 in velocity and 1 in javascript
#set($offset = $offset - 1)
@vmassol
vmassol / Main.ExternalLinks
Created October 31, 2011 18:13
Livetable for External Links
@vmassol
vmassol / gist:1328288
Created October 31, 2011 18:14
Old way without livetable to display external link status
{{velocity}}
#set ($states = $services.linkchecker.getLinkStates())
#foreach ($linkReference in $states.keySet())
* $linkReference (((
#set ($contentReferences = $states.get($linkReference))
|=Page|=State|=Last Checked time
#foreach ($contentReference in $contentReferences.keySet())
#if ($contentReference != $doc.getPrefixedFullName())
#set ($state = $contentReferences.get($contentReference))
@vmassol
vmassol / gist:1638857
Created January 19, 2012 08:55
Vagrant lucid32 issue
vmassol@vincent-massols-macbook-pro ~ $ vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
[vagrant] Downloading with Vagrant::Downloaders::HTTP...
[vagrant] Downloading box: http://files.vagrantup.com/lucid32.box
[vagrant] Extracting box...
[vagrant] Verifying box...
[vagrant] Cleaning up downloaded box...
/Library/Ruby/Gems/1.8/gems/vagrant-0.9.1/lib/vagrant/driver/virtualbox.rb:117:in `read_version': private method `split' called for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/vagrant-0.9.1/lib/vagrant/driver/virtualbox.rb:36:in `initialize'
from /Library/Ruby/Gems/1.8/gems/vagrant-0.9.1/lib/vagrant/action/box/verify.rb:13:in `new'
from /Library/Ruby/Gems/1.8/gems/vagrant-0.9.1/lib/vagrant/action/box/verify.rb:13:in `call'
@vmassol
vmassol / gist:2027780
Created March 13, 2012 09:15
Add ability to execute server side code from a client side UI test
To be added to TestUtil:
/**
* Sometimes it's useful to execute some script on the server to get information back to the client side. We do
* this by using the preview action on a temporary wiki page, passing the specified content.
*
* @param content the content to execute in a page
* @return the result of the page execution with the page rendered in plain mode
*/
@vmassol
vmassol / gist:2044262
Created March 15, 2012 13:43
Execute As User
@Override
public void executeAsUser(DocumentReference executingUserReference, DocumentReference securityDocumentReference,
Runnable runnable) throws IRCBotException
{
XWikiContext xwikiContext = getXWikiContext();
DocumentReference currentUserReference = xwikiContext.getUserReference();
XWikiDocument currentDocument = xwikiContext.getDoc();
try {
// Set executing user in the XWiki Context
xwikiContext.setUserReference(executingUserReference);
@vmassol
vmassol / gist:2158328
Created March 22, 2012 13:26
Ignore Browser with Regex
/*
* See the NOTICE file distributed with this work for additional
* information regarding copyright ownership.
*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
@vmassol
vmassol / gist:2160618
Created March 22, 2012 17:38
Printer
private String append(Object... objects)
{
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < objects.length; i += 2) {
String key = (String) objects[i];
Object value = objects[i + 1];
if (value instanceof List) {
appendList(buffer, key, (List) value);
} else {
appendLiteral(buffer, key, value);
@vmassol
vmassol / gist:2164507
Created March 22, 2012 21:00
Printer with ToStringBuilder
private class XWikiStyle extends StandardToStringStyle
{
public XWikiStyle()
{
super();
setUseClassName(false);
setUseIdentityHashCode(false);
setContentStart("");
setContentEnd("]");
setFieldNameValueSeparator(" = [");