Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

First, here is the updated (again) code for the Free Nodelet:

[% my $html = $VARS->{freenodelet} || 'Visit [Free Nodelet Settings]' .' to enter HTML to go here.'; $html= htmlcode( 'expandfreenodelet','', $html ); return $html; %]

Next, is the expandfreenodelet code that gets used above and below:

my( $html, $just )= @_; my $AUTHOR= getNodeById( $NODE->{author_user} ); my %var= ( id => $NODE->{node_id}, title => $NODE->{title}, author_id => $AUTHOR->{node_id}, author_name => $AUTHOR->{title}, author_title => $AUTHOR->{title}, user_id => $USER->{node_id}, user_name => $USER->{title}, user_title => $USER->{title}, ); # root_id root_title sect_id sect_title $html =~ s{`([\[\]]|`+|(\w+)([%&]?)`?|.)}{ my $s= $1; if( '[' eq $s ) { $just ? '[' : '`{'; } elsif( ']' eq $s ) { $just ? ']' : '`}'; } elsif( defined $2 ) { my( $key, $suff )= ( $2, $3 ); my $val; if( $key =~ /^_./ ) { $val= $q->param($key); $val= $q->param( substr($key,1) ) if ! defined $val; } else { $val= $var{ lc $key }; } if( ! defined $val ) { $val= "`$key$suff`" } elsif( $suff eq '%' ) { $val= $q->escape($val); } elsif( $suff eq '&' ) { $val= $q->escapeHTML($val); } $val; } elsif( $s =~ /^`/ ) { $just ? $s : '`'.$s; } else { $just ? '`'.$s : '``'.$s; } }seg; return $html if $just; $html =~ s{(<!--.*?-->)|\[([^\[\]]{1,4096})\]}{ $1 ? $1 : handleLinks($2) }seg; $html =~ s{`([{}]|`+|.)}{ my $s= $1; if( '{' eq $s ) { '['; } elsif( '}' eq $s ) { ']'; } elsif( $s =~ /^`/ ) { $s; } else { '`'.$s; } }seg; return $html;

Finally, here is the _freer opcode:

my $want= ($q->param("at"))[-1]; my $html= $VARS->{freenodelet}; my $update= 0; $html =~ s{(<!--(\w+-(?!->))?(.*?)(-\w+)?-->)}{ my( $cmnt, $pre, $mid, $post )= ( $1, $2, $3, $4 ); my $found= $pre || $post || ''; $found =~ s/-//; if( $found ne $want ) { $cmnt; } else { my $add= htmlcode( 'expandfreenodelet','', $mid, 1 ); $update++; $pre ? $add . $cmnt : $cmnt . $add; } }ges; # Everything::printLog( "Expanding -$want- in $USER->{title}'s freenod +elet: $update updates$/" ); $VARS->{freenodelet}= $html if $update;

- tye        


In reply to Re: Free Nodelet gets templating features (the code) by tye
in thread Free Nodelet gets templating features by tye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (7)
    As of 2014-07-26 15:16 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (178 votes), past polls