]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - doc/todo/pagespec_relative_to_a_target.mdwn
comment
[git.ikiwiki.info.git] / doc / todo / pagespec_relative_to_a_target.mdwn
index e92988c3e2dadef44e802bf6053fbf7c5535ee6d..00030cce61093192797a46a545389c324cf46078 100644 (file)
@@ -30,9 +30,9 @@ Note that if you try to inline `*/blah` you will match `foo/blah`,
 themselves rather than any relatives of theirs.
 
 This patch is useful for (among other things) constructing blogging 
 themselves rather than any relatives of theirs.
 
 This patch is useful for (among other things) constructing blogging 
-systems where leaf nodes are organized hierarchically; using has_child,
+systems where leaf nodes are organized hierarchically; using `has_child`,
 you can inline only leaf nodes and ignore "intermediate" nodes.
 you can inline only leaf nodes and ignore "intermediate" nodes.
-match_relative can be used recursively to match properties of arbitrary
+`match_relative` can be used recursively to match properties of arbitrary
 complexity: "show me all the pages who have children called foo that 
 have children called blah". I'm not sure what use it is, though.
 
 complexity: "show me all the pages who have children called foo that 
 have children called blah". I'm not sure what use it is, though.
 
@@ -57,7 +57,7 @@ diff -urNX ignorepats ikiwiki/IkiWiki/Plugin/relative.pm ikidev/IkiWiki/Plugin/r
 +
 +package IkiWiki::PageSpec;
 +
 +
 +package IkiWiki::PageSpec;
 +
-+sub match_relative($$;@) { #{{{
++sub match_relative($$;@) {
 +      my $parent = shift;
 +      my $spec = shift;
 +      my %params = @_;
 +      my $parent = shift;
 +      my $spec = shift;
 +      my %params = @_;
@@ -69,21 +69,33 @@ diff -urNX ignorepats ikiwiki/IkiWiki/Plugin/relative.pm ikidev/IkiWiki/Plugin/r
 +              }
 +      }
 +      return IkiWiki::FailReason->new("$parent can't match $spec against anything");
 +              }
 +      }
 +      return IkiWiki::FailReason->new("$parent can't match $spec against anything");
-+} #}}}
++}
 +
 +
-+sub match_has_child($$;@) { #{{{
++sub match_has_child($$;@) {
 +      my $page = shift;
 +      my $childname = shift;
 +      my $spec;
 +      my $page = shift;
 +      my $childname = shift;
 +      my $spec;
-+      if ($childname) { #{{{
++      if ($childname) {
 +              $spec = "$page/$childname or $page/*/$childname";
 +              $spec = "$page/$childname or $page/*/$childname";
-+      } #}}}
-+      else { #{{{
++      }
++      else {
 +              $spec = "$page/*";
 +              $spec = "$page/*";
-+      } #}}}
++      }
 +
 +      return match_relative($page, $spec, @_);
 +
 +      return match_relative($page, $spec, @_);
-+} #}}}
++}
 +
 +1
 +
 +1
-</pre>
\ No newline at end of file
+</pre>
+
+[[!tag patch]]
+
+> This looks really interesting.  It reminds me of [[!wikipedia XPath]] and its conditionals.
+> Those might actually work well adapted to pagespecs.  For instance, to write
+> "match any page with a child blah", you could just write *[blah] , or if you
+> don't want to use relative-by-default in the conditionals, *[./blah].
+> -- [[JoshTriplett]]
+
+> And it [[!taglink also_reminds_me|pagespec_in_DL_style]] of [[!wikipedia description logics]]: of course, given the relation `subpage` one could write a description-logic-style formula which would define the class of pages that are ("existentially") in a given relation (`subpage` or `inverse(subpage)*subpage`) to a certain other class of pages (e.g., named "blah") ("existentially" means there must exist a page, e.g., named "blah", which is in the given relation to the candidate).
+
+> Probably the model behind XPath is similar (although I don't know enough to say this definitely).--Ivan Z.