Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bin/armadietto.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const remoteStorageServer = {
allow: {
signup: conf.allow_signup || false
},
tosUrl: conf.terms_of_service_url,
cacheViews: conf.cache_views || false
});

Expand Down
1 change: 1 addition & 0 deletions bin/dev-conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"basePath": "",
"allow_signup": true,
"storage_path": "./dev-storage",
"terms_of_service_url": "https://community.remotestorage.io/tos",
"cache_views": true,
"http": {
"host": "127.0.0.1",
Expand Down
1 change: 1 addition & 0 deletions example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const server = new Armadietto({
allow: {
signup: true
},
tosUrl: 'https://community.remotestorage.io/tos',
cacheViews: false
});

Expand Down
2 changes: 1 addition & 1 deletion lib/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ header.topbar h1 a:focus {
header.topbar nav ul {
display: flex;
align-items: center;
justify-content: space-between;
justify-content: flex-end;
gap: .5rem;
margin: 0;
padding: 0;
Expand Down
3 changes: 2 additions & 1 deletion lib/controllers/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,15 @@ class Controller {
basePath: this.server._basePath,
title: locals.title || '',
signup: this.server._allow.signup,
tosUrl: this.server._options.tosUrl,
body: ejs.render(body, locals)
};
const html = Buffer.from(ejs.render(layout, globals));

const headers = {
'Content-Length': html.length,
'Content-Type': 'text/html; charset=utf8',
'Content-Security-Policy': "sandbox allow-scripts allow-forms allow-same-origin; default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self'; object-src 'none'; child-src 'none'; connect-src 'none'; base-uri 'self'; frame-ancestors 'none';",
'Content-Security-Policy': "sandbox allow-scripts allow-popups allow-forms allow-same-origin; default-src 'self'; script-src 'self'; style-src 'self'; font-src 'self'; object-src 'none'; child-src 'none'; connect-src 'none'; base-uri 'self'; frame-ancestors 'none';",
'X-Content-Type-Options': 'nosniff',
'Referrer-Policy': 'no-referrer'
};
Expand Down
10 changes: 8 additions & 2 deletions lib/views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ <h1>
</span>
</h1>


<nav role="navigation">
<ul>
<% if (signup) { %>
Expand All @@ -41,8 +42,13 @@ <h1>
<button id="switch">Switch</button>
</li>
</ul>
</nav>
</header>
<% if (typeof tosUrl !== 'undefined' && tosUrl) { %>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering, what's the && tosUrl for, when it's already not undefined?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point! It should probably be
if (typeof tosUrl === 'string' && tosUrl.trim().length > 1)

<ul>
<li><p><a href="<%= tosUrl %>" target="_blank">Terms of Service</a></p></li>
</ul>
<% } %>
</nav>
</header>

<main class="content" role="main">

Expand Down