#!/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/$node.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 ; $output = $node_text; $output =~ s|\[(.+?)\]|$1|g; $output = "\n\n
\n" . $output . "
\n\n"; } else { $output = "There is currently no musing \"$node\". You are welcome to create your own."; } $output = "\n$node - Muse\n\n" . "$node

$output\n


\n"; $output .= '
'; $output .= "\nEdit the node:
\n
\n"; $output .= "\n"; $output .= "\n
\n"; $output .= "
\n"; $output .= '
'; $output .= '[ Muse ] '; $output .= "\n"; # Otherwise, show him the list of nodes in the system. } else { my @file = ; foreach (@file) { s|data/||; # Get rid of data/ s/\.musing//; # Get rid of .musing $output .= "
  • $_
  • \n"; } $output = "\nMuse\n\nMUSE

    \n" . "Musings: \n"; $output .= '
    '; $output .= "\n"; } ## OUTPUT print $output; }