Changeset 6
- Timestamp:
- 05/16/07 04:56:59
- Files:
-
- xmlautoindex/trunk/Apache/XmlAutoIndex/Audio.pm (modified) (3 diffs)
- xmlautoindex/trunk/Apache/XmlAutoIndex/Default.pm (modified) (1 diff)
- xmlautoindex/trunk/Apache/XmlAutoIndex/core.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
xmlautoindex/trunk/Apache/XmlAutoIndex/Audio.pm
r1 r6 29 29 return Apache2::Const::OK(); 30 30 } 31 elsif($format eq 'audioPlaylist') 32 { 33 $this->request->content_type( "text/xml"); 34 $this->request->print( $this->getAudioPlayList( ) ); 35 return Apache2::Const::OK(); 36 } 31 37 else 32 38 { … … 35 41 } 36 42 43 # TODO: migrate audioPlaylist into RSS... 37 44 sub allowedFormat 38 45 { 39 46 my $this = shift; 40 return qw{ thumb fmxml meta };47 return qw{ thumb fmxml audioPlaylist meta }; 41 48 } 42 49 … … 84 91 EOF 85 92 } 93 94 sub getAudioPlayList 95 { 96 my $this = shift; 97 my $uri = $this->request->uri(); 98 99 my $directory = $this->request()->filename(); 100 101 my @files; 102 my @directories; 103 my @xml; 104 105 $directory =~ s/\/([^\/]*)$//; 106 my $selected = $1; 107 108 109 my $dir=IO::Dir->new( $directory); 110 unless ($dir) 111 { 112 $this->request->warn( "unable to read $directory: $!"); 113 return undef; 114 } 115 while ($_ = $dir->read()) 116 { 117 next if /^\./; #ignore hidden files 118 119 if ( -f "$directory/$_" ) 120 { 121 push @files, $_; 122 } 123 } 124 $dir->close(); 125 126 @files = sort @files; 127 128 my $count = 0; 129 130 FILE: foreach my $file (@files, @files) 131 { 132 133 last if ($count == scalar @files); # terminates once we have reached made the entire loop 134 135 next if ($count == 0 and $file ne $selected); # next until we reached the selected file 136 137 $count++; # count next file 138 139 140 #XXX: need to use lookup_dirent, but this method is not supported at this time 141 my $subrequest = $this->request()->lookup_file($file); 142 my $file_status = $subrequest->status(); 143 144 #if forbidden, ignore this file #TODO: should not put a warn in logs... 145 next if ($file_status >= 400 and $file_status < 500); 146 147 my $object = Apache::XmlAutoIndex::core->new( 148 request => $subrequest, 149 cgi => $this->cgi, 150 type => $subrequest->content_type(), 151 selected => ($file eq $selected), 152 ); 153 154 # XXX /!\ XXX order is important because first match is taken... 155 foreach my $class ( 'Apache::XmlAutoIndex::Audio' ) 156 { 157 bless( $object, $class); #perl pseudo OO tip: change class without copying data... 158 next FILE if $object->hidden(); 159 last if $object->match(); 160 } 161 162 push @xml, $object->xmlTrack(); 163 } 164 165 166 return 167 "<?xml version='1.0' encoding='iso-8859-1' ?>\n". 168 "<playlist version='1' xmlns='http://xspf.org/ns/0/'>\n". 169 " <trackList>\n". 170 join("\n", @xml). 171 " </trackList>\n". 172 "</playlist>"; 173 174 } 86 175 # ------------------------- 87 176 177 sub xmlTrack 178 { 179 my $this = shift; 180 my $uri = $this->request->uri(); 181 my $title = $this->request->filename();# TODO 182 $title =~ s/.*\///; 183 my $artist = ""; # TODO 184 my $id = $title; 185 186 $id = 'selected' if $this->selected(); 187 188 return <<EOF; 189 <track> 190 <title>$title</title> 191 <!-- creator>Artist</creator --> 192 <location>$uri</location> 193 <identifier>$id</identifier> 194 </track> 195 EOF 196 } 88 197 return 1; xmlautoindex/trunk/Apache/XmlAutoIndex/Default.pm
r1 r6 27 27 my $icon; 28 28 29 if ( $this->type =~ /directory/)29 if ($format eq 'thumb') 30 30 { 31 if ( $this-> request->uri =~ /\/(photo|image|picture)s?$/ )31 if ( $this->type =~ /directory/ ) 32 32 { 33 $icon = "/specials/emblem-pictures.png"; 33 if ( $this->request->uri =~ /\/(photo|image|picture)s?$/ ) 34 { 35 $icon = "/specials/emblem-pictures.png"; 36 } 37 elsif ( $this->request->uri =~ /\/(video|movie|film)s?$/ ) 38 { 39 $icon = "/specials/emblem-camera.png"; 40 } 41 elsif ( $this->request->uri =~ /\/(document|doc)s?$/) 42 { 43 $icon = "/specials/emblem-documents.png"; 44 } 45 elsif ( $this->request->uri =~ /\/(audio|musique|music|zik|zic)s?$/) 46 { 47 $icon = "/specials/emblem-audio.png"; 48 } 49 elsif ( $this->request->uri =~ /\/(perso|private|prive)s?$/ ) 50 { 51 $icon = "/specials/emblem-nowrite.png"; 52 } 53 elsif ( $this->request->uri =~ /\/(site|web|website|blog|wiki)s?$/ ) 54 { 55 $icon = "/specials/emblem-web.png"; 56 } 57 58 return $this->getIconsUri().$icon if ($icon and -e $this->getIconsLocalPath().$icon); 34 59 } 35 elsif ( $this->request->uri =~ /\/(video|movie|film)s?$/ ) 36 { 37 $icon = "/specials/emblem-camera.png"; 38 } 39 elsif ( $this->request->uri =~ /\/(document|doc)s?$/) 40 { 41 $icon = "/specials/emblem-documents.png"; 42 } 43 elsif ( $this->request->uri =~ /\/(audio|musique|music|zik|zic)s?$/) 44 { 45 $icon = "/specials/emblem-audio.png"; 46 } 47 elsif ( $this->request->uri =~ /\/(perso|private|prive)s?$/ ) 48 { 49 $icon = "/specials/emblem-nowrite.png"; 50 } 51 elsif ( $this->request->uri =~ /\/(site|web|website)s?$/ ) 52 { 53 $icon = "/specials/emblem-web.png"; 54 } 55 56 return $this->getIconsUri().$icon if ($icon and -e $this->getIconsLocalPath().$icon); 57 } 58 59 $thumb = $this->type; 60 $thumb =~ s/\//\-/; 61 $thumb .= ".png"; 62 if (not -e $this->getIconsLocalPath()."/".$thumb) 63 { 60 64 61 $thumb = $this->type; 65 $thumb =~ s/\/ .*$//;62 $thumb =~ s/\//\-/; 66 63 $thumb .= ".png"; 67 64 if (not -e $this->getIconsLocalPath()."/".$thumb) 68 65 { 69 $thumb = $unknown; 66 $thumb = $this->type; 67 $thumb =~ s/\/.*$//; 68 $thumb .= ".png"; 69 if (not -e $this->getIconsLocalPath()."/".$thumb) 70 { 71 $thumb = $unknown; 72 } 70 73 } 74 return $this->getIconsUri()."/".$thumb; 71 75 } 72 return $this->getIconsUri()."/".$thumb; 76 else 77 { 78 return $this->SUPER::getThumb( $format); 79 } 73 80 } 74 81 xmlautoindex/trunk/Apache/XmlAutoIndex/core.pm
r1 r6 349 349 350 350 require utf8; 351 utf8:: decode( $data);351 utf8::upgrade( $data); 352 352 353 353 require HTML::Entities;
