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,925 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.

Icon-Comment jsawers, 3 years and 123 days ago. Icon-Permalink

This is great, I was thinking of writing the same thing myself. I created a JAR file for easier installing

Icon-Comment mfranken, 3 years and 123 days ago. Icon-Permalink

You're welcome!

Icon-Comment plawrey, 3 years and 78 days ago. Icon-Permalink

Works well. Excelent.

Icon-Comment ryanv, 3 years and 66 days ago. Icon-Permalink

I'm running 1.0b1 binary dist, and I just copied the HTMLMacro.jar file into the /lib directory of snipsnap. However when I add the {html} tags on my snip they aren't recognized. Am I missing something or should I just be able to drop the jar file in, bounce the app, and go?

Icon-Comment jsawers, 3 years and 65 days ago. Icon-Permalink

that should be all that is required. when you go to the "snipsnap-help" snip, it lists all installed macros, is it listed there?

Icon-Comment GaryPaulson, 3 years and 62 days ago. Icon-Permalink

OK, I, a noob, just figure out how to make it work - and for my fellow noobs here is what I did - probably obvious to everyone else:

1) Download the file labled HTMLmacro.jar - it will download as a .zip file - just rename it to .jar

2) Put this file in the 'right' lib directory not the snip snap source code directory but the 'working' directory - on my machine it is:
C:/Documents and Settings/Garyapplications/_8668_/webapp/WEB-INF/lib

Now it works perfectly.

Icon-Comment eidosabi, 2 years and 125 days ago. Icon-Permalink

I followed GaryPaulson's instructions for noobs, with no success. I'm on 1.0b2-uttoxeter. Any suggestions?

Icon-Comment eidosabi, 2 years and 125 days ago. Icon-Permalink

Typical noob, now I've got it working. The trick - (I'm on a Mac) I had to kill Terminal, thus taking the SnipSnapServer offline, and then restart it (cd /snipsnap-1.0b2-uttoxeter/ -> ./run.sh).

Icon-Comment DaveLevy, 115 days ago. Icon-Permalink

I wish to echo Gary's comments, I have just done this. The complciations required of earlier versions of Snipsnap are no longer required.

Just down load the .jar to your instance CLASSPATH lib, and restart the server. I used V1.0b3, Java Server. For more, see also

>>http://davelevy.dyndns.info/snipsnap/space/Dave/Developing+Snipsnap

although there isn't very much more

Please login to post a 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 5 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