Skip to content

Commit

Permalink
Embed privacy.txt instead of loading it with a separate HTTP request
Browse files Browse the repository at this point in the history
  • Loading branch information
sffc committed Mar 29, 2021
1 parent 2148206 commit 85461f2
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 14 deletions.
10 changes: 0 additions & 10 deletions client/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ function getJsTimestamp() {
return fs.statSync("dist/js/app.js").mtime.valueOf();
}

function getPrivacyTimestamp() {
return fs.statSync("app/privacy_standalone.txt").mtime.valueOf() + fs.statSync("app/eula.txt").mtime.valueOf();
}

function getFileUtf8(filepath) {
return function() {
return fs.readFileSync(filepath).toString("utf-8");
Expand Down Expand Up @@ -162,12 +158,6 @@ module.exports = function (grunt) {
replace: getCssTimestamp,
flags: "g"
},
{
name: "privacy-timestamp",
search: "\\{!privacy-timestamp!\\}",
replace: getPrivacyTimestamp,
flags: "g"
},
{
name: "config-session-payloadMessageDelay",
search: "parseInt\\(\"\\d+!config.session.payloadMessageDelay\"\\)",
Expand Down
3 changes: 0 additions & 3 deletions client/app/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,6 @@ define(
/* * * * END EDITOR/CONSOLE/PROMPT, START GUI * * * */

// Privacy Policy
$.get("privacy.txt?{!privacy-timestamp!}", function (data) {
$("#privacy").find("article").html(data);
});
$("#privacy").find("[data-purpose='close']").click(function () {
anal.sitecontrol("privacy-close");
});
Expand Down
3 changes: 3 additions & 0 deletions front/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* <https://www.gnu.org/licenses/>.
*/

import Fs = require("fs");
import Path = require("path");

import { config, logger } from "./shared_wrap";
Expand Down Expand Up @@ -56,6 +57,8 @@ async function main() {
buildData.locales = config.front.locales;
}

buildData.privacy_html = await Fs.promises.readFile(Path.join(__dirname, "..", "..", config.front.static_path, "privacy.txt"), { encoding: "utf-8" });

try {
log.trace("Connecting to Mongo...");
await Mongo.connect();
Expand Down
1 change: 1 addition & 0 deletions front/src/express_setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export let server: Http.Server;
export interface BuildData {
locales_path?: string;
locales?: string[];
privacy_html?: string;
}

function getT(req: Express.Request) {
Expand Down
2 changes: 1 addition & 1 deletion front/src/views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ with Octave Online Server. If not, see <https://www.gnu.org/licenses/>.
</div></div></div>

<div id="privacy" data-purpose="popover" aria-hidden="true"><div><div>
<article></article>
<article><%- buildData.privacy_html %></article>
<span class="closebtn" data-purpose="close"></span>
</div></div></div>

Expand Down

0 comments on commit 85461f2

Please sign in to comment.