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
/*
* 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.Iterator;
import java.util.Map;


/**
* Plugin that adds a SocialSite OpenSocial Gadget to JSPWiki.
* <pre>
* [{SocialSiteAddGadget spec='' removable='' etc. etc.}]
* </pre>
* @author Dave Johnson
*/
public class SocialSiteAddGadget implements WikiPlugin {

public String execute(WikiContext context, Map params) throws PluginException {
StringBuilder sb = new StringBuilder();
try {
sb.append("<script type='text/javascript'>");
sb.append(" socialsite.addGadget({");
int count = 0;
for (Iterator it = params.keySet().iterator(); it.hasNext();) {
String key = (String)it.next();
if (key.startsWith("_")) continue;
String value = (String)params.get(key);
if (count > 0) sb.append(",");
sb.append("'").append(key.toString()).append("':'").append(value.toString()).append("'");
count++;
}
sb.append(" });");
sb.append("</script>");
} catch (Exception e) {
e.printStackTrace();
}
return sb.toString();
}
}

Change log

r9 by snoopdave on Mar 22, 2009   Diff
fixing  malformed HTML
Go to: 
Project members, sign in to write a code review

Older revisions

r8 by snoopdave on Mar 22, 2009   Diff
testing 1 2 3
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: 1939 bytes, 56 lines
Powered by Google Project Hosting