Skip to content

Commit 9dcba09

Browse files
committed
issue #10447 Add explicit links to static pages
Add a new file with dummy links to all html / xhtml output files and add a dummy link on the index page to this new file.
1 parent fcb8cfb commit 9dcba09

File tree

4 files changed

+67
-21
lines changed

4 files changed

+67
-21
lines changed

src/doxygen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11917,7 +11917,7 @@ void parseInput()
1191711917
if (generateEclipseHelp) Doxygen::indexList->addIndex<EclipseHelp>();
1191811918
if (generateHtmlHelp) Doxygen::indexList->addIndex<HtmlHelp>();
1191911919
if (generateQhp) Doxygen::indexList->addIndex<Qhp>();
11920-
if (generateSitemap) Doxygen::indexList->addIndex<Sitemap>();
11920+
Doxygen::indexList->addIndex<Sitemap>(generateSitemap);
1192111921
if (generateTreeView) Doxygen::indexList->addIndex<FTVHelp>(TRUE);
1192211922
if (generateDocSet) Doxygen::indexList->addIndex<DocSets>();
1192311923
Doxygen::indexList->initialize();

src/index.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4822,7 +4822,13 @@ static void writeIndex(OutputList &ol)
48224822
ol.endPageDoc();
48234823
}
48244824

4825+
QCString fn = Sitemap::crawlFileName;
4826+
addHtmlExtensionIfMissing(fn);
4827+
ol.writeString("<a href=\"" + fn + "\"/>\n");
4828+
Doxygen::indexList->addIndexFile(fn);
4829+
48254830
endFile(ol);
4831+
48264832
ol.disable(OutputType::Html);
48274833

48284834
//--------------------------------------------------------------------

src/sitemap.cpp

Lines changed: 58 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -26,52 +26,91 @@
2626
#include "sitemap.h"
2727
#include "textstream.h"
2828
#include "util.h"
29+
#include "version.h"
30+
#include "language.h"
2931
#include "portable.h"
3032

3133
class Sitemap::Private
3234
{
3335
public:
36+
bool site;
3437
std::ofstream docFile;
3538
TextStream doc;
36-
TextStream index;
39+
//TextStream index;
40+
std::ofstream crawlFile;
41+
TextStream crawl;
42+
3743
};
3844

39-
Sitemap::Sitemap() : p(std::make_unique<Private>()) {}
45+
Sitemap::Sitemap(const bool site) : p(std::make_unique<Private>()) {p->site = site;}
4046
Sitemap::~Sitemap() = default;
4147
Sitemap::Sitemap(Sitemap &&) = default;
4248

4349
void Sitemap::initialize()
4450
{
4551
QCString fileName = Config_getString(HTML_OUTPUT) + "/" + sitemapFileName;
52+
QCString fileNameCrawl = Config_getString(HTML_OUTPUT) + "/" + crawlFileName;
53+
addHtmlExtensionIfMissing(fileNameCrawl);
4654

47-
p->docFile = Portable::openOutputStream(fileName);
48-
if (!p->docFile.is_open())
55+
if (p->site)
4956
{
50-
term("Could not open file %s for writing\n", fileName.data());
57+
p->docFile = Portable::openOutputStream(fileName);
58+
if (!p->docFile.is_open())
59+
{
60+
term("Could not open file %s for writing\n", fileName.data());
61+
}
62+
p->doc.setStream(&p->docFile);
63+
64+
p->doc << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
65+
p->doc << "<urlset\n";
66+
p->doc << " xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n";
67+
p->doc << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
68+
p->doc << " xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n";
69+
p->doc << " http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n";
70+
}
71+
p->crawlFile = Portable::openOutputStream(fileNameCrawl);
72+
if (!p->crawlFile.is_open())
73+
{
74+
term("Could not open file %s for writing\n", fileNameCrawl.data());
5175
}
52-
p->doc.setStream(&p->docFile);
76+
p->crawl.setStream(&p->crawlFile);
77+
p->crawl << "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
78+
p->crawl << "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"" + theTranslator->trISOLang() + "\">\n";
79+
p->crawl << "<head>\n";
80+
p->crawl << "<title>Validator / crawler helper</title>\n";
81+
p->crawl << "<meta http-equiv=\"Content-Type\" content=\"text/xhtml;charset=UTF-8\"/>\n";
82+
p->crawl << "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=11\"/>\n";
5383

54-
p->doc << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
55-
p->doc << "<urlset\n";
56-
p->doc << " xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n";
57-
p->doc << " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n";
58-
p->doc << " xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n";
59-
p->doc << " http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n";
84+
p->crawl << "<meta name=\"generator\" content=\"Doxygen " + getDoxygenVersion() + "\"/>\n";
85+
p->crawl << "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\"/>\n";
86+
p->crawl << "</head>\n";
87+
p->crawl << "<body>\n";
6088
}
6189

6290
void Sitemap::finalize()
6391
{
64-
p->doc << "</urlset>\n";
65-
p->doc.flush();
66-
p->docFile.close();
92+
if (p->site)
93+
{
94+
p->doc << "</urlset>\n";
95+
p->doc.flush();
96+
p->docFile.close();
97+
}
98+
p->crawl << "</body>\n";
99+
p->crawl << "</html>\n";
100+
p->crawl.flush();
101+
p->crawlFile.close();
67102
}
68103

69104
void Sitemap::addIndexFile(const QCString & fileName)
70105
{
71106
QCString fn = fileName;
72-
QCString sidemapUrl = Config_getString(SITEMAP_URL);
73107
addHtmlExtensionIfMissing(fn);
74-
p->doc << " <url>\n";
75-
p->doc << " <loc>" << convertToXML(sidemapUrl + fn) << "</loc>\n";
76-
p->doc << " </url>\n";
108+
if (p->site)
109+
{
110+
QCString sidemapUrl = Config_getString(SITEMAP_URL);
111+
p->doc << " <url>\n";
112+
p->doc << " <loc>" << convertToXML(sidemapUrl + fn) << "</loc>\n";
113+
p->doc << " </url>\n";
114+
}
115+
p->crawl << " <a href=\"" << fn << "\"/>\n";
77116
}

src/sitemap.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class MemberDef;
2424
class Sitemap
2525
{
2626
public:
27-
Sitemap();
27+
Sitemap(bool const site);
2828
~Sitemap();
2929
Sitemap(Sitemap &&);
3030

@@ -43,6 +43,7 @@ class Sitemap
4343
void addStyleSheetFile(const QCString & name){}
4444

4545
static inline const QCString sitemapFileName = "sitemap.xml";
46+
static inline const QCString crawlFileName = "doxygen_crawl";
4647

4748
private:
4849
class Private;

0 commit comments

Comments
 (0)