#!/usr/bin/perl -wT
#########################################################
# Muse
# A "Web of Content" Manager by Adrian P. Dunston
#
# This is a sort of dumbed down single user of the
# Everything Engine that Perlmonks runs on.
# (www.everydevel.com)
#
# Write different nodes or "musings" and link them
# together by surrounding certain words with [brackets].
# In the case of the last sentence, the word "brackets"
# links to the node of that title.
#########################################################
use strict;
use warnings;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
start();
sub start {
my $cgi = new CGI;
my $output;
my $node_text;
my $node = param("node");
my $text = param("text");
print $cgi->header;
# Untaint
($node) = $node =~ /([A-Za-z0-9 -_.,?]{1,30})/g;
# If text has been passed, put it into its node.
if ($text) {
open(NODE, ">data/$node.musing") or die "Couldn't open data/$n
+ode.musing for writing because $!";
print NODE $text;
close NODE;
}
# If the user wants to see a node, show it to him with a form for
+editing it.
if ($node) {
if (open(NODE, "data/$node.musing")) {
$node_text .= $_ while <NODE>;
$output = $node_text;
$output =~ s|\[(.+?)\]|<a href="muse.cgi?node=$1">$1</a>|g
+;
$output = "\n\n<table width=\"65\%\" style=\"margin-left:
+50\"><tr><td>\n" . $output . "</td></tr></table>\n\n";
} else {
$output = "There is currently no musing \"$node\". You ar
+e welcome to create your own.";
}
$output = "<html>\n<head><title>$node - Muse</title></head>\n<
+body>\n" .
"<b style=\"font-size: 18pt\">$node</b><br><br>$output\n<b
+r><br><br>\n";
$output .= '<form action="muse.cgi" method="post">';
$output .= "\nEdit the node:<br>\n<textarea name=\"text\" rows
+=\"5\" cols=\"50\">$node_text</textarea><br>\n";
$output .= "<input type=\"hidden\" name=\"node\" value=\"$node
+\">\n";
$output .= "<input type=\"submit\" value=\"Edit Musing\">\n</f
+orm>\n";
$output .= "<hr>\n";
$output .= '<form action="muse.cgi" method="post"><input type=
+"text" name="node"><input type="submit" value="New Musing"></form>';
$output .= '[ <a href="muse.cgi">Muse</a> ] ';
$output .= "</body>\n</html>";
# Otherwise, show him the list of nodes in the system.
} else {
my @file = <data/*.musing>;
foreach (@file) {
s|data/||; # Get rid of data/
s/\.musing//; # Get rid of .musing
$output .= "<li><a href=\"muse.cgi?node=$_\">$_</a></li>\n
+";
}
$output = "<html>\n<head><title>Muse</title></head>\n<body>\n<
+u><b style=\"font-size: 24pt\">MUSE</b></u><br><br>\n" .
"Musings: \n<ul>\n$output\n</ul>";
$output .= '<form action="muse.cgi" method="post"><input type=
+"text" name="node"><input type="submit" value="New Musing"></form>';
$output .= "</body>\n</html>";
}
## OUTPUT
print $output;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|