[Home]WikiPatches/FileInclusion

UseModWiki | WikiPatches | RecentChanges | Preferences

File Inclusion

Short description

The wiki-user will be able to include snippets of wiki/html/text into the wiki-text after applying this patch.

You can write some markup into a file, store it in $InclusionDir? and turn $AllowInclusion? on. Then write

 include: file.html
into your wiki at the start of a line and it will be included at that spot. Useful for navigations and such.

== Diff -c's output ==

  *** 54,60 ****
      @IsbnNames @IsbnPre @IsbnPost $EmailFile $FavIcon $RssDays $UserHeader
      $UserBody $StartUID $ParseParas $AuthorFooter $UseUpload $AllUpload
      $UploadDir $UploadUrl $LimitFileUrl $MaintTrimRc $SearchButton 
  !   $EditNameLink $UseMetaWiki @ImageSites $BracketImg $BodyOnly );
    # Note: $NotifyDefault is kept because it was a config variable in 0.90
    # Other global variables:
    use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
  --- 54,61 ----
      @IsbnNames @IsbnPre @IsbnPost $EmailFile $FavIcon $RssDays $UserHeader
      $UserBody $StartUID $ParseParas $AuthorFooter $UseUpload $AllUpload
      $UploadDir $UploadUrl $LimitFileUrl $MaintTrimRc $SearchButton 
  !   $EditNameLink $UseMetaWiki @ImageSites $BracketImg $BodyOnly
  !   $AllowInclusion $InclusionDir );
    # Note: $NotifyDefault is kept because it was a config variable in 0.90
    # Other global variables:
    use vars qw(%Page %Section %Text %InterSite %SaveUrl %SaveNumUrl
  ***************
  *** 134,139 ****
  --- 135,146 ----
    $NewFS       = 0;           # 1 = new multibyte $FS,  0 = old $FS
    $UseUpload   = 0;           # 1 = allow uploads,      0 = no uploads
    
  + $AllowInclusion = 1;        # 1 = files (*.txt,*.html) may be included by include:file.html,
  +                             # 0 = files will not be included
  + $InclusionDir = "$DataDir/include"; # from where shall the files be included?
  + 
    # Minor options:
    $LogoLeft     = 0;      # 1 = logo on left,       0 = logo on right
    $RecentTop    = 1;      # 1 = recent on top,      0 = recent on bottom
  ***************
  *** 1625,1630 ****
  --- 1658,1675 ----
      local $_ = $text;
    
      if ($doLines < 2) { # 2 = do line-oriented only
  +     
  +     while ( m!include\:\s*((\w+\.?\w*|/)+)!gi and $AllowInclusion ) {
  +     
  +         my $FileName = $1;
  +         open FILE, "$InclusionDir/$FileName"
  +             or &ReportError(T("Cannot open $FileName: $!"));
  +         local $/;
  +         my $FileContent = <FILE>;
  +         close FILE
  +             or &ReportError(T("Cannot close $FileName: $!"));
  +         s!include\:\s*$FileName!$FileContent!i unless $FileName !~ /(html?|txt)$/i;
  +     }
        # The <nowiki> tag stores text with no markup (except quoting HTML)
        s/\<nowiki\>((.|\n)*?)\<\/nowiki\>/&StoreRaw($1)/ige;
        # The <pre> tag wraps the stored text with the HTML <pre> tag
  ***************

Hope this'll do! UdoGŁngerich -- 2005-09-24


UseModWiki | WikiPatches | RecentChanges | Preferences
Edit text of this page | View other revisions | Search MetaWiki
Last edited September 19, 2007 8:58 pm by JuanmaMP (diff)
Search: