My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* Copyright 2009 David M. Johnson.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.rollerweblogger.plugins;

import com.ecyrd.jspwiki.WikiContext;
import com.ecyrd.jspwiki.plugin.PluginException;
import com.ecyrd.jspwiki.plugin.WikiPlugin;
import java.util.Map;

/**
* Plugin that establishes SocialSite context for page owned by group.
* <pre>
* [{SocialSiteGroupContext group='' consumerUri="" authUri=''}]
* </pre>
* @author Dave Johnson
*/
public class SocialSiteGroupContext implements WikiPlugin {

public String execute(WikiContext context, Map params) throws PluginException {

String group = (String)params.get("group");
String consumerUri = (String)params.get("consumerUri");
String authUri = (String)params.get("authUri");

if (context.getWikiSession().isAuthenticated()) {
authUri += "?viewer=" + context.getWikiSession().getUserPrincipal().getName();
}

StringBuilder sb = new StringBuilder();
sb.append("<script type='text/javascript' src='").append(consumerUri).append("'></script>");
sb.append("<script type='text/javascript'>");
sb.append(" socialsite.setContext({");
sb.append(" 'attributes': {");
sb.append(" 'groupHandle': '").append(group).append("'");
sb.append(" },");
sb.append(" 'delegate': {");
sb.append(" 'method': 'GET',");
sb.append(" 'url': '").append(authUri).append("',");
sb.append(" 'headers': {");
sb.append(" 'cookie': document.cookie");
sb.append(" }");
sb.append(" }");
sb.append(" });");
sb.append("</script>");

return sb.toString();
}
}

Change log

r8 by snoopdave on Mar 22, 2009   Diff
testing 1 2 3
Go to: 
Project members, sign in to write a code review

Older revisions

r7 by snoopdave on Mar 18, 2009   Diff
Correct license header
r2 by snoopdave on Mar 17, 2009   Diff
initial commit
All revisions of this file

File info

Size: 2259 bytes, 62 lines
Powered by Google Project Hosting