/[pub]/suikawiki/script/misc/plugins/SuikaWiki09.wp2
Suika

Diff of /suikawiki/script/misc/plugins/SuikaWiki09.wp2

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by wakaba, Fri Jan 16 07:58:28 2004 UTC revision 1.5 by wakaba, Sun Feb 1 12:11:28 2004 UTC
# Line 47  Plugin: Line 47  Plugin:
47   \       )*   \       )*
48   \     )   \     )
49      }x;      }x;
50        my $WIKIRESOURCE;
51    
52  PluginConst:  PluginConst:
53    @NS_SW09:    @NS_SW09:
# Line 57  PluginConst: Line 58  PluginConst:
58      http://www.w3.org/1999/xhtml      http://www.w3.org/1999/xhtml
59    @NS_XHTML2:    @NS_XHTML2:
60      http://www.w3.org/2002/06/xhtml2      http://www.w3.org/2002/06/xhtml2
61      @WIKIRESOURCE:
62        {($WIKIRESOURCE ||= SuikaWiki::Plugin->module_package ('WikiResource'))}
63    
64  Format:  Format:
65    @ModuleName:    @ModuleName:
# Line 322  Format: Line 325  Format:
325                       parent => $result,                       parent => $result,
326                      });                      });
327          } elsif ($ln eq 'form') {          } elsif ($ln eq 'form') {
328            SuikaWiki::Plugin->module_package ('WikiFormCore')            my $ref = $source->get_attribute_value ('ref', default => 'form');
329                             ->make_content_form_in_html            if ($ref eq 'form') {
330                                 ($result,              SuikaWiki::Plugin->module_package ('WikiFormCore')
331                                  $source->get_attribute_value                               ->make_content_form_in_html
332                                                    ('input', default => ''),                                   ($result,
333                                  option => $source->get_attribute_value                                    $source->get_attribute_value
334                                                       ('option'),                                                      ('input', default => ''),
335                                  name => $source->get_attribute_value ('id'),                                    option => $source->get_attribute_value
336                                  o => $opt->{o},                                                         ('option'),
337                                  wiki => $opt->{o}->{wiki});                                    name => $source->get_attribute_value ('id'),
338                                      o => $opt->{o},
339                                      wiki => $opt->{o}->{wiki},
340                                      output => {
341                                        page => $opt->{page},
342                                      });
343              } elsif ($ref eq 'comment') {
344                SuikaWiki::Plugin->module_package ('WikiFormCore')
345                                 ->make_content_form_in_html
346                                     ($result,
347                                      $WIKIRESOURCE->get
348                                        (name => 'SuikaWiki/0.9:form:comment:input',
349                                         o => $opt->{o}, wiki => $opt->{o}->{wiki}),
350                                      option => $WIKIRESOURCE->get
351                                        (name => 'SuikaWiki/0.9:form:comment:option',
352                                         o => $opt->{o}, wiki => $opt->{o}->{wiki}),
353                                      name => $source->get_attribute_value ('id'),
354                                      o => $opt->{o},
355                                      wiki => $opt->{o}->{wiki},
356                                      output => {
357                                        page => $opt->{page},
358                                      });
359              } else {
360     ## TODO:
361              }
362          } elsif ($ln eq 'dr') {          } elsif ($ln eq 'dr') {
363            $apply_template_children->($source => $result);            $apply_template_children->($source => $result);
364          } elsif ($ln eq 'document') {          } elsif ($ln eq 'document') {
# Line 368  Format: Line 395  Format:
395                
396        $apply_template_children->($xml => $opt->{-parent});        $apply_template_children->($xml => $opt->{-parent});
397    
398          if ($opt->{-with_annotation_input}) {
399            SuikaWiki::Plugin->module_package ('WikiFormCore')
400                             ->make_content_form_in_html
401                                 ($opt->{-parent},
402                                  $WIKIRESOURCE->get
403                                    (name => 'SuikaWiki/0.9:form:footannotate:input',
404                                     o => $opt->{o}, wiki => $opt->{o}->{wiki}),
405                                  option => $WIKIRESOURCE->get
406                                    (name => 'SuikaWiki/0.9:form:footannotate:option',
407                                     o => $opt->{o}, wiki => $opt->{o}->{wiki}),
408                                  o => $opt->{o},
409                                  wiki => $opt->{o}->{wiki},
410                                  output => {
411                                    page => $opt->{page},
412                                  });
413          }
414    
415    
416    @Converter:    @Converter:
417      @@Type:      @@Type:
# Line 410  Format: Line 454  Format:
454                     $opt{o}->{form}->{output}->{index});                     $opt{o}->{form}->{output}->{index});
455        }        }
456                
457        unless (ref $form) {        my $ref;
458  ## TOOD:        if (ref $form) {
459   CORE::die "No form (ID $opt{o}->{form}->{output}->{id}; Index $opt{o}->{form}->{output}->{index})";          $ref = $form->get_attribute_value ('ref', default => 'form');
460          } else {
461            $ref = '#footannotate';
462        }        }
463                
464          
465        ## WikiForm Option        ## WikiForm Option
466        $opt{option} ||= $form->get_attribute_value ('option');        if ($ref eq 'form') {
467            $opt{option} ||= $form->get_attribute_value ('option');
468          } elsif ($ref eq 'comment') {
469            $opt{option} ||= $WIKIRESOURCE->get
470                               (name => 'SuikaWiki/0.9:form:comment:option',
471                                o => $opt{o}, wiki => $opt{o}->{wiki});
472          } elsif ($ref eq '#footannotate') {
473            $opt{option} ||= $WIKIRESOURCE->get
474                               (name => 'SuikaWiki/0.9:form:footannotate:option',
475                                o => $opt{o}, wiki => $opt{o}->{wiki});
476          } else {
477    ## TODO:
478          }
479        SuikaWiki::Plugin->module_package ('WikiFormCore')        SuikaWiki::Plugin->module_package ('WikiFormCore')
480                         ->set_option ($opt{option} => $opt{o}) if $opt{option};                         ->set_option ($opt{option} => $opt{o}) if $opt{option};
481                
482        ## Replace Output Template        ## Replace Output Template
483        my $result;        my $result;
484        $opt{template} ||= $form->get_attribute_value ('template', default => '');        if ($ref eq 'form') {
485            $opt{template} ||= $form->get_attribute_value
486                                        ('template', default => '');
487          } elsif ($ref eq 'comment') {
488            $opt{template} ||= $WIKIRESOURCE->get
489                                 (name => 'SuikaWiki/0.9:form:comment:template',
490                                  o => $opt{o}, wiki => $opt{o}->{wiki});
491          } elsif ($ref eq '#footannotate') {
492            $opt{template} ||= $WIKIRESOURCE->get
493                                 (name => 'SuikaWiki/0.9:form:footannotate:template',
494                                  o => $opt{o}, wiki => $opt{o}->{wiki});
495          }
496        try {        try {
497          $result = SuikaWiki::Plugin->text_formatter ('form_template')          $result = SuikaWiki::Plugin->text_formatter ('form_template')
498                           ->replace ($opt{template}, param => $opt{o});                           ->replace ($opt{template}, param => $opt{o});
# Line 437  Format: Line 507  Format:
507    
508        ## Insert        ## Insert
509        if (length $result) {        if (length $result) {
510          my $parent = $form->parent_node;          if ($ref eq '#footannotate') {
511          ## TODO:            my $parent;
512          CORE::die "No parent of form" unless ref $parent;            for (@{$xml->child_nodes}) {
513          my $children = $parent->child_nodes;              if ($_->node_type eq '#element' and
514                            $_->local_name eq 'document') {
515          $result .= "\x0A" unless substr ($result, -1) eq "\x0A";                for (@{$_->child_nodes}) {
516          $parent->append_new_node (type => '#element',                  if ($_->node_type eq '#element' and
517                                    namespace_uri => $NS_SW09,                      $_->local_name eq 'body') {
518                                    local_name => 'text')                    $parent = $_;
519                 ->append_text ($result);                    last;
520          my $node = pop @{$children};                  }
521          my $form_str = overload::StrVal ($form);                }
522          my $i = 0;              }
523          for (@{$children}) {            }
524            last if overload::StrVal ($_) eq $form_str;            CORE::die "Buggy implementation: no body element".$xml unless ref $parent;
525            $i++;            
526          }            $parent->append_new_node (type => '#element',
527          if ($opt{o}->{form}->{output}->{reverse}) {                                      namespace_uri => $NS_SW09,
528            splice @{$children}, $i + 1, 0, $node;                                      local_name => 'text')
529                     ->append_text ($result);
530          } else {          } else {
531            splice @{$children}, $i, 0, $node;            my $parent = $form->parent_node;
532              CORE::die "Byggy implementation: No parent of form" unless ref $parent;
533              my $children = $parent->child_nodes;
534              
535              $result .= "\x0A" unless substr ($result, -1) eq "\x0A";
536              $parent->append_new_node (type => '#element',
537                                        namespace_uri => $NS_SW09,
538                                        local_name => 'text')
539                     ->append_text ($result);
540              my $node = pop @{$children};
541              my $form_str = overload::StrVal ($form);
542              my $i = 0;
543              for (@{$children}) {
544                last if overload::StrVal ($_) eq $form_str;
545                $i++;
546              }
547              if ($opt{o}->{form}->{output}->{reverse}) {
548                splice @{$children}, $i + 1, 0, $node;
549              } else {
550                splice @{$children}, $i, 0, $node;
551              }
552          }          }
553          } else {
554    ## TODO:
555        }        }
556    
557        ## XML format -> Text format        ## XML format -> Text format
# Line 475  Format: Line 568  Format:
568          {          {
569            type => 'write',            type => 'write',
570            content => $text,            content => $text,
571              update_lastmodified => time,
572          },          },
573          {          {
574            type => 'view',            type => 'view',
# Line 482  Format: Line 576  Format:
576          },          },
577        ];        ];
578    
579      @HeadSummary:
580        @@Main:
581          my $xml = __FUNCPACK__->get_xml_tree (text => $source, opt => \%opt,
582                                                wiki => $self->{wiki});
583          return $xml->inner_text;
584    
585  FormattingRule:  FormattingRule:
586    @Category[list]:form-template    @Category[list]:form-template
587    @Name: index    @Name: index
# Line 1459  Function: Line 1559  Function:
1559      @@lang:en      @@lang:en
1560    @Main:    @Main:
1561    my $ElementDef = {    my $ElementDef = {
1562      ABBR    => {ln => 'abbr', ns_uri => $NS_SW09},      ABBR    => {ln => 'abbr', ns_uri => $NS_XHTML2},
1563      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},      CODE    => {ln => 'code', ns_uri => $NS_XHTML2},
1564      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},      DEL     => {ln => 'del',  ns_uri => $NS_XHTML1},
1565      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},      DFN     => {ln => 'dfn',  ns_uri => $NS_XHTML2},
# Line 1690  Resource: Line 1790  Resource:
1790          );}p,          );}p,
1791          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,          class=>{%if-linked-wikipage-exist(false=>{not-exist});}p,
1792        );        );
1793      @SuikaWiki/0.9:form:comment:input:
1794          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1795          %line (content => {
1796            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1797                    id => name, size => 6);
1798             [%text (description =>
1799                       {%res (name => {Form:Description:MailAddress});}p,
1800                     id => mail, size => 5);]
1801             %check (default, id => record-date,
1802                     label => {%res (name => {Form:Label:LogDate});}p,
1803                     description => {%res (name => {Form:Description:LogDate});}p);)
1804             %submit (label => {%res (name => {Form:Label:Add});}p,
1805                      description => {%res (name => {Form:Description:Add});}p);
1806             %we--update-lastmodified-datetime;
1807          }p);
1808      @SuikaWiki/0.9:form:comment:template:
1809        %n
1810       ;[%index;]%n
1811       ;%text(source=>msg);%n;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1812      @SuikaWiki/0.9:form:comment:option:
1813        %require (msg);
1814      @SuikaWiki/0.9:form:footannotate:input:
1815          %line (content => {%textarea (id=>msg,size=>20,lines=>3);}p);
1816          %line (content => {
1817            (%text (description => {%res (name => {Form:Description:HumanName});}p,
1818                    id => name, size => 6);
1819             [%text (description =>
1820                       {%res (name => {Form:Description:MailAddress});}p,
1821                     id => mail, size => 5);]
1822             %check (default, id => record-date,
1823                     label => {%res (name => {Form:Label:LogDate});}p,
1824                     description => {%res (name => {Form:Description:LogDate});}p);)
1825             %submit (label => {%res (name => {Form:Label:Add});}p,
1826                      description => {%res (name => {Form:Description:Add});}p);
1827             %we--update-lastmodified-datetime;
1828          }p);
1829      @SuikaWiki/0.9:form:footannotate:template:
1830         %n
1831        ;[%index;]%n
1832        ;%text(source=>msg);%n
1833        ;(%name;%text(source=>mail,prefix=>" [",suffix=>"]");%iif(source=>record-date,true=>" [WEAK[%date;]]");)%n;
1834      @SuikaWiki/0.9:form:footannotate:option:
1835        %require (msg);
1836    
1837  Error:  Error:
1838    @Name: text_parse    @Name: text_parse

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

[email protected]
ViewVC Help
Powered by ViewVC 1.1.24