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
#include "www.h"

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

StaticCriticalSection reflink_lock;
VectorMap<String, String> reflink;

struct ScanTopicIterator : RichText::Iterator {
String link;

virtual bool operator()(int pos, const RichPara& para)
{
if(!IsNull(para.format.label)) {
LLOG("label: " << para.format.label);
INTERLOCKED_(reflink_lock)
reflink.Add(para.format.label, link);
}
return false;
}
};

static void sDoFile(const char *path, const char *link)
{
ScanTopicIterator sti;
sti.link = link;
ParseQTF(ReadTopic(LoadFile(path))).Iterate(sti);
}

void GatherRefLinks(const char *upp)
{
#ifdef MTC
CoWork work;
#endif
for(FindFile pff(AppendFileName(upp, "*.*")); pff; pff.Next()) {
if(pff.IsFolder()) {
String package = pff.GetName();
String pdir = AppendFileName(upp, package);
TopicLink tl;
tl.package = package;
for(FindFile ff(AppendFileName(pdir, "*.tpp")); ff; ff.Next()) {
if(ff.IsFolder()) {
String group = GetFileTitle(ff.GetName());
tl.group = group;
String dir = AppendFileName(pdir, ff.GetName());
for(FindFile ft(AppendFileName(dir, "*.tpp")); ft; ft.Next()) {
if(ft.IsFile()) {
String path = AppendFileName(dir, ft.GetName());
tl.topic = GetFileTitle(ft.GetName());
String link = TopicLinkString(tl);
#ifdef MTC
work & callback2(sDoFile, path, link);
#else
ScanTopicIterator sti;
sti.link = link;
LLOG("Indexing topic " << path << " link: " << link);
ParseQTF(ReadTopic(LoadFile(path))).Iterate(sti);
#endif
}
}
}
}
}
}
}

struct GatherLinkIterator : RichText::Iterator {
Index<String> link;

virtual bool operator()(int pos, const RichPara& para)
{
for(int i = 0; i < para.GetCount(); i++) {
String l = para[i].format.link;
if(!IsNull(l)) {
LLOG("GatherLink " << l);
if(l[0] == ':') {
int q = reflink.Find(l);
int w = q;
if(q < 0)
q = reflink.Find(l + "::class");
if(q < 0)
q = reflink.Find(l + "::struct");
if(q < 0)
q = reflink.Find(l + "::union");
if(q >= 0)
l = reflink[q];
}
link.FindAdd(Nvl(reflink.Get(l, Null), l));
}
}
return false;
}
};

String TopicFileName(const char *dir, const char *topic)
{
TopicLink tl = ParseTopicLink(topic);
return AppendFileName(dir, AppendFileName(tl.package, AppendFileName(tl.group + ".tpp", tl.topic + ".tpp")));
}

String TopicFileName(const char *topic)
{
String p = TopicFileName(uppbox, topic);
if(FileExists(p))
return p;
p = TopicFileName(bazaar, topic);
if(FileExists(p))
return p;
return TopicFileName(uppsrc, topic);
}

String TopicFileNameHtml(const char *topic)
{
TopicLink tl = ParseTopicLink(topic);
tl.package.Replace("/","$");
tl.package.Replace("\\","$");
return tl.group + "$" + tl.package+ "$" + tl.topic + ".html";
}

static void sGatherTopics(VectorMap<String, Topic> *map, const char *topic)
{
GatherTopics(*map, topic);
}

String ChangeTopicLanguage(const String &topic, int lang);
String GetTopicLanguage(const String &topic);

String GatherTopics(VectorMap<String, Topic>& tt, const char *topic, String& title)
{
static StaticCriticalSection mapl;
LLOG("Gather topics: " << topic);
int q;
INTERLOCKED_(mapl)
q = tt.Find(topic);
if(q < 0) {
LLOG("GatherTopics " << topic);
Topic p = ReadTopic(LoadFile(TopicFileName(topic)));
title = p.title;
String t = p;
if(IsNull(t)) {
String topicEng = ChangeTopicLanguage(topic, LNG_('E','N','U','S'));
p = ReadTopic(LoadFile(TopicFileName(topicEng)));
String tt = p;
if(IsNull(tt))
return "index.html";
title = p.title;
p.title += " (translated)";
String help = "topic://uppweb/www/contribweb$" + GetTopicLanguage(topic);
p.text = String("{{1f1t0/50b0/50@(240.240.240) [<A2 ") + t_("This page has not been translated yet") +
"]. " + "[^" + help + "^ [<A2 " + t_("Do you want to translate it?") + "]]}}&&" + p.text;
}
INTERLOCKED_(mapl)
tt.Add(topic) = p;
GatherLinkIterator ti;
ParseQTF(t).Iterate(ti);
#ifdef MTC
CoWork work;
for(int i = 0; i < ti.link.GetCount(); i++)
work & callback2(sGatherTopics, &tt, ti.link[i]);
#else
for(int i = 0; i < ti.link.GetCount(); i++)
sGatherTopics(&tt, ti.link[i]);
#endif
} else {
INTERLOCKED_(mapl)
title = tt[q].title;
}
return TopicFileNameHtml(topic);
}

String GatherTopics(VectorMap<String, Topic>& map, const char *topic)
{
String dummy;
return GatherTopics(map, topic, dummy);
}

Change log

r4183 by koldo on Nov 19, 2011   Diff
uppweb: Included new release.
Go to: 
Project members, sign in to write a code review

Older revisions

r4086 by cxl on Oct 22, 2011   Diff
.uppbox
r3467 by dolik on May 28, 2011   Diff
uppweb: added documentation from
ide/SrcUpdater
r2470 by koldo on Jun 9, 2010   Diff
UppWeb: Added index page translation
to Simplified Chinese by Bonami
UppWeb: Included access to web page
source in footer
.UppWeb: Included new release 2467
All revisions of this file

File info

Size: 4674 bytes, 174 lines
Powered by Google Project Hosting