From nzskiwi at gmail.com Mon Sep 1 03:05:33 2014 From: nzskiwi at gmail.com (Simon) Date: Mon, 1 Sep 2014 20:05:33 +1200 Subject: [pmwiki-devel] Selecting random images, then displaying images in name order In-Reply-To: References: Message-ID: This works really well. Thanks again, rolling it out to all my websites On 26 August 2014 20:31, Simon wrote: > You are a star, that is really great. > > cheers to you Petko from 41.3 degrees south > > thanks, SImon > > > On 26 August 2014 01:37, Petko Yotov <5ko at 5ko.fr> wrote: > >> I have released a new version of Thumblist which includes the "order2=" >> parameter which reorders the list after a sample is extracted with "count=". >> >> Petko >> >> >> Simon writes: >> >>> I use Thumblist in many places. >>> >>> Petko clarified my (mis)understanding of the order parameter in pagelist >>> and its implementation in the recipe. (thanks) >>> >>> What I'd like to do is use the count and the order=random parameters to >>> select a subset of photos from a gallery, and then display them in name >>> order. >>> >>> Any suggestions of how to achieve this would be much appreciated >>> >> >> >> _______________________________________________ >> pmwiki-devel mailing list >> pmwiki-devel at pmichaud.com >> http://www.pmichaud.com/mailman/listinfo/pmwiki-devel >> > > > > -- > ____ > http://kiwiwiki.co.nz > -- ____ http://kiwiwiki.co.nz -------------- next part -------------- An HTML attachment was scrubbed... URL: From randy at brownragfilms.com Fri Sep 19 01:31:47 2014 From: randy at brownragfilms.com (Randy Brown) Date: Fri, 19 Sep 2014 01:31:47 -0500 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript Message-ID: I would appreciate help from someone who knows Javascript (which I don't). I'm creating a GUIEdit button that adds a markup expression containing a random number and text containing the same number. If I select in my edit form: My text and then click my guiedit button, I want a result like this: {(mymarkupexpression 2 "My text")} The above number is 2 Here's approximately what I've written to do this. Unfortunately, what I wrote uses the same number for each page load rather than for each button click. I want the number to change with each button click: $num = rand ( 1, 1000 ); SDVA($GUIButtons, array( 'mybutton' => array(8000, "{(mymarkupexpression ".$num." "", "")}\\nThe above number is ".$num."\\n", '$[Default text if none selected]', '$GUIButtonDirUrlFmt/mybuttonicon.png"$[DoXYZ]"','') )); $HTMLHeaderFmt['DoXYZ']= << EOF; Thanks, Randy -------------- next part -------------- An HTML attachment was scrubbed... URL: From pbowers at pobox.com Fri Sep 19 04:37:13 2014 From: pbowers at pobox.com (Peter Bowers) Date: Fri, 19 Sep 2014 11:37:13 +0200 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: On Fri, Sep 19, 2014 at 8:31 AM, Randy Brown wrote: > $num = rand ( 1, 1000 ); > SDVA($GUIButtons, array( > 'mybutton' => array(8000, "{(mymarkupexpression ".$num." "", > "")}\\nThe above number is ".$num."\\n", '$[Default text if none > selected]', > '$GUIButtonDirUrlFmt/mybuttonicon.png"$[DoXYZ]"','') > )); > $HTMLHeaderFmt['DoXYZ']= << > > EOF; > I don't think there's an easily configurable way to do this (i.e., nothing as simple as adding something to $GUIButtons - insButton() doesn't support executable javascript code due to quoting). However, in the spirit of fairly messy code that seems to work, try this in config.php: ===(snip)=== Markup('e_guibuttons', 'directives', '/\\(:e_guibuttons:\\)/e', "Keep(FmtPageName(GUIButtonCode(\$pagename), \$pagename).'')"); SDVA($HTMLHeaderFmt, array('guiedit2' => "\n")); ===(snip)=== It basically overrides the e_guibuttons markup so it will add your special button immediately after the rest of the GUI buttons. Then it defines a short javascript with a function to insert the button and another function to calculate the random number and construct your text. Note that I've hardcoded the random number to be between 1 and 10, hardcoded the access key to r, hardcoded the button to the imaginative text of "asdf", etc - it's messy but should get you 90% of the way there. -Peter -------------- next part -------------- An HTML attachment was scrubbed... URL: From 5ko at 5ko.fr Fri Sep 19 18:38:53 2014 From: 5ko at 5ko.fr (Petko Yotov) Date: Sat, 20 Sep 2014 01:38:53 +0200 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: See the page http://www.pmwiki.org/wiki/Test/GUIButtons?action=edit and the last button there "Test JS". You can insert any HTML in the GUI Edit toolbar. If the fourth element of the array starts with "<", it is inserted as-is, without relying on the function insButton(). So, we define the button in a local config file: $GUIButtons['test-js'] = array(5000, '', '', 'Test-JS', ""); instead of "" . The onclick part is important, when a user clicks on the button, it will fire your custom function. Your custom function can be defined in a javascript included by the skin, or even in the same config file: $HTMLFooterFmt['test-js'] = << function MyFunc(){ var r = Math.round(Math.random()*1000); insMarkup( "{(mymarkupexpression "+r+" \\"", "\\")}\\nThe above number is "+r+"\\n", "Default text if none selected"); } EOF; This custom function creates a random number between 0 and 1000, then calls insMarkup() with the constructed strings to be inserted at the position of the cursor. Hope this helps. Petko On 19.09.2014 08:31, Randy Brown wrote: > I would appreciate help from someone who knows Javascript (which I > don't). > > I'm creating a GUIEdit button that adds a markup expression containing > a random number and text containing the same number. > > If I select in my edit form: > > My text > > and then click my guiedit button, I want a result like this: > > {(mymarkupexpression 2 "My text")} > The above number is 2 > > Here's approximately what I've written to do this. Unfortunately, what > I wrote uses the same number for each page load rather than for each > button click. I want the number to change with each button click: > > $num = rand ( 1, 1000 ); > SDVA($GUIButtons, array( > 'mybutton' => array(8000, "{(mymarkupexpression ".$num." "", > "")}\nThe above number is ".$num."\n [1]", '$[Default text if > none selected]', > '$GUIButtonDirUrlFmt/mybuttonicon.png"$[DoXYZ]"','') > )); > $HTMLHeaderFmt['DoXYZ']= << > > EOF; > > Thanks, > > Randy > > Links: > ------ > [1] smb://n > > _______________________________________________ > pmwiki-devel mailing list > pmwiki-devel at pmichaud.com > http://www.pmichaud.com/mailman/listinfo/pmwiki-devel From randy at brownragfilms.com Fri Sep 19 14:49:31 2014 From: randy at brownragfilms.com (Randy Brown) Date: Fri, 19 Sep 2014 14:49:31 -0500 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: <132A5C11-87B0-4DDA-95F2-B37A56BAE1A5@brownragfilms.com> Thanks, Peter. It would be much cleaner if escapes could be defined or if there could be some other way to get around this problem. Buttons that allow interesting javascript would let us create buttons to put divs or conditionals with matching numbers into the markup. Just a thought for the developers. Maybe this should be a PITS entry. Randy On Sep 19, 2014, at 4:37 AM, Peter Bowers wrote: > I don't think there's an easily configurable way to do this (i.e., nothing as simple as adding something to $GUIButtons - insButton() doesn't support executable javascript code due to quoting). However, in the spirit of fairly messy code that seems to work, try this in config.php: From randy at brownragfilms.com Sat Sep 20 14:46:16 2014 From: randy at brownragfilms.com (Randy Brown) Date: Sat, 20 Sep 2014 14:46:16 -0500 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: This works., thank you! One problem: The img code you suggested doesn't find my icon. If I use both buttons, my previous code's button shows its icon, while the new code shows an icon-not-found image. Perhaps this is related to doing this outside of SDVA? I don't know how to fix it. Randy On Sep 19, 2014, at 6:38 PM, Petko Yotov <5ko at 5ko.fr> wrote: > See the page http://www.pmwiki.org/wiki/Test/GUIButtons?action=edit and the last button there "Test JS". > > You can insert any HTML in the GUI Edit toolbar. If the fourth element of the array starts with "<", it is inserted as-is, without relying on the function insButton(). > > So, we define the button in a local config file: > > $GUIButtons['test-js'] = array(5000, '', '', 'Test-JS', > ""); > > instead of "" . The onclick part is important, when a user clicks on the button, it will fire your custom function. > > Your custom function can be defined in a javascript included by the skin, or even in the same config file: > > $HTMLFooterFmt['test-js'] = << > EOF; > > This custom function creates a random number between 0 and 1000, then calls insMarkup() with the constructed strings to be inserted at the position of the cursor. > > Hope this helps. > > Petko > > On 19.09.2014 08:31, Randy Brown wrote: >> I would appreciate help from someone who knows Javascript (which I >> don't). >> I'm creating a GUIEdit button that adds a markup expression containing >> a random number and text containing the same number. >> If I select in my edit form: >> My text >> and then click my guiedit button, I want a result like this: >> {(mymarkupexpression 2 "My text")} >> The above number is 2 >> Here's approximately what I've written to do this. Unfortunately, what >> I wrote uses the same number for each page load rather than for each >> button click. I want the number to change with each button click: >> $num = rand ( 1, 1000 ); >> SDVA($GUIButtons, array( >> 'mybutton' => array(8000, "{(mymarkupexpression ".$num." "", >> "")}\nThe above number is ".$num."\n [1]", '$[Default text if >> none selected]', >> '$GUIButtonDirUrlFmt/mybuttonicon.png"$[DoXYZ]"','') >> )); >> $HTMLHeaderFmt['DoXYZ']= <<> >> EOF; >> Thanks, >> Randy >> Links: >> ------ >> [1] smb://n >> _______________________________________________ >> pmwiki-devel mailing list >> pmwiki-devel at pmichaud.com >> http://www.pmichaud.com/mailman/listinfo/pmwiki-devel > > _______________________________________________ > pmwiki-devel mailing list > pmwiki-devel at pmichaud.com > http://www.pmichaud.com/mailman/listinfo/pmwiki-devel From 5ko at 5ko.fr Sat Sep 20 15:13:52 2014 From: 5ko at 5ko.fr (Petko Yotov) Date: Sat, 20 Sep 2014 22:13:52 +0200 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: Try inserting a backslash before $GUIButtonDirUrlFmt: If that doesn't work, use the full url of your picture: Petko On 20.09.2014 21:46, Randy Brown wrote: > This works., thank you! > > One problem: The img code you suggested doesn't find my icon. If I use > both buttons, my previous code's button shows its icon, while the new > code shows an icon-not-found image. Perhaps this is related to doing > this outside of SDVA? I don't know how to fix it. > > Randy > > On Sep 19, 2014, at 6:38 PM, Petko Yotov <5ko at 5ko.fr> wrote: > >> See the page http://www.pmwiki.org/wiki/Test/GUIButtons?action=edit >> and the last button there "Test JS". >> >> You can insert any HTML in the GUI Edit toolbar. If the fourth element >> of the array starts with "<", it is inserted as-is, without relying on >> the function insButton(). >> >> So, we define the button in a local config file: >> >> $GUIButtons['test-js'] = array(5000, '', '', 'Test-JS', >> "> />"); >> >> instead of "> src='$GUIButtonDirUrlFmt/mybuttonicon.png' title='DoXYZ' >> onclick='MyFunc()'/>" . The onclick part is important, when a user >> clicks on the button, it will fire your custom function. From randy at brownragfilms.com Sat Sep 20 15:18:01 2014 From: randy at brownragfilms.com (Randy Brown) Date: Sat, 20 Sep 2014 15:18:01 -0500 Subject: [pmwiki-devel] How to create a GUIEdit button using Javascript In-Reply-To: References: Message-ID: <49140AB7-2FFA-4EEA-95CD-1674CE586937@brownragfilms.com> Backslash worked! Thanks, again. Randy On Sep 20, 2014, at 3:13 PM, Petko Yotov <5ko at 5ko.fr> wrote: > Try inserting a backslash before $GUIButtonDirUrlFmt: > > > > If that doesn't work, use the full url of your picture: > > > Petko > > On 20.09.2014 21:46, Randy Brown wrote: >> This works., thank you! >> One problem: The img code you suggested doesn't find my icon. If I use >> both buttons, my previous code's button shows its icon, while the new >> code shows an icon-not-found image. Perhaps this is related to doing >> this outside of SDVA? I don't know how to fix it. >> Randy >> On Sep 19, 2014, at 6:38 PM, Petko Yotov <5ko at 5ko.fr> wrote: >>> See the page http://www.pmwiki.org/wiki/Test/GUIButtons?action=edit and the last button there "Test JS". >>> You can insert any HTML in the GUI Edit toolbar. If the fourth element of the array starts with "<", it is inserted as-is, without relying on the function insButton(). >>> So, we define the button in a local config file: >>> $GUIButtons['test-js'] = array(5000, '', '', 'Test-JS', >>> ""); >>> instead of "" . The onclick part is important, when a user clicks on the button, it will fire your custom function. > > > _______________________________________________ > pmwiki-devel mailing list > pmwiki-devel at pmichaud.com > http://www.pmichaud.com/mailman/listinfo/pmwiki-devel From john.rankin at affinity.co.nz Wed Sep 24 23:06:19 2014 From: john.rankin at affinity.co.nz (John Rankin) Date: Thu, 25 Sep 2014 16:06:19 +1200 Subject: [pmwiki-devel] pagelist output problem Message-ID: <542394BB.2010908@affinity.co.nz> In pagelist.php, FmtPageList makes a call to Keep($out). When the PublishPDF recipe generates xml output from the wiki markup for a pagelist, it doesn't detect that $out is a block (it sees only the keep token), so wraps the pagelist output in an extra (incorrect) paragraph tag. I have got around this by creating a PrivateFmtPageList function, which calls FmtPageList, then checks to see if this returns a string starting with $KeepToken. If so, it adds '<:block>' to the start of the string, which suppresses the extra paragraph tag. On the other hand, pmwiki does this correctly, producing just a
, with no extra

wrapper, so I think I am doing it wrong. My question is, how does pmwiki determine that (:pagelist ... :) produces

...
and not

...

, when the
block is inside a Keep when block markup is evaluated? What do I need to do to get the same behaviour when generating xml? Is a PrivateFmtPageList function the best solution? I'm running pmwiki 2.2.63. In the past, pagelist added the
*after* the Keep call, so a simple "look for