diff --git a/public/global.js b/public/global.js
index e9400cf1..2237eb25 100644
--- a/public/global.js
+++ b/public/global.js
@@ -276,7 +276,7 @@ function len(item) {
}
function loadScript(name, callback) {
- let url = "//" +me.Site.URL+"/static/"+name
+ let url = "/static/"+name
$.getScript(url)
.done(callback)
.fail((e,xhr,settings,ex) => {
@@ -294,7 +294,7 @@ function DoNothingButPassBack(item) {
}
function fetchPhrases() {
- fetch("//" +me.Site.URL+"/api/phrases/?query=status,topic_list")
+ fetch("/api/phrases/?query=status,topic_list")
.then((resp) => resp.json())
.then((data) => {
console.log("loaded phrase endpoint data");
@@ -327,7 +327,9 @@ function fetchPhrases() {
}
(() => {
- runHook("pre_me");
+ runHook("pre_iife");
+ let loggedIn = document.head.querySelector("[property='x-loggedin']").content;
+
fetch("/api/me/")
.then((resp) => resp.json())
.then((data) => {
@@ -336,15 +338,6 @@ function fetchPhrases() {
me = data;
runHook("pre_init");
- if(me.User.ID > 0) {
- let toLoad = 1;
- loadScript("template_topics_topic.js", () => {
- console.log("Loaded template_topics_topic.js");
- toLoad--;
- if(toLoad===0) fetchPhrases();
- });
- }
-
// We can only get away with this because template_alert has no phrases, otherwise it too would have to be part of the "dance", I miss Go concurrency :(
loadScript("template_alert.js", () => {
console.log("Loaded template_alert.js");
@@ -360,6 +353,15 @@ function fetchPhrases() {
$(document).ready(mainInit);
});
+
+ if(loggedIn) {
+ let toLoad = 1;
+ loadScript("template_topics_topic.js", () => {
+ console.log("Loaded template_topics_topic.js");
+ toLoad--;
+ if(toLoad===0) fetchPhrases();
+ });
+ }
})();
function mainInit(){
@@ -667,8 +669,8 @@ function mainInit(){
console.log("content.value", content.value);
let attachItem;
- if(content.value == "") attachItem = "//" + me.Site.URL + "/attachs/" + hash + "." + ext;
- else attachItem = "\r\n//" + me.Site.URL + "/attachs/" + hash + "." + ext;
+ if(content.value == "") attachItem = "//" + window.location.host + "/attachs/" + hash + "." + ext;
+ else attachItem = "\r\n//" + window.location.host + "/attachs/" + hash + "." + ext;
content.value = content.value + attachItem;
console.log("content.value", content.value);
diff --git a/routes/api.go b/routes/api.go
index 64141a36..05d54e7a 100644
--- a/routes/api.go
+++ b/routes/api.go
@@ -229,7 +229,6 @@ type JsonMe struct {
// We don't want to expose too much information about the site, so we'll make this a small subset of common.site
type MeSite struct {
- URL string
MaxRequestSize int
}
@@ -243,7 +242,7 @@ func APIMe(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
// TODO: Use this header anywhere with a user check?
w.Header().Set("Cache-Control", "private")
- me := JsonMe{(&user).Me(), MeSite{common.Site.URL, common.Site.MaxRequestSize}}
+ me := JsonMe{(&user).Me(), MeSite{common.Site.MaxRequestSize}}
jsonBytes, err := json.Marshal(me)
if err != nil {
diff --git a/templates/header.html b/templates/header.html
index d48e6ef2..b37fc87c 100644
--- a/templates/header.html
+++ b/templates/header.html
@@ -11,6 +11,7 @@
{{range .Header.Scripts}}
{{end}}
+
{{if .Header.MetaDesc}}{{end}}