Skip to content

Commit 6f283f3

Browse files
author
Jared Hendrickson
committed
Added copyright footer to docs page within UI, added back button to docs page within UI, added link to Github page within docs page, fixed page title issue that printed the entire docs as the title tag
1 parent ce67d13 commit 6f283f3

2 files changed

Lines changed: 35 additions & 4 deletions

File tree

pfSense-pkg-API/files/usr/local/www/api/documentation/index.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,16 +1699,31 @@
16991699
function IsJsonString(str){try{JSON.parse(str);}catch(e){return false;}
17001700
return true;}
17011701
String.prototype.replaceAll=function(replaceThis,withThis){var re=new RegExp(RegExp.quote(replaceThis),"g");return this.replace(re,withThis);};RegExp.quote=function(str){return str.replace(/([.?*+^$[\]\\(){}-])/g,"\\$1");};function syntaxHighlight(json){json=json.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');return json.replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,function(match){var cls='number';if(/^"/.test(match)){if(/:$/.test(match)){cls='key';}else{cls='string';}}else if(/true|false/.test(match)){cls='boolean';}else if(/null/.test(match)){cls='null';}
1702-
return '<span class="'+cls+'">'+match+'</span>';});}</script><br><br><footer class="navbar-default navbar-fixed-bottom"><div class=container-fluid><div class="span12 text-center"><span data-toggle=tooltip title="If the application help you, please feel free to give a star to the project in github. Your star inspire me to work more on open-source projects like this!">Made with <em class=love-color>&#9829;</em> by <a href=https://github.com/thedevsaddam target=_blank class=text-muted>thedevsaddam</a> | Generated at: 2020-11-30 09:29:07 by <a href=https://github.com/thedevsaddam/docgen target=_blank class=text-muted>docgen</a></span></div></div></footer>
1702+
return '<span class="'+cls+'">'+match+'</span>';});}</script><br><br><footer class="navbar-default navbar-fixed-bottom"><div class=container-fluid><div class="span12 text-center"><span data-toggle=tooltip title="If the application help you, please feel free to give a star to the project in github. Your star inspire me to work more on open-source projects like this!">Made with <em class=love-color>&#9829;</em> by <a href=https://github.com/thedevsaddam target=_blank class=text-muted>thedevsaddam</a> | Generated at: 2020-11-30 12:17:30 by <a href=https://github.com/thedevsaddam/docgen target=_blank class=text-muted>docgen</a></span></div></div></footer>
1703+
<script type="text/javascript">
1704+
$(document).ready(function() {
1705+
document.title = 'pfSense REST API Documentation';
1706+
var curr_year = new Date().getFullYear();
1707+
document.querySelector('footer').innerHTML = "<p>Copyright &copy; " + curr_year + " - Jared Hendrickson</p><a href='/api/'>Back to pfSense</a> | <a href='https://github.com/jaredhendrickson13/pfsense-api'>View on Github</a>";
1708+
});
1709+
1710+
</script>
1711+
17031712
<style>
1713+
title {
1714+
content:"pfSense API Documentation";
1715+
}
17041716
body {
17051717
display: block;
17061718
width: 90%;
17071719
max-width: 1500px;
17081720
margin: 0 auto;
17091721
}
17101722
footer {
1711-
display:none;
1723+
text-align: center;
1724+
}
1725+
footer p {
1726+
margin: 2px;
17121727
}
17131728
div.col-md-12 {
17141729
margin-top: 20px;

tools/make_documentation.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,20 @@
3333
"""
3434
css = """
3535
<style>
36+
title {
37+
content:"pfSense API Documentation";
38+
}
3639
body {
3740
display: block;
3841
width: 90%;
3942
max-width: 1500px;
4043
margin: 0 auto;
4144
}
4245
footer {
43-
display:none;
46+
text-align: center;
47+
}
48+
footer p {
49+
margin: 2px;
4450
}
4551
div.col-md-12 {
4652
margin-top: 20px;
@@ -116,6 +122,16 @@
116122
}
117123
</style>
118124
"""
125+
js = """
126+
<script type="text/javascript">
127+
$(document).ready(function() {
128+
document.title = 'pfSense REST API Documentation';
129+
var curr_year = new Date().getFullYear();
130+
document.querySelector('footer').innerHTML = "<p>Copyright &copy; " + curr_year + " - Jared Hendrickson</p><a href='/api/'>Back to pfSense</a> | <a href='https://github.com/jaredhendrickson13/pfsense-api'>View on Github</a>";
131+
});
132+
133+
</script>
134+
"""
119135

120136
# Parses command line arguments and generates help pages
121137
def start_argparse():
@@ -153,7 +169,7 @@ def format_docs():
153169
# Write a new PHP script containing the HTML created by docgen, then override custom attributes and CSS
154170
with open("documentation.php", "w") as dw:
155171
html_doc = php + html_doc
156-
html_doc = html_doc + css
172+
html_doc = html_doc + js + css
157173
html_doc = html_doc.replace("{{$hostname}}", "<?echo $_SERVER['HTTP_HOST'];?>")
158174
dw.write(html_doc)
159175

0 commit comments

Comments
 (0)