diff --git a/uppbox/uppweb/www.cpp b/uppbox/uppweb/www.cpp index bef3535a0..4a05e95c9 100644 --- a/uppbox/uppweb/www.cpp +++ b/uppbox/uppweb/www.cpp @@ -1,1038 +1,1040 @@ -#include "www.h" -#define IMAGECLASS WWW -#define IMAGEFILE -#include -#include - -#define TFILE -#include - -#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 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) / " " + - HtmlCell() / HtmlArial(8) / HtmlBold() / txt + - HtmlCell().Width(10) / " " - )); - 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 escape; - -String QtfAsHtml(const char *qtf, Index& css, - const VectorMap& links, - const VectorMap& 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="\n" - "\n" - "Ultimate++ svn changes\n" - "http://ultimatepp.org/\n" - "This feed offers list of commits to Ultimate++ framework svn repository\n" - ""+ FormatDateRFC822(GetSysTime()) + "\n" - "en-us\n" - "\n\n"; - - String items; - for(int i = 0; i < min(30,svnlog.GetCount()); i++){ - items+="\n" - "Revision " + svnlog[i].revision + "\n" - "http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "\n" - "http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "\n" - "" + FormatDateRFC822(svnlog[i].time) + "\n" - "\n" - " Revision:" + svnlog[i].revision + "\n" - " Description:" + svnlog[i].msg + "\n" - " Submitted:" + FormatDateRFC822(svnlog[i].time) + " by " + svnlog[i].author + "\n" - " Affected files: \n" - " \n" - "
\n"; - for(int j = 0; j < svnlog[i].changes.GetCount(); j++) - items+="" + svnlog[i].changes[j].action + " " - "" + svnlog[i].changes[j].path + "
\n"; - items+= - "
\n" - " \n" - " \n" - "]]>
\n" - "
\n\n"; - } - SaveFile(AppendFileName(targetdir, "svnchanges.xml"), header + items + "
\n
\n"); -} - -VectorMap 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 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 &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 links; -VectorMap labels; -Htmls header, lastUpdate; - -Array bar; -Array 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 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 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 + "^ [ 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 << "
"; - page << "
  " - << h << "

"; - page << QtfAsHtml(n, css, links, targetdir, FormatIntAlpha(q) + "_n"); - page << "
"; - } - }*/ - 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)] + - "
" + - LoadFile(GetRcFile("facebook.txt")) + - "

" + -// "

" + - LoadFile(GetRcFile("adsense2.txt")) + - "

" + - LoadFile(GetRcFile("adlinks.txt")) + - (h > 25000 ? "

" + LoadFile(GetRcFile("adsense2.txt")) - : "") + - "


" + -// LoadFile(GetRcFile("referral.txt")) + -// LoadFile(GetRcFile("referral2.txt")) + -// LoadFile(GetRcFile("donations.txt")) + -// "

" + -// amazon[i % amazon.GetCount()] + - "


" + - 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) + - "

" + - HtmlLink("http://www.sdjournal.org/en/") / - HtmlImg(GetImageSrc(WWW::Sdj)).Border(0) + - "

" + - (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(""); - - 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 = - "\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", - "" - "\n" - "" -// "" - ) - - - .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

") + - BarItem(HtmlPackedTable().Width(-100) - / HtmlRow() / ( - HtmlCell() / Wimg(WWW::Language) + - HtmlCell() / Htmls("
"+GetNativeLangName(languages[i])+"
") - ),"border: 0px solid black;" - "padding-left:6px; padding-right:0px;" - "padding-top:4px; padding-bottom:4px;" - ) + Htmls("
"); - - - 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 amazon = Split(LoadFile(GetRcFile("amazon.txt")), '\n');//440 - - Vector 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") + "
" + - HtmlLink("http://www.mygooglepagerank.com", "_blank") / - "" + - "" + - HtmlLink("http://www.mygooglepagerank.com", "_blank") / - "" + - "" - ); - Cout() << "Finished OK\n"; -} +#include "www.h" +#define IMAGECLASS WWW +#define IMAGEFILE +#include +#include + +#define TFILE +#include + +#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 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) / " " + + HtmlCell() / HtmlArial(8) / HtmlBold() / txt + + HtmlCell().Width(10) / " " + )); + 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 escape; + +String QtfAsHtml(const char *qtf, Index& css, + const VectorMap& links, + const VectorMap& 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="\n" + "\n" + "Ultimate++ svn changes\n" + "http://ultimatepp.org/\n" + "This feed offers list of commits to Ultimate++ framework svn repository\n" + ""+ FormatDateRFC822(GetSysTime()) + "\n" + "en-us\n" + "\n\n"; + + String items; + for(int i = 0; i < min(30,svnlog.GetCount()); i++){ + items+="\n" + "Revision " + svnlog[i].revision + "\n" + "http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "\n" + "http://code.google.com/p/upp-mirror/source/detail?r=" + svnlog[i].revision + "\n" + "" + FormatDateRFC822(svnlog[i].time) + "\n" + "\n" + " Revision:" + svnlog[i].revision + "\n" + " Description:" + svnlog[i].msg + "\n" + " Submitted:" + FormatDateRFC822(svnlog[i].time) + " by " + svnlog[i].author + "\n" + " Affected files: \n" + " \n" + "
\n"; + for(int j = 0; j < svnlog[i].changes.GetCount(); j++) + items+="" + svnlog[i].changes[j].action + " " + "" + svnlog[i].changes[j].path + "
\n"; + items+= + "
\n" + " \n" + " \n" + "]]>
\n" + "
\n\n"; + } + SaveFile(AppendFileName(targetdir, "svnchanges.xml"), header + items + "
\n
\n"); +} + +VectorMap 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 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 &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 links; +VectorMap labels; +Htmls header, lastUpdate; + +Array bar; +Array 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 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 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 + "^ [ 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 << "
"; + page << "
  " + << h << "

"; + page << QtfAsHtml(n, css, links, targetdir, FormatIntAlpha(q) + "_n"); + page << "
"; + } + }*/ + 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)] + + "
" + + LoadFile(GetRcFile("facebook.txt")) + + "

" + +// "

" + + LoadFile(GetRcFile("adsense2.txt")) + + "

" + + LoadFile(GetRcFile("adlinks.txt")) + + (h > 25000 ? "

" + LoadFile(GetRcFile("adsense2.txt")) + : "") + + "


" + +// LoadFile(GetRcFile("referral.txt")) + +// LoadFile(GetRcFile("referral2.txt")) + +// LoadFile(GetRcFile("donations.txt")) + +// "

" + +// amazon[i % amazon.GetCount()] + + "


" + + 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) + + "

" + + HtmlLink("http://www.sdjournal.org/en/") / + HtmlImg(GetImageSrc(WWW::Sdj)).Border(0) + + "

" + + (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(""); + + 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 = + "\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", + "" + "\n" + "" +// "" + ) + + + .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

") + + BarItem(HtmlPackedTable().Width(-100) + / HtmlRow() / ( + HtmlCell() / Wimg(WWW::Language) + + HtmlCell() / Htmls("
"+GetNativeLangName(languages[i])+"
") + ),"border: 0px solid black;" + "padding-left:6px; padding-right:0px;" + "padding-top:4px; padding-bottom:4px;" + ) + Htmls("
"); + + + 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 amazon = Split(LoadFile(GetRcFile("amazon.txt")), '\n');//440 + + Vector 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") + "
" + + HtmlLink("http://www.mygooglepagerank.com", "_blank") / + "" + + "" + + HtmlLink("http://www.mygooglepagerank.com", "_blank") / + "" + + "" + ); + Cout() << "Finished OK\n"; +} diff --git a/uppbox/uppweb/www.h b/uppbox/uppweb/www.h index bd376c8d8..7480ec712 100644 --- a/uppbox/uppweb/www.h +++ b/uppbox/uppweb/www.h @@ -74,4 +74,6 @@ String SvnChanges(Vector &log, int limit, String filter, bool major = Vector SvnBazaarList(String bazaarPath, Vector &log); String BytesToString(uint64 _bytes, bool units = true); +String MakeExamples(const char *dir, const char *www, int language); + #endif diff --git a/uppbox/uppweb/www.tpp/all.i b/uppbox/uppweb/www.tpp/all.i index c2988a437..9d601d173 100644 --- a/uppbox/uppweb/www.tpp/all.i +++ b/uppbox/uppweb/www.tpp/all.i @@ -42,6 +42,10 @@ TOPIC("documentation$de-de") #include "documentation$de-de.tppi" END_TOPIC +TOPIC("documentation$en-us") +#include "documentation$en-us.tppi" +END_TOPIC + TOPIC("documentation$ru-ru") #include "documentation$ru-ru.tppi" END_TOPIC @@ -98,6 +102,10 @@ TOPIC("overview$de-de") #include "overview$de-de.tppi" END_TOPIC +TOPIC("reference$en-us") +#include "reference$en-us.tppi" +END_TOPIC + TOPIC("ss$de-de") #include "ss$de-de.tppi" END_TOPIC diff --git a/uppbox/uppweb/www.tpp/reference$en-us.tpp b/uppbox/uppweb/www.tpp/reference$en-us.tpp index 5ecbdc626..34bd65631 100644 --- a/uppbox/uppweb/www.tpp/reference$en-us.tpp +++ b/uppbox/uppweb/www.tpp/reference$en-us.tpp @@ -26,4 +26,4 @@ topic "Reference examples"; set of very simple examples, each demonstrating a single aspect of U`+`+ library.&] [s0; &] -[s0; ] \ No newline at end of file +[s0; ]] \ No newline at end of file diff --git a/uppbox/uppweb/www.tpp/reference$en-us.tppi b/uppbox/uppweb/www.tpp/reference$en-us.tppi new file mode 100644 index 000000000..70f87e5ce --- /dev/null +++ b/uppbox/uppweb/www.tpp/reference$en-us.tppi @@ -0,0 +1,7 @@ +TITLE("Reference examples") +COMPRESSED +120,156,133,148,91,111,219,70,16,133,255,10,1,185,69,43,211,198,206,109,47,228,75,0,39,175,41,144,34,79,130,80,83,244,218,38,42,75,46,73,183,9,138,250,183,247,44,165,184,121,171,4,145,2,184,103,46,223,156,225,134,171,139,11,87,187,149,251,159,79,243,62,223,119,47,251,121,187,217,115,140,237,16,156,182,29,133,246,151,212,190,190,190,94,167,196,109,9,69,8,69,78,133,152,72,157,83,14,100,201,37,139,20,157,4,101,11,206,154,231,110,236,158,182,155,46,74,187,254,228,161,226,218,86,66,66,142,60,43,78,57,113,172,196,70,49,42,5,139,146,188,111,250,238,121,30,142,135,237,102,87,116,37,153,64,230,66,244,74,16,169,177,4,83,136,85,137,240,159,44,248,16,154,121,152,247,25,34,242,161,237,148,219,155,162,212,218,175,80,30,7,72,149,213,171,68,22,138,204,62,137,38,69,221,196,205,48,103,84,185,131,166,232,138,204,144,80,77,73,0,68,131,9,142,5,220,213,37,98,100,141,206,12,9,243,151,111,148,10,160,162,243,72,199,193,202, +233,168,145,36,68,86,246,140,2,92,64,151,37,187,53,119,121,234,161,19,166,118,70,73,237,205,59,107,9,226,80,135,21,187,228,216,135,132,132,40,22,13,75,74,36,17,9,149,204,145,52,253,241,174,52,201,230,100,201,24,49,7,143,200,11,19,243,132,130,89,34,82,6,18,193,213,52,134,102,202,101,18,243,113,220,110,214,239,126,114,215,238,154,205,126,46,242,4,121,20,21,81,159,148,156,32,13,98,104,225,229,29,102,73,198,177,217,117,19,114,206,90,200,46,84,169,24,9,224,37,154,32,181,199,5,67,69,131,2,54,156,52,138,68,215,244,251,110,154,190,3,180,46,77,18,213,68,171,80,184,154,176,166,2,71,24,128,217,91,34,16,54,175,142,155,49,255,241,50,140,249,41,31,128,120,128,55,218,111,227,57,251,16,197,156,124,200,53,49,156,104,222,187,194,203,224,6,22,3,112,71,81,81,17,190,24,241,124,182,226,238,191,30,164,38,89,37,86,65,37,73,21,4,16,128,18,17,185,136,47,58,3,151,197,27,132,18,150,38,78,233,79,114,173,73,87, +1,30,198,164,146,150,244,73,10,63,6,126,246,206,48,7,62,201,185,80,231,11,112,39,142,229,183,144,39,171,9,203,128,18,201,12,125,11,80,115,68,239,6,246,178,248,155,66,108,62,230,191,166,247,221,156,207,134,89,223,92,156,156,70,190,38,191,114,69,111,49,97,128,164,133,159,168,38,78,34,198,201,196,59,112,156,78,187,92,196,101,159,150,93,124,11,18,106,10,216,44,244,106,134,238,23,25,58,15,84,74,225,152,124,161,112,14,114,123,181,31,14,165,14,56,163,61,153,97,125,115,73,20,74,160,136,133,137,209,59,73,128,1,6,206,224,116,188,13,34,6,141,57,51,214,160,188,14,250,223,187,135,124,123,117,94,213,191,127,251,231,135,15,31,175,62,255,90,109,38,107,171,31,183,111,55,110,171,79,249,62,143,249,208,231,234,195,151,238,233,121,159,167,242,192,125,255,32,159,31,84,221,152,43,108,213,240,112,200,119,213,124,172,238,142,253,75,177,78,245,249,246,242,246,178,154,31,199,227,203,195,99,213,85,83,158,171,227,125,245,103,30,191,86,211,80, +196,111,65,234,42,119,253,35,194,60,29,15,211,140,109,25,14,15,69,129,27,78,117,211,115,238,23,237,41,228,126,216,141,221,248,245,250,92,211,249,182,221,254,11,114,163,88,36, +