Mercurial > laserkard
diff echo.pl @ 51:95fa4bcc5d67 laserkard
[svn r52] implemented SVG backend
author | rlm |
---|---|
date | Wed, 03 Feb 2010 03:14:09 -0500 |
parents | 1ac1409ea68c |
children | 375225442677 |
line wrap: on
line diff
1.1 --- a/echo.pl Mon Feb 01 02:54:59 2010 -0500 1.2 +++ b/echo.pl Wed Feb 03 03:14:09 2010 -0500 1.3 @@ -14,6 +14,8 @@ 1.4 $Data::Dumper::Indent = 1; 1.5 use Storable; 1.6 use SVG; 1.7 +use Laserkard; 1.8 + 1.9 1.10 my $q = new CGI; 1.11 1.12 @@ -21,6 +23,14 @@ 1.13 1.14 my %hash = 1.15 ( 1.16 +'material' => \&Laserkard::material, 1.17 +'template' => \&Laserkard::template, 1.18 +'inputbox' => \&Laserkard::inputbox, 1.19 +'display' => \&Laserkard::display, 1.20 +'change_rules' => \&Laserkard::change_rules, 1.21 +'vanish' => \&Laserkard::vanish, 1.22 +'updateForm' => \&Laserkard::updateForm, 1.23 +'cardType' => \&Laserkard::cardType, 1.24 'echo' => \&echo 1.25 ); 1.26 1.27 @@ -36,21 +46,13 @@ 1.28 1.29 sub gen 1.30 { 1.31 - { 1.32 - local( $/, *FH ) ; 1.33 - open( FH, "<./echo.html" ) or die "sudden flaming death\n"; 1.34 - $a = <FH>; 1.35 - } 1.36 1.37 - { 1.38 - local( $/, *FH ) ; 1.39 - open( FH, "<./top_menu.include" ) or die "sudden flaming death\n"; 1.40 - $b = <FH>; 1.41 - } 1.42 1.43 1.44 1.45 -$a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl and with more memory problems :) 1.46 + 1.47 +$a = Laserkard::genEcho(); 1.48 + 1.49 1.50 1.51 1.52 @@ -64,26 +66,48 @@ 1.53 sub echo 1.54 { 1.55 1.56 - 1.57 -my $svg = $_[0]; 1.58 - 1.59 -my $destination = 'rlm@mit.edu'; 1.60 - 1.61 - 1.62 - 1.63 - 1.64 -$svg = &impose($svg); 1.65 - 1.66 - 1.67 - 1.68 1.69 1.70 -&mail($svg, $destination); 1.71 +my $svg = shift; 1.72 1.73 1.74 1.75 +#my $destination = 'rlm@mit.edu'; 1.76 1.77 -return "done."; 1.78 + 1.79 + 1.80 + 1.81 + 1.82 + 1.83 + 1.84 +my @cards = split (/S3ntinEL/, $svg); 1.85 +my $emmmm = shift; 1.86 +#return $emmmm; 1.87 + 1.88 +$cardsPerMail = 30; 1.89 +##### ok, now we have this awesome array with all the cards we need to print. 1.90 +# the numbers are right, so now we really just have to impose them. 1.91 +for $mails(0..int(($#cards) / $cardsPerMail)) 1.92 +{ 1.93 + 1.94 + 1.95 +my $start = $mails * $cardsPerMail; 1.96 + 1.97 +my $end = ($#cards >($start + $cardsPerMail)) ? ($start + $cardsPerMail) : $#cards; 1.98 + 1.99 +$svg = &impose(@cards[$start..$end]); 1.100 +#$svg = &impose($cards[$end]); 1.101 + 1.102 +&mail($svg, $emmmm); 1.103 +} 1.104 + 1.105 + 1.106 + 1.107 +return "done"; 1.108 + 1.109 +return $svg; 1.110 + 1.111 + 1.112 1.113 } 1.114 1.115 @@ -96,16 +120,84 @@ 1.116 #out purpose here is to take that one card, size it correctly, and make appropiate copies 1.117 #so that our supplier can simply import the file and print. 1.118 1.119 -$sss = $_[0]; 1.120 -$sss =~ s/^/\n\n\n/; 1.121 -$sss =~ s/$/\n\n\n/; 1.122 +my $xml = new XML::Simple; 1.123 +my @cards = @_; 1.124 + 1.125 + 1.126 +for (0..$#cards) 1.127 +{ 1.128 + 1.129 +$cards[$_] =~ s/^/\n\n\n/; 1.130 +$cards[$_] =~ s/$/\n\n\n/; 1.131 # you fucking bitch! 1.132 -$sss =~ s/Created wit........//; 1.133 - 1.134 +$cards[$_] =~ s/Created wit........//; 1.135 +} 1.136 1.137 # read XML file 1.138 -my $xml = new XML::Simple; 1.139 -my $data = $xml->XMLin($sss, ForceArray => 1); 1.140 + 1.141 + 1.142 + 1.143 + 1.144 +#print Dumper(%juzz); 1.145 + 1.146 + 1.147 +my $svg= SVG->new(width=>"18in",height=>"14in"); 1.148 + 1.149 +#print Dumper($juzz{'path'}[2]); 1.150 +#print "\n***************************\n"; 1.151 +#print Dumper($pathData); 1.152 + 1.153 + 1.154 + 1.155 + 1.156 +my $base = "scale(0.6057),matrix(1 0 0 -1 0 317), rotate(180),translate(-514,-317)"; 1.157 + 1.158 + 1.159 +my @cardCollection; 1.160 + 1.161 +for $name(0..$#cards) #22 letters for 22 cards 1.162 +{ 1.163 + 1.164 + #calcuate the thing's place in the grid: 1.165 + 1.166 + $cardsToARow = 5; 1.167 + $cardsToAColumn = 5; 1.168 + 1.169 + my $row = int($name/$cardsToARow); # cards to a row 1.170 + my $column = int($name % $cardsToAColumn); 1.171 + 1.172 + $margin = 25; 1.173 + $cardWidth = 514*0.6057; 1.174 + $cardHeight = 317*0.6057; 1.175 + 1.176 + 1.177 + $transX = 40 + ($margin + $cardWidth ) * $column; 1.178 + $transY = 40 + ($margin + $cardHeight) * $row; 1.179 + 1.180 + 1.181 + 1.182 + ${"group_".$name} = 1.183 + $svg->group( 1.184 + id => "group_".$name, 1.185 + transform => "translate($transX,$transY),"."$base" 1.186 + ); 1.187 + 1.188 + push @cardCollection, ${"group_".$name}; 1.189 +} 1.190 + 1.191 + 1.192 + 1.193 + 1.194 + 1.195 + 1.196 + 1.197 + 1.198 + 1.199 +for ($i = 0; $i <= $#cardCollection; $i++) 1.200 +{ 1.201 + 1.202 + 1.203 +my $data = $xml->XMLin($cards[$i], ForceArray => 1); 1.204 1.205 1.206 my %data = %$data; 1.207 @@ -123,65 +215,6 @@ 1.208 ); 1.209 1.210 1.211 - 1.212 - 1.213 -#print Dumper(%juzz); 1.214 - 1.215 - 1.216 -my $svg= SVG->new(width=>"18in",height=>"12in"); 1.217 - 1.218 -#print Dumper($juzz{'path'}[2]); 1.219 -#print "\n***************************\n"; 1.220 -#print Dumper($pathData); 1.221 - 1.222 - 1.223 - 1.224 - 1.225 -my $base = "scale(0.6057),matrix(1 0 0 -1 0 317), rotate(180),translate(-514,-317)"; 1.226 - 1.227 - 1.228 -my @cardCollection; 1.229 - 1.230 -for $name(0..21) #22 letters for 22 cards 1.231 -{ 1.232 - 1.233 - #calcuate the thing's place in the grid: 1.234 - 1.235 - $cardsToARow = 5; 1.236 - $cardsToAColumn = 5; 1.237 - 1.238 - my $row = int($name/$cardsToARow); # cards to a row 1.239 - my $column = int($name % $cardsToAColumn); 1.240 - 1.241 - $margin = 25; 1.242 - $cardWidth = 514*0.6057; 1.243 - $cardHeight = 317*0.6057; 1.244 - 1.245 - 1.246 - $transX = 40 + ($margin + $cardWidth ) * $column; 1.247 - $transY = 40 + ($margin + $cardHeight) * $row; 1.248 - 1.249 - 1.250 - 1.251 - ${"group_".$name} = 1.252 - $svg->group( 1.253 - id => "group_".$name, 1.254 - transform => "translate($transX,$transY),"."$base" 1.255 - ); 1.256 - 1.257 - push @cardCollection, ${"group_".$name}; 1.258 -} 1.259 - 1.260 - 1.261 - 1.262 - 1.263 - 1.264 - 1.265 - 1.266 - 1.267 -for ($i = 0; $i <= $#cardCollection; $i++) 1.268 -{ 1.269 - 1.270 for $pathData(@{$juzz{'path'}}) 1.271 { 1.272 $cardCollection[$i]->tag('path', %{$pathData}); 1.273 @@ -319,12 +352,7 @@ 1.274 1.275 $attach1 1.276 1.277 -$boundary 1.278 -Content-Type: application/octet-stream; name="huh.txt" 1.279 -Content-Transfer-Encoding: base64 1.280 -Content-Disposition: attachment; filename="huh.txt" 1.281 1.282 -$attach2 1.283 $boundary-- 1.284 1.285 END_OF_BODY