My favorites | Sign in
Project Home Downloads Source
Checkout   Browse   Changes    
 
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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
#include "www.h"
#define IMAGECLASS WWW
#define IMAGEFILE <uppweb/www.iml>
#include <Draw/iml.h>
#include <plugin/ftp/ftp.h>

#define TFILE <uppweb/www.t>
#include <Core/t.h>

#define LLOG(x) // LOG(x)

#ifdef PLATFORM_WIN32
String rootdir = "u:\\upp.src";
String uppbox = rootdir + "uppbox";
String uppsrc = rootdir + "uppsrc";
String reference = rootdir + "reference";
String examples = rootdir + "examples";
String targetdir = "u:\\uppwww";
String pdfdir = "u:\\pdf";
#else
String rootdir = "/root/upp.src";
String uppbox = rootdir + "uppbox";
String uppsrc = rootdir + "uppsrc";
String reference = rootdir + "reference";
String examples = rootdir + "examples";
String targetdir = "/var/www";
String diffdir = "/root/wwwupp";
String pdfdir = "/var/www";
#endif
String bazaar;
bool outPdf;
bool doSvn;

String GetRcFile(const char *s)
{
String f = GetDataFile(s);
if(FileExists(f))
return f;
return GetHomeDirFile("upp.src/uppbox/uppweb/" + AsString(s));
}

bool ContainsAt(const String &source, const String &pattern, int pos)
{
return pos >= 0
&& pos + pattern.GetLength() <= source.GetLength()
&& 0 == memcmp(source.Begin() + pos, pattern.Begin(), pattern.GetLength());
}

bool StartsWith(const String &source, const String &pattern)
{
return ContainsAt(source, pattern, 0);
}

bool EndsWith(const String &source, const String &pattern)
{
return ContainsAt(source, pattern, source.GetLength() - pattern.GetLength());
}

String ImgName(int q)
{
return Sprintf("%di.png", q);
}

typedef Image (*ImageFn)();

namespace Upp {
template<>
unsigned GetHashValue(const ::ImageFn& fn) { return (unsigned)(uintptr_t) fn; }
};

String GetImageSrc(ImageFn img)
{
static Index<ImageFn> il;
int q = il.Find(img);
if(il.Find(img) < 0) {
q = il.GetCount();
il.Add(img);
PNGEncoder png;
png.SaveFile(AppendFileName(targetdir, ImgName(q)),(*img)());
}
return ImgName(q);
}

Htmls Wimg(ImageFn img)
{
return HtmlImg(GetImageSrc(img)).Border(0);
}

Htmls RoundFrame(Htmls data, String border, Color bg)
{
return HtmlPackedTable().BgColor(bg).Width(-100)
.Attr("style", "border-style: solid; border-width: 1px; border-color: #" + border + ";")
/ HtmlLine() / data;
}

HtmlTag BoxWidth(int width)
{
return HtmlPackedTable().Width(width) / HtmlLine();
}

Htmls BarSection(const char *txt)
{
Htmls bar;
bar.Br();
bar << HtmlPackedTable().BgColor(WhiteGray).Width(-100) /
(HtmlRow() / (
HtmlCell().Width(10) / "&nbsp;" +
HtmlCell() / HtmlArial(8) / HtmlBold() / txt +
HtmlCell().Width(10) / "&nbsp;"
));
return bar;
}

Htmls BarCaption(const char *text)
{
return HtmlLine()
.Width(-100)
.VCenter()
.Style("background-image: url('" + GetImageSrc(WWW::Caption) + "'); "
"border: 0px solid black;"
"padding-left:12px; padding-right:0px; "
"padding-top:1px; padding-bottom:1px;"
"color:#FFFFFF;")
/ HtmlBold() / HtmlArial(8) / text;
}

Htmls BarCaptionLang(const char *text)
{
return HtmlLine()
.Width(20)
.VCenter()
.Style("background-image: url('" + GetImageSrc(WWW::News2) + "'); "
"border: 0px solid black;"
"padding-left:12px; padding-right:0px; "
"padding-top:1px; padding-bottom:1px;"
"color:#FFFFFF;")
/ HtmlBold() / HtmlArial(8) / text;
}

Htmls BarItem(Htmls content, const char *style)
{
String bgStyle = "background-image: url('" + GetImageSrc(WWW::Button) + "'); ";
return HtmlLine().Width(-100).VCenter().Style(bgStyle + style)
/ content;
}

Htmls BarLink(const char *link, const char *text, bool nxt = true)
{
String style = "border: 0px solid black; "
"padding-left:12px; padding-right:0px; "
"padding-top:6px; padding-bottom:6px;";
if(nxt)
style += " border-top: 1px solid #6E89AE;";

return BarItem( HtmlLink(link).Class("l1") / text, style );
}

Htmls SearchBar(const char *domain)
{
Htmls form =
HtmlForm("http://www.google.com/search", false, "GET")
.Style("margin:0px;padding:0px;") /
( HtmlHidden("ie", "UTF-8") +
HtmlHidden("oe", "UTF-8") +
HtmlEdit("q", 15) +
HtmlHidden("domains", domain) +
HtmlHidden("sitesearch", domain)
);

Htmls content;
content << HtmlPackedTable().Width(-100)
/ HtmlRow() / (
HtmlCell() / Wimg(WWW::google) +
HtmlCell() / form
);

String style = "border: 0px solid black; "
"padding-left:6px; padding-right:0px; "
"padding-top:4px; padding-bottom:4px;"
"border-top: 1px solid #6E89AE;";
return BarItem(content, style);
}

HtmlTag HtmlPadding(int p)
{
return HtmlPackedTable().Width(-100) /
HtmlLine();
}

VectorMap<String, String> escape;

String QtfAsHtml(const char *qtf, Index<String>& css,
const VectorMap<String, String>& links,
const VectorMap<String, String>& labels,
const String& outdir, const String& fn = Null)
{
return EncodeHtml(ParseQTF(qtf), css, links, labels, outdir, fn, Zoom(8, 40), escape, 40);
}

String GetText(const char *s)
{
return GetTopic(s).text;
}

String ChangeTopicLanguage(const String &topic, int lang) {
int pos = topic.ReverseFind('$');
if (pos < 0)
return "";
String langtxt = ToLower(LNGAsText(lang));
return topic.Left(pos+1) + langtxt + topic.Mid(pos+1+langtxt.GetCount());
}

String GetTopicLanguage(const String &topic) {
int pos = topic.ReverseFind('$');
if (pos < 0)
return "";
return topic.Mid(pos+1, 5);
}

String FormatDateRFC822(const Time& t) {
int tz = int((GetSysTime()-GetUtcTime())/60);
return Format("%s, %d %Mon %d %02d:%02d:%02d %s%04d",
DayName(DayOfWeek(t)).Left(3),
t.day,t.month,t.year,
t.hour,t.minute,t.second,
tz>0?"+":"",tz/60*100+(tz+1440)%60);
}

void CreateRssFeed() {
String header="<rss version=\"2.0\" xmlns:atom=\"http://www.w3.org/2005/Atom\">\n"
"<channel>\n"
"<title>Ultimate++ svn changes</title>\n"
"<link>http://ultimatepp.org/</link>\n"
"<description>This feed offers list of commits to Ultimate++ framework svn repository</description>\n"
"<lastBuildDate>"+ FormatDateRFC822(GetSysTime()) + "</lastBuildDate>\n"
"<language>en-us</language>\n"
"<atom:link href=\"http://ultimatepp.org/svnchanges.xml\" rel=\"self\" type=\"application/rss+xml\" />\n\n";

String items;
for(int i = 0; i < min(30,svnlog.GetCount()); i++){
items+="<item>\n"
"<title>Revision " + svnlog[i].revision + "</title>\n"
"<link>http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "</link>\n"
"<guid>http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "</guid>\n"
"<pubDate>" + FormatDateRFC822(svnlog[i].time) + "</pubDate>\n"
"<description><![CDATA[\n"
" <table style=\"font-size:small;\">\n"
" <tr><td>Revision:</td><td><b>" + svnlog[i].revision + "</b></td></tr>\n"
" <tr><td>Description:</td><td><code>" + svnlog[i].msg + "</code></td></tr>\n"
" <tr><td>Submitted:</td><td><i>" + FormatDateRFC822(svnlog[i].time) + "</i> by <i>" + svnlog[i].author + "</i></td></tr>\n"
" <tr><td>Affected files:</td><td>&nbsp;</td></tr>\n"
" <tr><td colspan=\"2\">\n"
" <div style=\"margin-left:20px;\">\n";
for(int j = 0; j < svnlog[i].changes.GetCount(); j++)
items+="<a href=\"http://code.google.com/p/upp-mirror/source/diff?spec=svn" + svnlog[i].revision + "&amp;r=" + svnlog[i].revision + "&amp;format=side&amp;path=" + svnlog[i].changes[j].path + "\" target=\"gcode\">" + svnlog[i].changes[j].action + "</a>&nbsp;"
"<a href=\"http://code.google.com/p/upp-mirror/source/browse" + svnlog[i].changes[j].path + "\" target=\"gcode\">" + svnlog[i].changes[j].path + "</a><br>\n";
items+=
" </div>\n"
" </td></tr>\n"
" </table>\n"
"]]></description>\n"
"</item>\n\n";
}
SaveFile(AppendFileName(targetdir, "svnchanges.xml"), header + items + "</channel>\n</rss>\n");
}

VectorMap<String, Topic> tt;

String Www(const char *topic, int lang, String topicLocation = "topic://uppweb/www/")
{
String strLang = ToLower(LNGAsText(lang));
String www = GatherTopics(tt, String().Cat() << topicLocation << topic << "$" << strLang);
if (www != "index.html")
return www;
return GatherTopics(tt, String().Cat() << topicLocation << topic << "$" << "en-us");
}

String FolderLinks(String package, String group, int lang)
{
String qtf;
FindFile ff(AppendFileName(AppendFileName(AppendFileName(uppsrc, package), group + ".tpp"), "*.tpp"));
while(ff) {
if(ff.IsFile()) {
if (ff.GetName().Find("en-us") >= 0) {
String title;
String tl = "topic://" + package + '/' + group + '/' + GetFileTitle(ff.GetName());
tl = ChangeTopicLanguage(tl, lang);
GatherTopics(tt, tl, title);
qtf << "________[^" << tl << "^ " << DeQtf(Nvl(title, tl)) << "]&";
}
}
ff.Next();
}
return qtf;
}

void AddFiles(String& qtf, const String& dir, const char* ext, bool& b)
{
FindFile ff(AppendFileName(dir, "*." + String(ext)));
while(ff) {
qtf << "[A4* " << DeQtf(ff.GetName()) << "]&&"
<< CppAsQtf(LoadFile(AppendFileName(dir, ff.GetName())))
<< "&&&";
ff.Next();
b = true;
}
}

struct Isort {
bool operator()(const String& a, const String& b) const
{
return ToUpper(a) < ToUpper(b);
}
};

String MakeExamples(const char *dir, const char *www, int language)
{
String ttxt;
FindFile ff(AppendFileName(dir, "*.*"));
ttxt << "{{1:3 ";
bool next = false;
Vector<String> ls;
while(ff) {
if(ff.IsFolder())
ls.Add(ff.GetName());
ff.Next();
}
Sort(ls, Isort());
for(int i = 0; i < ls.GetCount(); i++) {
String name = ls[i];
String link = String().Cat() << www << '$' << name << "$" << ToLower(LNGAsText(language)) << ".html";
Topic& topic = tt.Add(link);
topic.title = name;
String fn = AppendFileName(
AppendFileName(
AppendFileName(uppbox, "uppweb"),
String(www) + ".tpp"
),
topic.title + "$" + ToLower(LNGAsText(language)) + ".tpp"
);
String h = ReadTopic(LoadFile(fn)).text;
Package p;
p.Load(AppendFileName(AppendFileName(dir, name), name + ".upp"));
topic.text << "[R6* " << name << "]&&" << DeQtf(p.description) << "&";
if(h.GetCount())
topic.text << h;
topic.text << "[A2<l0r0 &&";
String d = AppendFileName(dir, name);
bool b = false;
AddFiles(topic.text, d, "h", b);
AddFiles(topic.text, d, "hpp", b);
AddFiles(topic.text, d, "cpp", b);
AddFiles(topic.text, d, "usc", b);
AddFiles(topic.text, d, "lay", b);
AddFiles(topic.text, d, "key", b);
AddFiles(topic.text, d, "brc", b);
AddFiles(topic.text, d, "sch", b);
AddFiles(topic.text, d, "xml", b);
if(b) {
if(next)
ttxt << "\n::^ ";
ttxt << "[^" << link << "^ " << DeQtf(topic.title) << "]::^ "
<< DeQtf(p.description);
next = true;
}
}
ttxt << "}}&&";
return ttxt;
}

void SrcDocs(Index<String> &x, String& qtf, const char *folder, int lang)
{
if(x.Find(folder) >= 0)
return;
x.Add(folder);
String srcdoc = FolderLinks(folder, "srcdoc", lang);
String src = FolderLinks(folder, "src", lang);
Package p;
p.Load(AppendFileName(uppsrc, AppendFileName(folder, GetFileName(folder) + ".upp")));
if(srcdoc.GetLength() || src.GetLength()) {
qtf << "&&&[*4@b " << folder << "]&";
if(!IsNull(p.description))
qtf << "[2 " << p.description << "]&";
if(srcdoc.GetCount()) {
qtf << "&[3/* " + Format(t_("Using %s"), folder) << "]&";
qtf << srcdoc;
}
if(src.GetCount()) {
qtf << "&[3/* " << Format(t_("%s reference"), folder) << "]&";
qtf << src;
}
}
}

int CharFilterLbl(int c)
{
return IsAlNum(c) ? c : '.';
}


void QtfAsPdf(PdfDraw &pdf, const char *qtf)
{
RichText txt = ParseQTF(qtf);
Size page = Size(3968, 6074);
UPP::Print(pdf, txt, page);
}

VectorMap<String, String> links;
VectorMap<String, String> labels;
Htmls header, lastUpdate;

Array <Htmls> bar;
Array <int> languages;

int GetLinkLanguage(const String &link) {
int pos = link.ReverseFind('$');
if (pos < 0)
return 0;
int lang = LNGFromText(ToUpper(link.Mid(pos+1)));
for (int i = 0; i < languages.GetCount(); ++i) {
if (languages[i] == lang)
return i;
}
return 0;
}

void ExportPage(int i)
{
Index<String> css;
String path = links.GetKey(i);
RLOG("Exporting " << path);

int ilang = GetLinkLanguage(path);
SetLanguage(languages[ilang]);
String text = GetText(path);
int h;
h = ParseQTF(tt[i].text).GetHeight(1000);

int isvn = svndata.Find(tt.GetKey(i));
String qtflangs;
String googleFile;
if (isvn > -1) {
String txt = String("[2 ") + t_("Last edit by %s on %s") + ".]";
qtflangs += Format(txt, svndata[isvn].author, Format(Date(svndata[isvn].time)));
googleFile = svndata[isvn].fullPath;
if (googleFile.GetCount() > rootdir.GetCount())
googleFile = UnixPath(googleFile.Mid(rootdir.GetCount()));
else
googleFile = "";
}
String strlang;
String jslang;
Array <String> arrLangs;
for (int il = 0; il < languages.GetCount(); ++il) {
String topic = ChangeTopicLanguage(path, languages[il]);
int itopic;
if ((itopic = tt.Find(topic)) >= 0) {
if (tt[itopic].title.Find(" (translated)") < 0) {
if (il != ilang) {
if (!strlang.IsEmpty())
strlang << ", ";
arrLangs.Add("[^" + links[itopic] + "^ [2 " + ToLower(GetNativeLangName(languages[il])) + "]]");
}
jslang+="'"+ links[itopic] +"':'" + GetNativeLangName(languages[il]) + "',";
}
}
}
if(!jslang.IsEmpty())
jslang.Trim(jslang.GetCount()-1);
if (arrLangs.GetCount() > 0) {
for (int i = 0; i < arrLangs.GetCount(); ++i) {
if (i == arrLangs.GetCount()-1 && i != 0)
strlang << String(" ") + t_("and") + " ";
else if (i > 0)
strlang << ", ";
strlang << arrLangs[i];
}
}
if (!strlang.IsEmpty())
qtflangs += Format(String("[2 ") + t_("This page is also in %s") + ".]", strlang);
if (tt[i].title.Find("How to contribute. Web page") < 0) {
String help = "topic://uppweb/www/contribweb$" + ToLower(LNGAsText(languages[ilang]));
qtflangs += " " + String("[^") + help + "^ [<A2 " + t_("Do you want to contribute?") + "]]";
if (googleFile != "")
qtflangs += ". [^http`:`/`/upp`-mirror.googlecode.com`/svn`/trunk" + DeQtf(googleFile) + "^/1 " + "T`+`+" + "]";
}

String langs = QtfAsHtml(qtflangs, css, links, labels, targetdir, links[i]);
String page = tt[i];

Array<String> htmlrep;
int posB = 0;
while (true) {
posB = page.Find("[IHTMLTEXT", posB);
if (posB < 0)
break;
int posBB = posB + (int)strlen("[IHTMLTEXT");
int pos0 = page.ReverseFind("[", posB-1);
int posE = page.Find(";2", posBB);
String html0 = page.Mid(posBB, posE - posBB);
html0.Replace("`", "");
htmlrep.Add(html0);
int posEE = page.Find("]&]", posE) + (int)strlen("]&]");

page = page.Left(pos0) + "QTFHTMLTEXT" + FormatInt(htmlrep.GetCount()-1) + page.Mid(posEE+1);
}

page = QtfAsHtml(page, css, links, labels, targetdir, links[i]);
for (int iHtml = 0; iHtml < htmlrep.GetCount(); ++iHtml)
page.Replace(String("QTFHTMLTEXT") + FormatInt(iHtml), htmlrep[iHtml]);

Color paper = SWhite;
if(path == "topic://uppweb/www/download$en-us")
page << LoadFile(GetRcFile("adsense3.txt"));
/* if(path == "topic://uppweb/www/index$en-us") {
for(int q = 0; q < news.GetCount(); q++) {
String n = GetText("uppweb/www_news/" + news[q]);
String h = news[q];
int i = h.Find('$');
if(i >= 0)
h = h.Mid(0, i);
if(h.GetLength() == 8)
h = h.Mid(0, 4) + '-' + h.Mid(4, 2) + '-' + h.Mid(6, 2);
page << "<br>";
page << "<div style='font-family:sans-serif; font-weight: bold; "
"font-height: 12px; color: White; background: #2020d0'>&nbsp;&nbsp;"
<< h << "</div><br>";
page << QtfAsHtml(n, css, links, targetdir, FormatIntAlpha(q) + "_n");
page << "<br>";
}
}*/
Color bg = Color(210, 217, 210);
Htmls footer;
footer << HtmlTable().Border(0).Width(-100) / HtmlLine() +
RoundFrame(HtmlPadding(8) / langs , "6E89AE;padding: 10px;", White);
Htmls html;
html <<
HtmlPackedTable().Width(-100) /
HtmlLine().ColSpan(3) / header +
HtmlPackedTable().Width(-100) / (
HtmlLine().ColSpan(3).BgColor(bg).Height(6) / "" +
HtmlRow() / (
HtmlTCell().Center() / BoxWidth(160).Center() / (
bar[GetLinkLanguage(path)] +
"<br>" +
LoadFile(GetRcFile("facebook.txt")) +
"<br><br>" +
// "<p align=\"center\">" +
LoadFile(GetRcFile("adsense2.txt")) +
"<br><br>" +
LoadFile(GetRcFile("adlinks.txt")) +
(h > 25000 ? "<br><br>" + LoadFile(GetRcFile("adsense2.txt"))
: "") +
"<br><br><br>" +
// LoadFile(GetRcFile("referral.txt")) +
// LoadFile(GetRcFile("referral2.txt")) +
// LoadFile(GetRcFile("donations.txt")) +
// "<br><br>" +
// amazon[i % amazon.GetCount()] +
"<br><br><br>" +
HtmlLink("http://sourceforge.net/projects/upp/") /
HtmlImg("http://sourceforge.net/sflogo.php?group_id=93970&type=2",
"SourceForge.net Logo").Border(0).Width(125).Height(37) +
"<br><br>" +
HtmlLink("http://www.sdjournal.org/en/") /
HtmlImg(GetImageSrc(WWW::Sdj)).Border(0) +
"<br><br>" +
(links[i] == "index.html" ? lastUpdate : Htmls()) +
HtmlImg("http://www.vol.cz/cgi-bin/wc/upp").Width(1).Height(1)
) +
HtmlTCell().BgColor(bg) / BoxWidth(6) / "" +
HtmlTCell().Width(-100).BgColor(bg) / (
RoundFrame(HtmlPadding(8) / page , "6E89AE;padding: 10px;", White) +
footer
)
)
) + Htmls("<script>var a={"+jslang+"};"
"var p=window.location.pathname.split(\"/\");p=p[p.length-1];"
"var s='<select id=\"lang\" onchange=\"window.location=document.getElementById(\\'lang\\').value;\">';"
"for(l in a){if(p==l){d=\" selected=1\"}else{d=\"\"}s+='<option value=\"'+l+'\"'+d+'>'+a[l]+'</option>'}"
"s+='</select>';"
"var d=document.createElement('div');d.innerHTML=s;"
"var c=document.getElementById('langs');c.replaceChild(d,c.firstChild);"
"document.getElementById('langbox').style.display='block';</script>");

String topicTitle = tt.GetKey(i);
String pageTitle = tt[i].title;
if(IsNull(pageTitle))
pageTitle = "Ultimate++";
if(StartsWith(topicTitle, "examples$"))
pageTitle = "Demos / " + pageTitle;
else if(StartsWith(topicTitle, "reference$"))
pageTitle = "Examples / " + pageTitle;

if(pageTitle != "Ultimate++")
pageTitle << " :: Ultimate++";

Htmls content =
"<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n" +
HtmlHeader(pageTitle, AsCss(css) +
"a.l1 { text-decoration:none; font-size: 8pt; font-family: sans-serif; "
"font-weight: normal; }\n"
"a.l1:link { color:#000000; }\n"
"a.l1:visited { color:#000080; }\n"
"a.l1:hover { color:#9933CC; }\n"
"a.l1:active { color:#000000; }\n"
"a.l2 { text-decoration:none; font-size: 12pt; font-family: sans-serif; "
"font-variant: small-caps; }\n"
"a.l2:link { color:#0066FF; }\n"
"a.l2:visited { color:#FF6600; }\n"
"a.l2:hover { color:#BC0624; }\n"
"a.l2:active { color:#BC0024; }\n",
"<META NAME=\"keywords\" "
"CONTENT=\""
"framework, toolkit, widget, c++, visual, studio, dev-cpp, builder, ide, class, component,"
"wxwidgets, qt, rapid, application, development, rad, mfc, linux, gui, sdl, directx, desktop"
"\">"
"<META name=\"robots\" content=\"index,follow\">\n"
"<LINK rel=\"alternate\" type=\"application/rss+xml\" title=\"SVN changes\" href=\"svnchanges.xml\">"
// "<link rel=\"shortcut icon\" href=\"/favicon.ico\" />"
)


.BgColor(bg)
.Alink(Red).Link(Black).Vlink(Blue)
/ html;
SaveFile(AppendFileName(targetdir, links[i]), content);
RLOG("Exported page " << links[i]);
}

String Downloads()
{
String r;
FindFile ff(AppendFileName(targetdir, "downloads/*.*"));
Vector<Time> tm;
Vector<String> fn;
Vector<String> path;
while(ff) {
if(ff.IsFile()) {
tm.Add(ff.GetLastWriteTime());
fn.Add(ff.GetName());
path.Add(ff.GetPath());
}
ff.Next();
}
IndexSort2(tm, fn, path, StdGreater<Time>());
for(int i = 0; i < fn.GetCount(); i++)
if(i < 40)
r << "[^downloads/" << fn[i] << "^ \1" << fn[i] << "\1 " << tm[i] << "&";
else
DeleteFile(ff.GetPath());
return r;
}

struct ProgramData {
String rootdir;
String targetdir;
String diffdir;
String pdfdir;
bool ftpUpload;
bool outPdf;
bool doSvn;
void Xmlize(XmlIO xml) {
xml
("rootdir", rootdir)
("targetdir", targetdir)
("diffdir", diffdir)
("pdfdir", pdfdir)
("ftpUpload", ftpUpload)
("outPdf", outPdf)
("doSvn", doSvn)
;
}
};



CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
#ifdef PLATFORM_POSIX
rootdir = GetHomeDirFile("upp.src");
targetdir = GetHomeDirFile("uppwww");
diffdir = GetHomeDirFile("wwwupp");
pdfdir = GetHomeDirFile("pdf");
#endif
outPdf = true;
doSvn = true;

RLOG("--- uppweb started at " << GetSysTime());

ProgramData data;

String configFile = GetHomeDirFile("uppweb.xml");
bool cfgloaded = false;
if (FileExists(configFile)) {
if (LoadFromXMLFile(data, configFile)) {
rootdir = data.rootdir;
targetdir = data.targetdir;
// diffdir = data.diffdir;
pdfdir = data.pdfdir;
// ftpupload = data.ftpUpload;
outPdf = data.outPdf;
doSvn = data.doSvn;
cfgloaded = true;
}
}
if (!cfgloaded) {
data.rootdir = rootdir;
data.targetdir = targetdir;
// data.diffdir = diffdir;
data.pdfdir = pdfdir;
// data.ftpUpload = ftpupload;
data.outPdf = outPdf;
data.doSvn = doSvn;
StoreAsXMLFile(data, NULL, configFile);
}
Cout() << "RootDir: " << rootdir << "\n";
Cout() << "TargetDir: " << targetdir << "\n";

String downloads = Downloads();

if (!DirectoryExists(rootdir)) {
Cout() << ("Directory " + DeQtf(rootdir) + " does not exist\n");
return;
}

uppbox = AppendFileName(rootdir, "uppbox");
uppsrc = AppendFileName(rootdir, "uppsrc");
reference = AppendFileName(rootdir, "reference");
examples = AppendFileName(rootdir, "examples");
bazaar = AppendFileName(rootdir, "bazaar");

Cout() << "Loading www.tpp\n";
InitWwwTpp();

languages.Add(LNG_('E','N','U','S')); // en-us has to be the first one
#ifndef _DEBUG // too slow to have them all while developing
languages.Add(LNG_('C','A','E','S'));
languages.Add(LNG_('C','S','C','Z'));
languages.Add(LNG_('D','E','D','E'));
languages.Add(LNG_('E','S','E','S'));
languages.Add(LNG_('E','U','E','S'));
languages.Add(LNG_('F','R','F','R'));
languages.Add(LNG_('R','O','R','O'));
languages.Add(LNG_('R','U','R','U'));
languages.Add(LNG_('Z','H','C','N'));
languages.Add(LNG_('Z','H','T','W'));
#endif

RealizeDirectory(targetdir);

if (outPdf) {
RealizeDirectory(pdfdir);
}
Cout() << "Gather ref links " << uppsrc << "\n";
GatherRefLinks(uppsrc);
Cout() << "Gather ref links " << AppendFileName(rootdir, "bazaar") << "\n";
GatherRefLinks(AppendFileName(rootdir, "bazaar"));

SaveFile(AppendFileName(targetdir, "sdj.gif"), LoadFile(GetRcFile("sdj.gif")));

String release = "4193";
escape.Add("RELEASE", release);
escape.Add("RELEASET", release);
escape.Add("UPDATETIME", Format("%`", GetUtcTime()));

if (doSvn) {
Cout() << "Processing svn\n";
GetSvnList(svndata, rootdir);
GetSvnLog(svnlog);
CreateRssFeed();
if (svnlog.GetCount() > 0) {
escape.Add("LATESTSVN", svnlog[0].revision);
//Index<String> css;
//escape.Add("SVNTABLE", QtfAsHtml(SvnChanges(svnlog, "", 100), css, links, labels, targetdir));
//escape.Add("ANCHOR", "<span id=\"svnTableAnchor\"></span>");
}
}

escape.Add("PAYPAL", LoadFile(GetRcFile("donations.txt")));

header = HtmlPackedTable()
.Width(-100)
.BgColor(White)
.Attr("style", "border: 1px solid #6E89AE;"
"padding-left: 10px;padding-right: 0px;padding-top: 0px;padding-bottom: 0px;")
/
HtmlRow() / (
HtmlCell() / HtmlLink("index.html") / Wimg(WWW::Logo6) +
HtmlCell().Right().Bottom()
.Style("padding-bottom: 5px; "
"background-image: url('" + GetImageSrc(WWW::HB) + "')")
/ HtmlArial(14) / (LoadFile(GetRcFile("adsense.txt")) + "&nbsp;&nbsp;"/* + "<br>..harnessing the real power of C++&nbsp;&nbsp;"*/)
);

bar.SetCount(languages.GetCount());

int lang = GetCurrentLanguage();
for (int i = 0; i < languages.GetCount(); ++i) {
Cout() << "Language " << LNGAsText(languages[i]);
Htmls bi, bex, bdoc, bcom, bcon, bsearch, blang;

SetLanguage(languages[i]);

Www("index", languages[i]);
Www("contribweb", languages[i]);
// bi << BarLink("index.html", "Home", false);
bi << BarLink(Www("overview", languages[i]), t_("Overview"), false);
bi << BarLink(Www("examples", languages[i]), t_("Examples"));
{
int di = tt.Find("topic://uppweb/www/examples$" + ToLower(LNGAsText(languages[i])));
tt[di].text << MakeExamples(examples, "examples", languages[i]);
tt[di].text << GetTopic("topic://uppweb/www/reference$" + ToLower(LNGAsText(languages[i]))).text;
tt[di].text << MakeExamples(reference, "reference", languages[i]);
}

bi << BarLink(Www("ss", languages[i]), t_("Screenshots"));
bi << BarLink(Www("comparison", languages[i]), t_("Comparisons"));
bi << BarLink(Www("apps", languages[i]), t_("Applications"));
bi << BarLink(Www("download", languages[i]), t_("Download"));

bi << BarLink(Www("documentation", languages[i]), t_("Manual"));
{
int di = tt.Find("topic://uppweb/www/documentation$" + ToLower(LNGAsText(languages[i])));
if (di >= 0) {
Index<String> x;
x.Clear();
String qtf;
SrcDocs(x, qtf, "Core", languages[i]);
SrcDocs(x, qtf, "Draw", languages[i]);
SrcDocs(x, qtf, "CtrlCore", languages[i]);
SrcDocs(x, qtf, "CtrlLib", languages[i]);
SrcDocs(x, qtf, "RichText", languages[i]);
SrcDocs(x, qtf, "RichEdit", languages[i]);
FindFile ff(AppendFileName(uppsrc, "*.*"));
Array <String> folders;
folders.Clear();
while(ff) {
if(ff.IsFolder())
folders.Add(ff.GetName());
ff.Next();
}
Sort(folders);
for (int ifold = 0; ifold < folders.GetCount(); ++ifold)
SrcDocs(x, qtf, folders[ifold], languages[i]);
tt[di].text << qtf;
}
}
bi << BarLink(Www("bazaar", languages[i]), t_("Bazaar"));
bi << BarLink(Www("Roadmap", languages[i]), t_("Status & Roadmap"));
bi << BarLink(Www("FAQ", languages[i]), t_("FAQ"));
bi << BarLink(Www("About", languages[i], "topic://ide/app/"), t_("Authors & License"));

bi << BarLink("http://www.ultimatepp.org/forum", t_("Forums"));
// bcom << BarLink(Www("mailing"), "Mailing lists");
// bi << BarLink("http://www.ultimatepp.org/wiki/index.php", "Wiki");
bi << BarLink(Www("Funding", languages[i]), t_("Funding Ultimate++"));
// bcom << BarLink(Www("helpus"), "Getting involved");
// bcom << BarLink("mailto: upp@ntllib.org", "Contact developers");

bsearch << BarCaption(t_("Search on this site"));
bsearch << SearchBar("www.ultimatepp.org");

blang << BarCaption(t_("Language"));
blang << Htmls("<div id=\"langbox\" style=\"display:none;\">") +
BarItem(HtmlPackedTable().Width(-100)
/ HtmlRow() / (
HtmlCell() / Wimg(WWW::Language) +
HtmlCell() / Htmls("<div id=\"langs\">"+GetNativeLangName(languages[i])+"</div>")
),"border: 0px solid black;"
"padding-left:6px; padding-right:0px;"
"padding-top:4px; padding-bottom:4px;"
) + Htmls("</div>");


HtmlTag bf = HtmlPackedTable()
.Width(-100)
.BgColor(White)
.Attr("style", "border-style: solid; border-width: 1px; border-color: #6E89AE;"
"padding: 0px");
String div = HtmlTable().Border(0).Width(-100) / HtmlLine();
bar[i] = bf / bi + div +
// bf / bex + div +
// bf / bdoc + div +
// bf / bcom + div +
// bf / bcon + div +
bf / bsearch + div +
bf / blang + div;
}
SetLanguage(lang);

for(int i = 0; i < tt.GetCount(); i++) {
String topic = tt.GetKey(i);
links.Add(topic, topic == "topic://uppweb/www/index$en-us" ? "index.html" :
memcmp(topic, "topic://", 8) ? topic : TopicFileNameHtml(topic));
}

String svntableStr = DeQtf("[svntable]");
for(int i = 0; i < tt.GetCount(); i++) {
if (tt[i].title == "Svn releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 300, ""));
else if (tt[i].title == "Svn Web releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "uppweb"));
else if (tt[i].title == "Svn Bazaar releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "bazaar"));
else if (tt[i].title == "Svn Upp releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "uppsrc"));
else if (tt[i].title == "Svn major releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 300, "", true));
else if (tt[i].title == "Svn Web major releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "uppweb", true));
else if (tt[i].title == "Svn Bazaar major releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "bazaar", true));
else if (tt[i].title == "Svn Upp major releases")
tt[i].text.Replace(svntableStr, SvnChanges(svnlog, 100, "uppsrc", true));
else
if(tt[i].title == "Nightly builds")
tt[i].text.Replace(String("<#downloads#>"), downloads);
else if (links[i].Find("index") >= 0) {
String win32 = "upp-win32-RELEASE.exe";
String win32release = win32;
win32release.Replace(String("RELEASE"), release);
String x11 = "upp-x11-src-RELEASE.tar.gz";
String x11release = x11;
x11release.Replace(String("RELEASE"), release);
tt[i].text.Replace(DeQtf(x11), DeQtf(x11release));
tt[i].text.Replace(DeQtf(win32), DeQtf(win32release));
}
}

for(int i = 0; i < reflink.GetCount(); i++) {
String l = reflink.GetKey(i);
String lbl = Filter(l, CharFilterLbl);
String f = links.Get(reflink[i], Null) + '#' + lbl;
links.Add(l, f);
static const char *x[] = { "::struct", "::class", "::union" };
for(int ii = 0; ii < 3; ii++) {
String e = x[ii];
if(EndsWith(l, e)) {
links.Add(l.Mid(0, l.GetLength() - e.GetLength()), f);
}
}
labels.Add(l, lbl);
}

Date d = GetSysDate();
lastUpdate = HtmlItalic() / HtmlArial(8) / HtmlFontColor(Gray()) /
(String().Cat() << "Last update " << GetSysDate());

// Vector<String> amazon = Split(LoadFile(GetRcFile("amazon.txt")), '\n');//440

Vector <SvnBazaarItems> bazaarItems = SvnBazaarList(bazaar, svnlog);

// To fill Bazaar page with real release dates and size
for(int i = 0; i < tt.GetCount(); i++) {
if (tt[i].title == "Bazaar") {
String page = tt[i];
for (int j = 0; j < bazaarItems.GetCount(); ++j) {
int pos = page.Find("2 " + DeQtf(bazaarItems[j].name) + "]]");
if (pos < 0)
pos = page.Find("2 " + DeQtf(bazaarItems[j].name) + "\r\n]]");
if (pos >= 0) {
pos = page.Find("::", pos);
pos = page.Find("::", pos);
pos = page.Find(":: [s0;=2", pos);
if (pos >= 0)
pos += (int)strlen(":: [s0;=2");
String strDate;
if (pos >= 0) {
Time t = bazaarItems[j].lastChange;
if (IsNull(t))
strDate = "Not in Svn log";
else
strDate = Format("%Mon", t.month) + " " + FormatInt(t.year);
page.Insert(pos, " " + strDate);
}
pos = page.Find(":: [s0;=2", pos);
if (pos >= 0)
pos += (int)strlen(":: [s0;=2");
String strSz;
if (pos >= 0) {
if (bazaarItems[j].size == 0)
strSz = "Not in Svn log";
else
strSz = BytesToString(bazaarItems[j].size);

page.Insert(pos, " " + strSz);
}
}
}
tt[i].text = page;
}
}

LLOG("G: " << MemoryUsedKb());

/*
if (outPdf) {
PdfDraw pdf;
for(int i = 0; i < tt.GetCount(); i++)
QtfAsPdf(pdf, tt[i]);
SaveFile(AppendFileName(pdfdir, "Upp.pdf"), pdf.Finish());
}
*/

LLOG("H: " << MemoryUsedKb());

for(int i = 0; i < tt.GetCount(); i++)
ExportPage(i);
SetLanguage(lang);

LLOG("I: " << MemoryUsedKb());

// SaveFile(AppendFileName(targetdir, "favicon.ico"), LoadFile(AppendFileName(uppsrc, "ide/ide.ico")));
SaveFile(AppendFileName(targetdir, "stats.html"),
HtmlImg("http://www.vol.cz/cgi-bin/wc/upp") + "<br>" +
HtmlLink("http://www.mygooglepagerank.com", "_blank") /
"<img src=\"http://www.mygooglepagerank.com/PRimage.php?url=http://upp.sf.net\" "
"border=\"0\" width=\"66\" height=\"13\" "
"alt=\"Google PageRank&trade; - Post your PR with MyGooglePageRank.com\">" +
"<noscript>" +
HtmlLink("http://www.mygooglepagerank.com").Title("My Google Page Rank") /
"My Google Page Rank" +
"</noscript>" +
HtmlLink("http://www.mygooglepagerank.com", "_blank") /
"<img src=\"http://www.mygooglepagerank.com/PRimage.php?url=http://www.ultimatepp.org\" "
"border=\"0\" width=\"66\" height=\"13\" "
"alt=\"Google PageRank&trade; - Post your PR with MyGooglePageRank.com\">" +
"<noscript>" +
HtmlLink("http://www.mygooglepagerank.com").Title("My Google Page Rank") /
"My Google Page Rank" +
"</noscript>"
);
Cout() << "Finished OK\n";
}

Change log

r4866 by cxl on Apr 27, 2012   Diff
.uppweb
Go to: 
Project members, sign in to write a code review

Older revisions

r4865 by cxl on Apr 27, 2012   Diff
uppweb: added timestamps to nightly
builds
r4532 by koldo on Feb 3, 2012   Diff
UppWeb: More translations thanks to
borbek
r4494 by cxl on Jan 30, 2012   Diff
.uppbox uppweb Downloads
All revisions of this file

File info

Size: 33522 bytes, 1036 lines
Powered by Google Project Hosting