Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

Scratchpads Revisited and some XML Node View Changes

by demerphq (Chancellor)
on Jun 13, 2004 at 22:41 UTC ( #366368=monkdiscuss: print w/ replies, xml ) Need Help??

A whole slew of new scratchpad features have been rolled out today, in addition to a hopefully useful XML feature. If I've done my job right you shouldn't have noticed much. But there is always the possibility of bugs lurking so please feel free to let me or pmdev know of any issues you find.

Scratchpad Changes:

The old scratchpads are now totally gone. This is good because it satisfies the initial intention, of lowering the cost of fetching user information on the site. Its also good because now its alot easier to handle the pads in a more flexible way. Its also good becuase it resolves some nits in the overall approach of supplying scratchpads only when a user wants them (an important objective as many of users are non participatory).

So what has really changed? Well scratchpads now have two parts. A private part for yourself only and a public part for others to see. The rendering logic for users viewing their own pads is a little lacking so expect improvements and please offer suggestions. Whats really changed is under the hood. The user table got a new column, called user_scratchpad which is now used to store the id of a users scratchpad if they have one. So XML heads will probably want to take advantage of this.

The other main change involved in this is that now Scratch Pad Viewer is a true proxy for handling nodes. This means that if a user who has no scratchpad wants to create it (a link is provided on their homenodes) go the Scratch Pad Viwer where the magic of creating a new pad is handled. This will work in XML as well, but more on that in a moment. Non owners wont see links to non existing scratchpads any more, and now the scratchpad viewer will tell you if the user has no pad instead of confusingly creating it on their behalf. If a user is allowed to edit a scratchpad then saying something like

/ +scratchpad_doctext=Public

will do the right thing regardless of whether they have a scratchpad or not. This should make writing clients that talk to PM easier.

XML Changes:

The changes to the XML interface are twofold. One relates to scratchpads so we will handle that first. There is a new "passthrough mechanism" in place for XML nodes. If you request a node with "displaytype=xml" and "passthrough=1" and the node is configured appropriately by the gods then page specific non standard XML will result. In the case of the Scratch Pad Viewer youll see the XML for the selected users scratchpad in XML. This means you can do a single step fetch from username to scratchpad contents in XML. Its even more useful because it couples with the new proxy behaviour such that if you do both for a new user you get the new pads id in the returned XML.

The second set of useful changes was originally to help synchronization between PM and the pmdev test enviornment. This is the addition of two flags to the node xml display mode. Each are provided by passing "xmlstyle=FLAG" in the query. One is "clean" which returns the contents of fields without adding trailing newlines to start tags which is nice if your parser doesnt agree that these newlines should be ignored (like the parse used by the synchonization code). The second is "flat" which instead of returning useful fields in "data" element wrapped around multiple "field" elements (with other useful stuff at the root level), it will return one tag per field, with the tag named after the field. An attribute "field_name" will hold the true value of the DB field involved, and is normally the same as the name of the tag. (Flat implies and overrides clean.) Thus for de-merphq's scratchpad we have the "flat" and "normal" looks: (this is pasted from my browser the newlines are not as might be expected)

<?xml version="1.0" encoding="ISO-8859-1" ?> <node id="366276" title="flux8's scratchpad" created="2004-06-13 13: +28:52" updated=""> <type id="182711">scratchpad</type> <author id="357600">flux8</author> <reputation field_name="reputation">0</reputation> <doctext field_name="doctext" /> <privatetext field_name="privatetext" /> </node>
<?xml version="1.0" encoding="ISO-8859-1" ?> <node id="366276" title="flux8's scratchpad" created="2004-06-13 13:2 +8:52" updated=""> <type id="182711">scratchpad</type> <author id="357600">flux8</author> <data> <field name="reputation">0</field> <field name="doctext" /> <field name="privatetext" /> </data> </node>

This makes it much easier to use certain parsers. Especially the version of XML::Simple in use on the site. For now these XML changes are restricted to the displaytype=xml mode, but its likely that ill port them to the other xml tickers if it makes sense to do so. Somewhen anyway :-)

Anway, I hope people enjoy and find this stuff useful.


    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi

Comment on Scratchpads Revisited and some XML Node View Changes
Select or Download Code
Re: Scratchpads Revisited and some XML Node View Changes
by ggg (Scribe) on Jun 14, 2004 at 03:41 UTC
    Thank you for all your work on this, demerphq.
Re: Scratchpads Revisited and some XML Node View Changes
by dfaure (Chaplain) on Jun 14, 2004 at 07:36 UTC

    You did it well, thanks...

    HTH, Dominique
Re: Scratchpads Revisited and some XML Node View Changes
by calin (Deacon) on Jun 14, 2004 at 13:45 UTC

    The "add to scratchpad" link in "Personal Nodelet" currently adds the link to the current node to the public scratchpad. I would prefer to add it to the private one (I use it mainly as a bookmarking tool).

    Anyway, the new scratchpad stuff is neat! ++

      We expect to rollout a way to do what you want soon. I believe that ysth is currently working on it. And thanks. :-)


        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi

Re: Scratchpads Revisited and some XML Node View Changes (personal nodelet)
by tye (Cardinal) on Jun 14, 2004 at 21:21 UTC

    It looks like people who were using the "Personal Nodelet" to record a list of bookmarks on their private scratchpad have lost this ability (and may be adding these to their public scratchpad if they haven't been paying attention).

    My idea for how to deal with this is to have the Personal Nodelet bottom links change from (with useless links for the sake of making it look the same):

    add "The title of this node"
    add to scratchpad

    To something like:

    foo is cool
    bar is cooler

    Add "The title of this node" to public / private pad or nodelet.

    except w/o the blank line (that I have because I'm not allowed to say <div align="right"> so I used <p align="right">).

    - tye        

      This is pretty much done now. I went with a slightly different spacing as i thought the one you proposed didnt work so well with longer titles.


        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: monkdiscuss [id://366368]
Approved by Old_Gray_Bear
Front-paged by Old_Gray_Bear
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (12)
As of 2014-07-24 09:38 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (158 votes), past polls