Skip to content

Commit

Permalink
minor fixes to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
davetaz committed May 20, 2024
1 parent 20d6a85 commit 6c31f28
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 1 deletion.
24 changes: 24 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,30 @@ app.use(function(req, res, next) {
next();
});

app.use((req, res, next) => {
// Read package.json file
fs.readFile(path.join(__dirname, 'package.json'), 'utf8', (err, data) => {
if (err) {
console.error('Error reading package.json:', err);
return next();
}

try {
const packageJson = JSON.parse(data);
// Extract version from package.json
var software = {};
software.version = packageJson.version;
software.homepage = packageJson.homepage;
software.versionLink = packageJson.homepage + "/releases/tag/v" + packageJson.version;
res.locals.software = software;
} catch (error) {
console.error('Error parsing package.json:', error);
}

next();
});
});

// Logout route
app.post('/logout', function(req, res, next){
req.logout(function(err) {
Expand Down
1 change: 1 addition & 0 deletions middleware/project.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const projectController = require('../controllers/project');
const pages = require('../pages.json');

const loadProject = async (req, res, next) => {
res.locals.pages = pages;
if (req.params.id) {
if (req.params.id !== req.session.projectId) {
req.session.projectId = req.params.id;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"bugs": {
"url": "https://github.com/theodi/care.theodi.org/issues"
},
"homepage": "https://github.com/theodi/care.theodi.org/#readme",
"homepage": "https://github.com/theodi/care.theodi.org",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^16.4.5",
Expand Down
9 changes: 9 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ section {
font-weight: 700;
font-size: 3rem;
}
.version {
position: absolute;
top: -10px;
right: 10px;
}
.version a {
color: white;
font-size: 0.7rem;
}
/*
* Lists
*/
Expand Down
2 changes: 2 additions & 0 deletions views/partials/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

</head>
<body>
<p class="version"><a href="<%= software.versionLink %>" target="_blank">v<%= software.version %></a></p>
<div class="sidebar">
<img class="odi-logo" src="/images/odi-logo.png">
<ul class="main-menu">
Expand All @@ -39,6 +40,7 @@
<li><a href="/disclaimer" class="toggle-link">Disclaimer</a></li>
<% } %>
</ul>

<% if (typeof project !== 'undefined') { %>
<nav class="projectProgress">
<h1>Current evaluation</h1>
Expand Down

0 comments on commit 6c31f28

Please sign in to comment.