[pmwiki-devel] Using forms to introduce and edit constrained PmWiki markup
Harry Forsdick
harry at forsdick.com
Sat May 19 20:29:49 CDT 2007
*Ben Wilson* <dausha at gmail.com> suggested that I move this discussion over
to pmwiki-devel. So, here we are...
*Forwarded Conversation*
Subject: *Using forms to introduce and edit constrained PmWiki markup*
------------------------
* From: Harry Forsdick* <harry at forsdick.com> To: pmwiki-users at pmichaud.com
Date: Sat, May 19, 2007 at 6:33 AM
I have a calendar application where I want to be able to enter and edit a
limited number of calendar item types. This calendar (for a Cable Access TV
organization) is designed to hold four types of items: MEETING, CLASS,
SHOOT, EVENT.
To date I have created four directives for the standard meeting types and
documented these markups for users to enter and edit calendar items:
*Markup Examples for Calendar Entries*
(:meeting 'Meeting Title' time=1pm place='Cary Library':)
*MEETING*
1pm *Meeting Title*
Location: *Cary Library*
(:class 'Class Title' time=7pm place='Kites End'\
attending='Larry, Moe, Curley' instructor='Mike':)
*CLASS*
7pm *Class Title*
Location: *Kites End*
Attending: *Larry, Moe, Curley*
Instructor: *Mike *
(:shoot 'Selectmens Meeting' time=7:30pm place='Cary Hall'\
staff='Jen, George':)
*SHOOT*
7:30pm *Selectmens Meeting*
Location: *Cary Hall*
Staff/Vols: *Jen, George*
(:event 'Discovery Day' time=10am place='Lexington Center':)
*EVENT*
10am *Discovery Day*
Location: *Lexington Center*
This all works quite well, but I am finding that people in the organization
still feel uncomfortable with using free form markup to specify and edit
their calendar entries. So, I would like to see if I can use a form to
create and edit a calendar entry.
This brings up two related considerations relating to the production of
PmWiki markup as the result of the output of a form and (in a related but
different issue) how to create a new directive that expands into PmWiki
markup (instead of HTML). I really like the power of PmWiki markup, but
frequently would like to create these "macros".
Since each entry can be represented on a separate line in the buffer, and I
know how to parse a single line to get the various tokens of the directive,
I know how to take an existing PmWiki page buffer of my restricted markup,
and represent it in a form.
The part that I do not know how to do is how to get at the contents of the
PmWiki markup in a page and the related issue of how to replace the contents
of a PmWiki marked up page with the output of a form. I assume I am going
to have to have a separate edit link in the output representation of the
calendar items.
Can anyone help me revealing how I can do this?
Thanks,
Harry
--
Harry Forsdick
781.861.6149 (home) 781.799.6002 (cell)
http://www.forsdick.com
http://forsdick.blogspot.com
http://www.lexdig.com
--------
* From: Ben Wilson* <dausha at gmail.com> To: Harry Forsdick <
harry at forsdick.com>
Cc: pmwiki-users at pmichaud.com
Date: Sat, May 19, 2007 at 9:22 AM
On 5/19/07, Harry Forsdick <harry at forsdick.com> wrote:
[...]
> This all works quite well, but I am finding that people in the
organization still feel uncomfortable with using free form markup to specify
and edit their calendar entries. So, I would like to see if I can use a
form to create and edit a calendar entry.
>
> This brings up two related considerations relating to the production of
PmWiki markup as the result of the output of a form and (in a related but
different issue) how to create a new directive that expands into PmWiki
markup (instead of HTML). I really like the power of PmWiki markup, but
frequently would like to create these "macros".
>
> Since each entry can be represented on a separate line in the buffer, and
I know how to parse a single line to get the various tokens of the
directive, I know how to take an existing PmWiki page buffer of my
restricted markup, and represent it in a form.
>
> The part that I do not know how to do is how to get at the contents of the
PmWiki markup in a page and the related issue of how to replace the contents
of a PmWiki marked up page with the output of a form. I assume I am going
to have to have a separate edit link in the output representation of the
calendar items.
>
> Can anyone help me revealing how I can do this?
Here's an approach:
1. Build a markup for your form: (:kalendra-form:):
Markup("kalendra-form","directives","/\(:kalendra-form:\)/e",
"RenderKalendraForm();");
2. Create the "RenderkalendraForm" with the appropriate markup. The
example below will return the PmWiki markup that will then be
processed. I'll assume you know how to build a form in PmWiki:
function RenderKalendraForm() {
return<<<OUTPUT
(:div id=kalendra:)
put your form here
(:input type=hidden name=action value=kalendraform:)
(:divend:)
OUTPUT;
# Or, if reading from another page:
global $KalendraFormPageName
$page = ReadPage($pagename);
return $page['text'];
}
3. Build your return function. You'll have to decide what the action
is and build that into your form. I'm doing this of the top of my
head, so you'll need to verify the functions I'm calling.
$HandleActions['kalendraform'] = 'HandleKalendraForm';
function HandleKalendraForm($pagename, $auth='edit') {
# Get your form input via $_REQUEST
# Convert input into wiki markup
# Retrieve target page and clone ($new = $page =
ReadPage($pagename, $auth);)
# Do your text work on $new
# PostPage($pagename, $page, $new);
}
That should give you a start. Perhaps this discussion could be
continued on pmwiki-dev?
--
Ben Wilson
"Words are the only thing which will last forever" Churchill
--------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/pmwiki-devel/attachments/20070519/686a8227/attachment.html
More information about the pmwiki-devel
mailing list