Browse Source

Generalize base template for different platforms

master
Matt Baer 3 years ago
parent
commit
34c3470e14
3 changed files with 35 additions and 9 deletions
  1. +5
    -2
      handlers.go
  2. +23
    -0
      platform/platforms.go
  3. +7
    -7
      templates/base.tmpl

+ 5
- 2
handlers.go View File

@@ -1,6 +1,7 @@
package main

import (
"code.as/writeas/developers-site/platform"
"fmt"
"github.com/writeas/web-core/log"
"net/http"
@@ -55,9 +56,11 @@ func viewPage(w http.ResponseWriter, r *http.Request) {
return
}
p := struct {
Path string
Path string
Platform platform.Platform
}{
Path: name,
Path: name,
Platform: platform.WriteAs,
}

err = t.ExecuteTemplate(w, "base", p)


+ 23
- 0
platform/platforms.go View File

@@ -0,0 +1,23 @@
package platform

type Platform struct {
Name string
URL string
LogoURL string
StyleSheetURL string
CodeAsName string
GitHubName string
MatomoID int
}

var (
WriteAs = Platform{
Name: "Write.as",
URL: "https://write.as",
LogoURL: "https://write.as/img/w-sq.svg",
StyleSheetURL: "https://write.as/css/write.css",
CodeAsName: "writeas",
GitHubName: "writeas",
MatomoID: 7,
}
)

+ 7
- 7
templates/base.tmpl View File

@@ -3,14 +3,14 @@
<head>
{{ template "head" . }}
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" type="text/css" href="https://write.as/css/write.css" />
<link rel="stylesheet" type="text/css" href="{{.Platform.StyleSheetURL}}" />
<link rel="stylesheet" type="text/css" href="/css/dev.css" />
</head>
<body {{template "body-attrs" .}}>
<header style="margin: 1rem;">
<nav id="full-nav" class="solutionize">
<div class="left-side">
<a href="https://write.as" class="dim"><img alt="Write.as - home" src="https://write.as/img/w-sq.svg"/></a>
<a href="{{.Platform.URL}}" class="dim"><img alt="{{.Platform.Name}} - home" src="{{.Platform.LogoURL}}"/></a>
</div>
<nav id="user-nav">
<nav class="tabs" aria-label="Main Navigation">
@@ -38,7 +38,7 @@
(function() {
var u="https://analytics.write.as/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '7']);
_paq.push(['setSiteId', '{{.Platform.MatomoID}}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
@@ -56,7 +56,7 @@
})();
</script>

<noscript><p><img src="https://analytics.write.as/piwik.php?idsite=7&rec=1" style="border:0;" alt="" /></p></noscript>
<noscript><p><img src="https://analytics.write.as/piwik.php?idsite={{.Platform.MatomoID}}&rec=1" style="border:0;" alt="" /></p></noscript>
</body>
</html>{{end}}

@@ -82,8 +82,8 @@
<h3>open source</h3>
<ul>
<li><a href="https://writefreely.org">writefreely</a></li>
<li><a href="https://code.as/writeas">code.as</a></li>
<li><a href="https://github.com/writeas">github</a></li>
<li><a href="https://code.as/{{.Platform.CodeAsName}}">code.as</a></li>
{{if .Platform.GitHubName}}<li><a href="https://github.com/{{.Platform.GitHubName}}">github</a></li>{{end}}
</ul>
</div>
<div class="fourth">
@@ -94,7 +94,7 @@
</ul>
</div>
<div class="fourth">
<h3><a class="home" style="font-weight: normal" href="https://write.as">write.as</a></h3>
<h3><a class="home" style="font-weight: normal; text-transform: lowercase" href="https://write.as">Write.as</a></h3>
<ul>
<li><a href="https://write.as/contact">contact</a></li>
<li><a href="https://write.as/privacy">privacy</a></li>


Loading…
Cancel
Save