Skip to content

Commit 8454a69

Browse files
committed
Reworking the web reference generation for CSS and Libraries/Tools
1 parent 1f00237 commit 8454a69

4 files changed

Lines changed: 153 additions & 140 deletions

File tree

generate/environment.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,20 @@
22

33
require('../config.php');
44
require('lib/Translation.class.php');
5-
$benchmark_start = microtime_float();
6-
7-
// arguments
8-
$lang = isSet($_POST['lang']) ? $_POST['lang'] : 'en';
95

10-
// get translation file
11-
//$translation = new Translation($lang);
6+
$benchmark_start = microtime_float();
127

138
// make overview page
14-
$source = CONTENTDIR."api_$lang/environment/";
15-
$path = REFERENCEDIR . ($lang == 'en' ? '' : "/$lang") . "/environment/";
9+
$source = CONTENTDIR."api_en/environment/";
10+
$path = REFERENCEDIR . "/environment/";
1611

1712
make_necessary_directories($path."images/file");
1813

1914
$page = new Page("Environment (IDE)", "Environment", "Environment", '../../');
2015
$page->content(file_get_contents($source."index.html"));
21-
$page->language($lang);
16+
$page->language("en");
2217

23-
writeFile('reference/'.($lang=='en'?'':"$lang/").'environment/index.html', $page->out());
18+
writeFile('reference/environment/index.html', $page->out());
2419

2520
copydirr($source.'/images', $path.'/images');
2621

generate/libraries.php

Lines changed: 69 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,78 @@
1-
<?
2-
3-
require_once('../config.php');
4-
require_once('lib/Ref.class.php');
5-
require_once('lib/Translation.class.php');
1+
<?
2+
3+
require_once('../config.php');
4+
require_once('lib/Ref.class.php');
5+
require_once('lib/Translation.class.php');
6+
67
$benchmark_start = microtime_float();
78

89

9-
// content/static/libraries.html
10+
11+
1012
$where = CONTENTDIR . 'static/';
13+
1114
putenv('HOME=' . CONTENTDIR);
1215

16+
1317
// update the file on the server
14-
`cd $where && /usr/bin/svn update libraries.html`;
15-
16-
// arguments
17-
$lang = isset($_POST['lang']) ? $_POST['lang'] : 'en';
18-
19-
// get translation file
20-
$translation = new Translation($lang);
21-
22-
// each lib
23-
$libraries = array('net', 'serial', 'video', 'opengl', 'dxf', 'pdf');
24-
25-
$lib_dir = 'reference/'.($lang != 'en' ? "$lang/" : '').'libraries';
26-
27-
// get library index
28-
$index = CONTENTDIR."api_$lang/libraries/index.html";
29-
$page = new Page('Libraries', 'Libraries');
30-
$page->content(file_get_contents($index));
31-
make_necessary_directories(BASEDIR.$lib_dir.'/images/include.php');
32-
writeFile($lib_dir.'/index.html', $page->out());
33-
copydirr(CONTENTDIR."api_$lang/libraries/images", BASEDIR.$lib_dir.'/images');
34-
35-
// copy over the files for the contributed libraries
36-
copy(CONTENTDIR."static/libraries.html", BASEDIR.$lib_dir.'/libraries.html');
37-
38-
39-
// foreach lib
40-
foreach ($libraries as $lib) {
41-
$source = "api_$lang/LIB_$lib";
42-
$destination = ($lang != 'en' ? "$lang/" : '')."libraries/$lib";
43-
make_necessary_directories(REFERENCEDIR.$destination.'/images/include');
44-
45-
// get xml files
46-
if (!$files = getXMLFiles(CONTENTDIR.$source)) {
47-
//echo "couldn't open files";
48-
} else {
49-
// parse xml files and create pages
50-
foreach ($files as $file) {
51-
$page = new LibReferencePage(new Ref($source.'/'.$file), $lib, $translation, $lang);
52-
$page->write();
53-
}
54-
}
55-
56-
// template and copy index
57-
$index = CONTENTDIR.$source.'/index.html';
58-
if($lib == 'pdf' || $lib == 'dxf') {
59-
$page = new Page(strtoupper($lib) . ' \\ Libraries', 'Libraries', 'Library-index');
60-
} else {
18+
19+
`cd $where && /usr/bin/svn update libraries.html`;
20+
21+
22+
// each lib
23+
$libraries = array('net', 'serial', 'video', 'dxf', 'pdf');
24+
$lib_dir = 'reference/libraries';
25+
26+
// get library index
27+
$index = CONTENTDIR."api_en/libraries/index.html";
28+
$page = new Page('Libraries', 'Libraries');
29+
$page->content(file_get_contents($index));
30+
make_necessary_directories(BASEDIR.$lib_dir.'/images/include.php');
31+
writeFile($lib_dir.'/index.html', $page->out());
32+
copydirr(CONTENTDIR."api_en/libraries/images", BASEDIR.$lib_dir.'/images');
33+
34+
// copy over the files for the contributed libraries
35+
copy(CONTENTDIR."static/libraries.html", BASEDIR.$lib_dir.'/libraries.html');
36+
37+
38+
// foreach lib
39+
foreach ($libraries as $lib) {
40+
$source = "api_en/LIB_$lib";
41+
$destination = "libraries/$lib";
42+
make_necessary_directories(REFERENCEDIR.$destination.'/images/include');
43+
44+
// get xml files
45+
if (!$files = getXMLFiles(CONTENTDIR.$source)) {
46+
//echo "couldn't open files";
47+
} else {
48+
// parse xml files and create pages
49+
foreach ($files as $file) {
50+
$page = new LibReferencePage(new Ref($source.'/'.$file), $lib, $translation, "en");
51+
$page->write();
52+
}
53+
}
54+
55+
// template and copy index
56+
$index = CONTENTDIR.$source.'/index.html';
57+
if($lib == 'pdf' || $lib == 'dxf') {
58+
$page = new Page(strtoupper($lib) . ' \\ Libraries', 'Libraries', 'Library-index');
59+
} else {
6160
//$page = new Page(ucfirst($lib) . ' \\ Libraries', 'Library-index');
62-
$page = new Page(ucfirst($lib) . ' \\ Libraries', 'Libraries');
63-
}
64-
$page->language($lang);
65-
$page->content(file_get_contents($index));
66-
writeFile('reference/'.$destination.'/index.html', $page->out());
67-
68-
// copy images directory
69-
copydirr(CONTENTDIR.$source.'/images', REFERENCEDIR.$destination.'/images');
70-
71-
}
72-
73-
$benchmark_end = microtime_float();
74-
$execution_time = round($benchmark_end - $benchmark_start, 4);
75-
76-
?>
77-
78-
<h2>Library Generation Successful</h2>
61+
$page = new Page(ucfirst($lib) . ' \\ Libraries', 'Libraries');
62+
}
63+
$page->language("en");
64+
$page->content(file_get_contents($index));
65+
writeFile('reference/'.$destination.'/index.html', $page->out());
66+
67+
// copy images directory
68+
copydirr(CONTENTDIR.$source.'/images', REFERENCEDIR.$destination.'/images');
69+
70+
}
71+
72+
$benchmark_end = microtime_float();
73+
$execution_time = round($benchmark_end - $benchmark_start, 4);
74+
75+
?>
76+
77+
<h2>Library Generation Successful</h2>
7978
<p>Generated files in <?=$execution_time?> seconds.</p>

generate/staticpages.php

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,76 @@
1-
<?
2-
3-
require('../config.php');
4-
$benchmark_start = microtime_float();
1+
<?
52

6-
// make troubleshooting page
7-
$source = CONTENTDIR."static";
3+
require('../config.php');
4+
5+
$benchmark_start = microtime_float();
6+
7+
// make troubleshooting page
8+
$source = CONTENTDIR."static";
89
$path = BASEDIR;
9-
10+
1011

1112
// update the files on the server via SVN
1213

14+
1315
// look for the .subversion folder somewhere else
16+
1417
// otherwise will go looking for /home/root/.subversion or some other user
18+
1519
$where = CONTENTDIR . 'static';
20+
1621
putenv('HOME=' . CONTENTDIR);
1722

1823

19-
`cd $where && /usr/bin/svn update`;
20-
21-
// make troubleshooting page
22-
$source = CONTENTDIR."static/";
23-
#$path = BASEDIR;
2424

25-
$page = new Page("Books", "Books");
26-
$page->content(file_get_contents($source."books.html"));
25+
`cd $where && /usr/bin/svn update`;
26+
27+
// make troubleshooting page
28+
$source = CONTENTDIR."static/";
29+
#$path = BASEDIR;
30+
31+
$page = new Page("Books", "Books");
32+
$page->content(file_get_contents($source."books.html"));
2733
writeFile('learning/books/index.html', $page->out());
34+
35+
2836
// copy over the errata file for Processing: A Programming Handbook...
37+
2938
copy($source.'processing-errata.txt', $path.'learning/books/processing-errata.txt');
30-
31-
$page = new Page("Copyright", "Copyright");
32-
$page->content(file_get_contents($source."copyright.html"));
39+
40+
$page = new Page("Copyright", "Copyright");
41+
$page->content(file_get_contents($source."copyright.html"));
42+
3343
writeFile('copyright.html', $page->out());
3444

35-
// Copy over the images for the shop index
45+
// Copy over the images for the shop index
3646
if (!is_dir($path.'shop')) {
47+
3748
mkdir($path.'shop', '0757');
49+
3850
}
51+
3952
if (!is_dir($path.'shop/imgs')) {
53+
4054
mkdir($path.'shop/imgs', '0757');
55+
4156
}
42-
if (is_dir($path.'shop/imgs')) {
57+
58+
if (is_dir($path.'shop/imgs')) {
4359
copydirr($source.'shop/'.'imgs', $path.'shop/imgs', null, 0757, true);
44-
}
4560

46-
$page = new Page("Shop", "Shop");
47-
$page->content(file_get_contents($source.'shop/'."index.html"));
61+
}
62+
63+
$page = new Page("Shop", "Shop");
64+
$page->content(file_get_contents($source.'shop/'."index.html"));
4865
writeFile('shop/index.html', $page->out());
4966

50-
51-
$benchmark_end = microtime_float();
52-
$execution_time = round($benchmark_end - $benchmark_start, 4);
53-
54-
?>
55-
56-
<h2>Static page generation Successful</h2>
57-
<p>Generated files in <?=$execution_time?> seconds.</p>
58-
<!--<p>Page put here: <?=$source."faq.html"?></p>-->
67+
68+
$benchmark_end = microtime_float();
69+
$execution_time = round($benchmark_end - $benchmark_start, 4);
70+
71+
?>
72+
73+
<h2>Static page generation Successful</h2>
74+
<p>Generated files in <?=$execution_time?> seconds.</p>
75+
<!--<p>Page put here: <?=$source."faq.html"?></p>-->
5976
<!--<p>Page put here: <?=$path.'faq.html'?></p>-->

generate/tools.php

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
1-
<?
2-
1+
<?
2+
33
require_once('../config.php');
4-
require_once('lib/Translation.class.php');
5-
$benchmark_start = microtime_float();
6-
7-
// arguments
8-
$lang = isset($_POST['lang']) ? $_POST['lang'] : 'en';
9-
$tools_dir = 'reference/'.($lang != 'en' ? "$lang/" : '').'tools';
10-
11-
// get translation file
12-
$translation = new Translation($lang);
13-
14-
// get tools index
15-
$index = CONTENTDIR."api_en/tools/index.html";
16-
$page = new Page('Tools', 'Tools');
17-
$page->content(file_get_contents($index));
18-
//make_necessary_directories(BASEDIR.$tools_dir.'/images/include.php');
4+
require_once('lib/Translation.class.php');
5+
$benchmark_start = microtime_float();
6+
7+
// arguments
8+
//$lang = isset($_POST['lang']) ? $_POST['lang'] : 'en';
9+
//$tools_dir = 'reference/'.($lang != 'en' ? "$lang/" : '').'tools';
10+
11+
// get translation file
12+
//$translation = new Translation($lang);
13+
14+
// get tools index
15+
$index = CONTENTDIR."api_en/tools/index.html";
16+
$page = new Page('Tools', 'Tools');
17+
$page->content(file_get_contents($index));
18+
//make_necessary_directories(BASEDIR.$tools_dir.'/images/include.php');
1919
writeFile($tools_dir.'/index.html', $page->out());
2020

2121
if (!is_dir(BASEDIR.$tools_dir.'/images')) {
22-
mkdir(BASEDIR.$tools_dir.'/images', '0757');
23-
}
24-
copydirr(CONTENTDIR."api_$lang/tools/images", BASEDIR.$tools_dir.'/images');
25-
26-
// copy over the files for the contributed libraries
22+
23+
mkdir(BASEDIR.$tools_dir.'/images', 0757);
24+
25+
}
26+
copydirr(CONTENTDIR."api_en/tools/images", BASEDIR.$tools_dir.'/images');
27+
28+
// copy over the files for the contributed libraries
2729
copy(CONTENTDIR."static/tools.html", BASEDIR.$tools_dir.'/tools.html');
28-
29-
$benchmark_end = microtime_float();
30-
$execution_time = round($benchmark_end - $benchmark_start, 4);
31-
32-
?>
33-
34-
<h2>Tool Generation Successful</h2>
30+
31+
$benchmark_end = microtime_float();
32+
$execution_time = round($benchmark_end - $benchmark_start, 4);
33+
34+
?>
35+
36+
<h2>Tool Generation Successful</h2>
3537
<p>Generated files in <?=$execution_time?> seconds.</p>

0 commit comments

Comments
 (0)