Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Comment on

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

I've hacked together some quick enhancements for the Free Nodelet. Go to Nodelet Settings and enable the Free Nodelet if you haven't already.

The main features are:

  • No longer foul up square brackets in JavaScript inside HTML comments.
  • A way to get JavaScript square brackets even outside of HTML comments.
  • A way to "Add this node" similar to what the "Personal Nodelet" has, but more powerful.
  • Simple templates for making interesting links like "How AnonyMonk sees this node" or "This node's author's most-recent write-ups".

This enhancement should be considered experimental, as it was a quick hack and a much better design may be proposed after we get more experience with it. But I wanted to actually deploy it so anyone could play with it in order to encourage feedback on how to improve it. So, please try it out, but realize that we might announce major changes sooner or later that may break some of what you write.

All of the features (except the first) are provided by a simple templating system that uses ` (backtick) as the only metacharacter. This was chosen because it is a character that is not useful in JavaScript nor HTML.

Only in the Free Nodelet, `id` gets replaced with the current node's node_id. `title` gets replaced with the current node's title. If using the title in HTML (almost always), use `title&` instead to get the title with &, <, >, [, and ] characters escaped as HTML entities. To use a title in a URL, use `title%` to have it URL-escaped (using %xx).

The following items get expanded if put between a pair of backticks (`) in the Free Nodelet:

  • id - current node's ID
  • title - current node's title
  • author_id - current node's author's user ID number
  • author_name - current node's author's name
  • author_title - same as author_name ("title" of their home node)
  • user_id - your ID (useful for writing macros that another user can paste into their nodelet)
  • user_name - your monk name
  • user_title - same as user_name
  • _arg - the value of the CGI parameter '_arg' or 'arg' ("arg" can be anything, but the leading _ is required).
Each of the above can have a & or % on the end (just before the closing backtick). Other items like root_id, root_title, sect_id, and sect_title may be added in future. You don't need to use & nor % on *id items, since they expand to just digits and digits don't need to be escaped.

The above expansions happen before [...] links are processed, so you can make a link like [id://`id`|Bookmark node `id`].

The following substitutions are also made:

  • `[ becomes [
  • `] becomes ]
  • `` becomes `
  • ``` becomes ``
  • ```` becomes ```
  • etc.
Note that `[ gets expanded in such a way that the resulting [ will not be processed as a PerlMonk's link specification. So the resulting [ can be part of some JavaScript. Inside of HTML comments, either `[ or just [ can be used.

Note that "HTML comments" at PerlMonks simply start with "<!--" and simply end with "-->". In real HTML comments, whitespace is allowed inside these start/end sequences and occurrences of "--" inside the comments have special meaning. Since the Free Nodelet's HTML is not filtered by PerlMonks, if you put "--" inside your HTML comments there, you might "confuse" your browser, but PerlMonks doesn't care about any appearances of "--" in your HTML comments when it comes to deciding where to not process [...] as a link.

A `_foo` gets expanded to whatever the _foo parameter was set to in the URL (or POST) used to fetch the page, such as via ;_foo=bar. If the no "_foo" parameter exists, then the value of the "foo" parameter is used instead. If not even a "foo" parameter exists, then the item is left as `_foo`, just as is done with any unrecognized template-like item.

Below I'll include a couple of annoted examples of how to use these features and even the source code I used to implement the features. I look forward to your feedback.

- tye        

In reply to Free Nodelet gets templating features by tye

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others romping around the Monastery: (2)
    As of 2018-05-26 01:04 GMT
    Find Nodes?
      Voting Booth?