diff --git a/bazaar/UltimateBook/MakeExamples.cpp b/bazaar/UltimateBook/MakeExamples.cpp new file mode 100644 index 000000000..5651052a9 --- /dev/null +++ b/bazaar/UltimateBook/MakeExamples.cpp @@ -0,0 +1,143 @@ +#include +#include "Functions4U/Functions4U.h" + +using namespace Upp; + +String CppAsQtf(const String& str) +{ + static const char *cpp[] = { + "__asm", "else", "struct", + "enum", "switch", "auto", "__except", "template", + "explicit", "this", + "bool", "extern", "mutable", "thread", + "break", "false", "throw", + "case", "__fastcall", "namespace", "true", + "catch", "__finally", "new", "try", + "__cdecl", "float", "__try", + "char", "for", "operator", "typedef", + "class", "friend", "private", "typeid", + "const", "goto", "protected", "typename", + "const_cast", "if", "public", "union", + "continue", "inline", "register", "unsigned", + "__declspec", "__inline", "reinterpret_cast", "using", + "using", "default", "int", "return", + "delete", "__int8", "short", "__uuidof", + "dllexport", "__int16", "signed", "virtual", + "dllimport", "__int32", "sizeof", "void", + "do", "__int64", "static", "volatile", + "double", "__leave", "static_cast", + "dynamic_cast", "long", "__stdcall", "while", + "include", "define", "ifdef", "ifndef", "endif", + NULL + }; + static Index keyword; + if(keyword.GetCount() == 0) + for(const char **q = cpp; *q; q++) + keyword.Add(*q); + + const char *s = str; + StringBuffer qtf; + qtf << "[l0r0= 0) + qtf << "[@B " << DeQtf(id) << "]"; + else + qtf << DeQtf(id); + } + else { + if(*s == '\t') + qtf << "____"; + else + if(*s == '\n') + qtf << '&'; + else + if((byte)*s >= 32) + if(strchr("!+-*^/%~&|=[]:?<>.#", *s)) + qtf << "[@B `" << *s << "]"; + else + qtf << '`' << *s; + s++; + } + } + 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 *webdir, const char *dir, const char *www, String language, GatherTpp &tt) +{ + 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 << "$" << language << ".html"; + Topic& topic = tt.AddTopic(link); + topic.title = name; + String fn = AppendFileName( + AppendFileName( + webdir, + String(www) + ".tpp" + ), + topic.title + "$" + 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 +#include "Functions4U/Functions4U.h" + +using namespace Upp; + +String FolderLinks(const String uppsrc, const String package, const String group, const String lang, GatherTpp &tt) +{ + String qtf; + FindFile ff(AppendFileName(AppendFileName(AppendFileName(uppsrc, package), group + ".tpp"), "*.tpp")); + while(ff) { + if(ff.IsFile()) { + if (ff.GetName().Find(lang) >= 0) { + String title; + String tl = "topic://" + package + '/' + group + '/' + GetFileTitle(ff.GetName()); + tt.GatherTopics(tl, title); + qtf << "________[^" << tl << "^ " << DeQtf(Nvl(title, tl)) << "]&"; + } + } + ff.Next(); + } + return qtf; +} + +void SrcDocs(Index &x, String& qtf, String uppsrc, const char *folder, String lang, GatherTpp &tt) +{ + if(x.Find(folder) >= 0) + return; + x.Add(folder); + String srcdoc = FolderLinks(uppsrc, folder, "srcdoc", lang, tt); + String src = FolderLinks(uppsrc, folder, "src", lang, tt); + 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; + } + } +} \ No newline at end of file diff --git a/bazaar/UltimateBook/UltimateBook.upp b/bazaar/UltimateBook/UltimateBook.upp index c8b308d5a..10a50e058 100644 --- a/bazaar/UltimateBook/UltimateBook.upp +++ b/bazaar/UltimateBook/UltimateBook.upp @@ -1,3 +1,27 @@ +description "Ultimate++ website generation and export.\377"; + +uses + Web, + RichText, + plugin\gif, + CtrlLib, + CtrlLib, + plugin\png, + plugin\ftp, + Sql, + Controls4U, + GridCtrl, + ide; + +options(GCC) -DNOWSTRING; + file + MakeExamples.cpp, + SrcDocs.cpp, + www.cpp, + book.lay, srcdoc.tpp; +mainconfig + "" = "GUI"; + diff --git a/bazaar/UltimateBook/book.lay b/bazaar/UltimateBook/book.lay new file mode 100644 index 000000000..4fb67a262 --- /dev/null +++ b/bazaar/UltimateBook/book.lay @@ -0,0 +1,12 @@ +LAYOUT(main, 412, 156) + ITEM(Option, doPdf, SetLabel(t_("Do .pdf")).LeftPosZ(8, 64).BottomPosZ(105, 19)) + ITEM(Option, doHtml, SetLabel(t_("Do .html")).LeftPosZ(8, 64).BottomPosZ(125, 19)) + ITEM(EditFile, pdfFile, HSizePosZ(140, 8).BottomPosZ(105, 19)) + ITEM(Label, dv___3, SetLabel(t_("Html folder:")).LeftPosZ(80, 60).BottomPosZ(125, 19)) + ITEM(Label, dv___4, SetLabel(t_("Pdf file:")).LeftPosZ(80, 60).BottomPosZ(105, 19)) + ITEM(EditFolder, htmlFolder, HSizePosZ(140, 8).BottomPosZ(125, 19)) + ITEM(Button, go, SetLabel(t_("Go")).RightPosZ(8, 72).BottomPosZ(8, 24)) + ITEM(Label, action, HSizePosZ(4, 8).TopPosZ(64, 19)) + ITEM(ProgressIndicator, progress, LeftPosZ(4, 400).TopPosZ(88, 24)) +END_LAYOUT + diff --git a/bazaar/UltimateBook/icon.ico b/bazaar/UltimateBook/icon.ico new file mode 100644 index 000000000..4012786aa Binary files /dev/null and b/bazaar/UltimateBook/icon.ico differ diff --git a/bazaar/UltimateBook/init b/bazaar/UltimateBook/init index 69d8c0ddb..7ebd8a225 100644 --- a/bazaar/UltimateBook/init +++ b/bazaar/UltimateBook/init @@ -1,3 +1,13 @@ #ifndef _UltimateBook_icpp_init_stub #define _UltimateBook_icpp_init_stub +#include "Web/init" +#include "RichText/init" +#include "plugin\gif/init" +#include "CtrlLib/init" +#include "plugin\png/init" +#include "plugin\ftp/init" +#include "Sql/init" +#include "Controls4U/init" +#include "GridCtrl/init" +#include "ide/init" #endif diff --git a/bazaar/UltimateBook/www.cpp b/bazaar/UltimateBook/www.cpp new file mode 100644 index 000000000..3ec8fff76 --- /dev/null +++ b/bazaar/UltimateBook/www.cpp @@ -0,0 +1,127 @@ +#include +#include + +using namespace Upp; + +#define LAYOUTFILE +#include + +String MakeExamples(const char *webdir, const char *dir, const char *www, String language, GatherTpp &tt); +void SrcDocs(Index &x, String& qtf, String uppsrc, const char *folder, String lang, GatherTpp &tt); + +class Main : public Withmain { + typedef Main CLASSNAME; + +public: + Main(); + ~Main(); + + void DoGo(); + void Xmlize(XmlIO xml) { + xml + ("HtmlFolder", htmlFolder) + ("PdfFile", pdfFile) + ("DoPdf", doPdf) + ("DoHtml", doHtml) + ; + } +private: + EditString grFolder; + String configFile; + String indexFile; + + bool SetProgress(int value, int total); +}; + +Main::Main() { + CtrlLayout(*this, "Ultimate Book"); + Sizeable().Zoomable(); + + go.WhenAction = THISBACK(DoGo); + progress.Set(0, 1); + + configFile = GetHomeDirFile("ultimatebook.xml"); + LoadFromXMLFile(*this, configFile); +} + +Main::~Main() { + StoreAsXMLFile(*this, NULL, configFile); +} + +GUI_APP_MAIN { + Main main; + + main.Execute(); +} + +bool Main::SetProgress(int value, int total) { + progress.Set(value, total); + Ctrl::ProcessEvents(); + return false; +} + +void Main::DoGo() +{ + GatherTpp tpp; + + String uppfolder = "C:/Desarrollo/Upp_Extra/upp-mirror/"; + String uppsrc = uppfolder + "uppsrc"; + + tpp.AddFolder(uppfolder + "uppbox/uppweb"); + tpp.AddFolder(uppsrc); + tpp.AddFolder(uppfolder + "bazaar"); + + action = "Loading pages"; + tpp.Load(uppsrc + "uppbox/uppweb/www.tpp/index$en-us.tpp", THISBACK(SetProgress)); + + { // Make examples pages + int id = tpp.FindTopic("topic://uppweb/www/examples$en-us"); + if (id == -1) { + Exclamation("Error gathering examples"); + return; + } + tpp.GetTopic(id).text << MakeExamples(uppfolder + "uppbox/uppweb", uppfolder + "examples", + "examples", "en-us", tpp); + tpp.GetTopic(id).text << ReadTopic(LoadFile(uppfolder + "uppbox/uppweb/www.tpp/reference$en-us.tpp")).text; + tpp.GetTopic(id).text << MakeExamples(uppfolder + "uppbox/uppweb", uppfolder + "reference", + "reference", "en-us", tpp); + } + + { // Make documentation pages + int id = tpp.FindTopic("topic://uppweb/www/documentation$en-us"); + if (id == -1) { + Exclamation("Error gathering documentation"); + return; + } + + Index x; + x.Clear(); + String qtf; + SrcDocs(x, qtf, uppsrc, "Core", "en-us", tpp); + SrcDocs(x, qtf, uppsrc, "Draw", "en-us", tpp); + SrcDocs(x, qtf, uppsrc, "CtrlCore", "en-us", tpp); + SrcDocs(x, qtf, uppsrc, "CtrlLib", "en-us", tpp); + SrcDocs(x, qtf, uppsrc, "RichText", "en-us", tpp); + SrcDocs(x, qtf, uppsrc, "RichEdit", "en-us", tpp); + FindFile ff(AppendFileName(uppfolder + "uppsrc", "*.*")); + while(ff) { + if(ff.IsFolder()) + SrcDocs(x, qtf, uppsrc, ff.GetName(), "en-us", tpp); + ff.Next(); + } + tpp.GetTopic(id).text << qtf; + } + + if (doHtml) { + action = "Making html"; + tpp.MakeHtml(~htmlFolder, THISBACK(SetProgress)); + } + + if (doPdf) { + action = "Making pdf"; + tpp.MakePdf(~pdfFile, THISBACK(SetProgress)); + } + action = ""; +} + +