[MKDoc-commit] [1.6] --exclude functionality backported from 1.8 to hide empty Files

bruno at mkdoc.demon.co.uk bruno at mkdoc.demon.co.uk
Fri Sep 9 15:40:17 BST 2005


Log Message:
-----------
[1.6] --exclude functionality backported from 1.8 to hide empty Files menu

Tags:
----
mkdoc-1-6

Modified Files:
--------------
    mkd/flo:
        Editor.pm
    mkd/templates/fragments/menu_files:
        en.html

-------------- next part --------------
Index: Editor.pm
===================================================================
RCS file: /var/spool/cvs/mkd/flo/Editor.pm,v
retrieving revision 1.12.2.47
retrieving revision 1.12.2.48
diff -Lflo/Editor.pm -Lflo/Editor.pm -u -r1.12.2.47 -r1.12.2.48
--- flo/Editor.pm
+++ flo/Editor.pm
@@ -230,6 +230,25 @@
 sub access
 {
     my $self = shift;
+   
+    # process the --exclude flag
+    # search @_ for 'exclude' followed by something
+    my %exclude = ();
+    for (my $i = 0; $i < @_; $i++)
+    {
+	if (defined $_[$i] and $_[$i] eq 'exclude')
+	{
+	    my ($key, $val) = splice @_, $i, 2;
+            $exclude{$val}  = $val;
+	}
+    }
+
+    scalar %exclude and do {
+        return map {
+            my $name = $_->name();
+            $exclude{$name} ? () : $_;
+        } $self->access (@_);
+    };
     
     # search @_ for 'negate'
     my $component_negate = 'no';
Index: en.html
===================================================================
RCS file: /var/spool/cvs/mkd/templates/fragments/menu_files/Attic/en.html,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -Ltemplates/fragments/menu_files/en.html -Ltemplates/fragments/menu_files/en.html -u -r1.1.2.5 -r1.1.2.6
--- templates/fragments/menu_files/en.html
+++ templates/fragments/menu_files/en.html
@@ -17,7 +17,8 @@
 <div
   class="files"
   xmlns:petal="http://purl.org/petal/1.0/"
-  petal:condition="true: self/components_list --file"
+  petal:define="File_Loop self/components --file --exclude 'style.css' --exclude 'logo.png' --exclude 'script.js' --exclude 'favicon.ico';"
+  petal:condition="true: File_Loop"
 >
 
   <h2>
@@ -33,17 +34,13 @@
   </h2>
 
   <div
-    petal:define="File_Loop self/components_list --file;"
     petal:repeat="file File_Loop"
     petal:omit-tag=""
   >
     <p
       petal:attributes="class string:file-${file/extension}"
       class="file-file"
-      petal:condition="true:  file/title;
-                       false: file/name_is --style.css; 
-                       false: file/name_is --favicon.ico;
-                       false: file/name_is --script.js;"
+      petal:condition="true:  file/title;"
     >
       <a 
         href="http://example.com/"


More information about the MKDoc-commit mailing list