[Bio] / KBaseTutorials / add_links_to_tutorials.pl Repository:
ViewVC logotype

Annotation of /KBaseTutorials/add_links_to_tutorials.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (view) (download) (as text)

1 : disz 1.1
2 :     use strict;
3 :     use Data::Dumper;
4 : olson 1.4 use Getopt::Long;
5 : disz 1.1
6 : olson 1.4 my $linkmap;
7 :     my $in_pre_only;
8 : olson 1.5 my $skip_commands;
9 : olson 1.4 my $rc = GetOptions("linkmap=s" => \$linkmap,
10 : olson 1.5 "inpre" => \$in_pre_only,
11 :     "skip-commands" => \$skip_commands);
12 : olson 1.4
13 :     ($rc && @ARGV == 4) or die "Usage: $0 cdmi-target cdmi-entity-target idserver-target spec-dir\n";
14 :    
15 :     my $cdmi_url = shift;
16 :     my $cdmi_entity_url = shift;
17 :     my $idserver_url = shift;
18 : olson 1.2 my $spec_dir = shift;
19 : disz 1.1
20 : olson 1.4 #my $cdmi_url = "http://bio-admin-2.mcs.anl.gov/ksite/index.php/developers/api-documentation/cdmi-test/#";
21 :     #my $cdmi_url = "http://www.mcs.anl.gov/~olson/cdmi.html#";
22 :     #my $cdmi_entity_url = "http://www.mcs.anl.gov/~olson/ksapling.html#";
23 :     #my $idserver_url = "http://www.mcs.anl.gov/~olson/idserver.html#";
24 :    
25 :     my @links;
26 :     if (open(L, "<", $linkmap))
27 :     {
28 :     while (<L>)
29 :     {
30 :     chomp;
31 :     my($old, $new) = split(/\t/);
32 :     push(@links, [$old, $new]);
33 :     }
34 :     close(L);
35 :     }
36 : disz 1.1
37 :     my %links;
38 :    
39 : olson 1.5 if (!$skip_commands)
40 :     {
41 :     my @cdmi = `grep funcdef $spec_dir/CDMI-API.spec`;
42 :     my @cdmi_entity = `grep funcdef $spec_dir/CDMI-EntityAPI.spec`;
43 :     my @idserver = `grep funcdef $spec_dir/IDServer-API.spec`;
44 :    
45 :     foreach my $line (@cdmi) {
46 : disz 1.1 $line =~ /funcdef\s+(\S+?)\(/;
47 : olson 1.4 my $l = $1;
48 : disz 1.3 $links{$1} = "<a href=\"$cdmi_url$1\" target='_blank'>$l</a>";
49 : olson 1.5 }
50 :     foreach my $line (@cdmi_entity) {
51 : disz 1.1 $line =~ /funcdef\s+(\S+?)\(/;
52 : olson 1.4 my $l = $1;
53 : disz 1.3 $links{$1} = "<a href=\"$cdmi_entity_url$l\" target='_blank'>$1</a>";
54 : olson 1.5 }
55 :     foreach my $line (@idserver) {
56 : disz 1.1 $line =~ /funcdef\s+(\S+?)\(/;
57 : olson 1.4 my $l = $1;
58 : disz 1.3 $links{$1} = "<a href=\"$idserver_url$l\" target='_blank'>$1</a>";
59 : olson 1.5 }
60 : disz 1.1 }
61 :    
62 : olson 1.4 my $x = join("", <STDIN>);
63 : disz 1.1
64 :     foreach my $cmd (keys(%links)) {
65 : olson 1.4 if ($in_pre_only)
66 :     {
67 :     $x =~ s/(<pre>\s*)\b$cmd\b/$1$links{$cmd}/g;
68 :     }
69 :     else
70 :     {
71 :     $x =~ s/\b$cmd\b/$links{$cmd}/g;
72 :     }
73 :     }
74 :    
75 :     for my $lent (@links)
76 :     {
77 :     my($old, $new) = @$lent;
78 : olson 1.5 $x =~ s/href="$old(#.*)?"/href="$new$1"/g;
79 : disz 1.1 }
80 : olson 1.4
81 : disz 1.1 print $x;

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3