The easy Weblog and Wiki Software
[ start | index | login ]
start > mfranken > HTMLMacro

HTMLMacro

Created by mfranken. Last edited by DaveLevy, 115 days ago. Viewed 1,926 times. #14
[diff] [history] [edit] [rdf]
labels
attachments
HTMLMacro.jar (6605)
snipsnap.war (6751132)
I've created a HTMLMacro (as well as a simple ButtonMacro) that allows you to put arbitrary HTML code into your snips.

The >>attached war file contains these macros, it is based on 1.0b1-uttoxeter.

You use it like this:

{html}
Your <b>html</b> here.
{html}

The code is as follows:

package org.snipsnap.render.macro;

import java.io.IOException; import java.io.Writer;

import org.radeox.util.Encoder; import org.radeox.util.i18n.ResourceManager; import org.snipsnap.render.macro.parameter.SnipMacroParameter;

/** * Macro that renders HTML directly. * * @author mfranken */ public class HTMLMacro extends SnipMacro { public String getName() { return "html"; }

public String getDescription() { return ResourceManager.getString("i18n.messages", "macro.html.description"); }

/** * Writes out HTML code directly. * * Use as follows: <code>{html}code{html}</code> * * @see org.snipsnap.render.macro.SnipMacro#execute(java.io.Writer, org.snipsnap.render.macro.parameter.SnipMacroParameter) */ public void execute(Writer writer, SnipMacroParameter params) throws IOException {

if (params.getLength() == 0) { writer.write(Encoder.unescape(params.getContent())); return; } else { throw new IllegalArgumentException("Number of arguments does not match"); } } }

Make sure you add the following stuff to src/META-INF/services/org.radeox.macro.Macro

org.snipsnap.render.macro.HTMLMacro

and to your messages.properties, e.g. src/apps/default/WEB-INF/classes/i18n/message_en.properties this:

# HTML Macro
macro.html.description=Render any HTML directly.


jsawers here. I could not get it to work from the war file download. So I took the source code and packaged it up properly, so it can be dropped into any install like a regular macro. I ended up tweaking the package names, but the code is all mfranken. I attached HTMLMacro.jar so you can download it.

DaveLevy For users of the Java Server, the .jar need only be copied to the library directory named in the CLASSPATH.

9 comments (by GaryPaulson, mfranken, eidosabi, ryanv, jsawers, plawrey, DaveLevy) | post comment

What is SnipSnap?
SnipSnap is a free and easy to install weblog and wiki tool written in Java.

SnipSnap download
Current version: 1.0b3-uttoxeter
Try our >>Web Start Demo!

Resources

5567 Users and 13710 Snips. Installed 5 years and 311 days ago

Logged in Users: (2)
… and 13 Guests.

snipsnap-changed for older changes.

< May 2008 >
SunMonTueWedThuFriSat
123
45678910
11121314151617
18192021222324
25262728293031

snipsnap
Listed on BlogShares
XHTML 1.0 validated
CSS validated
RSS 2.0 validated
RSS Feed

pico-powered

Powered by SnipSnap 1.0b3-uttoxeter
YourKit >>Java Profiler

Fraunhofer FIRST

snipsnap.org | Copyright 2000-2006 Fraunhofer FIRST