[R] www.r-project.org

Manuel López-Ibáñez manuellopezibanez at yahoo.es
Tue Apr 25 20:59:54 CEST 2006


Barry Rowlingson wrote:
>   The frame-based nature of the CRAN pages is slightly problematic, 
> since you click on a menu item and the URL doesn't change. Hence there's 
> no way to send someone a URL that gives them the same view as you'd get 
> if you go to the home page and then click on 'screenshots', for example.
> 
> Sure you can send them to:
> 
> http://www.r-project.org/screenshots/screenshots.html
> 
> but then they dont see the menu.
> 

Moreover, the menu gets lost also when an element of the menu is opened 
in a new window (or tab).

> It probably wouldn't take long to bash out a serviceable replacement 
> using something like HTML::Mason but then you'd have to find a hosting 
> provider that supported it (or PHP or IYFTLH[1]). I dont think it 
> warrants a full-on CMS given the size of www.r-project.org (not 
> including CRAN stuff). I'd just hack up some m4 scripts and 'include' 
> the menu into a flat file.
> 

I have a perl script that reads a number of HTML files looking for 
"include directories" which instruct it to put at that point the content 
of another file.

For example, file "index.html" may contain the line:

<!--#include file="menu.htm"-->

The script replaces that line with the content of "menu.htm".

Thus, the files from the site are processed before being uploaded to the 
web site in order to create the final html pages. There is no need for 
Apache directives, no scripts, no PHP, no CMS. And more important, no 
frames!

Here is the script. You may consider it GPL ;)

#!/usr/bin/perl -w

@files = `ls *.html`;
$outdir = "../";

`mkdir -p $outdir`; #or die "Cannot create $outdir";

FILE: foreach $file (@files) {
     $file =~ s/\n//g;
     open(INPUT, "<$file") or (warn("*** Cannot read $file\n") and next 
FILE);
     @buffer = <INPUT>;
     close INPUT;

   LINE: foreach $line (@buffer) {
	if($line =~ /<!--#include file="([\w\.]+)"-->/) {
	    open(INPUT, "<$1") or
	    (warn("*** Cannot read $1 included in $file\n") and next LINE);
	    $temp = join("", <INPUT>);
	    close INPUT;
	    $line =~ s[<!--#include file="([\w\.]+)"-->]
	    [<!-- $1 -->\n$temp];
	    print "\t$1 included in $file\n";
	}
     }
     open(OUTPUT, ">$outdir/$file") or
     (warn("*** Cannot write $outdir/$file\n") and next FILE);
     print OUTPUT @buffer;
     close OUTPUT;
     print "$file processed\n";
}


		
______________________________________________ 
LLama Gratis a cualquier PC del Mundo. 
Llamadas a fijos y móviles desde 1 céntimo por minuto. 
http://es.voice.yahoo.com




More information about the R-help mailing list