-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathknit_projects.pl
333 lines (265 loc) · 9.62 KB
/
knit_projects.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
#!perl5
use File::Spec::Functions qw(rel2abs);
use File::Basename;
use List::Util qw(first);
$site_directory = dirname(rel2abs($0))."\\";
print $site_directory."\n";
$menu_file = $site_directory."projects_base\\project_menu.html";
@projects = qw(sn_2014 panda epub tour_forecast mobileoffice udbs minimod sn_2010 peoplemap sri_cad mom sn_2006 dmu adhd nhcei_site r180_edit gizmos frontline_site ips maxracks_site fe_site seaquest hypertv tencore sr read180 eschool lmaw fws aftts);
#@projects = qw(mobileoffice udbs minimod sn_2014 panda epub tour_forecast);
@long_content=qw(c scripting director mac);
@strong_names = ("Maxracks","Grassroots Technologies", "Sackler Institute for Developmental Psychobiology");
@emp_names = ("MobileOffice", "UDBS-Plus", "Starry Night", "Math-O-Matic", "PeopleMap", "Gizmos");
@strong_names = ("RCO, Inc.", "Open Platform Group", "eSkills Learning, LLC", "Simulation Curriculum", "Imaginova", "ExploreLearning", "Scholastic, Inc.", "Sackler Institute for Developmental Psychobiology", "eSkills Learning");
# set up the client and skills hashes
%clients = (
sc => ["sn_2014","tle", "sri_cad", "sn_2010"],
scholastic => ["dmu", "r180_edit", "ips"],
all => \@projects
);
%archive_clients = (
mullaghdun => ["mom"],
sackler => ["adhd"],
explorelearning => ["gizmos"],
imaginova => ["sn_2006"],
sri => ["sri_cad"],
nhcei => ["nhcei_site"],
actv => ["hypertv","eschool"],
maxracks => ["maxracks_site"],
frontline => ["frontline_site"],
feralette => ["fe_site"],
flat => ["seaquest"],
catharon => ["tencore"],
eb => ["fws"],
vtech => ["fws"],
terra => ["aftts"],
cw => ["bb","tm"],
ctw => ["lmaw","lips"],
mazer => ["dfi"],
cuny => ["cuny_math"]
);
%skills = (
ios => ["mobileoffice", "minimod"],
c => [ "sn_2014","mobileoffice", "minimod", "udbs", "dmu", "r180_edit", "sn_2010", "ips"],
java => ["panda", "tle"],
scripting => ["epub","minimod","sri_cad", "ips"],
mysql => ["panda","udbs", "sri_cad", "peoplemap"],
web => ["tour_forecast", "panda", "grd", "epub", "peoplemap"],
);
%archive_skills = (
c => [ "sn_2014","mobileoffice", "minimod", "udbs", "dmu", "r180_edit", "sn_2006", "ips","hypertv","tencore","sr","eschool","lmaw","fws","aftts","bb","tm","lips","cuny_math"],
director => ["mom","adhd","gizmos", "ips","seaquest","read180","aftts","dfi"],
mac => ["sn_2010", "dmu", "r180_edit", "sn_2006", "ips","hypertv","tencore","sr","eschool","lmaw","aftts","lips","cuny_math"],
cd => ["ips","lmaw","fws","aftts","dfi"],
apps => ["ips","tencore","lmaw","fws","lips"],
plugins => ["hypertv","eschool","aftts"],
porting => ["maxracks_site","hypertv","sr","lmaw","dfi","cuny_math"],
project_mgmt => ["sri_cad", "mom", "sn_2006","ips", "maxracks_site","hypertv"],
production => ["sri_cad", "peoplemap","sn_2006","ips", "maxracks_site","hypertv"],
web => ["peoplemap", "nhcei_site", "frontline_site", "maxracks_site","fe_site"],
scripting => ["minimod", "sri_cad", "peoplemap", "sn_2006","ips", "nhcei_site","maxracks_site","fws"],
mysql => ["udbs", "sri_cad", "peoplemap","frontline_site", "maxracks_site"],
);
%entities = (
xrgb => ["gizmos", "frontline_site", "maxracks_site","ips","hypertv","fe_site"],
boing => ["fws","aftts","tm","bb", "lmaw", "maxracks_site"]
);
@indices = qw(index missing);
# do the index files
foreach $index (@indices) {
#get the blurb
$project_buf = getFileBuf($site_directory."index_base\\".$index."_base.html");
$title=extractTitle($project_buf);
$project_buf = stripHTMLHeader($project_buf);
# get the page template
$menu_buf = getFileBuf($menu_file);
$menu_buf =~ s/\.\.\///g;
#replace the ^CONTENT tag
$menu_buf =~ s/\^CONTENT/$project_buf/;
$menu_buf =~ s/\^TITLE/$title/;
$project_file = $site_directory.$index.".html";
open(PROJECT_FILE, ">",$project_file) || die "can't open file '$project_file'.\n";
print PROJECT_FILE $menu_buf;
close PROJECT_FILE;
if ($index =~ m/index/) {
$project_file = $site_directory.$index.".htm";
open(PROJECT_FILE, ">:utf8",$project_file) || die "can't open file '$project_file'.\n";
print PROJECT_FILE $menu_buf;
close PROJECT_FILE;
}
}
# do the projects
foreach $project (@projects) {
#get the project blurb
$project_buf = getFileBuf($site_directory."projects_base\\".$project."_base.html");
$title=extractTitle($project_buf);
$project_buf = stripHTMLHeader($project_buf);
# get the page template
$menu_buf = getFileBuf($menu_file);
#replace the ^CONTENT tag
$menu_buf =~ s/\^CONTENT/$project_buf/;
$menu_buf =~ s/\^TITLE/$title/;
$project_file = $site_directory."projects\\".$project.".html";
open(PROJECT_FILE, ">".$project_file) || die "can't open project file '$project_file'.\n";
print PROJECT_FILE $menu_buf;
close PROJECT_FILE;
}
#do the skills
foreach $skill (keys %skills) {
$skill_buf = getFileBuf($site_directory."skills_base\\".$skill."_base.html");
$title=extractTitle($skill_buf);
$skill_buf = stripHTMLHeader($skill_buf);
#print $skill_buf."\n\n";
my $evenOrOdd = 0;
foreach $project (@{$skills{$skill}}) {
#get the project blurb
$project_buf = tackOnProject($project, ($evenOrOdd % 2) == 0);
$skill_buf = $skill_buf.$project_buf;
$evenOrOdd++;
}
# get the page template
$menu_buf = getFileBuf($menu_file);
# if this is a not long skill page, change the background color....
#if( $skill =~ m/c|scripting|director|mac/ ) {
# print "changing'...".$skill."\n";
# $menu_buf =~ s/id=\"container\"/id=\"container\" style=\"background\-color\:\#FAFAFA;\"/i;
# $menu_buf =~ s/id=\"body_right\"/id=\"body_right\" style=\"background\-color\:\#FCFCFC;\"/i;
# $menu_buf =~ s/id=\"body_left"/id=\"body_left\" style=\"border\:0;\"/i;
# $menu_buf =~ s/id=\"content\"/id=\"content\" style=\"border\-left\:1px solid \#C0C0C0;\"/i;
# }
#replace the ^CONTENT tag
$menu_buf =~ s/\^CONTENT/$skill_buf/;
$menu_buf =~ s/\^TITLE/$title/;
$skill_file = $site_directory."skills\\".$skill.".html";
open(SKILL_FILE, ">".$skill_file) || die "can't open skill file '$skill_file'.\n";
print SKILL_FILE $menu_buf;
close SKILL_FILE;
}
#do the clients
foreach $client (keys %clients) {
$client_buf = getFileBuf($site_directory."clients_base\\".$client."_base.html");
$title=extractTitle($client_buf);
$client_buf = stripHTMLHeader($client_buf);
my $evenOrOdd = 0;
foreach $project (@{$clients{$client}}) {
#get the project blurb
$project_buf = tackOnProject($project, ($evenOrOdd % 2) == 0);
$client_buf = $client_buf.$project_buf;
$evenOrOdd++;
}
# get the page template
$menu_buf = getFileBuf($menu_file);
#replace the ^CONTENT tag
$menu_buf =~ s/\^CONTENT/$client_buf/;
$menu_buf =~ s/\^TITLE/$title/;
$client_file = $site_directory."clients\\".$client.".html";
open(CLIENT_FILE, ">".$client_file) || die "can't open client file '$client_file'.\n";
print CLIENT_FILE $menu_buf;
close CLIENT_FILE;
}
#do the entities
#foreach $entity (keys %entities) {
# $entity_buf = "";
# foreach $project (@{$entities{$entity}}) {
# #get the project blurb
# $project_buf = getFileBuf($site_directory."projects_base\\".$project."_base.html");
# $project_buf = stripHTMLHeader($project_buf);
# $entity_buf = $entity_buf.$project_buf.$sep_html;
# }
# # get the page template
# $menu_buf = getFileBuf($menu_file);
#replace the ^CONTENT tag
# $menu_buf =~ s/\^CONTENT/$entity_buf/;
# $entity_file = $site_directory."entities\\".$entity.".html";
# open(ENTITY_FILE, ">".$entity_file) || die "can't open entity file '$entity_file'.\n";
# print ENTITY_FILE $menu_buf;
# close ENTITY_FILE;
#}
sub getFileBuf {
my $the_file = shift;
my $buf = "";
open(THEFILE, "<:encoding(UTF-8)",$the_file) || die "can't open file '$the_file'.\n";
read( THEFILE, $buf, 30000) || die "can't read file '$the_file'.\n";
close(THEFILE);
return $buf;
}
sub stripHTMLHeader {
my $out_buf = "";
$_ = shift;
if (/<body>(.*)<\/body>/si) {
$out_buf = $1;
}
@paras = split("<p>", $out_buf);
pop(@paras);
$html=join("<p>",@paras);
return join("<p>",@paras);
}
sub extractTitle {
my $out_buf = "";
$_ = shift;
if (/<title>(.*)<\/title>/si) {
$out_buf = $1;
}
return $out_buf;
}
sub extractAbstract {
my $out_buf = "";
$_ = shift;
if (/<body>(.*)<\/body>/si) {
$out_buf = $1;
}
return $out_buf;
}
sub extractSummary {
my $out_buf = "";
$_ = shift;
if (/<body>(.*)<\/body>/si) {
$out_buf = $1;
}
@paras = split("<p>", $out_buf);
if( scalar(@paras) >= 2) {
$sum_buf=pop(@paras);
@sum_list=split("</p>", $sum_buf);
return shift(@sum_list);
}else {
return $out_buf;
}
}
sub extractDetail {
$_ = shift;
my $out_buf = extractAbstract($_);
@paras = split("<p>", $out_buf);
if( scalar(@paras) >= 2) {
pop(@paras);
return join("<p>",@paras);
}else {
return $out_buf;
}
}
sub tackOnProject {
my $project= shift;
my $evenOrOdd = shift;
my $project_buf = getFileBuf($site_directory."projects_base\\".$project."_base.html");
my $short_buf=extractDetail($project_buf);
if( ($evenOrOdd % 2) == 0 ) {
$short_buf = "<div class='project_cell project_cell_even'>".$short_buf;
}
else {
$short_buf = "<div class='project_cell project_cell_odd'>".$short_buf;
}
return $short_buf."</div>";
# my $out_buf = "";
# $out_buf =$short_buf;
# my $proj_title=extractTitle($project_buf);
# $out_buf = "<p><h4 class=\"proj_hdr\">".$proj_title."</h4>\n";
# my $index = first { $projects[$_] eq $project } 0 .. $#projects;
# if( $index > 0 || $projects[0] eq $project) {
# $out_buf = $out_buf." <a href=\"../projects/".$project.".html\">[<em>details...</em>]</a>";
# print $project, " ", $index, "\n";
# }
# else {
# print $project, " has no details\n";
# }
# $out_buf = $out_buf."</p>\n";
# return $out_buf;
}