Esempio n. 1
0
void GatherTpp::GatherRefLinks(const char *upp)
{
	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);
							ScanTopicIterator sti(&reflink);
							sti.link = link;
							ParseQTF(ReadTopic(LoadFile(path))).Iterate(sti);
						}
					}
				}
			}
		}
	}
}
Esempio n. 2
0
String GatherTpp::GatherTopics(const char *topic, String& title)
{
	static StaticCriticalSection mapl;
	int q;
	INTERLOCKED_(mapl)
		q = tt.Find(topic);
	if(q < 0) {
		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(&reflink);
		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++)
			GatherTopics(ti.link[i]);
#endif
	} else {
		INTERLOCKED_(mapl)
			title = tt[q].title;
	}
	return TopicFileNameHtml(topic);
}
Esempio n. 3
0
void TopicLinkDlg::Topic()
{
	if(package.IsCursor() && group.IsCursor() && topic.IsCursor()) {
		link <<= LinkString();
		RichText txt = ParseQTF(ReadTopic(LoadFile(
						NormalizePath(
							AppendFileName(PackageGroup(group.GetCurrentName()),
		        			               topic.GetCurrentName() + ".tpp")
		               ))).text);
		Vector<String> ref = GatherLabels(txt);
		label.Clear();
		for(int i = 0; i < ref.GetCount(); i++)
			label.Add(ref[i]);
	}
}
Esempio n. 4
0
String GatherTpp::GatherTopics(const char *topic, String& title)
{
	int q = tt.Find(topic);
	if(q < 0) {
		Topic p = ReadTopic(LoadFile(TopicFileName(topic)));
		title = p.title;
		String t = p;
		if(IsNull(t)) 
			return "index.html";
		tt.Add(topic) = p;
		GatherLinkIterator ti(&(reflink));
		ParseQTF(t).Iterate(ti);
		for(int i = 0; i < ti.link.GetCount(); i++) {
			String dummy;
			GatherTopics(ti.link[i], dummy);
		}
	} else 
		title = tt[q].title;
	return TopicFileNameHtml(topic);
}
Esempio n. 5
0
void SyncTopicFile(const String& link)
{
	String path = GetTopicPath(link);
	LLOG("SyncTopicFile " << link << " path: " << path);
	TopicInfo& ti = topic_info().GetPut(link);
	Time tm = FileGetTime(path);
	if(ti.path == ":ide:" || ti.path == path && ti.time == tm)
		return;
	String fn = TopicCacheName(path);
	if(FileGetTime(fn) > tm) {
		LLOG("Loading topic from cache");
		ClearLinkRef(link);
		FileIn in(fn);
		LTIMING("Loading topic from cache");
		if(in) {
			String s = in.GetLine();
			if(s == tdx_version) {
				ti.title = in.GetLine();
				ti.words.Clear();
				ti.path = path;
				ti.time = tm;
				while(!in.IsEof()) {
					String x = in.GetLine();
					if(IsNull(x))
						break;
					AddLinkRef(link, x);
				}
				while(!in.IsEof()) {
					String x = in.GetLine();
					if(IsNull(x))
						break;
					ti.words.Add(TopicWordIndex(x));
				}
				Sort(ti.words);
				return;
			}
		}
	}
	Topic tp = ReadTopic(LoadFile(path));
	SyncTopicFile(ParseQTF(tp.text), link, path, tp.title);
}
Esempio n. 6
0
void TopicEditor::Hyperlink(String& link, WString& text)
{
	TopicLinkDlg d;
	d.link <<= link;
	String label;
	TopicLink tl;
	int q = link.ReverseFind('#');
	if(q >= 0) {
		label = link.Mid(q + 1);
		tl = ParseTopicLink(link.Mid(0, q));
	}
	else
		tl = ParseTopicLink(link);
	if(IsNull(tl.topic)) {
		d.package.FindSetCursor(GetFileTitle(GetFileFolder(grouppath))) &&
		d.group.FindSetCursor(GetFileTitle(grouppath)) &&
		d.topic.FindSetCursor(topic.GetCurrentName());
	}
	else {
		d.package.FindSetCursor(tl.package) &&
		d.group.FindSetCursor(tl.group) &&
		d.topic.FindSetCursor(tl.topic) &&
		d.label.FindSetCursor(label);
	}
	int c = d.Run();
	if(c == IDCANCEL)
		return;
	link = ~d.link;
	if(c == IDOK)
		return;
	if(d.topic.IsCursor()) {
		String fn = AppendFileName(d.PackageGroup(d.group.GetCurrentName()),
		                           d.topic.GetCurrentName() + ".tpp");
		text = ReadTopic(LoadFile(fn)).title.ToWString();
	}
}