Merge pull request #497 from thelounge/astorije/about-section

Add information on the About section of the client
This commit is contained in:
Maxime Poulin 2016-07-16 14:52:12 -04:00 committed by GitHub
commit 001a3c57e0
2 changed files with 22 additions and 2 deletions

View File

@ -324,8 +324,17 @@
</div>
<div class="col-sm-12">
<p class="about">
You're currently running version <%= version %><br>
<a href="https://github.com/thelounge/lounge/blob/master/CHANGELOG.md#readme" target="_blank">View the change log</a>
<% if (gitCommit) { %>
The Lounge is running from source
(<a href="https://github.com/thelounge/lounge/tree/<%= gitCommit %>" target="_blank"><code><%= gitCommit %></code></a>).<br>
<% } else { %>
The Lounge is in version <strong><%= version %></strong>
(<a href="https://github.com/thelounge/lounge/releases/tag/v<%= version %>" target="_blank">See release notes</a>).<br>
<% } %>
<a href="https://thelounge.github.io/" target="_blank">Website</a><br>
<a href="https://thelounge.github.io/docs/" target="_blank">Documentation</a><br>
<a href="https://github.com/thelounge/lounge/issues/new" target="_blank">Report a bug</a>
</p>
</div>
</div>

View File

@ -80,6 +80,16 @@ function allRequests(req, res, next) {
return next();
}
// Information to populate the About section in UI, either from npm or from git
try {
var gitCommit = require("child_process")
.execSync("git rev-parse --short HEAD") // Returns hash of current commit
.toString()
.trim();
} catch (e) {
// Not a git repository or git is not installed: treat it as npm release
}
function index(req, res, next) {
if (req.url.split("?")[0] !== "/") {
return next();
@ -90,6 +100,7 @@ function index(req, res, next) {
pkg,
Helper.config
);
data.gitCommit = gitCommit;
var template = _.template(file);
res.setHeader("Content-Security-Policy", "default-src *; style-src * 'unsafe-inline'; script-src 'self'; child-src 'none'; object-src 'none'; form-action 'none'; referrer no-referrer;");
res.setHeader("Content-Type", "text/html");