Skip to content

Commit 40037fd

Browse files
committed
Handling of TIMESTAMP in html footer and header
After review.
1 parent 0c79c81 commit 40037fd

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

src/htmlgen.cpp

+22
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ static QCString g_footer_file;
6767
static QCString g_footer;
6868
static QCString g_mathjax_code;
6969
static QCString g_latex_macro;
70+
static QCString g_build_date_str;
71+
static bool g_build_date = false;
7072
static constexpr auto hex="0123456789ABCDEF";
7173

7274
static const SelectionMarkerInfo htmlMarkerInfo = { '<', "<!--BEGIN ",10,"<!--END ",8,"-->",3 };
@@ -628,6 +630,7 @@ static QCString substituteHtmlKeywords(const QCString &file,
628630
{ "$treeview", [&]() { return treeViewCssJs; } },
629631
{ "$searchbox", [&]() { return searchBox; } },
630632
{ "$search", [&]() { return searchCssJs; } },
633+
{ "$builddate", [&]() { return g_build_date_str;} },
631634
{ "$mathjax", [&]() { return mathJaxJs; } },
632635
{ "$darkmode", [&]() { return darkModeJs; } },
633636
{ "$generatedby", [&]() { return generatedBy; } },
@@ -1167,6 +1170,19 @@ void HtmlGenerator::addCodeGen(OutputCodeList &list)
11671170
list.add<HtmlCodeGeneratorDefer>(m_codeGen);
11681171
}
11691172

1173+
static bool hasDateReplacement(const QCString &str)
1174+
{
1175+
return (str.contains("$datetime",false) ||
1176+
str.contains("$date",false) ||
1177+
str.contains("$time",false) ||
1178+
str.contains("$year",false) ||
1179+
((Config_getEnum(TIMESTAMP) != TIMESTAMP_t::NO) && str.contains("$generatedby",false)) ||
1180+
str.contains("class=\"datetime\"",false) ||
1181+
str.contains("class=\"date\"",false) ||
1182+
str.contains("class=\"time\"",false) ||
1183+
str.contains("class=\"year\"",false)
1184+
);
1185+
}
11701186
void HtmlGenerator::init()
11711187
{
11721188
QCString dname = Config_getString(HTML_OUTPUT);
@@ -1180,6 +1196,7 @@ void HtmlGenerator::init()
11801196
{
11811197
g_header_file=Config_getString(HTML_HEADER);
11821198
g_header=fileToString(g_header_file);
1199+
g_build_date = (g_build_date || hasDateReplacement(g_header));
11831200
//printf("g_header='%s'\n",qPrint(g_header));
11841201
QCString result = substituteHtmlKeywords(g_header_file,g_header,QCString(),QCString());
11851202
checkBlocks(result,Config_getString(HTML_HEADER),htmlMarkerInfo);
@@ -1188,6 +1205,7 @@ void HtmlGenerator::init()
11881205
{
11891206
g_header_file="header.html";
11901207
g_header = ResourceMgr::instance().getAsString(g_header_file);
1208+
g_build_date = (g_build_date || hasDateReplacement(g_header));
11911209
QCString result = substituteHtmlKeywords(g_header_file,g_header,QCString(),QCString());
11921210
checkBlocks(result,"<default header.html>",htmlMarkerInfo);
11931211
}
@@ -1196,6 +1214,7 @@ void HtmlGenerator::init()
11961214
{
11971215
g_footer_file=Config_getString(HTML_FOOTER);
11981216
g_footer=fileToString(g_footer_file);
1217+
g_build_date = (g_build_date || hasDateReplacement(g_footer));
11991218
//printf("g_footer='%s'\n",qPrint(g_footer));
12001219
QCString result = substituteHtmlKeywords(g_footer_file,g_footer,QCString(),QCString());
12011220
checkBlocks(result,Config_getString(HTML_FOOTER),htmlMarkerInfo);
@@ -1204,6 +1223,7 @@ void HtmlGenerator::init()
12041223
{
12051224
g_footer_file = "footer.html";
12061225
g_footer = ResourceMgr::instance().getAsString(g_footer_file);
1226+
g_build_date = (g_build_date || hasDateReplacement(g_footer));
12071227
QCString result = substituteHtmlKeywords(g_footer_file,g_footer,QCString(),QCString());
12081228
checkBlocks(result,"<default footer.html>",htmlMarkerInfo);
12091229
}
@@ -1318,13 +1338,15 @@ void HtmlGenerator::init()
13181338
}
13191339
}
13201340

1341+
if (g_build_date)
13211342
{
13221343
std::ofstream f = Portable::openOutputStream(dname+"/build_date.js");
13231344
if (f.is_open())
13241345
{
13251346
TextStream t(&f);
13261347
writeBuildDateJS(t);
13271348
}
1349+
g_build_date_str = "<script type=\"text/javascript\" src=\"$relpath^build_date.js\"></script>";
13281350
}
13291351
}
13301352

templates/html/header.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<!--END FULL_SIDEBAR-->
1717
<script type="text/javascript" src="$relpath^jquery.js"></script>
1818
<script type="text/javascript" src="$relpath^dynsections.js"></script>
19-
<script type="text/javascript" src="$relpath^build_date.js"></script>
19+
$builddate
2020
<!--BEGIN COPY_CLIPBOARD-->
2121
<script type="text/javascript" src="$relpath^clipboard.js"></script>
2222
<!--END COPY_CLIPBOARD-->

0 commit comments

Comments
 (0)