This file is indexed.

/usr/lib/Wt/examples/widgetgallery/TopicTemplate.C is in witty-examples 3.3.0-1build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 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
/*
 * Copyright (C) 2012 Emweb bvba
 *
 * See the LICENSE file for terms of use.
 */

#include <boost/algorithm/string.hpp>

#include "TopicTemplate.h"

#include <Wt/WStringStream>

TopicTemplate::TopicTemplate(const char *trKey)
  : Wt::WTemplate(tr(trKey))
{
  setInternalPathEncoding(true);

#ifndef WT_TARGET_JAVA
  setCondition("if:cpp", true);
  setCondition("if:java", false);
  bindString("doc-url", "http://www.webtoolkit.eu/wt/doc/reference/html/");
#else
  setCondition("if:cpp", false);
  setCondition("if:java", true);
  bindString("doc-url", "http://www.webtoolkit.eu/"
	     "jwt/latest/doc/javadoc/eu/webtoolkit/jwt/");
#endif
}

std::string TopicTemplate::getString(const std::string& varName)
{
  std::stringstream ss;
  std::vector<Wt::WString> args;

  resolveString(varName, args, ss);

  return ss.str();
}

std::string TopicTemplate::docUrl(const std::string& className)
{
  Wt::WStringStream ss;

#if !defined(WT_TARGET_JAVA)
  ss << getString("doc-url") << "class" << escape("Wt::" + className)
     << ".html";
#else
  boost::replace_all(className, ".", "/");
  ss << getString("doc-url") << className << ".html";
#endif

  return ss.str();
}

void TopicTemplate::resolveString(const std::string& varName,
				  const std::vector<Wt::WString>& args,
				  std::ostream& result)
{
  if (varName == "doc-link") {
    std::string className = args[0].toUTF8();

#ifndef WT_TARGET_JAVA
    boost::replace_all(className, "-", "::");
#else
    boost::replace_all(className, "Render-", "render.");    
#endif

    result << "<a href=\"" << docUrl(className)
	   << "\" target=\"_blank\">";

#ifdef WT_TARGET_JAVA
    boost::replace_all(className, "render.", "");
#endif // WT_TARGET_JAVA

    result << className << "</a>";
  } else if (varName == "src") {
    std::string exampleName = args[0].toUTF8();
    result << "<fieldset class=\"src\">"
	   << "<legend>source</legend>"
           << tr("src-" + exampleName).toUTF8()
	   << "</fieldset>";
  } else
    WTemplate::resolveString(varName, args, result);
}

std::string TopicTemplate::escape(const std::string &name)
{
  Wt::WStringStream ss;

  for (unsigned i = 0; i < name.size(); ++i) {
    if (name[i] != ':')
      ss << name[i];
    else
      ss << "_1";
  }

  return ss.str();
}